-
-
Save addaleax/4cb6d8dc35e4c4adfe89b8d55680f0f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- deps/v8/include/v8.h 2017-05-06 20:26:52.304139042 +0200 | |
+++ ../../v8-wrap/v8/include/v8.h 2017-05-04 16:28:42.456713336 +0200 | |
@@ -128,7 +128,6 @@ | |
template<class T, class P> class WeakCallbackObject; | |
class FunctionTemplate; | |
class ObjectTemplate; | |
-class Data; | |
template<typename T> class FunctionCallbackInfo; | |
template<typename T> class PropertyCallbackInfo; | |
class StackTrace; | |
@@ -151,6 +150,9 @@ | |
class GlobalHandles; | |
} // namespace internal | |
+namespace debug { | |
+class ConsoleCallArguments; | |
+} // namespace debug | |
// --- Handles --- | |
@@ -159,7 +161,6 @@ | |
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ | |
} | |
- | |
/** | |
* An object reference managed by the v8 garbage collector. | |
* | |
@@ -173,10 +174,16 @@ | |
* allocated on the heap. | |
* | |
* There are two types of handles: local and persistent handles. | |
+ * | |
* Local handles are light-weight and transient and typically used in | |
- * local operations. They are managed by HandleScopes. Persistent | |
- * handles can be used when storing objects across several independent | |
- * operations and have to be explicitly deallocated when they're no | |
+ * local operations. They are managed by HandleScopes. That means that a | |
+ * HandleScope must exist on the stack when they are created and that they are | |
+ * only valid inside of the HandleScope active during their creation. | |
+ * For passing a local handle to an outer HandleScope, an EscapableHandleScope | |
+ * and its Escape() method must be used. | |
+ * | |
+ * Persistent handles can be used when storing objects across several | |
+ * independent operations and have to be explicitly deallocated when they're no | |
* longer used. | |
* | |
* It is safe to extract the object stored in the handle by | |
@@ -254,6 +261,11 @@ | |
return !operator==(that); | |
} | |
+ /** | |
+ * Cast a handle to a subclass, e.g. Local<Value> to Local<Object>. | |
+ * This is only valid if the handle actually refers to a value of the | |
+ * target type. | |
+ */ | |
template <class S> V8_INLINE static Local<T> Cast(Local<S> that) { | |
#ifdef V8_ENABLE_CHECKS | |
// If we're going to perform the type check then we have to check | |
@@ -263,6 +275,11 @@ | |
return Local<T>(T::Cast(*that)); | |
} | |
+ /** | |
+ * Calling this is equivalent to Local<S>::Cast(). | |
+ * In particular, this is only valid if the handle actually refers to a value | |
+ * of the target type. | |
+ */ | |
template <class S> | |
V8_INLINE Local<S> As() const { | |
return Local<S>::Cast(*this); | |
@@ -339,15 +356,26 @@ | |
V8_INLINE bool IsEmpty() const { return val_ == nullptr; } | |
+ /** | |
+ * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, | |
+ * |false| is returned and |out| is left untouched. | |
+ */ | |
template <class S> | |
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const { | |
out->val_ = IsEmpty() ? nullptr : this->val_; | |
return !IsEmpty(); | |
} | |
- // Will crash if the MaybeLocal<> is empty. | |
+ /** | |
+ * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, | |
+ * V8 will crash the process. | |
+ */ | |
V8_INLINE Local<T> ToLocalChecked(); | |
+ /** | |
+ * Converts this MaybeLocal<> to a Local<>, using a default value if this | |
+ * MaybeLocal<> is empty. | |
+ */ | |
template <class S> | |
V8_INLINE Local<S> FromMaybe(Local<S> default_value) const { | |
return IsEmpty() ? default_value : Local<S>(val_); | |
@@ -357,8 +385,10 @@ | |
T* val_; | |
}; | |
- | |
-// Eternal handles are set-once handles that live for the life of the isolate. | |
+/** | |
+ * Eternal handles are set-once handles that live for the lifetime of the | |
+ * isolate. | |
+ */ | |
template <class T> class Eternal { | |
public: | |
V8_INLINE Eternal() : val_(nullptr) {} | |
@@ -377,7 +407,7 @@ | |
static const int kInternalFieldsInWeakCallback = 2; | |
- | |
+static const int kEmbedderFieldsInWeakCallback = 2; | |
template <typename T> | |
class WeakCallbackInfo { | |
@@ -385,11 +415,11 @@ | |
typedef void (*Callback)(const WeakCallbackInfo<T>& data); | |
WeakCallbackInfo(Isolate* isolate, T* parameter, | |
- void* internal_fields[kInternalFieldsInWeakCallback], | |
+ void* embedder_fields[kEmbedderFieldsInWeakCallback], | |
Callback* callback) | |
: isolate_(isolate), parameter_(parameter), callback_(callback) { | |
- for (int i = 0; i < kInternalFieldsInWeakCallback; ++i) { | |
- internal_fields_[i] = internal_fields[i]; | |
+ for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) { | |
+ embedder_fields_[i] = embedder_fields[i]; | |
} | |
} | |
@@ -399,11 +429,11 @@ | |
V8_INLINE V8_DEPRECATED("use indexed version", | |
void* GetInternalField1() const) { | |
- return internal_fields_[0]; | |
+ return embedder_fields_[0]; | |
} | |
V8_INLINE V8_DEPRECATED("use indexed version", | |
void* GetInternalField2() const) { | |
- return internal_fields_[1]; | |
+ return embedder_fields_[1]; | |
} | |
V8_DEPRECATED("Not realiable once SetSecondPassCallback() was used.", | |
@@ -423,7 +453,7 @@ | |
Isolate* isolate_; | |
T* parameter_; | |
Callback* callback_; | |
- void* internal_fields_[kInternalFieldsInWeakCallback]; | |
+ void* embedder_fields_[kEmbedderFieldsInWeakCallback]; | |
}; | |
@@ -438,10 +468,10 @@ | |
* An object reference that is independent of any handle scope. Where | |
* a Local handle only lives as long as the HandleScope in which it was | |
* allocated, a PersistentBase handle remains valid until it is explicitly | |
- * disposed. | |
+ * disposed using Reset(). | |
* | |
* A persistent handle contains a reference to a storage cell within | |
- * the v8 engine which holds an object value and which is updated by | |
+ * the V8 engine which holds an object value and which is updated by | |
* the garbage collector whenever the object is moved. A new storage | |
* cell can be created using the constructor or PersistentBase::Reset and | |
* existing handles can be disposed using PersistentBase::Reset. | |
@@ -899,6 +929,11 @@ | |
internal::Object** escape_slot_; | |
}; | |
+/** | |
+ * A SealHandleScope acts like a handle scope in which no handle allocations | |
+ * are allowed. It can be useful for debugging handle leaks. | |
+ * Handles can be allocated within inner normal HandleScopes. | |
+ */ | |
class V8_EXPORT SealHandleScope { | |
public: | |
SealHandleScope(Isolate* isolate); | |
@@ -1060,19 +1095,41 @@ | |
/** | |
* ModuleDeclarationInstantiation | |
* | |
- * Returns false if an exception occurred during instantiation. | |
+ * Returns false if an exception occurred during instantiation. (In the case | |
+ * where the callback throws an exception, that exception is propagated.) | |
*/ | |
V8_WARN_UNUSED_RESULT bool Instantiate(Local<Context> context, | |
ResolveCallback callback); | |
/** | |
* ModuleEvaluation | |
+ * | |
+ * Returns the completion value. | |
*/ | |
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context); | |
}; | |
-// Node.js-specific: This will be implemented by a later V8 upgrade! | |
-class DynamicImportResult; | |
+/** | |
+ * This is an unfinished experimental feature, and is only exposed | |
+ * here for internal testing purposes. DO NOT USE. | |
+ * | |
+ * A compiled JavaScript module. | |
+ */ | |
+class V8_EXPORT DynamicImportResult { | |
+ public: | |
+ /** | |
+ * Resolves the promise with the namespace object of the given | |
+ * module. | |
+ */ | |
+ V8_WARN_UNUSED_RESULT bool FinishDynamicImportSuccess(Local<Context> context, | |
+ Local<Module> module); | |
+ | |
+ /** | |
+ * Rejects the promise with the given exception. | |
+ */ | |
+ V8_WARN_UNUSED_RESULT bool FinishDynamicImportFailure(Local<Context> context, | |
+ Local<Value> exception); | |
+}; | |
/** | |
* A compiled JavaScript script, tied to a Context which was active when the | |
@@ -1364,7 +1421,7 @@ | |
* CachedData instance is still valid; the tag has no other meaing. | |
* | |
* Background: The data carried by CachedData may depend on the exact | |
- * V8 version number or currently compiler flags. This means when | |
+ * V8 version number or current compiler flags. This means that when | |
* persisting CachedData, the embedder must take care to not pass in | |
* data from another V8 version, or the same version with different | |
* features enabled. | |
@@ -1615,6 +1672,11 @@ | |
* constructor via "new". | |
*/ | |
bool IsConstructor() const; | |
+ | |
+ /** | |
+ * Returns whether or not the associated functions is defined in wasm. | |
+ */ | |
+ bool IsWasm() const; | |
}; | |
@@ -1684,21 +1746,21 @@ | |
public: | |
virtual ~Delegate() {} | |
- /* | |
+ /** | |
* Handles the case where a DataCloneError would be thrown in the structured | |
* clone spec. Other V8 embedders may throw some other appropriate exception | |
* type. | |
*/ | |
virtual void ThrowDataCloneError(Local<String> message) = 0; | |
- /* | |
+ /** | |
* The embedder overrides this method to write some kind of host object, if | |
* possible. If not, a suitable exception should be thrown and | |
* Nothing<bool>() returned. | |
*/ | |
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 | |
@@ -1713,7 +1775,7 @@ | |
virtual Maybe<uint32_t> GetWasmModuleTransferId( | |
Isolate* isolate, Local<WasmCompiledModule> module); | |
- /* | |
+ /** | |
* 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. | |
@@ -1725,7 +1787,7 @@ | |
virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, | |
size_t* actual_size); | |
- /* | |
+ /** | |
* Frees a buffer allocated with |ReallocateBufferMemory|. | |
*/ | |
virtual void FreeBufferMemory(void* buffer); | |
@@ -1735,24 +1797,24 @@ | |
ValueSerializer(Isolate* isolate, Delegate* delegate); | |
~ValueSerializer(); | |
- /* | |
+ /** | |
* Writes out a header, which includes the format version. | |
*/ | |
void WriteHeader(); | |
- /* | |
+ /** | |
* Serializes a JavaScript value into the buffer. | |
*/ | |
V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context, | |
Local<Value> value); | |
- /* | |
+ /** | |
* Returns the stored data. This serializer should not be used once the buffer | |
* is released. The contents are undefined if a previous write has failed. | |
*/ | |
V8_DEPRECATE_SOON("Use Release()", std::vector<uint8_t> ReleaseBuffer()); | |
- /* | |
+ /** | |
* Returns the stored data (allocated using the delegate's | |
* AllocateBufferMemory) and its size. This serializer should not be used once | |
* the buffer is released. The contents are undefined if a previous write has | |
@@ -1760,7 +1822,7 @@ | |
*/ | |
V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release(); | |
- /* | |
+ /** | |
* Marks an ArrayBuffer as havings its contents transferred out of band. | |
* Pass the corresponding ArrayBuffer in the deserializing context to | |
* ValueDeserializer::TransferArrayBuffer. | |
@@ -1768,7 +1830,7 @@ | |
void TransferArrayBuffer(uint32_t transfer_id, | |
Local<ArrayBuffer> array_buffer); | |
- /* | |
+ /** | |
* Similar to TransferArrayBuffer, but for SharedArrayBuffer. | |
*/ | |
V8_DEPRECATE_SOON("Use Delegate::GetSharedArrayBufferId", | |
@@ -1776,7 +1838,7 @@ | |
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. | |
@@ -1785,7 +1847,7 @@ | |
*/ | |
void SetTreatArrayBufferViewsAsHostObjects(bool mode); | |
- /* | |
+ /** | |
* Write raw data in various common formats to the buffer. | |
* Note that integer types are written in base-128 varint format, not with a | |
* binary copy. For use during an override of Delegate::WriteHostObject. | |
@@ -1817,14 +1879,14 @@ | |
public: | |
virtual ~Delegate() {} | |
- /* | |
+ /** | |
* The embedder overrides this method to read some kind of host object, if | |
* possible. If not, a suitable exception should be thrown and | |
* MaybeLocal<Object>() returned. | |
*/ | |
virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); | |
- /* | |
+ /** | |
* Get a WasmCompiledModule given a transfer_id previously provided | |
* by ValueSerializer::GetWasmModuleTransferId | |
*/ | |
@@ -1837,25 +1899,25 @@ | |
Delegate* delegate); | |
~ValueDeserializer(); | |
- /* | |
+ /** | |
* Reads and validates a header (including the format version). | |
* May, for example, reject an invalid or unsupported wire format. | |
*/ | |
V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context); | |
- /* | |
+ /** | |
* Deserializes a JavaScript value from the buffer. | |
*/ | |
V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context); | |
- /* | |
+ /** | |
* Accepts the array buffer corresponding to the one passed previously to | |
* ValueSerializer::TransferArrayBuffer. | |
*/ | |
void TransferArrayBuffer(uint32_t transfer_id, | |
Local<ArrayBuffer> array_buffer); | |
- /* | |
+ /** | |
* Similar to TransferArrayBuffer, but for SharedArrayBuffer. | |
* The id is not necessarily in the same namespace as unshared ArrayBuffer | |
* objects. | |
@@ -1863,7 +1925,7 @@ | |
void TransferSharedArrayBuffer(uint32_t id, | |
Local<SharedArrayBuffer> shared_array_buffer); | |
- /* | |
+ /** | |
* Must be called before ReadHeader to enable support for reading the legacy | |
* wire format (i.e., which predates this being shipped). | |
* | |
@@ -1872,14 +1934,19 @@ | |
*/ | |
void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); | |
- /* | |
+ /** | |
+ * Expect inline wasm in the data stream (rather than in-memory transfer) | |
+ */ | |
+ void SetExpectInlineWasm(bool allow_inline_wasm); | |
+ | |
+ /** | |
* Reads the underlying wire format version. Likely mostly to be useful to | |
* legacy code reading old wire format versions. Must be called after | |
* ReadHeader. | |
*/ | |
uint32_t GetWireFormatVersion() const; | |
- /* | |
+ /** | |
* Reads raw data in various common formats to the buffer. | |
* Note that integer types are read in base-128 varint format, not with a | |
* binary copy. For use during an override of Delegate::ReadHostObject. | |
@@ -1906,7 +1973,7 @@ | |
public: | |
static Local<NativeWeakMap> New(Isolate* isolate); | |
void Set(Local<Value> key, Local<Value> value); | |
- Local<Value> Get(Local<Value> key); | |
+ Local<Value> Get(Local<Value> key) const; | |
bool Has(Local<Value> key); | |
bool Delete(Local<Value> key); | |
}; | |
@@ -2252,6 +2319,8 @@ | |
Local<String> TypeOf(Isolate*); | |
+ Maybe<bool> InstanceOf(Local<Context> context, Local<Object> object); | |
+ | |
private: | |
V8_INLINE bool QuickIsUndefined() const; | |
V8_INLINE bool QuickIsNull() const; | |
@@ -2304,9 +2373,25 @@ | |
static void CheckCast(Value* obj); | |
}; | |
+/** | |
+ * A flag describing different modes of string creation. | |
+ * | |
+ * Aside from performance implications there are no differences between the two | |
+ * creation modes. | |
+ */ | |
+enum class NewStringType { | |
+ /** | |
+ * Create a new string, always allocating new storage memory. | |
+ */ | |
+ kNormal, | |
-enum class NewStringType { kNormal, kInternalized }; | |
- | |
+ /** | |
+ * Acts as a hint that the string should be created in the | |
+ * old generation heap space and be deduplicated if an identical string | |
+ * already exists. | |
+ */ | |
+ kInternalized | |
+}; | |
/** | |
* A JavaScript string value (ECMA-262, 4.3.17). | |
@@ -2321,7 +2406,7 @@ | |
ONE_BYTE_ENCODING = 0x8 | |
}; | |
/** | |
- * Returns the number of characters in this string. | |
+ * Returns the number of characters (UTF-16 code units) in this string. | |
*/ | |
int Length() const; | |
@@ -2332,14 +2417,16 @@ | |
int Utf8Length() const; | |
/** | |
- * Returns whether this string is known to contain only one byte data. | |
+ * Returns whether this string is known to contain only one byte data, | |
+ * i.e. ISO-8859-1 code points. | |
* Does not read the string. | |
* False negatives are possible. | |
*/ | |
bool IsOneByte() const; | |
/** | |
- * Returns whether this string contain only one byte data. | |
+ * Returns whether this string contain only one byte data, | |
+ * i.e. ISO-8859-1 code points. | |
* Will read the entire string in some cases. | |
*/ | |
bool ContainsOnlyOneByte() const; | |
@@ -2646,7 +2733,7 @@ | |
}; | |
/** | |
- * Converts an object to a two-byte string. | |
+ * Converts an object to a two-byte (UTF-16-encoded) string. | |
* If conversion to a string fails (eg. due to an exception in the toString() | |
* method of the object) then the length() method returns 0 and the * operator | |
* returns NULL. | |
@@ -2681,30 +2768,43 @@ | |
*/ | |
class V8_EXPORT Symbol : public Name { | |
public: | |
- // Returns the print name string of the symbol, or undefined if none. | |
+ /** | |
+ * Returns the print name string of the symbol, or undefined if none. | |
+ */ | |
Local<Value> Name() const; | |
- // Create a symbol. If name is not empty, it will be used as the description. | |
+ /** | |
+ * Create a symbol. If name is not empty, it will be used as the description. | |
+ */ | |
static Local<Symbol> New(Isolate* isolate, | |
Local<String> name = Local<String>()); | |
- // Access global symbol registry. | |
- // Note that symbols created this way are never collected, so | |
- // they should only be used for statically fixed properties. | |
- // Also, there is only one global name space for the names used as keys. | |
- // To minimize the potential for clashes, use qualified names as keys. | |
+ /** | |
+ * Access global symbol registry. | |
+ * Note that symbols created this way are never collected, so | |
+ * they should only be used for statically fixed properties. | |
+ * Also, there is only one global name space for the names used as keys. | |
+ * To minimize the potential for clashes, use qualified names as keys. | |
+ */ | |
static Local<Symbol> For(Isolate *isolate, Local<String> name); | |
- // Retrieve a global symbol. Similar to |For|, but using a separate | |
- // registry that is not accessible by (and cannot clash with) JavaScript code. | |
+ /** | |
+ * Retrieve a global symbol. Similar to |For|, but using a separate | |
+ * registry that is not accessible by (and cannot clash with) JavaScript code. | |
+ */ | |
static Local<Symbol> ForApi(Isolate *isolate, Local<String> name); | |
// Well-known symbols | |
+ static Local<Symbol> GetHasInstance(Isolate* isolate); | |
+ static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate); | |
static Local<Symbol> GetIterator(Isolate* isolate); | |
- static Local<Symbol> GetUnscopables(Isolate* isolate); | |
+ static Local<Symbol> GetMatch(Isolate* isolate); | |
+ static Local<Symbol> GetReplace(Isolate* isolate); | |
+ static Local<Symbol> GetSearch(Isolate* isolate); | |
+ static Local<Symbol> GetSplit(Isolate* isolate); | |
static Local<Symbol> GetToPrimitive(Isolate* isolate); | |
static Local<Symbol> GetToStringTag(Isolate* isolate); | |
- static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate); | |
+ static Local<Symbol> GetUnscopables(Isolate* isolate); | |
V8_INLINE static Symbol* Cast(Value* obj); | |
@@ -2721,20 +2821,26 @@ | |
*/ | |
class V8_EXPORT Private : public Data { | |
public: | |
- // Returns the print name string of the private symbol, or undefined if none. | |
+ /** | |
+ * Returns the print name string of the private symbol, or undefined if none. | |
+ */ | |
Local<Value> Name() const; | |
- // Create a private symbol. If name is not empty, it will be the description. | |
+ /** | |
+ * Create a private symbol. If name is not empty, it will be the description. | |
+ */ | |
static Local<Private> New(Isolate* isolate, | |
Local<String> name = Local<String>()); | |
- // Retrieve a global private symbol. If a symbol with this name has not | |
- // been retrieved in the same isolate before, it is created. | |
- // Note that private symbols created this way are never collected, so | |
- // they should only be used for statically fixed properties. | |
- // Also, there is only one global name space for the names used as keys. | |
- // To minimize the potential for clashes, use qualified names as keys, | |
- // e.g., "Class#property". | |
+ /** | |
+ * Retrieve a global private symbol. If a symbol with this name has not | |
+ * been retrieved in the same isolate before, it is created. | |
+ * Note that private symbols created this way are never collected, so | |
+ * they should only be used for statically fixed properties. | |
+ * Also, there is only one global name space for the names used as keys. | |
+ * To minimize the potential for clashes, use qualified names as keys, | |
+ * e.g., "Class#property". | |
+ */ | |
static Local<Private> ForApi(Isolate* isolate, Local<String> name); | |
private: | |
@@ -3000,15 +3106,16 @@ | |
Local<Value> key); | |
V8_DEPRECATE_SOON("Use maybe version", bool Delete(Local<Value> key)); | |
- // TODO(dcarney): mark V8_WARN_UNUSED_RESULT | |
- Maybe<bool> Delete(Local<Context> context, Local<Value> key); | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context, | |
+ Local<Value> key); | |
V8_DEPRECATED("Use maybe version", bool Has(uint32_t index)); | |
- V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index); | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, | |
+ uint32_t index); | |
V8_DEPRECATED("Use maybe version", bool Delete(uint32_t index)); | |
- // TODO(dcarney): mark V8_WARN_UNUSED_RESULT | |
- Maybe<bool> Delete(Local<Context> context, uint32_t index); | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context, | |
+ uint32_t index); | |
V8_DEPRECATED("Use maybe version", | |
bool SetAccessor(Local<String> name, | |
@@ -3024,8 +3131,8 @@ | |
Local<Value> data = Local<Value>(), | |
AccessControl settings = DEFAULT, | |
PropertyAttribute attribute = None)); | |
- // TODO(dcarney): mark V8_WARN_UNUSED_RESULT | |
- Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name, | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(Local<Context> context, | |
+ Local<Name> name, | |
AccessorNameGetterCallback getter, | |
AccessorNameSetterCallback setter = 0, | |
MaybeLocal<Value> data = MaybeLocal<Value>(), | |
@@ -3038,6 +3145,16 @@ | |
AccessControl settings = DEFAULT); | |
/** | |
+ * Sets a native data property like Template::SetNativeDataProperty, but | |
+ * this method sets on this object directly. | |
+ */ | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> SetNativeDataProperty( | |
+ Local<Context> context, Local<Name> name, | |
+ AccessorNameGetterCallback getter, | |
+ AccessorNameSetterCallback setter = nullptr, | |
+ Local<Value> data = Local<Value>(), PropertyAttribute attributes = None); | |
+ | |
+ /** | |
* Functionality for private properties. | |
* This is an experimental feature, use at your own risk. | |
* Note: Private properties are not inherited. Do not rely on this, since it | |
@@ -3515,6 +3632,7 @@ | |
protected: | |
friend class internal::FunctionCallbackArguments; | |
friend class internal::CustomArguments<FunctionCallbackInfo>; | |
+ friend class debug::ConsoleCallArguments; | |
static const int kHolderIndex = 0; | |
static const int kIsolateIndex = 1; | |
static const int kReturnValueDefaultValueIndex = 2; | |
@@ -3775,12 +3893,12 @@ | |
* Ignored if the promise is no longer pending. | |
*/ | |
V8_DEPRECATE_SOON("Use maybe version", void Resolve(Local<Value> value)); | |
- // TODO(dcarney): mark V8_WARN_UNUSED_RESULT | |
- Maybe<bool> Resolve(Local<Context> context, Local<Value> value); | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> Resolve(Local<Context> context, | |
+ Local<Value> value); | |
V8_DEPRECATE_SOON("Use maybe version", void Reject(Local<Value> value)); | |
- // TODO(dcarney): mark V8_WARN_UNUSED_RESULT | |
- Maybe<bool> Reject(Local<Context> context, Local<Value> value); | |
+ V8_WARN_UNUSED_RESULT Maybe<bool> Reject(Local<Context> context, | |
+ Local<Value> value); | |
V8_INLINE static Resolver* Cast(Value* obj); | |
@@ -3927,11 +4045,44 @@ | |
static void CheckCast(Value* obj); | |
}; | |
+// TODO(mtrofin): rename WasmCompiledModule to WasmModuleObject, for | |
+// consistency with internal APIs. | |
class V8_EXPORT WasmCompiledModule : public Object { | |
public: | |
typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; | |
// A buffer that is owned by the caller. | |
typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; | |
+ | |
+ // An opaque, native heap object for transferring wasm modules. It | |
+ // supports move semantics, and does not support copy semantics. | |
+ class TransferrableModule final { | |
+ public: | |
+ TransferrableModule(TransferrableModule&& src) = default; | |
+ TransferrableModule(const TransferrableModule& src) = delete; | |
+ | |
+ TransferrableModule& operator=(TransferrableModule&& src) = default; | |
+ TransferrableModule& operator=(const TransferrableModule& src) = delete; | |
+ | |
+ private: | |
+ typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer; | |
+ friend class WasmCompiledModule; | |
+ TransferrableModule(OwnedBuffer&& code, OwnedBuffer&& bytes) | |
+ : compiled_code(std::move(code)), wire_bytes(std::move(bytes)) {} | |
+ | |
+ OwnedBuffer compiled_code = {nullptr, 0}; | |
+ OwnedBuffer wire_bytes = {nullptr, 0}; | |
+ }; | |
+ | |
+ // Get an in-memory, non-persistable, and context-independent (meaning, | |
+ // suitable for transfer to another Isolate and Context) representation | |
+ // of this wasm compiled module. | |
+ TransferrableModule GetTransferrableModule(); | |
+ | |
+ // Efficiently re-create a WasmCompiledModule, without recompiling, from | |
+ // a TransferrableModule. | |
+ static MaybeLocal<WasmCompiledModule> FromTransferrableModule( | |
+ Isolate* isolate, const TransferrableModule&); | |
+ | |
// Get the wasm-encoded bytes that were used to compile this module. | |
Local<String> GetWasmWireBytes(); | |
@@ -3947,16 +4098,49 @@ | |
V8_INLINE static WasmCompiledModule* Cast(Value* obj); | |
private: | |
+ // TODO(ahaas): please remove the friend once streamed compilation is | |
+ // implemented | |
+ friend class WasmModuleObjectBuilder; | |
+ | |
static MaybeLocal<WasmCompiledModule> Deserialize( | |
Isolate* isolate, const CallerOwnedBuffer& serialized_module, | |
const CallerOwnedBuffer& wire_bytes); | |
static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, | |
const uint8_t* start, | |
size_t length); | |
+ static CallerOwnedBuffer AsCallerOwned( | |
+ const TransferrableModule::OwnedBuffer& buff) { | |
+ return {buff.first.get(), buff.second}; | |
+ } | |
+ | |
WasmCompiledModule(); | |
static void CheckCast(Value* obj); | |
}; | |
+class V8_EXPORT WasmModuleObjectBuilder final { | |
+ public: | |
+ WasmModuleObjectBuilder(Isolate* isolate) : isolate_(isolate) {} | |
+ // The buffer passed into OnBytesReceived is owned by the caller. | |
+ void OnBytesReceived(const uint8_t*, size_t size); | |
+ MaybeLocal<WasmCompiledModule> Finish(); | |
+ | |
+ private: | |
+ Isolate* isolate_ = nullptr; | |
+ // TODO(ahaas): We probably need none of this below here once streamed | |
+ // compilation is implemented. | |
+ typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer; | |
+ | |
+ // Disable copy semantics *in this implementation*. We can choose to | |
+ // relax this, albeit it's not clear why. | |
+ WasmModuleObjectBuilder(const WasmModuleObjectBuilder&) = delete; | |
+ WasmModuleObjectBuilder(WasmModuleObjectBuilder&&) = default; | |
+ WasmModuleObjectBuilder& operator=(const WasmModuleObjectBuilder&) = delete; | |
+ WasmModuleObjectBuilder& operator=(WasmModuleObjectBuilder&&) = default; | |
+ | |
+ std::vector<Buffer> received_buffers_; | |
+ size_t total_size_ = 0; | |
+}; | |
+ | |
#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | |
// The number of required internal fields can be defined by embedder. | |
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | |
@@ -4011,7 +4195,8 @@ | |
/** | |
* malloc/free based convenience allocator. | |
* | |
- * Caller takes ownership. | |
+ * Caller takes ownership, i.e. the returned object needs to be freed using | |
+ * |delete allocator| once it is no longer in use. | |
*/ | |
static Allocator* NewDefaultAllocator(); | |
}; | |
@@ -4055,8 +4240,11 @@ | |
/** | |
* Create a new ArrayBuffer over an existing memory block. | |
* The created array buffer is by default immediately in externalized state. | |
- * The memory block will not be reclaimed when a created ArrayBuffer | |
- * is garbage-collected. | |
+ * In externalized state, the memory block will not be reclaimed when a | |
+ * created ArrayBuffer is garbage-collected. | |
+ * In internalized state, the memory block will be released using | |
+ * |Allocator::Free| once all ArrayBuffers referencing it are collected by | |
+ * the garbage collector. | |
*/ | |
static Local<ArrayBuffer> New( | |
Isolate* isolate, void* data, size_t byte_length, | |
@@ -4107,6 +4295,7 @@ | |
V8_INLINE static ArrayBuffer* Cast(Value* obj); | |
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | |
+ static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | |
private: | |
ArrayBuffer(); | |
@@ -4160,6 +4349,8 @@ | |
static const int kInternalFieldCount = | |
V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; | |
+ static const int kEmbedderFieldCount = | |
+ V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; | |
private: | |
ArrayBufferView(); | |
@@ -4569,11 +4760,12 @@ | |
*/ | |
enum Flags { | |
kNone = 0, | |
- kGlobal = 1, | |
- kIgnoreCase = 2, | |
- kMultiline = 4, | |
- kSticky = 8, | |
- kUnicode = 16 | |
+ kGlobal = 1 << 0, | |
+ kIgnoreCase = 1 << 1, | |
+ kMultiline = 1 << 2, | |
+ kSticky = 1 << 3, | |
+ kUnicode = 1 << 4, | |
+ kDotAll = 1 << 5, | |
}; | |
/** | |
@@ -4628,7 +4820,8 @@ | |
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) | |
+ F(ArrayProto_values, array_values_iterator) \ | |
+ F(IteratorPrototype, initial_iterator_prototype) | |
enum Intrinsic { | |
#define V8_DECL_INTRINSIC(name, iname) k##name, | |
@@ -5962,19 +6155,7 @@ | |
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); | |
+typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&); | |
// --- Garbage Collection Callbacks --- | |
@@ -6037,6 +6218,11 @@ | |
size_t heap_size_limit() { return heap_size_limit_; } | |
size_t malloced_memory() { return malloced_memory_; } | |
size_t peak_malloced_memory() { return peak_malloced_memory_; } | |
+ | |
+ /** | |
+ * Returns a 0/1 boolean, which signifies whether the V8 overwrite heap | |
+ * garbage with a bit pattern. | |
+ */ | |
size_t does_zap_garbage() { return does_zap_garbage_; } | |
private: | |
@@ -6285,7 +6471,7 @@ | |
* wrappers from them when called through |AdvanceTracing|. | |
*/ | |
virtual void RegisterV8References( | |
- const std::vector<std::pair<void*, void*> >& internal_fields) = 0; | |
+ const std::vector<std::pair<void*, void*> >& embedder_fields) = 0; | |
/** | |
* Called at the beginning of a GC cycle. | |
@@ -6348,6 +6534,9 @@ | |
CallbackFunction callback; | |
void* data; | |
}; | |
+// Note that these fields are called "internal fields" in the API and called | |
+// "embedder fields" within V8. | |
+typedef SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback; | |
/** | |
* Callback and supporting data used to implement embedder logic to deserialize | |
@@ -6363,6 +6552,7 @@ | |
void* data); | |
void* data; | |
}; | |
+typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback; | |
/** | |
* Isolate represents an isolated instance of the V8 engine. V8 isolates have | |
@@ -6394,8 +6584,9 @@ | |
* The optional entry_hook allows the host application to provide the | |
* address of a function that's invoked on entry to every V8-generated | |
* function. Note that entry_hook is invoked at the very start of each | |
- * generated function. Furthermore, if an entry_hook is given, V8 will | |
- * not use a snapshot, including custom snapshots. | |
+ * generated function. | |
+ * An entry_hook can only be provided in no-snapshot builds; in snapshot | |
+ * builds it must be nullptr. | |
*/ | |
FunctionEntryHook entry_hook; | |
@@ -6447,7 +6638,7 @@ | |
/** | |
* Whether calling Atomics.wait (a function that may block) is allowed in | |
- * this isolate. | |
+ * this isolate. This can also be configured via SetAllowAtomicsWait. | |
*/ | |
bool allow_atomics_wait; | |
@@ -6686,6 +6877,12 @@ | |
void Dispose(); | |
/** | |
+ * Dumps activated low-level V8 internal stats. This can be used instead | |
+ * of performing a full isolate disposal. | |
+ */ | |
+ void DumpAndResetStats(); | |
+ | |
+ /** | |
* Discards all V8 thread-specific data for the Isolate. Should be used | |
* if a thread is terminating and it has used an Isolate that will outlive | |
* the thread -- all thread-specific data for an Isolate is discarded when | |
@@ -7210,6 +7407,14 @@ | |
AllowCodeGenerationFromStringsCallback callback); | |
/** | |
+ * Embedder over{ride|load} injection points for wasm APIs. | |
+ */ | |
+ void SetWasmModuleCallback(ExtensionCallback callback); | |
+ void SetWasmCompileCallback(ExtensionCallback callback); | |
+ void SetWasmInstanceCallback(ExtensionCallback callback); | |
+ void SetWasmInstantiateCallback(ExtensionCallback callback); | |
+ | |
+ /** | |
* Check if V8 is dead and therefore unusable. This is the case after | |
* fatal errors such as out-of-memory situations. | |
*/ | |
@@ -7293,6 +7498,13 @@ | |
*/ | |
bool IsInUse(); | |
+ /** | |
+ * Set whether calling Atomics.wait (a function that may block) is allowed in | |
+ * this isolate. This can also be configured via | |
+ * CreateParams::allow_atomics_wait. | |
+ */ | |
+ void SetAllowAtomicsWait(bool allow); | |
+ | |
Isolate() = delete; | |
~Isolate() = delete; | |
Isolate(const Isolate&) = delete; | |
@@ -7664,6 +7876,35 @@ | |
*/ | |
static void ShutdownPlatform(); | |
+#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID | |
+ /** | |
+ * Give the V8 signal handler a chance to handle a fault. | |
+ * | |
+ * This function determines whether a memory access violation can be recovered | |
+ * by V8. If so, it will return true and modify context to return to a code | |
+ * fragment that can recover from the fault. Otherwise, TryHandleSignal will | |
+ * return false. | |
+ * | |
+ * The parameters to this function correspond to those passed to a Linux | |
+ * signal handler. | |
+ * | |
+ * \param signal_number The signal number. | |
+ * | |
+ * \param info A pointer to the siginfo_t structure provided to the signal | |
+ * handler. | |
+ * | |
+ * \param context The third argument passed to the Linux signal handler, which | |
+ * points to a ucontext_t structure. | |
+ */ | |
+ static bool TryHandleSignal(int signal_number, void* info, void* context); | |
+#endif // V8_OS_LINUX | |
+ | |
+ /** | |
+ * Enable the default signal handler rather than using one provided by the | |
+ * embedder. | |
+ */ | |
+ static bool RegisterDefaultSignalHandler(); | |
+ | |
private: | |
V8(); | |
@@ -7790,20 +8031,33 @@ | |
V8_INLINE bool IsNothing() const { return !has_value_; } | |
V8_INLINE bool IsJust() const { return has_value_; } | |
- // Will crash if the Maybe<> is nothing. | |
+ /** | |
+ * An alias for |FromJust|. Will crash if the Maybe<> is nothing. | |
+ */ | |
V8_INLINE T ToChecked() const { return FromJust(); } | |
+ /** | |
+ * Converts this Maybe<> to a value of type T. If this Maybe<> is | |
+ * nothing (empty), |false| is returned and |out| is left untouched. | |
+ */ | |
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { | |
if (V8_LIKELY(IsJust())) *out = value_; | |
return IsJust(); | |
} | |
- // Will crash if the Maybe<> is nothing. | |
+ /** | |
+ * Converts this Maybe<> to a value of type T. If this Maybe<> is | |
+ * nothing (empty), V8 will crash the process. | |
+ */ | |
V8_INLINE T FromJust() const { | |
if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing(); | |
return value_; | |
} | |
+ /** | |
+ * Converts this Maybe<> to a value of type T, using a default value if this | |
+ * Maybe<> is nothing (empty). | |
+ */ | |
V8_INLINE T FromMaybe(const T& default_value) const { | |
return has_value_ ? value_ : default_value; | |
} | |
@@ -7953,6 +8207,11 @@ | |
void SetVerbose(bool value); | |
/** | |
+ * Returns true if verbosity is enabled. | |
+ */ | |
+ bool IsVerbose() const; | |
+ | |
+ /** | |
* Set whether or not this TryCatch should capture a Message object | |
* which holds source information about where the exception | |
* occurred. True by default. | |
@@ -8077,7 +8336,7 @@ | |
* \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 | |
+ * \param embedder_fields_deserializer Optional callback to deserialize | |
* internal fields. It should match the SerializeInternalFieldCallback used | |
* to serialize. | |
* | |
@@ -8088,7 +8347,7 @@ | |
static MaybeLocal<Context> FromSnapshot( | |
Isolate* isolate, size_t context_snapshot_index, | |
- DeserializeInternalFieldsCallback internal_fields_deserializer = | |
+ DeserializeInternalFieldsCallback embedder_fields_deserializer = | |
DeserializeInternalFieldsCallback(), | |
ExtensionConfiguration* extensions = nullptr, | |
MaybeLocal<Value> global_object = MaybeLocal<Value>()); | |
@@ -8144,16 +8403,14 @@ | |
Isolate* GetIsolate(); | |
/** | |
- * The field at kDebugIdIndex is reserved for V8 debugger implementation. | |
- * The value is propagated to the scripts compiled in given Context and | |
- * can be used for filtering scripts. | |
+ * The field at kDebugIdIndex used to be reserved for the inspector. | |
+ * It now serves no purpose. | |
*/ | |
enum EmbedderDataFields { kDebugIdIndex = 0 }; | |
/** | |
* Gets the embedder data with the given index, which must have been set by a | |
- * previous call to SetEmbedderData with the same index. Note that index 0 | |
- * currently has a special meaning for Chrome's debugger. | |
+ * previous call to SetEmbedderData with the same index. | |
*/ | |
V8_INLINE Local<Value> GetEmbedderData(int index); | |
@@ -8669,11 +8926,11 @@ | |
template <class T> | |
void* WeakCallbackInfo<T>::GetInternalField(int index) const { | |
#ifdef V8_ENABLE_CHECKS | |
- if (index < 0 || index >= kInternalFieldsInWeakCallback) { | |
+ if (index < 0 || index >= kEmbedderFieldsInWeakCallback) { | |
V8::InternalFieldOutOfBounds(index); | |
} | |
#endif | |
- return internal_fields_[index]; | |
+ return embedder_fields_[index]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment