diff options
Diffstat (limited to 'deps/v8/include')
-rw-r--r-- | deps/v8/include/libplatform/libplatform.h | 11 | ||||
-rw-r--r-- | deps/v8/include/v8-debug.h | 80 | ||||
-rw-r--r-- | deps/v8/include/v8-inspector.h | 6 | ||||
-rw-r--r-- | deps/v8/include/v8-version-string.h | 33 | ||||
-rw-r--r-- | deps/v8/include/v8-version.h | 6 | ||||
-rw-r--r-- | deps/v8/include/v8.h | 465 |
6 files changed, 410 insertions, 191 deletions
diff --git a/deps/v8/include/libplatform/libplatform.h b/deps/v8/include/libplatform/libplatform.h index 40f3f66892..cab467fd50 100644 --- a/deps/v8/include/libplatform/libplatform.h +++ b/deps/v8/include/libplatform/libplatform.h @@ -35,6 +35,17 @@ V8_PLATFORM_EXPORT bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate); /** + * Runs pending idle tasks for at most |idle_time_in_seconds| seconds. + * + * The caller has to make sure that this is called from the right thread. + * This call does not block if no task is pending. The |platform| has to be + * created using |CreateDefaultPlatform|. + */ +V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform, + v8::Isolate* isolate, + double idle_time_in_seconds); + +/** * Attempts to set the tracing controller for the given platform. * * The |platform| has to be created using |CreateDefaultPlatform|. diff --git a/deps/v8/include/v8-debug.h b/deps/v8/include/v8-debug.h index 6385a31d85..777b8aaa3e 100644 --- a/deps/v8/include/v8-debug.h +++ b/deps/v8/include/v8-debug.h @@ -16,11 +16,9 @@ namespace v8 { enum DebugEvent { Break = 1, Exception = 2, - NewFunction = 3, - BeforeCompile = 4, - AfterCompile = 5, - CompileError = 6, - AsyncTaskEvent = 7, + AfterCompile = 3, + CompileError = 4, + AsyncTaskEvent = 5, }; class V8_EXPORT Debug { @@ -87,7 +85,6 @@ class V8_EXPORT Debug { virtual ~Message() {} }; - /** * An event details object passed to the debug event listener. */ @@ -145,7 +142,7 @@ class V8_EXPORT Debug { * * \param message the debug message handler message object * - * A MessageHandler2 does not take possession of the message data, + * A MessageHandler does not take possession of the message data, * and must not rely on the data persisting after the handler returns. */ typedef void (*MessageHandler)(const Message& message); @@ -167,33 +164,37 @@ class V8_EXPORT Debug { static void CancelDebugBreak(Isolate* isolate); // Check if a debugger break is scheduled in the given isolate. - static bool CheckDebugBreak(Isolate* isolate); + V8_DEPRECATED("No longer supported", + static bool CheckDebugBreak(Isolate* isolate)); // Message based interface. The message protocol is JSON. - static void SetMessageHandler(Isolate* isolate, MessageHandler handler); - - static void SendCommand(Isolate* isolate, - const uint16_t* command, int length, - ClientData* client_data = NULL); - - /** - * Run a JavaScript function in the debugger. - * \param fun the function to call - * \param data passed as second argument to the function - * With this call the debugger is entered and the function specified is called - * with the execution state as the first argument. This makes it possible to - * get access to information otherwise not available during normal JavaScript - * execution e.g. details on stack frames. Receiver of the function call will - * be the debugger context global object, however this is a subject to change. - * The following example shows a JavaScript function which when passed to - * v8::Debug::Call will return the current line of JavaScript execution. - * - * \code - * function frame_source_line(exec_state) { - * return exec_state.frame(0).sourceLine(); - * } - * \endcode - */ + V8_DEPRECATED("No longer supported", + static void SetMessageHandler(Isolate* isolate, + MessageHandler handler)); + + V8_DEPRECATED("No longer supported", + static void SendCommand(Isolate* isolate, + const uint16_t* command, int length, + ClientData* client_data = NULL)); + + /** + * Run a JavaScript function in the debugger. + * \param fun the function to call + * \param data passed as second argument to the function + * With this call the debugger is entered and the function specified is called + * with the execution state as the first argument. This makes it possible to + * get access to information otherwise not available during normal JavaScript + * execution e.g. details on stack frames. Receiver of the function call will + * be the debugger context global object, however this is a subject to change. + * The following example shows a JavaScript function which when passed to + * v8::Debug::Call will return the current line of JavaScript execution. + * + * \code + * function frame_source_line(exec_state) { + * return exec_state.frame(0).sourceLine(); + * } + * \endcode + */ // TODO(dcarney): data arg should be a MaybeLocal static MaybeLocal<Value> Call(Local<Context> context, v8::Local<v8::Function> fun, @@ -202,8 +203,9 @@ class V8_EXPORT Debug { /** * Returns a mirror object for the given object. */ - static MaybeLocal<Value> GetMirror(Local<Context> context, - v8::Local<v8::Value> obj); + V8_DEPRECATED("No longer supported", + static MaybeLocal<Value> GetMirror(Local<Context> context, + v8::Local<v8::Value> obj)); /** * Makes V8 process all pending debug messages. @@ -236,7 +238,8 @@ class V8_EXPORT Debug { * "Evaluate" debug command behavior currently is not specified in scope * of this method. */ - static void ProcessDebugMessages(Isolate* isolate); + V8_DEPRECATED("No longer supported", + static void ProcessDebugMessages(Isolate* isolate)); /** * Debugger is running in its own context which is entered while debugger @@ -245,13 +248,16 @@ class V8_EXPORT Debug { * to change. The Context exists only when the debugger is active, i.e. at * least one DebugEventListener or MessageHandler is set. */ - static Local<Context> GetDebugContext(Isolate* isolate); + V8_DEPRECATED("Use v8-inspector", + static Local<Context> GetDebugContext(Isolate* isolate)); /** * While in the debug context, this method returns the top-most non-debug * context, if it exists. */ - static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate); + V8_DEPRECATED( + "No longer supported", + static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate)); /** * Enable/disable LiveEdit functionality for the given Isolate diff --git a/deps/v8/include/v8-inspector.h b/deps/v8/include/v8-inspector.h index 0855ac101b..d0925adba0 100644 --- a/deps/v8/include/v8-inspector.h +++ b/deps/v8/include/v8-inspector.h @@ -248,9 +248,9 @@ class V8_EXPORT V8Inspector { class V8_EXPORT Channel { public: virtual ~Channel() {} - virtual void sendProtocolResponse(int callId, - const StringView& message) = 0; - virtual void sendProtocolNotification(const StringView& message) = 0; + virtual void sendResponse(int callId, + std::unique_ptr<StringBuffer> message) = 0; + virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0; virtual void flushProtocolNotifications() = 0; }; virtual std::unique_ptr<V8InspectorSession> connect( diff --git a/deps/v8/include/v8-version-string.h b/deps/v8/include/v8-version-string.h new file mode 100644 index 0000000000..075282de4c --- /dev/null +++ b/deps/v8/include/v8-version-string.h @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_VERSION_STRING_H_ +#define V8_VERSION_STRING_H_ + +#include "v8-version.h" // NOLINT(build/include) + +// This is here rather than v8-version.h to keep that file simple and +// machine-processable. + +#if V8_IS_CANDIDATE_VERSION +#define V8_CANDIDATE_STRING " (candidate)" +#else +#define V8_CANDIDATE_STRING "" +#endif + +#define V8_SX(x) #x +#define V8_S(x) V8_SX(x) + +#if V8_PATCH_LEVEL > 0 +#define V8_VERSION_STRING \ + V8_S(V8_MAJOR_VERSION) \ + "." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) "." V8_S( \ + V8_PATCH_LEVEL) V8_CANDIDATE_STRING +#else +#define V8_VERSION_STRING \ + V8_S(V8_MAJOR_VERSION) \ + "." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) V8_CANDIDATE_STRING +#endif + +#endif // V8_VERSION_STRING_H_ diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 663964616f..2301f219b3 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -9,9 +9,9 @@ // NOTE these macros are used by some of the tool scripts and the build // system so their names cannot be changed without changing the scripts. #define V8_MAJOR_VERSION 5 -#define V8_MINOR_VERSION 6 -#define V8_BUILD_NUMBER 326 -#define V8_PATCH_LEVEL 57 +#define V8_MINOR_VERSION 7 +#define V8_BUILD_NUMBER 492 +#define V8_PATCH_LEVEL 69 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 5348ba7e48..b513c7f1f3 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/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,30 +961,21 @@ 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) + : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) | + (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0)) {} V8_INLINE ScriptOriginOptions(int flags) - : flags_(flags & - (kIsEmbedderDebugScript | kIsSharedCrossOrigin | kIsOpaque)) {} - bool IsEmbedderDebugScript() const { - return (flags_ & kIsEmbedderDebugScript) != 0; - } + : flags_(flags & (kIsSharedCrossOrigin | kIsOpaque | kIsWasm)) {} bool IsSharedCrossOrigin() const { return (flags_ & kIsSharedCrossOrigin) != 0; } bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; } + bool IsWasm() const { return (flags_ & kIsWasm) != 0; } int Flags() const { return flags_; } private: - enum { - kIsEmbedderDebugScript = 1, - kIsSharedCrossOrigin = 1 << 1, - kIsOpaque = 1 << 2 - }; + enum { kIsSharedCrossOrigin = 1, kIsOpaque = 1 << 1, kIsWasm = 1 << 2 }; const int flags_; }; @@ -999,9 +990,10 @@ 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>()); + V8_INLINE Local<Value> ResourceName() const; V8_INLINE Local<Integer> ResourceLineOffset() const; V8_INLINE Local<Integer> ResourceColumnOffset() const; @@ -1486,6 +1478,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,6 +1710,19 @@ 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. @@ -1766,8 +1776,10 @@ 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)); /* * Write raw data in various common formats to the buffer. @@ -1834,9 +1846,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 +1921,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 +1940,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 +1951,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 +2022,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 +2042,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,73 +2087,61 @@ 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; @@ -2151,7 +2153,6 @@ class V8_EXPORT Value : public Data { /** * Returns true if this value is a DataView. - * This is an experimental feature. */ bool IsDataView() const; @@ -2244,11 +2245,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 +2293,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); }; @@ -2391,7 +2394,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 +2428,7 @@ class V8_EXPORT String : public Name { void operator=(const ExternalStringResourceBase&) = delete; private: - friend class v8::internal::Heap; + friend class internal::Heap; }; /** @@ -2669,8 +2672,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 +2696,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 +3697,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 +3722,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 +3787,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 +3944,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 +3999,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 +4099,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 +4146,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 +4165,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 +4182,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 +4199,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 +4216,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 +4233,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 +4250,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 +4267,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 +4284,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 +4301,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 +4318,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 +4448,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 +4465,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 +4478,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 +4495,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 +4511,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 +4527,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 +4580,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); }; @@ -5144,7 +5144,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 +5158,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 +5623,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 +5730,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 +5799,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 +5922,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 +6297,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 @@ -6283,8 +6347,7 @@ class V8_EXPORT Isolate { create_histogram_callback(nullptr), add_histogram_sample_callback(nullptr), array_buffer_allocator(nullptr), - external_references(nullptr), - deserialize_internal_fields_callback(nullptr) {} + external_references(nullptr) {} /** * The optional entry_hook allows the host application to provide the @@ -6340,12 +6403,6 @@ class V8_EXPORT Isolate { * entire lifetime of the isolate. */ intptr_t* external_references; - - /** - * Specifies an optional callback to deserialize internal fields. It - * should match the SerializeInternalFieldCallback used to serialize. - */ - DeserializeInternalFieldsCallback deserialize_internal_fields_callback; }; @@ -6481,12 +6538,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); @@ -6725,8 +6795,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_DEPRECATE_SOON("Use EmbedderHeapTracer", + void SetObjectGroupId(const Persistent<T>& object, + UniqueId id)); /** * Allows the host application to declare implicit references from an object @@ -6735,8 +6807,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_DEPRECATE_SOON("Use EmbedderHeapTracer", + void SetReferenceFromGroup(UniqueId id, + const Persistent<T>& child)); /** * Allows the host application to declare implicit references from an object @@ -6744,8 +6818,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_DEPRECATE_SOON("Use EmbedderHeapTracer", + void SetReference(const Persistent<T>& parent, + const Persistent<S>& child)); typedef void (*GCCallback)(Isolate* isolate, GCType type, GCCallbackFlags flags); @@ -6888,6 +6964,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 +7103,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 +7184,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 +7212,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 +7722,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 +7751,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 +7960,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 +7984,7 @@ class V8_EXPORT TryCatch { bool rethrow_ : 1; bool has_terminated_ : 1; - friend class v8::internal::Isolate; + friend class internal::Isolate; }; @@ -7922,10 +8057,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 +8131,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. @@ -8336,8 +8491,8 @@ 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 kJSObjectType = 0xbc; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; static const int kForeignType = 0x87; @@ -8856,17 +9011,16 @@ 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) : 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()), script_id_(script_id), source_map_url_(source_map_url) {} @@ -8920,9 +9074,8 @@ 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::kNormal) .ToLocalChecked(), value); } @@ -9056,6 +9209,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 +9701,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 +9709,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 +9718,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 +9796,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(); } |