aboutsummaryrefslogtreecommitdiff
path: root/include/v8.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2017-06-06 11:06:27 +0100
committerBen Murdoch <benm@google.com>2017-06-07 12:29:44 +0100
commit62ed631aa0ff23db68a47fd423efa9c019ff2c9e (patch)
tree1df435310690642f8fd4628d6d16462d05ffc797 /include/v8.h
parentb0475911e4499628ec03ff93ce693450724887c2 (diff)
downloadv8-62ed631aa0ff23db68a47fd423efa9c019ff2c9e.tar.gz
Merge V8 5.8.283.32
Test: Build V8 for arm, arm64, x86, x86_64, mips, mips64 and set a PAC script from the UI on bullhead Change-Id: I7cc773b5daca34d869e768a1deebae3876f2dfac
Diffstat (limited to 'include/v8.h')
-rw-r--r--include/v8.h529
1 files changed, 371 insertions, 158 deletions
diff --git a/include/v8.h b/include/v8.h
index 5348ba7e..baf44170 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -666,7 +666,7 @@ struct CopyablePersistentTraits {
/**
* A PersistentBase which allows copy and assignment.
*
- * Copy, assignment and destructor bevavior is controlled by the traits
+ * Copy, assignment and destructor behavior is controlled by the traits
* class M.
*
* Note: Persistent class hierarchy is subject to future changes.
@@ -867,8 +867,8 @@ class V8_EXPORT HandleScope {
HandleScope(const HandleScope&) = delete;
void operator=(const HandleScope&) = delete;
- void* operator new(size_t size) = delete;
- void operator delete(void*, size_t) = delete;
+ void* operator new(size_t size);
+ void operator delete(void*, size_t);
protected:
V8_INLINE HandleScope() {}
@@ -919,8 +919,8 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
EscapableHandleScope(const EscapableHandleScope&) = delete;
void operator=(const EscapableHandleScope&) = delete;
- void* operator new(size_t size) = delete;
- void operator delete(void*, size_t) = delete;
+ void* operator new(size_t size);
+ void operator delete(void*, size_t);
private:
internal::Object** Escape(internal::Object** escape_value);
@@ -934,8 +934,8 @@ class V8_EXPORT SealHandleScope {
SealHandleScope(const SealHandleScope&) = delete;
void operator=(const SealHandleScope&) = delete;
- void* operator new(size_t size) = delete;
- void operator delete(void*, size_t) = delete;
+ void* operator new(size_t size);
+ void operator delete(void*, size_t);
private:
internal::Isolate* const isolate_;
@@ -961,29 +961,31 @@ class V8_EXPORT Data {
*/
class ScriptOriginOptions {
public:
- V8_INLINE ScriptOriginOptions(bool is_embedder_debug_script = false,
- bool is_shared_cross_origin = false,
- bool is_opaque = false)
- : flags_((is_embedder_debug_script ? kIsEmbedderDebugScript : 0) |
- (is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
- (is_opaque ? kIsOpaque : 0)) {}
+ V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
+ bool is_opaque = false, bool is_wasm = false,
+ bool is_module = false)
+ : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
+ (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
+ (is_module ? kIsModule : 0)) {}
V8_INLINE ScriptOriginOptions(int flags)
: flags_(flags &
- (kIsEmbedderDebugScript | kIsSharedCrossOrigin | kIsOpaque)) {}
- bool IsEmbedderDebugScript() const {
- return (flags_ & kIsEmbedderDebugScript) != 0;
- }
+ (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
+
bool IsSharedCrossOrigin() const {
return (flags_ & kIsSharedCrossOrigin) != 0;
}
bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
+ bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
+ bool IsModule() const { return (flags_ & kIsModule) != 0; }
+
int Flags() const { return flags_; }
private:
enum {
- kIsEmbedderDebugScript = 1,
- kIsSharedCrossOrigin = 1 << 1,
- kIsOpaque = 1 << 2
+ kIsSharedCrossOrigin = 1,
+ kIsOpaque = 1 << 1,
+ kIsWasm = 1 << 2,
+ kIsModule = 1 << 3
};
const int flags_;
};
@@ -999,9 +1001,11 @@ class ScriptOrigin {
Local<Integer> resource_column_offset = Local<Integer>(),
Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(),
Local<Integer> script_id = Local<Integer>(),
- Local<Boolean> resource_is_embedder_debug_script = Local<Boolean>(),
Local<Value> source_map_url = Local<Value>(),
- Local<Boolean> resource_is_opaque = Local<Boolean>());
+ Local<Boolean> resource_is_opaque = Local<Boolean>(),
+ Local<Boolean> is_wasm = Local<Boolean>(),
+ Local<Boolean> is_module = Local<Boolean>());
+
V8_INLINE Local<Value> ResourceName() const;
V8_INLINE Local<Integer> ResourceLineOffset() const;
V8_INLINE Local<Integer> ResourceColumnOffset() const;
@@ -1191,6 +1195,8 @@ class V8_EXPORT ScriptCompiler {
// alive.
V8_INLINE const CachedData* GetCachedData() const;
+ V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
+
// Prevent copying.
Source(const Source&) = delete;
Source& operator=(const Source&) = delete;
@@ -1433,7 +1439,7 @@ class V8_EXPORT ScriptCompiler {
private:
static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
- Isolate* isolate, Source* source, CompileOptions options, bool is_module);
+ Isolate* isolate, Source* source, CompileOptions options);
};
@@ -1486,6 +1492,11 @@ class V8_EXPORT Message {
int GetEndPosition() const;
/**
+ * Returns the error level of the message.
+ */
+ int ErrorLevel() const;
+
+ /**
* Returns the index within the line of the first character where
* the error occurred.
*/
@@ -1713,9 +1724,26 @@ class V8_EXPORT ValueSerializer {
virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
/*
+ * Called when the ValueSerializer is going to serialize a
+ * SharedArrayBuffer object. The embedder must return an ID for the
+ * object, using the same ID if this SharedArrayBuffer has already been
+ * serialized in this buffer. When deserializing, this ID will be passed to
+ * ValueDeserializer::TransferSharedArrayBuffer as |transfer_id|.
+ *
+ * If the object cannot be serialized, an
+ * exception should be thrown and Nothing<uint32_t>() returned.
+ */
+ virtual Maybe<uint32_t> GetSharedArrayBufferId(
+ Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
+
+ /*
* Allocates memory for the buffer of at least the size provided. The actual
* size (which may be greater or equal) is written to |actual_size|. If no
* buffer has been allocated yet, nullptr will be provided.
+ *
+ * If the memory cannot be allocated, nullptr should be returned.
+ * |actual_size| will be ignored. It is assumed that |old_buffer| is still
+ * valid in this case and has not been modified.
*/
virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
size_t* actual_size);
@@ -1757,7 +1785,7 @@ class V8_EXPORT ValueSerializer {
/*
* Marks an ArrayBuffer as havings its contents transferred out of band.
- * Pass the corresponding JSArrayBuffer in the deserializing context to
+ * Pass the corresponding ArrayBuffer in the deserializing context to
* ValueDeserializer::TransferArrayBuffer.
*/
void TransferArrayBuffer(uint32_t transfer_id,
@@ -1766,8 +1794,19 @@ class V8_EXPORT ValueSerializer {
/*
* Similar to TransferArrayBuffer, but for SharedArrayBuffer.
*/
- void TransferSharedArrayBuffer(uint32_t transfer_id,
- Local<SharedArrayBuffer> shared_array_buffer);
+ V8_DEPRECATE_SOON("Use Delegate::GetSharedArrayBufferId",
+ void TransferSharedArrayBuffer(
+ uint32_t transfer_id,
+ Local<SharedArrayBuffer> shared_array_buffer));
+
+ /*
+ * Indicate whether to treat ArrayBufferView objects as host objects,
+ * i.e. pass them to Delegate::WriteHostObject. This should not be
+ * called when no Delegate was passed.
+ *
+ * The default is not to treat ArrayBufferViews as host objects.
+ */
+ void SetTreatArrayBufferViewsAsHostObjects(bool mode);
/*
* Write raw data in various common formats to the buffer.
@@ -1834,9 +1873,10 @@ class V8_EXPORT ValueDeserializer {
/*
* Similar to TransferArrayBuffer, but for SharedArrayBuffer.
- * transfer_id exists in the same namespace as unshared ArrayBuffer objects.
+ * The id is not necessarily in the same namespace as unshared ArrayBuffer
+ * objects.
*/
- void TransferSharedArrayBuffer(uint32_t transfer_id,
+ void TransferSharedArrayBuffer(uint32_t id,
Local<SharedArrayBuffer> shared_array_buffer);
/*
@@ -1908,9 +1948,16 @@ class V8_EXPORT Value : public Data {
*/
V8_INLINE bool IsNull() const;
- /**
- * Returns true if this value is true.
+ /**
+ * Returns true if this value is either the null or the undefined value.
+ * See ECMA-262
+ * 4.3.11. and 4.3.12
*/
+ V8_INLINE bool IsNullOrUndefined() const;
+
+ /**
+ * Returns true if this value is true.
+ */
bool IsTrue() const;
/**
@@ -1920,7 +1967,6 @@ class V8_EXPORT Value : public Data {
/**
* Returns true if this value is a symbol or a string.
- * This is an experimental feature.
*/
bool IsName() const;
@@ -1932,7 +1978,6 @@ class V8_EXPORT Value : public Data {
/**
* Returns true if this value is a symbol.
- * This is an experimental feature.
*/
bool IsSymbol() const;
@@ -2004,7 +2049,6 @@ class V8_EXPORT Value : public Data {
/**
* Returns true if this value is a Symbol object.
- * This is an experimental feature.
*/
bool IsSymbolObject() const;
@@ -2025,19 +2069,16 @@ class V8_EXPORT Value : public Data {
/**
* Returns true if this value is a Generator function.
- * This is an experimental feature.
*/
bool IsGeneratorFunction() const;
/**
* Returns true if this value is a Generator object (iterator).
- * This is an experimental feature.
*/
bool IsGeneratorObject() const;
/**
* Returns true if this value is a Promise.
- * This is an experimental feature.
*/
bool IsPromise() const;
@@ -2073,85 +2114,66 @@ class V8_EXPORT Value : public Data {
/**
* Returns true if this value is an ArrayBuffer.
- * This is an experimental feature.
*/
bool IsArrayBuffer() const;
/**
* Returns true if this value is an ArrayBufferView.
- * This is an experimental feature.
*/
bool IsArrayBufferView() const;
/**
* Returns true if this value is one of TypedArrays.
- * This is an experimental feature.
*/
bool IsTypedArray() const;
/**
* Returns true if this value is an Uint8Array.
- * This is an experimental feature.
*/
bool IsUint8Array() const;
/**
* Returns true if this value is an Uint8ClampedArray.
- * This is an experimental feature.
*/
bool IsUint8ClampedArray() const;
/**
* Returns true if this value is an Int8Array.
- * This is an experimental feature.
*/
bool IsInt8Array() const;
/**
* Returns true if this value is an Uint16Array.
- * This is an experimental feature.
*/
bool IsUint16Array() const;
/**
* Returns true if this value is an Int16Array.
- * This is an experimental feature.
*/
bool IsInt16Array() const;
/**
* Returns true if this value is an Uint32Array.
- * This is an experimental feature.
*/
bool IsUint32Array() const;
/**
* Returns true if this value is an Int32Array.
- * This is an experimental feature.
*/
bool IsInt32Array() const;
/**
* Returns true if this value is a Float32Array.
- * This is an experimental feature.
*/
bool IsFloat32Array() const;
/**
* Returns true if this value is a Float64Array.
- * This is an experimental feature.
*/
bool IsFloat64Array() const;
/**
- * Returns true if this value is a SIMD Float32x4.
- * This is an experimental feature.
- */
- bool IsFloat32x4() const;
-
- /**
* Returns true if this value is a DataView.
- * This is an experimental feature.
*/
bool IsDataView() const;
@@ -2244,11 +2266,12 @@ class V8_EXPORT Value : public Data {
template <class T> V8_INLINE static Value* Cast(T* value);
- Local<String> TypeOf(v8::Isolate*);
+ Local<String> TypeOf(Isolate*);
private:
V8_INLINE bool QuickIsUndefined() const;
V8_INLINE bool QuickIsNull() const;
+ V8_INLINE bool QuickIsNullOrUndefined() const;
V8_INLINE bool QuickIsString() const;
bool FullIsUndefined() const;
bool FullIsNull() const;
@@ -2291,9 +2314,10 @@ class V8_EXPORT Name : public Primitive {
*/
int GetIdentityHash();
- V8_INLINE static Name* Cast(v8::Value* obj);
+ V8_INLINE static Name* Cast(Value* obj);
+
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -2310,7 +2334,7 @@ class V8_EXPORT String : public Name {
enum Encoding {
UNKNOWN_ENCODING = 0x1,
TWO_BYTE_ENCODING = 0x0,
- ONE_BYTE_ENCODING = 0x4
+ ONE_BYTE_ENCODING = 0x8
};
/**
* Returns the number of characters in this string.
@@ -2391,7 +2415,7 @@ class V8_EXPORT String : public Name {
/**
* A zero length string.
*/
- V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
+ V8_INLINE static Local<String> Empty(Isolate* isolate);
/**
* Returns true if the string is external
@@ -2425,7 +2449,8 @@ class V8_EXPORT String : public Name {
void operator=(const ExternalStringResourceBase&) = delete;
private:
- friend class v8::internal::Heap;
+ friend class internal::Heap;
+ friend class v8::String;
};
/**
@@ -2669,8 +2694,6 @@ class V8_EXPORT String : public Name {
/**
* A JavaScript symbol (ECMA-262 edition 6)
- *
- * This is an experimental feature. Use at your own risk.
*/
class V8_EXPORT Symbol : public Name {
public:
@@ -2695,14 +2718,15 @@ class V8_EXPORT Symbol : public Name {
// Well-known symbols
static Local<Symbol> GetIterator(Isolate* isolate);
static Local<Symbol> GetUnscopables(Isolate* isolate);
+ static Local<Symbol> GetToPrimitive(Isolate* isolate);
static Local<Symbol> GetToStringTag(Isolate* isolate);
static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
- V8_INLINE static Symbol* Cast(v8::Value* obj);
+ V8_INLINE static Symbol* Cast(Value* obj);
private:
Symbol();
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -3695,7 +3719,7 @@ class V8_EXPORT Function : public Object {
/**
* Tells whether this function is builtin.
*/
- bool IsBuiltin() const;
+ V8_DEPRECATED("this should no longer be used.", bool IsBuiltin() const);
/**
* Returns scriptId.
@@ -3720,10 +3744,15 @@ class V8_EXPORT Function : public Object {
/**
* An instance of the built-in Promise constructor (ES6 draft).
- * This API is experimental. Only works with --harmony flag.
*/
class V8_EXPORT Promise : public Object {
public:
+ /**
+ * State of the promise. Each value corresponds to one of the possible values
+ * of the [[PromiseState]] field.
+ */
+ enum PromiseState { kPending, kFulfilled, kRejected };
+
class V8_EXPORT Resolver : public Object {
public:
/**
@@ -3780,6 +3809,17 @@ class V8_EXPORT Promise : public Object {
*/
bool HasHandler();
+ /**
+ * Returns the content of the [[PromiseResult]] field. The Promise must not
+ * be pending.
+ */
+ Local<Value> Result();
+
+ /**
+ * Returns the value of the [[PromiseState]] field.
+ */
+ PromiseState State();
+
V8_INLINE static Promise* Cast(Value* obj);
private:
@@ -3926,7 +3966,6 @@ enum class ArrayBufferCreationMode { kInternalized, kExternalized };
/**
* An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT ArrayBuffer : public Object {
public:
@@ -3982,8 +4021,6 @@ class V8_EXPORT ArrayBuffer : public Object {
*
* The Data pointer of ArrayBuffer::Contents is always allocated with
* Allocator::Allocate that is set via Isolate::CreateParams.
- *
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Contents { // NOLINT
public:
@@ -4084,8 +4121,6 @@ class V8_EXPORT ArrayBuffer : public Object {
/**
* A base class for an instance of one of "views" over ArrayBuffer,
* including TypedArrays and DataView (ES6 draft 15.13).
- *
- * This API is experimental and may change significantly.
*/
class V8_EXPORT ArrayBufferView : public Object {
public:
@@ -4133,7 +4168,6 @@ class V8_EXPORT ArrayBufferView : public Object {
/**
* A base class for an instance of TypedArray series of constructors
* (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT TypedArray : public ArrayBufferView {
public:
@@ -4153,7 +4187,6 @@ class V8_EXPORT TypedArray : public ArrayBufferView {
/**
* An instance of Uint8Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Uint8Array : public TypedArray {
public:
@@ -4171,7 +4204,6 @@ class V8_EXPORT Uint8Array : public TypedArray {
/**
* An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Uint8ClampedArray : public TypedArray {
public:
@@ -4189,7 +4221,6 @@ class V8_EXPORT Uint8ClampedArray : public TypedArray {
/**
* An instance of Int8Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Int8Array : public TypedArray {
public:
@@ -4207,7 +4238,6 @@ class V8_EXPORT Int8Array : public TypedArray {
/**
* An instance of Uint16Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Uint16Array : public TypedArray {
public:
@@ -4225,7 +4255,6 @@ class V8_EXPORT Uint16Array : public TypedArray {
/**
* An instance of Int16Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Int16Array : public TypedArray {
public:
@@ -4243,7 +4272,6 @@ class V8_EXPORT Int16Array : public TypedArray {
/**
* An instance of Uint32Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Uint32Array : public TypedArray {
public:
@@ -4261,7 +4289,6 @@ class V8_EXPORT Uint32Array : public TypedArray {
/**
* An instance of Int32Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Int32Array : public TypedArray {
public:
@@ -4279,7 +4306,6 @@ class V8_EXPORT Int32Array : public TypedArray {
/**
* An instance of Float32Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Float32Array : public TypedArray {
public:
@@ -4297,7 +4323,6 @@ class V8_EXPORT Float32Array : public TypedArray {
/**
* An instance of Float64Array constructor (ES6 draft 15.13.6).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT Float64Array : public TypedArray {
public:
@@ -4315,7 +4340,6 @@ class V8_EXPORT Float64Array : public TypedArray {
/**
* An instance of DataView constructor (ES6 draft 15.13.7).
- * This API is experimental and may change significantly.
*/
class V8_EXPORT DataView : public ArrayBufferView {
public:
@@ -4446,7 +4470,7 @@ class V8_EXPORT Date : public Object {
*/
double ValueOf() const;
- V8_INLINE static Date* Cast(v8::Value* obj);
+ V8_INLINE static Date* Cast(Value* obj);
/**
* Notification that the embedder has changed the time zone,
@@ -4463,7 +4487,7 @@ class V8_EXPORT Date : public Object {
static void DateTimeConfigurationChangeNotification(Isolate* isolate);
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -4476,10 +4500,10 @@ class V8_EXPORT NumberObject : public Object {
double ValueOf() const;
- V8_INLINE static NumberObject* Cast(v8::Value* obj);
+ V8_INLINE static NumberObject* Cast(Value* obj);
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -4493,10 +4517,10 @@ class V8_EXPORT BooleanObject : public Object {
bool ValueOf() const;
- V8_INLINE static BooleanObject* Cast(v8::Value* obj);
+ V8_INLINE static BooleanObject* Cast(Value* obj);
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -4509,17 +4533,15 @@ class V8_EXPORT StringObject : public Object {
Local<String> ValueOf() const;
- V8_INLINE static StringObject* Cast(v8::Value* obj);
+ V8_INLINE static StringObject* Cast(Value* obj);
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
/**
* A Symbol object (ECMA-262 edition 6).
- *
- * This is an experimental feature. Use at your own risk.
*/
class V8_EXPORT SymbolObject : public Object {
public:
@@ -4527,10 +4549,10 @@ class V8_EXPORT SymbolObject : public Object {
Local<Symbol> ValueOf() const;
- V8_INLINE static SymbolObject* Cast(v8::Value* obj);
+ V8_INLINE static SymbolObject* Cast(Value* obj);
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -4580,10 +4602,10 @@ class V8_EXPORT RegExp : public Object {
*/
Flags GetFlags() const;
- V8_INLINE static RegExp* Cast(v8::Value* obj);
+ V8_INLINE static RegExp* Cast(Value* obj);
private:
- static void CheckCast(v8::Value* obj);
+ static void CheckCast(Value* obj);
};
@@ -4600,8 +4622,11 @@ class V8_EXPORT External : public Value {
static void CheckCast(v8::Value* obj);
};
-
-#define V8_INTRINSICS_LIST(F) F(ArrayProto_values, array_values_iterator)
+#define V8_INTRINSICS_LIST(F) \
+ F(ArrayProto_entries, array_entries_iterator) \
+ F(ArrayProto_forEach, array_for_each_iterator) \
+ F(ArrayProto_keys, array_keys_iterator) \
+ F(ArrayProto_values, array_values_iterator)
enum Intrinsic {
#define V8_DECL_INTRINSIC(name, iname) k##name,
@@ -5144,7 +5169,11 @@ class V8_EXPORT FunctionTemplate : public Template {
/** Get the InstanceTemplate. */
Local<ObjectTemplate> InstanceTemplate();
- /** Causes the function template to inherit from a parent function template.*/
+ /**
+ * Causes the function template to inherit from a parent function template.
+ * This means the the function's prototype.__proto__ is set to the parent
+ * function's prototype.
+ **/
void Inherit(Local<FunctionTemplate> parent);
/**
@@ -5154,6 +5183,14 @@ class V8_EXPORT FunctionTemplate : public Template {
Local<ObjectTemplate> PrototypeTemplate();
/**
+ * A PrototypeProviderTemplate is another function template whose prototype
+ * property is used for this template. This is mutually exclusive with setting
+ * a prototype template indirectly by calling PrototypeTemplate() or using
+ * Inherit().
+ **/
+ void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
+
+ /**
* Set the class name of the FunctionTemplate. This is used for
* printing objects created with the function created from the
* FunctionTemplate as its constructor.
@@ -5611,9 +5648,9 @@ class V8_EXPORT Extension { // NOLINT
const char** deps = 0,
int source_length = -1);
virtual ~Extension() { }
- virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Local<v8::String> name) {
- return v8::Local<v8::FunctionTemplate>();
+ virtual Local<FunctionTemplate> GetNativeFunctionTemplate(
+ Isolate* isolate, Local<String> name) {
+ return Local<FunctionTemplate>();
}
const char* name() const { return name_; }
@@ -5718,7 +5755,7 @@ typedef void (*FatalErrorCallback)(const char* location, const char* message);
typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom);
-typedef void (*MessageCallback)(Local<Message> message, Local<Value> error);
+typedef void (*MessageCallback)(Local<Message> message, Local<Value> data);
// --- Tracing ---
@@ -5787,6 +5824,27 @@ typedef void (*BeforeCallEnteredCallback)(Isolate*);
typedef void (*CallCompletedCallback)(Isolate*);
typedef void (*DeprecatedCallCompletedCallback)();
+/**
+ * PromiseHook with type kInit is called when a new promise is
+ * created. When a new promise is created as part of the chain in the
+ * case of Promise.then or in the intermediate promises created by
+ * Promise.{race, all}/AsyncFunctionAwait, we pass the parent promise
+ * otherwise we pass undefined.
+ *
+ * PromiseHook with type kResolve is called at the beginning of
+ * resolve or reject function defined by CreateResolvingFunctions.
+ *
+ * PromiseHook with type kBefore is called at the beginning of the
+ * PromiseReactionJob.
+ *
+ * PromiseHook with type kAfter is called right at the end of the
+ * PromiseReactionJob.
+ */
+enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
+
+typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
+ Local<Value> parent);
+
// --- Promise Reject Callback ---
enum PromiseRejectEvent {
kPromiseRejectWithNoHandler = 0,
@@ -5889,6 +5947,21 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
*/
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context);
+// --- WASM compilation callbacks ---
+
+/**
+ * Callback to check if a buffer source may be compiled to WASM, given
+ * the compilation is attempted as a promise or not.
+ */
+
+typedef bool (*AllowWasmCompileCallback)(Isolate* isolate, Local<Value> source,
+ bool as_promise);
+
+typedef bool (*AllowWasmInstantiateCallback)(Isolate* isolate,
+ Local<Value> module_or_bytes,
+ MaybeLocal<Value> ffi,
+ bool as_promise);
+
// --- Garbage Collection Callbacks ---
/**
@@ -6249,17 +6322,33 @@ class V8_EXPORT EmbedderHeapTracer {
};
/**
- * Callback to the embedder used in SnapshotCreator to handle internal fields.
+ * Callback and supporting data used in SnapshotCreator to implement embedder
+ * logic to serialize internal fields.
*/
-typedef StartupData (*SerializeInternalFieldsCallback)(Local<Object> holder,
- int index);
+struct SerializeInternalFieldsCallback {
+ typedef StartupData (*CallbackFunction)(Local<Object> holder, int index,
+ void* data);
+ SerializeInternalFieldsCallback(CallbackFunction function = nullptr,
+ void* data_arg = nullptr)
+ : callback(function), data(data_arg) {}
+ CallbackFunction callback;
+ void* data;
+};
/**
- * Callback to the embedder used to deserialize internal fields.
+ * Callback and supporting data used to implement embedder logic to deserialize
+ * internal fields.
*/
-typedef void (*DeserializeInternalFieldsCallback)(Local<Object> holder,
- int index,
- StartupData payload);
+struct DeserializeInternalFieldsCallback {
+ typedef void (*CallbackFunction)(Local<Object> holder, int index,
+ StartupData payload, void* data);
+ DeserializeInternalFieldsCallback(CallbackFunction function = nullptr,
+ void* data_arg = nullptr)
+ : callback(function), data(data_arg) {}
+ void (*callback)(Local<Object> holder, int index, StartupData payload,
+ void* data);
+ void* data;
+};
/**
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
@@ -6284,7 +6373,7 @@ class V8_EXPORT Isolate {
add_histogram_sample_callback(nullptr),
array_buffer_allocator(nullptr),
external_references(nullptr),
- deserialize_internal_fields_callback(nullptr) {}
+ allow_atomics_wait(true) {}
/**
* The optional entry_hook allows the host application to provide the
@@ -6342,10 +6431,10 @@ class V8_EXPORT Isolate {
intptr_t* external_references;
/**
- * Specifies an optional callback to deserialize internal fields. It
- * should match the SerializeInternalFieldCallback used to serialize.
+ * Whether calling Atomics.wait (a function that may block) is allowed in
+ * this isolate.
*/
- DeserializeInternalFieldsCallback deserialize_internal_fields_callback;
+ bool allow_atomics_wait;
};
@@ -6481,12 +6570,25 @@ class V8_EXPORT Isolate {
kLegacyDateParser = 33,
kDefineGetterOrSetterWouldThrow = 34,
kFunctionConstructorReturnedUndefined = 35,
+ kAssigmentExpressionLHSIsCallInSloppy = 36,
+ kAssigmentExpressionLHSIsCallInStrict = 37,
+ kPromiseConstructorReturnedUndefined = 38,
// If you add new values here, you'll also need to update Chromium's:
// UseCounter.h, V8PerIsolateData.cpp, histograms.xml
kUseCounterFeatureCount // This enum value must be last.
};
+ enum MessageErrorLevel {
+ kMessageLog = (1 << 0),
+ kMessageDebug = (1 << 1),
+ kMessageInfo = (1 << 2),
+ kMessageError = (1 << 3),
+ kMessageWarning = (1 << 4),
+ kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
+ kMessageWarning,
+ };
+
typedef void (*UseCounterCallback)(Isolate* isolate,
UseCounterFeature feature);
@@ -6707,6 +6809,14 @@ class V8_EXPORT Isolate {
Local<Context> GetEnteredContext();
/**
+ * Returns either the last context entered through V8's C++ API, or the
+ * context of the currently running microtask while processing microtasks.
+ * If a context is entered while executing a microtask, that context is
+ * returned.
+ */
+ Local<Context> GetEnteredOrMicrotaskContext();
+
+ /**
* Schedules an exception to be thrown when returning to JavaScript. When an
* exception has been scheduled it is illegal to invoke any JavaScript
* operation; the caller must return immediately and only after the exception
@@ -6725,8 +6835,10 @@ class V8_EXPORT Isolate {
* garbage collection types it is sufficient to provide object groups
* for partially dependent handles only.
*/
- template<typename T> void SetObjectGroupId(const Persistent<T>& object,
- UniqueId id);
+ template <typename T>
+ V8_DEPRECATED("Use EmbedderHeapTracer",
+ void SetObjectGroupId(const Persistent<T>& object,
+ UniqueId id));
/**
* Allows the host application to declare implicit references from an object
@@ -6735,8 +6847,10 @@ class V8_EXPORT Isolate {
* are removed. It is intended to be used in the before-garbage-collection
* callback function.
*/
- template<typename T> void SetReferenceFromGroup(UniqueId id,
- const Persistent<T>& child);
+ template <typename T>
+ V8_DEPRECATED("Use EmbedderHeapTracer",
+ void SetReferenceFromGroup(UniqueId id,
+ const Persistent<T>& child));
/**
* Allows the host application to declare implicit references from an object
@@ -6744,8 +6858,10 @@ class V8_EXPORT Isolate {
* too. After each garbage collection, all implicit references are removed. It
* is intended to be used in the before-garbage-collection callback function.
*/
- template<typename T, typename S>
- void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
+ template <typename T, typename S>
+ V8_DEPRECATED("Use EmbedderHeapTracer",
+ void SetReference(const Persistent<T>& parent,
+ const Persistent<S>& child));
typedef void (*GCCallback)(Isolate* isolate, GCType type,
GCCallbackFlags flags);
@@ -6888,6 +7004,12 @@ class V8_EXPORT Isolate {
DeprecatedCallCompletedCallback callback));
/**
+ * Experimental: Set the PromiseHook callback for various promise
+ * lifecycle events.
+ */
+ void SetPromiseHook(PromiseHook hook);
+
+ /**
* Set callback to notify about promise reject with no handler, or
* revocation of such a previous notification once the handler is added.
*/
@@ -7021,6 +7143,23 @@ class V8_EXPORT Isolate {
void SetRAILMode(RAILMode rail_mode);
/**
+ * Optional notification to tell V8 the current isolate is used for debugging
+ * and requires higher heap limit.
+ */
+ void IncreaseHeapLimitForDebugging();
+
+ /**
+ * Restores the original heap limit after IncreaseHeapLimitForDebugging().
+ */
+ void RestoreOriginalHeapLimit();
+
+ /**
+ * Returns true if the heap limit was increased for debugging and the
+ * original heap limit was not restored yet.
+ */
+ bool IsHeapLimitIncreasedForDebugging();
+
+ /**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
*
@@ -7085,13 +7224,23 @@ class V8_EXPORT Isolate {
AllowCodeGenerationFromStringsCallback callback);
/**
+ * Set the callback to invoke to check if wasm compilation from
+ * the specified object is allowed. By default, wasm compilation
+ * is allowed.
+ *
+ * Similar for instantiate.
+ */
+ void SetAllowWasmCompileCallback(AllowWasmCompileCallback callback);
+ void SetAllowWasmInstantiateCallback(AllowWasmInstantiateCallback callback);
+
+ /**
* Check if V8 is dead and therefore unusable. This is the case after
* fatal errors such as out-of-memory situations.
*/
bool IsDead();
/**
- * Adds a message listener.
+ * Adds a message listener (errors only).
*
* The same message listener can be added more than once and in that
* case it will be called more than once for each message.
@@ -7103,6 +7252,21 @@ class V8_EXPORT Isolate {
Local<Value> data = Local<Value>());
/**
+ * Adds a message listener.
+ *
+ * The same message listener can be added more than once and in that
+ * case it will be called more than once for each message.
+ *
+ * If data is specified, it will be passed to the callback when it is called.
+ * Otherwise, the exception object will be passed to the callback instead.
+ *
+ * A listener can listen for particular error levels by providing a mask.
+ */
+ bool AddMessageListenerWithErrorLevel(MessageCallback that,
+ int message_levels,
+ Local<Value> data = Local<Value>());
+
+ /**
* Remove all message listeners from the specified callback function.
*/
void RemoveMessageListeners(MessageCallback that);
@@ -7598,10 +7762,23 @@ class V8_EXPORT SnapshotCreator {
Isolate* GetIsolate();
/**
- * Add a context to be included in the snapshot blob.
+ * Set the default context to be included in the snapshot blob.
+ * The snapshot will not contain the global proxy, and we expect one or a
+ * global object template to create one, to be provided upon deserialization.
+ */
+ void SetDefaultContext(Local<Context> context);
+
+ /**
+ * Add additional context to be included in the snapshot blob.
+ * The snapshot will include the global proxy.
+ *
+ * \param callback optional callback to serialize internal fields.
+ *
* \returns the index of the context in the snapshot blob.
*/
- size_t AddContext(Local<Context> context);
+ size_t AddContext(Local<Context> context,
+ SerializeInternalFieldsCallback callback =
+ SerializeInternalFieldsCallback());
/**
* Add a template to be included in the snapshot blob.
@@ -7614,12 +7791,10 @@ class V8_EXPORT SnapshotCreator {
* This must not be called from within a handle scope.
* \param function_code_handling whether to include compiled function code
* in the snapshot.
- * \param callback to serialize embedder-set internal fields.
* \returns { nullptr, 0 } on failure, and a startup snapshot on success. The
* caller acquires ownership of the data array in the return value.
*/
- StartupData CreateBlob(FunctionCodeHandling function_code_handling,
- SerializeInternalFieldsCallback callback = nullptr);
+ StartupData CreateBlob(FunctionCodeHandling function_code_handling);
// Disallow copying and assigning.
SnapshotCreator(const SnapshotCreator&) = delete;
@@ -7825,21 +8000,21 @@ class V8_EXPORT TryCatch {
* UseAfterReturn is enabled, then the address returned will be the address
* of the C++ try catch handler itself.
*/
- static void* JSStackComparableAddress(v8::TryCatch* handler) {
+ static void* JSStackComparableAddress(TryCatch* handler) {
if (handler == NULL) return NULL;
return handler->js_stack_comparable_address_;
}
TryCatch(const TryCatch&) = delete;
void operator=(const TryCatch&) = delete;
- void* operator new(size_t size) = delete;
- void operator delete(void*, size_t) = delete;
+ void* operator new(size_t size);
+ void operator delete(void*, size_t);
private:
void ResetInternal();
- v8::internal::Isolate* isolate_;
- v8::TryCatch* next_;
+ internal::Isolate* isolate_;
+ TryCatch* next_;
void* exception_;
void* message_obj_;
void* js_stack_comparable_address_;
@@ -7849,7 +8024,7 @@ class V8_EXPORT TryCatch {
bool rethrow_ : 1;
bool has_terminated_ : 1;
- friend class v8::internal::Isolate;
+ friend class internal::Isolate;
};
@@ -7922,10 +8097,30 @@ class V8_EXPORT Context {
MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
MaybeLocal<Value> global_object = MaybeLocal<Value>());
+ /**
+ * Create a new context from a (non-default) context snapshot. There
+ * is no way to provide a global object template since we do not create
+ * a new global object from template, but we can reuse a global object.
+ *
+ * \param isolate See v8::Context::New.
+ *
+ * \param context_snapshot_index The index of the context snapshot to
+ * deserialize from. Use v8::Context::New for the default snapshot.
+ *
+ * \param internal_fields_deserializer Optional callback to deserialize
+ * internal fields. It should match the SerializeInternalFieldCallback used
+ * to serialize.
+ *
+ * \param extensions See v8::Context::New.
+ *
+ * \param global_object See v8::Context::New.
+ */
+
static MaybeLocal<Context> FromSnapshot(
Isolate* isolate, size_t context_snapshot_index,
+ DeserializeInternalFieldsCallback internal_fields_deserializer =
+ DeserializeInternalFieldsCallback(),
ExtensionConfiguration* extensions = nullptr,
- MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
MaybeLocal<Value> global_object = MaybeLocal<Value>());
/**
@@ -7976,7 +8171,7 @@ class V8_EXPORT Context {
void Exit();
/** Returns an isolate associated with a current context. */
- v8::Isolate* GetIsolate();
+ Isolate* GetIsolate();
/**
* The field at kDebugIdIndex is reserved for V8 debugger implementation.
@@ -8308,10 +8503,10 @@ class Internals {
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
static const int kContextEmbedderDataIndex = 5;
- static const int kFullStringRepresentationMask = 0x07;
- static const int kStringEncodingMask = 0x4;
+ static const int kFullStringRepresentationMask = 0x0f;
+ static const int kStringEncodingMask = 0x8;
static const int kExternalTwoByteRepresentationTag = 0x02;
- static const int kExternalOneByteRepresentationTag = 0x06;
+ static const int kExternalOneByteRepresentationTag = 0x0a;
static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
static const int kExternalMemoryOffset = 4 * kApiPointerSize;
@@ -8336,11 +8531,11 @@ class Internals {
static const int kNodeIsIndependentShift = 3;
static const int kNodeIsActiveShift = 4;
- static const int kJSObjectType = 0xbc;
- static const int kJSApiObjectType = 0xbb;
+ static const int kJSApiObjectType = 0xb9;
+ static const int kJSObjectType = 0xba;
static const int kFirstNonstringType = 0x80;
- static const int kOddballType = 0x83;
- static const int kForeignType = 0x87;
+ static const int kOddballType = 0x82;
+ static const int kForeignType = 0x86;
static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3;
@@ -8856,17 +9051,17 @@ ScriptOrigin::ScriptOrigin(Local<Value> resource_name,
Local<Integer> resource_column_offset,
Local<Boolean> resource_is_shared_cross_origin,
Local<Integer> script_id,
- Local<Boolean> resource_is_embedder_debug_script,
Local<Value> source_map_url,
- Local<Boolean> resource_is_opaque)
+ Local<Boolean> resource_is_opaque,
+ Local<Boolean> is_wasm, Local<Boolean> is_module)
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
- options_(!resource_is_embedder_debug_script.IsEmpty() &&
- resource_is_embedder_debug_script->IsTrue(),
- !resource_is_shared_cross_origin.IsEmpty() &&
+ options_(!resource_is_shared_cross_origin.IsEmpty() &&
resource_is_shared_cross_origin->IsTrue(),
- !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue()),
+ !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
+ !is_wasm.IsEmpty() && is_wasm->IsTrue(),
+ !is_module.IsEmpty() && is_module->IsTrue()),
script_id_(script_id),
source_map_url_(source_map_url) {}
@@ -8915,14 +9110,16 @@ const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
return cached_data;
}
+const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions() const {
+ return resource_options;
+}
Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
return value ? True(isolate) : False(isolate);
}
-
-void Template::Set(Isolate* isolate, const char* name, v8::Local<Data> value) {
- Set(v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
+void Template::Set(Isolate* isolate, const char* name, Local<Data> value) {
+ Set(String::NewFromUtf8(isolate, name, NewStringType::kInternalized)
.ToLocalChecked(),
value);
}
@@ -9056,6 +9253,23 @@ bool Value::QuickIsNull() const {
return (I::GetOddballKind(obj) == I::kNullOddballKind);
}
+bool Value::IsNullOrUndefined() const {
+#ifdef V8_ENABLE_CHECKS
+ return FullIsNull() || FullIsUndefined();
+#else
+ return QuickIsNullOrUndefined();
+#endif
+}
+
+bool Value::QuickIsNullOrUndefined() const {
+ typedef internal::Object O;
+ typedef internal::Internals I;
+ O* obj = *reinterpret_cast<O* const*>(this);
+ if (!I::HasHeapObjectTag(obj)) return false;
+ if (I::GetInstanceType(obj) != I::kOddballType) return false;
+ int kind = I::GetOddballKind(obj);
+ return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind;
+}
bool Value::IsString() const {
#ifdef V8_ENABLE_CHECKS
@@ -9531,7 +9745,7 @@ template<typename T>
void Isolate::SetObjectGroupId(const Persistent<T>& object,
UniqueId id) {
TYPE_CHECK(Value, T);
- SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id);
+ SetObjectGroupId(reinterpret_cast<internal::Object**>(object.val_), id);
}
@@ -9539,8 +9753,7 @@ template<typename T>
void Isolate::SetReferenceFromGroup(UniqueId id,
const Persistent<T>& object) {
TYPE_CHECK(Value, T);
- SetReferenceFromGroup(id,
- reinterpret_cast<v8::internal::Object**>(object.val_));
+ SetReferenceFromGroup(id, reinterpret_cast<internal::Object**>(object.val_));
}
@@ -9549,8 +9762,8 @@ void Isolate::SetReference(const Persistent<T>& parent,
const Persistent<S>& child) {
TYPE_CHECK(Object, T);
TYPE_CHECK(Value, S);
- SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_),
- reinterpret_cast<v8::internal::Object**>(child.val_));
+ SetReference(reinterpret_cast<internal::Object**>(parent.val_),
+ reinterpret_cast<internal::Object**>(child.val_));
}
@@ -9627,14 +9840,14 @@ void V8::SetFatalErrorHandler(FatalErrorCallback callback) {
void V8::RemoveGCPrologueCallback(GCCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->RemoveGCPrologueCallback(
- reinterpret_cast<v8::Isolate::GCCallback>(callback));
+ reinterpret_cast<Isolate::GCCallback>(callback));
}
void V8::RemoveGCEpilogueCallback(GCCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->RemoveGCEpilogueCallback(
- reinterpret_cast<v8::Isolate::GCCallback>(callback));
+ reinterpret_cast<Isolate::GCCallback>(callback));
}
void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }