diff options
Diffstat (limited to 'deps/v8/include/v8.h')
-rw-r--r-- | deps/v8/include/v8.h | 307 |
1 files changed, 127 insertions, 180 deletions
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index f100153364..c09f610333 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -433,20 +433,6 @@ class WeakCallbackInfo { V8_INLINE T* GetParameter() const { return parameter_; } V8_INLINE void* GetInternalField(int index) const; - V8_INLINE V8_DEPRECATED("use indexed version", - void* GetInternalField1() const) { - return embedder_fields_[0]; - } - V8_INLINE V8_DEPRECATED("use indexed version", - void* GetInternalField2() const) { - return embedder_fields_[1]; - } - - V8_DEPRECATED("Not realiable once SetSecondPassCallback() was used.", - bool IsFirstPass() const) { - return callback_ != nullptr; - } - // When first called, the embedder MUST Reset() the Global which triggered the // callback. The Global itself is unusable for anything else. No v8 other api // calls may be called in the first callback. Should additional work be @@ -579,16 +565,22 @@ template <class T> class PersistentBase { * independent handle should not assume that it will be preceded by a global * GC prologue callback or followed by a global GC epilogue callback. */ - V8_INLINE void MarkIndependent(); + V8_DEPRECATE_SOON( + "Objects are always considered independent. " + "Use MarkActive to avoid collecting otherwise dead weak handles.", + V8_INLINE void MarkIndependent()); /** * Marks the reference to this object as active. The scavenge garbage - * collection should not reclaim the objects marked as active. + * collection should not reclaim the objects marked as active, even if the + * object held by the handle is otherwise unreachable. + * * This bit is cleared after the each garbage collection pass. */ V8_INLINE void MarkActive(); - V8_INLINE bool IsIndependent() const; + V8_DEPRECATE_SOON("See MarkIndependent.", + V8_INLINE bool IsIndependent() const); /** Checks if the handle holds the only reference to an object. */ V8_INLINE bool IsNearDeath() const; @@ -984,9 +976,6 @@ class V8_EXPORT Data { }; /** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * * A container type that holds relevant metadata for module loading. * * This is passed back to the embedder as part of @@ -1008,9 +997,6 @@ class V8_EXPORT ScriptOrModule { }; /** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * * An array to hold Primitive values. This is used by the embedder to * pass host defined options to the ScriptOptions during compilation. * @@ -1441,6 +1427,26 @@ class V8_EXPORT ScriptCompiler { }; /** + * The reason for which we are not requesting or providing a code cache. + */ + enum NoCacheReason { + kNoCacheNoReason = 0, + kNoCacheBecauseCachingDisabled, + kNoCacheBecauseNoResource, + kNoCacheBecauseInlineScript, + kNoCacheBecauseModule, + kNoCacheBecauseStreamingSource, + kNoCacheBecauseInspector, + kNoCacheBecauseScriptTooSmall, + kNoCacheBecauseCacheTooCold, + kNoCacheBecauseV8Extension, + kNoCacheBecauseExtensionModule, + kNoCacheBecausePacScript, + kNoCacheBecauseInDocumentWrite, + kNoCacheBecauseResourceWithNoCacheHandler + }; + + /** * Compiles the specified script (context-independent). * Cached data as part of the source object can be optionally produced to be * consumed later to speed up compilation of identical source scripts. @@ -1456,10 +1462,12 @@ class V8_EXPORT ScriptCompiler { static V8_DEPRECATED("Use maybe version", Local<UnboundScript> CompileUnbound( Isolate* isolate, Source* source, - CompileOptions options = kNoCompileOptions)); + CompileOptions options = kNoCompileOptions, + NoCacheReason no_cache_reason = kNoCacheNoReason)); static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript( Isolate* isolate, Source* source, - CompileOptions options = kNoCompileOptions); + CompileOptions options = kNoCompileOptions, + NoCacheReason no_cache_reason = kNoCacheNoReason); /** * Compiles the specified script (bound to current context). @@ -1475,10 +1483,12 @@ class V8_EXPORT ScriptCompiler { static V8_DEPRECATED( "Use maybe version", Local<Script> Compile(Isolate* isolate, Source* source, - CompileOptions options = kNoCompileOptions)); + CompileOptions options = kNoCompileOptions, + NoCacheReason no_cache_reason = kNoCacheNoReason)); static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile( Local<Context> context, Source* source, - CompileOptions options = kNoCompileOptions); + CompileOptions options = kNoCompileOptions, + NoCacheReason no_cache_reason = kNoCacheNoReason); /** * Returns a task which streams script data into V8, or NULL if the script @@ -1568,7 +1578,8 @@ class V8_EXPORT ScriptCompiler { private: static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal( - Isolate* isolate, Source* source, CompileOptions options); + Isolate* isolate, Source* source, CompileOptions options, + NoCacheReason no_cache_reason); }; @@ -2070,20 +2081,6 @@ class V8_EXPORT ValueDeserializer { PrivateData* private_; }; -/** - * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap - * but can be created without entering a v8::Context and hence shouldn't - * escape to JavaScript. - */ -class V8_EXPORT NativeWeakMap : public Data { - public: - static Local<NativeWeakMap> New(Isolate* isolate); - void Set(Local<Value> key, Local<Value> value); - Local<Value> Get(Local<Value> key) const; - bool Has(Local<Value> key); - bool Delete(Local<Value> key); -}; - // --- Value --- @@ -3709,8 +3706,6 @@ class FunctionCallbackInfo { V8_INLINE int Length() const; /** Accessor for the available arguments. */ V8_INLINE Local<Value> operator[](int i) const; - V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead", - Local<Function> Callee() const); /** Returns the receiver. This corresponds to the "this" value. */ V8_INLINE Local<Object> This() const; /** @@ -3735,7 +3730,7 @@ class FunctionCallbackInfo { /** The ReturnValue for the call. */ V8_INLINE ReturnValue<T> GetReturnValue() const; // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 8; + static const int kArgsLength = 6; protected: friend class internal::FunctionCallbackArguments; @@ -3746,9 +3741,7 @@ class FunctionCallbackInfo { static const int kReturnValueDefaultValueIndex = 2; static const int kReturnValueIndex = 3; static const int kDataIndex = 4; - static const int kCalleeIndex = 5; - static const int kContextSaveIndex = 6; - static const int kNewTargetIndex = 7; + static const int kNewTargetIndex = 5; V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, internal::Object** values, int length); @@ -5262,7 +5255,7 @@ typedef void (*GenericNamedPropertySetterCallback)( * defineProperty(). * * Use `info.GetReturnValue().Set(value)` to set the property attributes. The - * value is an interger encoding a `v8::PropertyAttribute`. + * value is an integer encoding a `v8::PropertyAttribute`. * * \param property The name of the property for which the request was * intercepted. @@ -5986,7 +5979,7 @@ class V8_EXPORT ObjectTemplate : public Template { bool IsImmutableProto(); /** - * Makes the ObjectTempate for an immutable prototype exotic object, with an + * Makes the ObjectTemplate for an immutable prototype exotic object, with an * immutable __proto__. */ void SetImmutableProto(); @@ -6292,6 +6285,20 @@ typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)( Local<String> specifier); /** + * HostInitializeImportMetaObjectCallback is called the first time import.meta + * is accessed for a module. Subsequent access will reuse the same value. + * + * The method combines two implementation-defined abstract operations into one: + * HostGetImportMetaProperties and HostFinalizeImportMeta. + * + * The embedder should use v8::Object::CreateDataProperty to add properties on + * the meta object. + */ +typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context, + Local<Module> module, + Local<Object> meta); + +/** * 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 @@ -6418,6 +6425,9 @@ typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context, // --- WebAssembly compilation callbacks --- typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&); +typedef bool (*AllowWasmCodeGenerationCallback)(Local<Context> context, + Local<String> source); + // --- Callback for APIs defined on v8-supported objects, but implemented // by the embedder. Example: WebAssembly.{compile|instantiate}Streaming --- typedef void (*ApiImplementationCallback)(const FunctionCallbackInfo<Value>&); @@ -7049,9 +7059,15 @@ class V8_EXPORT Isolate { kConstructorNonUndefinedPrimitiveReturn = 39, kLabeledExpressionStatement = 40, kLineOrParagraphSeparatorAsLineTerminator = 41, + kIndexAccessor = 42, + kErrorCaptureStackTrace = 43, + kErrorPrepareStackTrace = 44, + kErrorStackTraceLimit = 45, + kWebAssemblyInstantiation = 46, // If you add new values here, you'll also need to update Chromium's: - // UseCounter.h, V8PerIsolateData.cpp, histograms.xml + // web_feature.mojom, UseCounterCallback.cpp, and enums.xml. V8 changes to + // this list need to be landed first, then changes on the Chromium side. kUseCounterFeatureCount // This enum value must be last. }; @@ -7102,9 +7118,6 @@ class V8_EXPORT Isolate { AbortOnUncaughtExceptionCallback callback); /** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * * This specifies the callback called by the upcoming dynamic * import() language feature to load modules. */ @@ -7112,6 +7125,16 @@ class V8_EXPORT Isolate { HostImportModuleDynamicallyCallback callback); /** + * This is an unfinished experimental feature, and is only exposed + * here for internal testing purposes. DO NOT USE. + * + * This specifies the callback called by the upcoming importa.meta + * language feature to retrieve host-defined meta data for a module. + */ + void SetHostInitializeImportMetaObjectCallback( + HostInitializeImportMetaObjectCallback callback); + + /** * Optional notification that the system is running low on memory. * V8 uses these notifications to guide heuristics. * It is allowed to call this function from another thread while @@ -7275,8 +7298,8 @@ class V8_EXPORT Isolate { * is initialized. It is the embedder's responsibility to stop all CPU * profiling activities if it has started any. */ - V8_DEPRECATE_SOON("CpuProfiler should be created with CpuProfiler::New call.", - CpuProfiler* GetCpuProfiler()); + V8_DEPRECATED("CpuProfiler should be created with CpuProfiler::New call.", + CpuProfiler* GetCpuProfiler()); /** Returns true if this isolate has a current context. */ bool InContext(); @@ -7703,6 +7726,13 @@ class V8_EXPORT Isolate { AllowCodeGenerationFromStringsCallback callback); /** + * Set the callback to invoke to check if wasm code generation should + * be allowed. + */ + void SetAllowWasmCodeGenerationCallback( + AllowWasmCodeGenerationCallback callback); + + /** * Embedder over{ride|load} injection points for wasm APIs. The expectation * is that the embedder sets them at most once. */ @@ -7958,50 +7988,6 @@ class V8_EXPORT V8 { void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)); /** - * Enables the host application to receive a notification before a - * garbage collection. Allocations are not allowed in the - * callback function, you therefore cannot manipulate objects (set - * or delete properties for example) since it is possible such - * operations will result in the allocation of objects. It is possible - * to specify the GCType filter for your callback. But it is not possible to - * register the same callback function two times with different - * GCType filters. - */ - static V8_DEPRECATED( - "Use isolate version", - void AddGCPrologueCallback(GCCallback callback, - GCType gc_type_filter = kGCTypeAll)); - - /** - * This function removes callback which was installed by - * AddGCPrologueCallback function. - */ - static V8_DEPRECATED("Use isolate version", - void RemoveGCPrologueCallback(GCCallback callback)); - - /** - * Enables the host application to receive a notification after a - * garbage collection. Allocations are not allowed in the - * callback function, you therefore cannot manipulate objects (set - * or delete properties for example) since it is possible such - * operations will result in the allocation of objects. It is possible - * to specify the GCType filter for your callback. But it is not possible to - * register the same callback function two times with different - * GCType filters. - */ - static V8_DEPRECATED( - "Use isolate version", - void AddGCEpilogueCallback(GCCallback callback, - GCType gc_type_filter = kGCTypeAll)); - - /** - * This function removes callback which was installed by - * AddGCEpilogueCallback function. - */ - static V8_DEPRECATED("Use isolate version", - void RemoveGCEpilogueCallback(GCCallback callback)); - - /** * Initializes V8. This function needs to be called before the first Isolate * is created. It always returns true. */ @@ -8086,35 +8072,6 @@ class V8_EXPORT V8 { void VisitExternalResources(ExternalResourceVisitor* visitor)); /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor)); - - /** - * Iterates through all the persistent handles in isolate's heap that have - * class_ids. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitHandlesWithClassIds(Isolate* isolate, - PersistentHandleVisitor* visitor)); - - /** - * 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_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitHandlesForPartialDependence(Isolate* isolate, - PersistentHandleVisitor* visitor)); - - /** * Initialize the ICU library bundled with V8. The embedder should only * invoke this method when using the bundled ICU. Returns true on success. * @@ -8383,18 +8340,45 @@ class Maybe { friend Maybe<U> Just(const U& u); }; - template <class T> inline Maybe<T> Nothing() { return Maybe<T>(); } - template <class T> inline Maybe<T> Just(const T& t) { return Maybe<T>(t); } +// A template specialization of Maybe<T> for the case of T = void. +template <> +class Maybe<void> { + public: + V8_INLINE bool IsNothing() const { return !is_valid_; } + V8_INLINE bool IsJust() const { return is_valid_; } + + V8_INLINE bool operator==(const Maybe& other) const { + return IsJust() == other.IsJust(); + } + + V8_INLINE bool operator!=(const Maybe& other) const { + return !operator==(other); + } + + private: + struct JustTag {}; + + Maybe() : is_valid_(false) {} + explicit Maybe(JustTag) : is_valid_(true) {} + + bool is_valid_; + + template <class U> + friend Maybe<U> Nothing(); + friend Maybe<void> JustVoid(); +}; + +inline Maybe<void> JustVoid() { return Maybe<void>(Maybe<void>::JustTag()); } /** * An external exception handler. @@ -8803,7 +8787,7 @@ class V8_EXPORT Context { * stack. * https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack */ - class BackupIncumbentScope { + class V8_EXPORT BackupIncumbentScope { public: /** * |backup_incumbent_context| is pushed onto the backup incumbent settings @@ -9047,8 +9031,7 @@ class Internals { // These values match non-compiler-dependent values defined within // the implementation of v8. static const int kHeapObjectMapOffset = 0; - static const int kMapInstanceTypeAndBitFieldOffset = - 1 * kApiPointerSize + kApiIntSize; + static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; static const int kStringResourceOffset = 3 * kApiPointerSize; static const int kOddballKindOffset = 4 * kApiPointerSize + sizeof(double); @@ -9084,14 +9067,14 @@ class Internals { static const int kNodeStateIsWeakValue = 2; static const int kNodeStateIsPendingValue = 3; static const int kNodeStateIsNearDeathValue = 4; - static const int kNodeIsIndependentShift = 3; static const int kNodeIsActiveShift = 4; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; static const int kForeignType = 0x87; - static const int kJSApiObjectType = 0xbf; - static const int kJSObjectType = 0xc0; + static const int kJSSpecialApiObjectType = 0xbc; + static const int kJSApiObjectType = 0xc0; + static const int kJSObjectType = 0xc1; static const int kUndefinedOddballKind = 5; static const int kNullOddballKind = 3; @@ -9125,9 +9108,7 @@ class Internals { V8_INLINE static int GetInstanceType(const internal::Object* obj) { typedef internal::Object O; O* map = ReadField<O*>(obj, kHeapObjectMapOffset); - // Map::InstanceType is defined so that it will always be loaded into - // the LS 8 bits of one 16-bit word, regardless of endianess. - return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff; + return ReadField<uint16_t>(map, kMapInstanceTypeOffset); } V8_INLINE static int GetOddballKind(const internal::Object* obj) { @@ -9284,16 +9265,11 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) { M::Copy(that, this); } - template <class T> bool PersistentBase<T>::IsIndependent() const { - typedef internal::Internals I; - if (this->IsEmpty()) return false; - return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), - I::kNodeIsIndependentShift); + return true; } - template <class T> bool PersistentBase<T>::IsNearDeath() const { typedef internal::Internals I; @@ -9374,13 +9350,7 @@ void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const { } template <class T> -void PersistentBase<T>::MarkIndependent() { - typedef internal::Internals I; - if (this->IsEmpty()) return; - I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), - true, - I::kNodeIsIndependentShift); -} +void PersistentBase<T>::MarkIndependent() {} template <class T> void PersistentBase<T>::MarkActive() { @@ -9551,13 +9521,6 @@ Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { template<typename T> -Local<Function> FunctionCallbackInfo<T>::Callee() const { - return Local<Function>(reinterpret_cast<Function*>( - &implicit_args_[kCalleeIndex])); -} - - -template<typename T> Local<Object> FunctionCallbackInfo<T>::This() const { return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); } @@ -9697,7 +9660,8 @@ Local<Value> Object::GetInternalField(int index) { // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (instance_type == I::kJSObjectType || - instance_type == I::kJSApiObjectType) { + instance_type == I::kJSApiObjectType || + instance_type == I::kJSSpecialApiObjectType) { int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); O* value = I::ReadField<O*>(obj, offset); O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value); @@ -9717,7 +9681,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) { // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(instance_type == I::kJSObjectType || - instance_type == I::kJSApiObjectType)) { + instance_type == I::kJSApiObjectType || + instance_type == I::kJSSpecialApiObjectType)) { int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); return I::ReadField<void*>(obj, offset); } @@ -10404,24 +10369,6 @@ void V8::VisitExternalResources(ExternalResourceVisitor* visitor) { isolate->VisitExternalResources(visitor); } - -void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->VisitHandlesWithClassIds(visitor); -} - - -void V8::VisitHandlesWithClassIds(Isolate* isolate, - PersistentHandleVisitor* visitor) { - isolate->VisitHandlesWithClassIds(visitor); -} - - -void V8::VisitHandlesForPartialDependence(Isolate* isolate, - PersistentHandleVisitor* visitor) { - isolate->VisitHandlesForPartialDependence(visitor); -} - /** * \example shell.cc * A simple shell that takes a list of expressions on the |