diff options
Diffstat (limited to 'chromium/v8/include/v8.h')
-rw-r--r-- | chromium/v8/include/v8.h | 206 |
1 files changed, 118 insertions, 88 deletions
diff --git a/chromium/v8/include/v8.h b/chromium/v8/include/v8.h index 6ecc48af332..b4b920555b2 100644 --- a/chromium/v8/include/v8.h +++ b/chromium/v8/include/v8.h @@ -118,6 +118,7 @@ class Arguments; class DeferredHandles; class Heap; class HeapObject; +class ExternalString; class Isolate; class LocalEmbedderHeapTracer; class MicrotaskQueue; @@ -549,7 +550,7 @@ template <class T> class PersistentBase { * is alive. Only allowed when the embedder is asked to trace its heap by * EmbedderHeapTracer. */ - V8_DEPRECATE_SOON( + V8_DEPRECATED( "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", V8_INLINE void RegisterExternalReference(Isolate* isolate) const); @@ -572,14 +573,10 @@ template <class T> class PersistentBase { * * This bit is cleared after the each garbage collection pass. */ - V8_DEPRECATE_SOON("Use TracedGlobal.", V8_INLINE void MarkActive()); + V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive()); V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const); - /** Checks if the handle holds the only reference to an object. */ - V8_DEPRECATED("Garbage collection internal state should not be relied on.", - V8_INLINE bool IsNearDeath() const); - /** Returns true if the handle's reference is weak. */ V8_INLINE bool IsWeak() const; @@ -1535,7 +1532,12 @@ class V8_EXPORT ScriptCompiler { public: enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 }; - StreamedSource(ExternalSourceStream* source_stream, Encoding encoding); + V8_DEPRECATE_SOON( + "This class takes ownership of source_stream, so use the constructor " + "taking a unique_ptr to make these semantics clearer", + StreamedSource(ExternalSourceStream* source_stream, Encoding encoding)); + StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream, + Encoding encoding); ~StreamedSource(); internal::ScriptStreamingData* impl() const { return impl_.get(); } @@ -2518,9 +2520,9 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt( Local<Context> context) const; - V8_DEPRECATE_SOON("ToBoolean can never throw. Use Local version.", - V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( - Local<Context> context) const); + V8_DEPRECATED("ToBoolean can never throw. Use Local version.", + V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( + Local<Context> context) const); V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( @@ -2536,16 +2538,16 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const; Local<Boolean> ToBoolean(Isolate* isolate) const; - V8_DEPRECATE_SOON("Use maybe version", - Local<Number> ToNumber(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<String> ToString(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Object> ToObject(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Integer> ToInteger(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Int32> ToInt32(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local<Number> ToNumber(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local<String> ToString(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local<Object> ToObject(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local<Integer> ToInteger(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local<Int32> ToInt32(Isolate* isolate) const); /** * Attempts to convert a string to an array index. @@ -2796,7 +2798,7 @@ class V8_EXPORT String : public Name { void operator=(const ExternalStringResourceBase&) = delete; private: - friend class internal::Heap; + friend class internal::ExternalString; friend class v8::String; friend class internal::ScopedExternalStringLock; }; @@ -2904,7 +2906,7 @@ class V8_EXPORT String : public Name { int length = -1); /** Allocates a new string from UTF-16 data.*/ - static V8_DEPRECATE_SOON( + static V8_DEPRECATED( "Use maybe version", Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data, NewStringType type = kNormalString, @@ -2953,7 +2955,7 @@ class V8_EXPORT String : public Name { * should the underlying buffer be deallocated or modified except through the * destructor of the external string resource. */ - static V8_DEPRECATE_SOON( + static V8_DEPRECATED( "Use maybe version", Local<String> NewExternal(Isolate* isolate, ExternalOneByteStringResource* resource)); @@ -4527,9 +4529,6 @@ class V8_EXPORT WasmModuleObject : public Object { static void CheckCast(Value* obj); }; -V8_DEPRECATED("Use WasmModuleObject", - typedef WasmModuleObject WasmCompiledModule); - /** * The V8 interface for WebAssembly streaming compilation. When streaming * compilation is initiated, V8 passes a {WasmStreaming} object to the embedder @@ -5165,8 +5164,7 @@ class V8_EXPORT SharedArrayBuffer : public Object { allocation_length_(0), allocation_mode_(Allocator::AllocationMode::kNormal), deleter_(nullptr), - deleter_data_(nullptr), - is_growable_(false) {} + deleter_data_(nullptr) {} void* AllocationBase() const { return allocation_base_; } size_t AllocationLength() const { return allocation_length_; } @@ -5178,13 +5176,12 @@ class V8_EXPORT SharedArrayBuffer : public Object { size_t ByteLength() const { return byte_length_; } DeleterCallback Deleter() const { return deleter_; } void* DeleterData() const { return deleter_data_; } - bool IsGrowable() const { return is_growable_; } private: Contents(void* data, size_t byte_length, void* allocation_base, size_t allocation_length, Allocator::AllocationMode allocation_mode, DeleterCallback deleter, - void* deleter_data, bool is_growable); + void* deleter_data); void* data_; size_t byte_length_; @@ -5193,7 +5190,6 @@ class V8_EXPORT SharedArrayBuffer : public Object { Allocator::AllocationMode allocation_mode_; DeleterCallback deleter_; void* deleter_data_; - bool is_growable_; friend class SharedArrayBuffer; }; @@ -5225,9 +5221,11 @@ class V8_EXPORT SharedArrayBuffer : public Object { * Create a new SharedArrayBuffer over an existing memory block. Propagate * flags to indicate whether the underlying buffer can be grown. */ - static Local<SharedArrayBuffer> New( - Isolate* isolate, const SharedArrayBuffer::Contents&, - ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); + V8_DEPRECATED("Use New method with data, and byte_length instead.", + static Local<SharedArrayBuffer> New( + Isolate* isolate, const SharedArrayBuffer::Contents&, + ArrayBufferCreationMode mode = + ArrayBufferCreationMode::kExternalized)); /** * Returns true if SharedArrayBuffer is externalized, that is, does not @@ -5316,11 +5314,10 @@ class V8_EXPORT Date : public Object { * This API should not be called more than needed as it will * negatively impact the performance of date operations. */ - V8_DEPRECATE_SOON( - "Use Isolate::DateTimeConfigurationChangeNotification", - static void DateTimeConfigurationChangeNotification( - Isolate* isolate, - TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip)); + V8_DEPRECATED("Use Isolate::DateTimeConfigurationChangeNotification", + static void DateTimeConfigurationChangeNotification( + Isolate* isolate, TimeZoneDetection time_zone_detection = + TimeZoneDetection::kSkip)); private: static void CheckCast(Value* obj); @@ -6500,10 +6497,6 @@ class V8_EXPORT Extension { // NOLINT bool auto_enable_; }; -V8_DEPRECATED( - "Use unique_ptr version or stop using extension (http://crbug.com/334679).", - void V8_EXPORT RegisterExtension(Extension* extension)); - void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>); // --- Statics --- @@ -6686,7 +6679,7 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context, * first accessed. The return value will be used as the stack value. If this * callback is registed, the |Error.prepareStackTrace| API will be disabled. * |sites| is an array of call sites, specified in - * https://github.com/v8/v8/wiki/Stack-Trace-API + * https://v8.dev/docs/stack-trace-api */ typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context, Local<Value> error, @@ -6724,11 +6717,8 @@ enum PromiseRejectEvent { class PromiseRejectMessage { public: PromiseRejectMessage(Local<Promise> promise, PromiseRejectEvent event, - Local<Value> value, Local<StackTrace> stack_trace) - : promise_(promise), - event_(event), - value_(value), - stack_trace_(stack_trace) {} + Local<Value> value) + : promise_(promise), event_(event), value_(value) {} V8_INLINE Local<Promise> GetPromise() const { return promise_; } V8_INLINE PromiseRejectEvent GetEvent() const { return event_; } @@ -6738,13 +6728,13 @@ class PromiseRejectMessage { Local<Promise> promise_; PromiseRejectEvent event_; Local<Value> value_; - Local<StackTrace> stack_trace_; }; typedef void (*PromiseRejectCallback)(PromiseRejectMessage message); // --- Microtasks Callbacks --- -typedef void (*MicrotasksCompletedCallback)(Isolate*); +V8_DEPRECATE_SOON("Use *WithData version.", + typedef void (*MicrotasksCompletedCallback)(Isolate*)); typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*); typedef void (*MicrotaskCallback)(void* data); @@ -6778,7 +6768,8 @@ class V8_EXPORT MicrotaskQueue { /** * Creates an empty MicrotaskQueue instance. */ - static std::unique_ptr<MicrotaskQueue> New(); + static std::unique_ptr<MicrotaskQueue> New( + Isolate* isolate, MicrotasksPolicy policy = MicrotasksPolicy::kAuto); virtual ~MicrotaskQueue() = default; @@ -6826,6 +6817,12 @@ class V8_EXPORT MicrotaskQueue { */ virtual bool IsRunningMicrotasks() const = 0; + /** + * Returns the current depth of nested MicrotasksScope that has + * kRunMicrotasks. + */ + virtual int GetMicrotasksScopeDepth() const = 0; + private: friend class internal::MicrotaskQueue; MicrotaskQueue() = default; @@ -7174,6 +7171,13 @@ enum JitCodeEventOptions { */ typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); +/** + * Callback function passed to SetUnhandledExceptionCallback. + */ +#if defined(V8_OS_WIN) +typedef int (*UnhandledExceptionCallback)( + _EXCEPTION_POINTERS* exception_pointers); +#endif /** * Interface for iterating through all external resources in the heap. @@ -8231,12 +8235,20 @@ class V8_EXPORT Isolate { * Executing scripts inside the callback will not re-trigger microtasks and * the callback. */ - void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); + V8_DEPRECATE_SOON("Use *WithData version.", + void AddMicrotasksCompletedCallback( + MicrotasksCompletedCallback callback)); + void AddMicrotasksCompletedCallback( + MicrotasksCompletedCallbackWithData callback, void* data = nullptr); /** * Removes callback that was installed by AddMicrotasksCompletedCallback. */ - void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); + V8_DEPRECATE_SOON("Use *WithData version.", + void RemoveMicrotasksCompletedCallback( + MicrotasksCompletedCallback callback)); + void RemoveMicrotasksCompletedCallback( + MicrotasksCompletedCallbackWithData callback, void* data = nullptr); /** * Sets a callback for counting the number of times a feature of V8 is used. @@ -8380,13 +8392,13 @@ class V8_EXPORT Isolate { /** * Returns a memory range that can potentially contain jitted code. Code for * V8's 'builtins' will not be in this range if embedded builtins is enabled. - * Instead, see GetEmbeddedCodeRange. * * On Win64, embedders are advised to install function table callbacks for * these ranges, as default SEH won't be able to unwind through jitted code. - * * The first page of the code range is reserved for the embedder and is - * committed, writable, and executable. + * committed, writable, and executable, to be used to store unwind data, as + * documented in + * https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64. * * Might be empty on other platforms. * @@ -8519,17 +8531,6 @@ class V8_EXPORT Isolate { /** * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids and are candidates to be marked as partially dependent - * handles. This will visit handles to young objects created since the last - * garbage collection but is free to visit an arbitrary superset of these - * objects. - */ - V8_DEPRECATED( - "Use VisitHandlesWithClassIds", - void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor)); - - /** - * Iterates through all the persistent handles in the current isolate's heap * that have class_ids and are weak to be marked as inactive if there is no * pending activity for the handle. */ @@ -8797,6 +8798,20 @@ class V8_EXPORT V8 { */ static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler); +#if defined(V8_OS_WIN) + /** + * On Win64, by default V8 does not emit unwinding data for jitted code, + * which means the OS cannot walk the stack frames and the system Structured + * Exception Handling (SEH) cannot unwind through V8-generated code: + * https://code.google.com/p/v8/issues/detail?id=3598. + * + * This function allows embedders to register a custom exception handler for + * exceptions in V8-generated code. + */ + static void SetUnhandledExceptionCallback( + UnhandledExceptionCallback unhandled_exception_callback); +#endif + private: V8(); @@ -9782,17 +9797,6 @@ bool PersistentBase<T>::IsIndependent() const { } template <class T> -bool PersistentBase<T>::IsNearDeath() const { - typedef internal::Internals I; - if (this->IsEmpty()) return false; - uint8_t node_state = - I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)); - return node_state == I::kNodeStateIsNearDeathValue || - node_state == I::kNodeStateIsPendingValue; -} - - -template <class T> bool PersistentBase<T>::IsWeak() const { typedef internal::Internals I; if (this->IsEmpty()) return false; @@ -10313,7 +10317,7 @@ AccessorSignature* AccessorSignature::Cast(Data* data) { } Local<Value> Object::GetInternalField(int index) { -#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS) +#ifndef V8_ENABLE_CHECKS typedef internal::Address A; typedef internal::Internals I; A obj = *reinterpret_cast<A*>(this); @@ -10324,7 +10328,12 @@ Local<Value> Object::GetInternalField(int index) { instance_type == I::kJSApiObjectType || instance_type == I::kJSSpecialApiObjectType) { int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index); - A value = I::ReadTaggedAnyField(obj, offset); + A value = I::ReadRawField<A>(obj, offset); +#ifdef V8_COMPRESS_POINTERS + // We read the full pointer value and then decompress it in order to avoid + // dealing with potential endiannes issues. + value = I::DecompressTaggedAnyField(obj, static_cast<int32_t>(value)); +#endif internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(obj); A* result = HandleScope::CreateHandle(isolate, value); @@ -10336,7 +10345,7 @@ Local<Value> Object::GetInternalField(int index) { void* Object::GetAlignedPointerFromInternalField(int index) { -#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS) +#ifndef V8_ENABLE_CHECKS typedef internal::Address A; typedef internal::Internals I; A obj = *reinterpret_cast<A*>(this); @@ -10925,7 +10934,11 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryAtLastMarkCompactOffset); - const int64_t amount = *external_memory + change_in_bytes; + // Embedders are weird: we see both over- and underflows here. Perform the + // addition with unsigned types to avoid undefined behavior. + const int64_t amount = + static_cast<int64_t>(static_cast<uint64_t>(change_in_bytes) + + static_cast<uint64_t>(*external_memory)); *external_memory = amount; int64_t allocation_diff_since_last_mc = @@ -10947,13 +10960,24 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( } Local<Value> Context::GetEmbedderData(int index) { -#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS) +#ifndef V8_ENABLE_CHECKS typedef internal::Address A; typedef internal::Internals I; + A ctx = *reinterpret_cast<const A*>(this); + A embedder_data = + I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset); + int value_offset = + I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index); + A value = I::ReadRawField<A>(embedder_data, value_offset); +#ifdef V8_COMPRESS_POINTERS + // We read the full pointer value and then decompress it in order to avoid + // dealing with potential endiannes issues. + value = + I::DecompressTaggedAnyField(embedder_data, static_cast<int32_t>(value)); +#endif internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject( *reinterpret_cast<A*>(this)); - A* result = - HandleScope::CreateHandle(isolate, I::ReadEmbedderData<A>(this, index)); + A* result = HandleScope::CreateHandle(isolate, value); return Local<Value>(reinterpret_cast<Value*>(result)); #else return SlowGetEmbedderData(index); @@ -10962,9 +10986,15 @@ Local<Value> Context::GetEmbedderData(int index) { void* Context::GetAlignedPointerFromEmbedderData(int index) { -#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS) +#ifndef V8_ENABLE_CHECKS + typedef internal::Address A; typedef internal::Internals I; - return I::ReadEmbedderData<void*>(this, index); + A ctx = *reinterpret_cast<const A*>(this); + A embedder_data = + I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset); + int value_offset = + I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index); + return I::ReadRawField<void*>(embedder_data, value_offset); #else return SlowGetAlignedPointerFromEmbedderData(index); #endif |