V8: v8 Namespace Reference (original) (raw)
| Namespaces | |
|---|---|
| namespace | api_internal |
| namespace | base |
| namespace | debug |
| namespace | detail |
| namespace | internal |
| namespace | metrics |
| namespace | platform |
| Functions | |
|---|---|
| void | RegisterExtension (std::unique_ptr< Extension >) |
| template<CTypeInfo::Identifier type_info_id, typename T > | |
| bool | TryToCopyAndConvertArrayToCppBuffer (Local< Array > src, T *dst, uint32_t max_length) |
| template | |
| constexpr Maybe< T > | Nothing () |
| template | |
| Maybe< T > | Just (const T &t) |
| template<class T , std::enable_if_t<!std::is_lvalue_reference_v< T > > * = nullptr> | |
| Maybe< T > | Just (T &&t) |
| Maybe< void > | JustVoid () |
| template<class T , std::size_t N> | |
| constexpr std::array< std::remove_cv_t< T >, N > | to_array (T(&a)[N]) |
| template<class T , std::size_t N> | |
| constexpr std::array< std::remove_cv_t< T >, N > | to_array (T(&&a)[N]) |
| internal::ExternalPointerTag | ToExternalPointerTag (v8::EmbedderDataTypeTag api_tag) |
| SharedMemoryHandle | SharedMemoryHandleFromFileDescriptor (SharedMemoryHandle::PlatformHandle handle) |
| SharedMemoryHandle::PlatformHandle | FileDescriptorFromSharedMemoryHandle (SharedMemoryHandle handle) |
| Local< Primitive > | Undefined (Isolate *isolate) |
| Local< Primitive > | Null (Isolate *isolate) |
| Local< Boolean > | True (Isolate *isolate) |
| Local< Boolean > | False (Isolate *isolate) |
| constexpr CppHeapPointerTagRange | kAnyCppHeapPointer (CppHeapPointerTag::kFirstTag, CppHeapPointerTag::kLastTag) |
| bool | operator== (const TracedReferenceBase &lhs, const TracedReferenceBase &rhs) |
| template | |
| bool | operator== (const TracedReferenceBase &lhs, const v8::Local< U > &rhs) |
| template | |
| bool | operator== (const v8::Local< U > &lhs, const TracedReferenceBase &rhs) |
| bool | operator!= (const TracedReferenceBase &lhs, const TracedReferenceBase &rhs) |
| template | |
| bool | operator!= (const TracedReferenceBase &lhs, const v8::Local< U > &rhs) |
| template | |
| bool | operator!= (const v8::Local< U > &lhs, const TracedReferenceBase &rhs) |
| constexpr bool | IsExternal (StateTag state) |
| constexpr bool | IsIdle (StateTag state) |
| constexpr uint32_t | CurrentValueSerializerFormatVersion () |
| bool | TryHandleWebAssemblyTrapPosix (int sig_code, siginfo_t *info, void *context) |
| bool | TryHandleWebAssemblyTrapWindows (EXCEPTION_POINTERS *exception) |
| Variables | |
|---|---|
| constexpr ExternalPointerTypeTag | kExternalPointerTypeTagDefault = 0 |
| constexpr v8::ExternalPointerTypeTag | kFastAPIPointerTag |
| constexpr EmbedderDataTypeTag | kEmbedderDataTypeTagDefault = 0 |
This file provides additional API on top of the default one for making API calls, which come from embedder C++ functions. The functions are being called directly from optimized code, doing all the necessary typechecks in the compiler itself, instead of on the embedder side. Hence the "fast" in the name. Example usage might look like:
void FastMethod(int param, bool another_param);
signature, length, constructor_behavior
side_effect_type,
static CFunction Make(F *func, CFunctionInfo::Int64Representation int64_rep=CFunctionInfo::Int64Representation::kNumber)
Definition: v8-fast-api-calls.h:405
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const CFunction *c_function=nullptr, uint16_t instance_type=0, uint16_t allowed_receiver_instance_type_range_start=0, uint16_t allowed_receiver_instance_type_range_end=0)
By design, fast calls are limited by the following requirements, which the embedder should enforce themselves:
- they should not allocate on the JS heap;
- they should not trigger JS execution. To enforce them, the embedder could use the existing v8::Isolate::DisallowJavascriptExecutionScope and a utility similar to Blink's NoAllocationScope: https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/heap/thread_state_scopes.h;l=16
Due to these limitations, it's not directly possible to report errors by throwing a JS exception or to otherwise do an allocation. There is an alternative way of creating fast calls that supports falling back to the slow call and then performing the necessary allocation. When one creates the fast method by using CFunction::MakeWithFallbackSupport instead of CFunction::Make, the fast callback gets as last parameter an output variable, through which it can request falling back to the slow call. So one might declare their method like:
Definition: v8-fast-api-calls.h:455
If the callback wants to signal an error condition or to perform an allocation, it must set options.fallback to true and do an early return from the fast method. Then V8 checks the value of options.fallback and if it's true, falls back to executing the SlowCallback, which is capable of reporting the error (either by throwing a JS exception or logging to the console) or doing the allocation. It's the embedder's responsibility to ensure that the fast callback is idempotent up to the point where error and fallback conditions are checked, because otherwise executing the slow callback might produce visible side-effects twice.
An example for custom embedder type support might employ a way to wrap/ unwrap various C++ types in JSObject instances, e.g:
template <typename T, int offset>
assert(offset < wrapper->InternalFieldCount());
return reinterpret_cast<T*>(
wrapper->GetAlignedPointerFromInternalField(offset));
}
class CustomEmbedderType {
public:
return GetInternalField<CustomEmbedderType,
kV8EmbedderWrapperObjectIndex>(wrapper);
}
CustomEmbedderType* receiver = static_cast<CustomEmbedderType*>(
receiver_obj->GetAlignedPointerFromInternalField(
kV8EmbedderWrapperObjectIndex));
}
static void SlowMethod(
CustomEmbedderType* receiver = Unwrap(instance);
receiver->Method(param);
}
};
void SetupCustomEmbedderObject(v8::Isolate* isolate,
CustomEmbedderType* embedder_object) {
MakeV8CFunction(CustomEmbedderType::FastMethod);
Localv8::FunctionTemplate method_template =
object_template->SetInternalFieldCount(
kV8EmbedderWrapperObjectIndex + 1);
object_template->Set(isolate, "method", method_template);
object_template->NewInstance(context).ToLocalChecked();
object->SetAlignedPointerInInternalField(
kV8EmbedderWrapperObjectIndex,
reinterpret_cast<void*>(embedder_object));
}
Definition: v8-fast-api-calls.h:384
Definition: v8-function-callback.h:121
Definition: v8-isolate.h:291
Definition: v8-local-handle.h:366
static Local< T > Cast(Local< S > that)
Definition: v8-local-handle.h:423
static Local< ObjectTemplate > New(Isolate *isolate, Local< FunctionTemplate > constructor=Local< FunctionTemplate >())
For instance if {object} is exposed via a global "obj" variable, one could write in JS: function hot_func() { obj.method(42); } and once {hot_func} gets optimized, CustomEmbedderType::FastMethod will be called instead of the slow version, with the following arguments: receiver := the {embedder_object} from above param := 42
Currently supported return types:
- void
- bool
- int32_t
- uint32_t
- float32_t
- float64_t Currently supported argument types:
pointer to an embedder type
- JavaScript array of primitive types
- bool
- int32_t
- uint32_t
- int64_t
- uint64_t
- float32_t
- float64_t
The 64-bit integer types currently have the IDL (unsigned) long long semantics: https://heycam.github.io/webidl/#abstract-opdef-converttoint In the future we'll extend the API to also provide conversions from/to BigInt to preserve full precision. The floating point types currently have the IDL (unrestricted) semantics, which is the only one used by WebGL. We plan to add support also for restricted floats/doubles, similarly to the BigInt conversion policies. We also differ from the specific NaN bit pattern that WebIDL prescribes (https://heycam.github.io/webidl/#es-unrestricted-float) in that Blink passes NaN values as-is, i.e. doesn't normalize them.
To be supported types:
- TypedArrays and ArrayBuffers
- arrays of embedder types
The API offers a limited support for function overloads:
void FastMethod_2Args(int param, bool another_param);
void FastMethod_3Args(int param, bool another_param, int third_param);
MakeV8CFunction(FastMethod_2Args);
MakeV8CFunction(FastMethod_3Args);
const v8::CFunction fast_method_overloads[] = {fast_method_2args_c_func,
fast_method_3args_c_func};
Localv8::FunctionTemplate method_template =
isolate, SlowCallback, data, signature, length,
constructor_behavior, side_effect_type,
{fast_method_overloads, 2});
static Local< FunctionTemplate > NewWithCFunctionOverloads(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const MemorySpan< const CFunction > &c_function_overloads={})
In this example a single FunctionTemplate is associated to multiple C++ functions. The overload resolution is currently only based on the number of arguments passed in a call. For example, if this method_template is registered with a wrapper JS object as described above, a call with two arguments: obj.method(42, true); will result in a fast call to FastMethod_2Args, while a call with three or more arguments: obj.method(42, true, 11); will result in a fast call to FastMethod_3Args. Instead a call with less than two arguments, like: obj.method(42); would not result in a fast call but would fall back to executing the associated SlowCallback.
The v8 JavaScript engine.
Profiler support for the V8 JavaScript engine.
Support for Persistent containers.
C++11 embedders can use STL containers with Global values, but pre-C++11 does not support the required move semantic and hence may want these container classes.
Compile-time constants.
This header provides access to information about the value serializer at compile time, without declaring or defining any symbols that require linking to V8.
◆ AccessCheckCallback
Returns true if the given context should be allowed to access the given object.
◆ AccessorNameGetterCallback
This callback function is called when getting a particular data property (i.e. when performing [[Get]] operation).
The callback returns the result by calling info.GetReturnValue().[Set](classv8%5F1%5F1Set.html)(..).
Parameters
| property | The name of the property being requested. |
|---|---|
| info | Information about the intercepted request, such as isolate, object holding the property, return value. See PropertyCallbackInfo. |
See Object::SetNativeDataProperty and ObjectTemplate::SetNativeDataProperty methods.
◆ AccessorNameSetterCallback
This callback function is called when setting a particular data property (i.e. when performing [[Set]] operation).
In case of operation failure the callback should
- call
info.GetReturnValue().Set(false), - (optionally) upon operation failure and info.ShouldThrowOnError() is true (indicating execution in ‘'use strict’` mode) the callback can throw TypeError if the error message needs to include more details than a TypeError thrown by V8 in this case.
Parameters
| property | The name of the property being requested. |
|---|---|
| info | Information about the intercepted request, such as isolate, object holding the property, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`. |
See Object::SetNativeDataProperty and ObjectTemplate::SetNativeDataProperty methods.
◆ AddCrashKeyCallback
◆ AddHistogramSampleCallback
◆ AllocateCrashKeyStringCallback
◆ AllowWasmCodeGenerationCallback
◆ ApiImplementationCallback
◆ BackingStoreDeleterCallback
◆ BeforeCallEnteredCallback
◆ CallCompletedCallback
◆ CFunctionBuilder
◆ CompileHintCallback
Callback for requesting a compile hint for a function from the embedder. The first parameter is the position of the function in source code and the second parameter is embedder data to be passed back.
◆ CounterLookupCallback
Callback function passed to SetUnhandledExceptionCallback.
◆ CppHeapPointerTagRange
◆ CrashKey
◆ CreateHistogramCallback
◆ DcheckErrorCallback
◆ EmbedderDataTypeTag
A tag for embedder data. Objects with different C++ types should use different values of EmbedderDataTypeTag when written to embedder data. The allowed range is 0..V8_EMBEDDER_DATA_TAG_COUNT - 1. If this is not sufficient, V8_EMBEDDER_DATA_TAG_COUNT can be increased.
◆ EntropySource
EntropySource is used as a callback function when v8 needs a source of entropy.
◆ ExceptionPropagationCallback
◆ ExtensionCallback
◆ ExternalPointerTypeTag
A tag for external pointers. Objects with different C++ types should use different values of ExternalPointerTypeTag when using v8::External. The allowed range is 0..V8_EXTERNAL_POINTER_TAG_COUNT - 1. If this is not sufficient, V8_EXTERNAL_POINTER_TAG_COUNT can be increased.
◆ FailedAccessCheckCallback
◆ FatalErrorCallback
◆ FunctionCallback
◆ GCCallback
◆ Handle
◆ HostCreateShadowRealmContextCallback
HostCreateShadowRealmContextCallback is called each time a ShadowRealm is being constructed in the initiator_context.
The method combines Context creation and implementation defined abstract operation HostInitializeShadowRealm into one.
The embedder should use v8::Context::New or v8::Context:NewFromSnapshot to create a new context. If the creation fails, the embedder must propagate that exception by returning an empty MaybeLocal.
◆ HostImportModuleDynamicallyCallback
HostImportModuleDynamicallyCallback is called when we require the embedder to load a module. This is used as part of the dynamic import syntax.
The referrer contains metadata about the script/module that calls import.
The specifier is the name of the module that should be imported.
The import_attributes are import attributes for this request in the form: [key1, value1, key2, value2, ...] where the keys and values are of type v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and returned from ModuleRequest::GetImportAttributes(), this array does not contain the source Locations of the attributes.
The embedder must compile, instantiate, evaluate the Module, and obtain its namespace object.
The Promise returned from this function is forwarded to userland JavaScript. The embedder must resolve this promise with the module namespace object. In case of an exception, the embedder must reject this promise with the exception. If the promise creation itself fails (e.g. due to stack overflow), the embedder must propagate that exception by returning an empty MaybeLocal.
◆ HostImportModuleWithPhaseDynamicallyCallback
HostImportModuleWithPhaseDynamicallyCallback is called when we require the embedder to load a module with a specific phase. This is used as part of the dynamic import syntax.
The referrer contains metadata about the script/module that calls import.
The specifier is the name of the module that should be imported.
The phase is the phase of the import requested.
The import_attributes are import attributes for this request in the form: [key1, value1, key2, value2, ...] where the keys and values are of type v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and returned from ModuleRequest::GetImportAttributes(), this array does not contain the source Locations of the attributes.
The Promise returned from this function is forwarded to userland JavaScript. The embedder must resolve this promise according to the phase requested:
- For ModuleImportPhase::kSource, the promise must be resolved with a compiled ModuleSource object, or rejected with a SyntaxError if the module does not support source representation.
- For ModuleImportPhase::kEvaluation, the promise must be resolved with a ModuleNamespace object of a module that has been compiled, instantiated, and evaluated.
In case of an exception, the embedder must reject this promise with the exception. If the promise creation itself fails (e.g. due to stack overflow), the embedder must propagate that exception by returning an empty MaybeLocal.
This callback is still experimental and is only invoked for source phase imports.
◆ HostInitializeImportMetaObjectCallback
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.
◆ IndexedPropertyDefinerCallbackV2
◆ IndexedPropertyDeleterCallbackV2
◆ IndexedPropertyDescriptorCallbackV2
◆ IndexedPropertyEnumeratorCallback
Returns an array containing the indices of the properties the indexed property getter intercepts.
Note: The values in the array must be uint32_t.
◆ IndexedPropertyGetterCallbackV2
◆ IndexedPropertyQueryCallbackV2
◆ IndexedPropertySetterCallbackV2
◆ InterruptCallback
◆ IsJSApiWrapperNativeErrorCallback
IsJSApiWrapperNativeErrorCallback is called on an JSApiWrapper object to determine if Error.isError should return true or false. For instance, in an HTML embedder, DOMExceptions return true when passed to Error.isError.
◆ JitCodeEventHandler
Callback function passed to SetJitCodeEventHandler.
Parameters
| event | code add, move or removal event. |
|---|
◆ LogEventCallback
◆ MessageCallback
◆ MicrotaskCallback
◆ MicrotasksCompletedCallbackWithData
◆ ModifyCodeGenerationFromStringsCallback
Callback to check if codegen is allowed from a source object, and convert the source to string if necessary. See: ModifyCodeGenerationFromStrings.
◆ ModifyCodeGenerationFromStringsCallback2
◆ NamedPropertyDefinerCallback
Interceptor for [[DefineOwnProperty]] requests on an object.
If the interceptor handles the request (i.e. the property should not be looked up beyond the interceptor or in case an exception was thrown) it should
- use
info.GetReturnValue().Set(false)to indicate that the operation failed, - (optionally) upon operation failure and info.ShouldThrowOnError() is true (indicating execution in ‘'use strict’` mode) the callback can throw TypeError if the error message needs to include more details than a TypeError thrown by V8 in this case,
- return
[Intercepted::kYes](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a1ea590aa4a64767508460736ac0edaa9). If the interceptor does not handle the request it must return[Intercepted::kNo](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a8cc8e60acfa3ae6089df773013fd73a2)and it must not produce side effects.
Parameters
| property | The name of the property for which the request was intercepted. |
|---|---|
| desc | The property descriptor which is used to define the property if the request is not intercepted. |
| info | Information about the intercepted request, such as isolate, object holding the property, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`. |
See also [ObjectTemplate::SetHandler](classv8%5F1%5F1ObjectTemplate.html#a3d5666f1e9b0f46df6b4dbb7cfbb6114).
◆ NamedPropertyDeleterCallback
Interceptor for [[Delete]] requests on an object.
If the interceptor handles the request (i.e. the property should not be looked up beyond the interceptor or in case an exception was thrown) it should
- use
info.GetReturnValue().Set(false)to indicate that the operation failed, - (optionally) upon operation failure and info.ShouldThrowOnError() is true (indicating execution in ‘'use strict’` mode) the callback can throw TypeError if the error message needs to include more details than a TypeError thrown by V8 in this case,
- return
[Intercepted::kYes](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a1ea590aa4a64767508460736ac0edaa9). If the interceptor does not handle the request it must return[Intercepted::kNo](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a8cc8e60acfa3ae6089df773013fd73a2)and it must not produce side effects.
Parameters
| property | The name of the property for which the request was intercepted. |
|---|---|
| info | Information about the intercepted request, such as isolate, object holding the property, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`. |
See also [ObjectTemplate::SetHandler](classv8%5F1%5F1ObjectTemplate.html#a3d5666f1e9b0f46df6b4dbb7cfbb6114).
◆ NamedPropertyDescriptorCallback
Interceptor for [[GetOwnProperty]] requests on an object.
If the interceptor handles the request (i.e. the property should not be looked up beyond the interceptor or in case an exception was thrown) it should
- (optionally) use
info.GetReturnValue().Set()to set the return value which must be object that can be converted to a PropertyDescriptor (for example, a value returned byv8::Object::getOwnPropertyDescriptor), - return
[Intercepted::kYes](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a1ea590aa4a64767508460736ac0edaa9). If the interceptor does not handle the request it must return[Intercepted::kNo](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a8cc8e60acfa3ae6089df773013fd73a2)and it must not produce side effects.
Parameters
| property | The name of the property for which the request was intercepted. \info Information about the intercepted request, such as isolate, receiver, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`. |
|---|
See also [ObjectTemplate::SetHandler](classv8%5F1%5F1ObjectTemplate.html#a3d5666f1e9b0f46df6b4dbb7cfbb6114).
◆ NamedPropertyEnumeratorCallback
Returns an array containing the names of the properties the named property getter intercepts.
Note: The values in the array must be of type v8::Name.
◆ NamedPropertyGetterCallback
Interceptor for [[Get]] requests on an object.
If the interceptor handles the request (i.e. the property should not be looked up beyond the interceptor or in case an exception was thrown) it should
- (optionally) use info.GetReturnValue().Set()` to set the return value (by default the result is set to v8::Undefined),
- return
[Intercepted::kYes](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a1ea590aa4a64767508460736ac0edaa9). If the interceptor does not handle the request it must return[Intercepted::kNo](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a8cc8e60acfa3ae6089df773013fd73a2)and it must not produce side effects.
Parameters
| property | The name of the property for which the request was intercepted. |
|---|---|
| info | Information about the intercepted request, such as isolate, object holding the property, return value. See PropertyCallbackInfo. |
}
templ->InstanceTemplate()->SetHandler(
LocalContext env;
->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
.ToLocalChecked()
->NewInstance(env.local())
.ToLocalChecked())
.FromJust();
CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
friend class Global
Definition: v8-local-handle.h:468
Definition: v8-function-callback.h:224
ReturnValue< T > GetReturnValue() const
Definition: v8-function-callback.h:685
Isolate * GetIsolate() const
Definition: v8-function-callback.h:661
Intercepted
Definition: v8-template.h:138
Definition: v8-template.h:692
See also [ObjectTemplate::SetHandler](classv8%5F1%5F1ObjectTemplate.html#a3d5666f1e9b0f46df6b4dbb7cfbb6114).
◆ NamedPropertyQueryCallback
Intercepts all requests that query the attributes of the property, e.g. [[GetOwnProperty]], [[DefineOwnProperty]], [[Set]] and derived ones like Object.prototype.propertyIsEnumerable() and similar.
If the interceptor handles the request (i.e. the property should not be looked up beyond the interceptor or in case an exception was thrown) it should
- (optionally) use
info.GetReturnValue().Set()to set to an Integer value encoding a[v8::PropertyAttribute](namespacev8.html#a05f25f935e108a1ea2d150e274602b87)bits, - return
[Intercepted::kYes](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a1ea590aa4a64767508460736ac0edaa9). If the interceptor does not handle the request it must return[Intercepted::kNo](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a8cc8e60acfa3ae6089df773013fd73a2)and it must not produce side effects.
Parameters
| property | The name of the property for which the request was intercepted. |
|---|---|
| info | Information about the intercepted request, such as isolate, receiver, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`. |
Note
Some functions query the property attributes internally, even though they do not return the attributes. For example, hasOwnProperty() can trigger this interceptor depending on the state of the object.
See also [ObjectTemplate::SetHandler](classv8%5F1%5F1ObjectTemplate.html#a3d5666f1e9b0f46df6b4dbb7cfbb6114).
◆ NamedPropertySetterCallback
Interceptor for [[Set]] requests on an object.
If the interceptor handles the request (i.e. the property should not be looked up beyond the interceptor or in case an exception was thrown) it should
- use
info.GetReturnValue().Set(false)to indicate that the operation failed, - (optionally) upon operation failure and info.ShouldThrowOnError() is true (indicating execution in ‘'use strict’` mode) the callback can throw TypeError if the error message needs to include more details than a TypeError thrown by V8 in this case,
- return
[Intercepted::kYes](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a1ea590aa4a64767508460736ac0edaa9). If the interceptor does not handle the request it must return[Intercepted::kNo](namespacev8.html#af6fda56e02b3f46cded582193435f3a7a8cc8e60acfa3ae6089df773013fd73a2)and it must not produce side effects.
Parameters
| property | The name of the property for which the request was intercepted. |
|---|---|
| value | The value which the property will have if the request is not intercepted. |
| info | Information about the intercepted request, such as isolate, object holding the property, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`. |
See also [ObjectTemplate::SetHandler](classv8%5F1%5F1ObjectTemplate.html#a3d5666f1e9b0f46df6b4dbb7cfbb6114).
◆ NativeObject
◆ NearHeapLimitCallback
This callback is invoked when the heap size is close to the heap limit and V8 is likely to abort with out-of-memory error. The callback can extend the heap limit by returning a value that is greater than the current_heap_limit. The initial heap limit is the limit that was set after heap setup.
◆ OOMErrorCallback
◆ OOMErrorCallbackWithData
◆ PersistentContainerValue
◆ PlatformSharedMemoryHandle
◆ PrepareStackTraceCallback
PrepareStackTraceCallback is called when the stack property of an error is 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://v8.dev/docs/stack-trace-api
◆ PrintCurrentStackTraceFilterCallback
◆ ProfilerId
◆ PromiseHook
◆ PromiseRejectCallback
◆ ReturnAddressLocationResolver
ReturnAddressLocationResolver is used as a callback function when v8 is resolving the location of a return address on the stack. Profilers that change the return address on the stack can use this to resolve the stack location to wherever the profiler stashed the original return address.
Parameters
| return_addr_location | A location on stack where a machine return address resides. |
|---|
Returns
Either return_addr_location, or else a pointer to the profiler's copy of the original return address.
Note
The resolver function must not cause garbage collection.
◆ SetCrashKeyStringCallback
◆ SharedArrayBufferConstructorEnabledCallback
◆ SnapshotObjectId
◆ StackState
Indicator for the stack state.
◆ UniquePersistent
◆ V8FatalErrorCallback
◆ WasmAsyncResolvePromiseCallback
◆ WasmCustomDescriptorsEnabledCallback
◆ WasmLoadSourceMapCallback
◆ WasmStreamingCallback
◆ AccessType
Access type specification.
| Enumerator |
|---|
| ACCESS_GET |
| ACCESS_SET |
| ACCESS_HAS |
| ACCESS_DELETE |
| ACCESS_KEYS |
◆ ArrayBufferCreationMode
| Enumerator |
|---|
| kInternalized |
| kExternalized |
◆ BackingStoreInitializationMode
| Enumerator |
|---|
| kZeroInitialized |
| kUninitialized |
◆ BackingStoreOnFailureMode
| Enumerator |
|---|
| kReturnNull |
| kOutOfMemory |
◆ BlockingType
A "blocking call" refers to any call that causes the calling thread to wait off-CPU. It includes but is not limited to calls that wait on synchronous file I/O operations: read or write a file from disk, interact with a pipe or a socket, rename or delete a file, enumerate files in a directory, etc. Acquiring a low contention lock is not considered a blocking call. BlockingType indicates the likelihood that a blocking call will actually block.
| Enumerator |
|---|
| kMayBlock |
| kWillBlock |
◆ CodeEventType
Note that this enum may be extended in the future. Please include a default case if this enum is used in a switch statement.
| Enumerator |
|---|
| kUnknownType |
| kBuiltinType |
| kCallbackType |
| kEvalType |
| kFunctionType |
| kInterpretedFunctionType |
| kHandlerType |
| kBytecodeHandlerType |
| kLazyCompileType |
| kRegExpType |
| kScriptType |
| kStubType |
| kRelocationType |
◆ ConstructorBehavior
◆ ContextDependants
Signal for dependants of contexts. Useful for ContextDisposedNotification() to implement different strategies.
| Enumerator | |
|---|---|
| kNoDependants | Context has no dependants. These are usually top-level contexts. |
| kSomeDependants | Context has some dependants, i.e., it may depend on other contexts. This is usually the case for inner contexts. |
◆ CppHeapPointerTag
A pointer tag used for wrapping and unwrapping [CppHeap](classv8%5F1%5F1CppHeap.html) pointers as used with JS API wrapper objects that rely on [v8::Object::Wrap()](classv8%5F1%5F1Object.html#a962119246ca8e9258338200d37e1e408) and [v8::Object::Unwrap()](classv8%5F1%5F1Object.html#ac9812adb53766f0410d3275c53b49cfa).
The CppHeapPointers use a range-based type checking scheme, where on access to a pointer, the actual type of the pointer is checked to be within a specified range of types. This allows supporting type hierarchies, where a type check for a supertype must succeed for any subtype.
The tag is currently in practice limited to 15 bits since it needs to fit together with a marking bit into the unused parts of a pointer.
| Enumerator | |
|---|---|
| kFirstTag | |
| kNullTag | |
| kDefaultTag | The lower type ids are reserved for the embedder to assign. For that, the main requirement is that all (transitive) child classes of a given parent class have type ids in the same range, and that there are no unrelated types in that range. For example, given the following type hierarchy: A F / \ B E / \ C D a potential type id assignment that satistifes these requirements is {C: 0, D: 1, B: 2, A: 3, E: 4, F: 5}. With that, the type check for type A would check for the range [0, 4], while the check for B would check range [0, 2], and for F it would simply check [5, 5]. In addition, there is an option for performance tweaks: if the size of the type range corresponding to a supertype is a power of two and starts at a power of two (e.g. [0x100, 0x13f]), then the compiler can often optimize the type check to use even fewer instructions (essentially replace a AND + SUB with a single AND). |
| kZappedEntryTag | |
| kEvacuationEntryTag | |
| kFreeEntryTag | |
| kLastTag |
◆ CpuProfileSource
Identifies which component initiated CPU profiling for proper attribution.
| Enumerator | |
|---|---|
| kUnspecified | Default value when no explicit source is specified. |
| kInspector | Profiling initiated via the DevTools Inspector protocol. |
| kSelfProfiling | Profiling initiated by the embedder (e.g., Blink) via self-profiling API. |
| kInternal | Profiling initiated internally by V8 (e.g., tracing CPU profiler). |
◆ CpuProfilingLoggingMode
| Enumerator |
|---|
| kLazyLogging |
| kEagerLogging |
◆ CpuProfilingMode
| Enumerator |
|---|
| kLeafNodeLineNumbers |
| kCallerLineNumbers |
◆ CpuProfilingNamingMode
| Enumerator |
|---|
| kStandardNaming |
| kDebugNaming |
◆ CpuProfilingStatus
| Enumerator |
|---|
| kStarted |
| kAlreadyStarted |
| kErrorTooManyProfilers |
◆ CrashKeyId
| Enumerator |
|---|
| kIsolateAddress |
| kReadonlySpaceFirstPageAddress |
| kMapSpaceFirstPageAddress |
| kOldSpaceFirstPageAddress |
| kCodeRangeBaseAddress |
| kCodeSpaceFirstPageAddress |
| kDumpType |
| kSnapshotChecksumCalculated |
| kSnapshotChecksumExpected |
◆ CrashKeySize
| Enumerator |
|---|
| Size32 |
| Size64 |
| Size256 |
| Size1024 |
◆ EmbedderStateTag
◆ ExceptionContext
This is a part of experimental Api and might be changed without further notice. Do not use it.
| Enumerator |
|---|
| kUnknown |
| kConstructor |
| kOperation |
| kAttributeGet |
| kAttributeSet |
| kIndexedQuery |
| kIndexedGetter |
| kIndexedDescriptor |
| kIndexedSetter |
| kIndexedDefiner |
| kIndexedDeleter |
| kNamedQuery |
| kNamedGetter |
| kNamedDescriptor |
| kNamedSetter |
| kNamedDefiner |
| kNamedDeleter |
| kNamedEnumerator |
◆ GCCallbackFlags
GCCallbackFlags is used to notify additional information about the GC callback.
- kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for constructing retained object infos.
- kGCCallbackFlagForced: The GC callback is for a forced GC for testing.
- kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback is called synchronously without getting posted to an idle task.
- kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called in a phase where V8 is trying to collect all available garbage (e.g., handling a low memory notification).
- kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to trigger an idle garbage collection.
| Enumerator |
|---|
| kNoGCCallbackFlags |
| kGCCallbackFlagConstructRetainedObjectInfos |
| kGCCallbackFlagForced |
| kGCCallbackFlagSynchronousPhantomCallbackProcessing |
| kGCCallbackFlagCollectAllAvailableGarbage |
| kGCCallbackFlagCollectAllExternalMemory |
| kGCCallbackScheduleIdleGarbageCollection |
| kGCCallbackFlagLastResort |
◆ GCType
Applications can register callback functions which will be called before and after certain garbage collection operations. Allocations are not allowed in the callback functions, you therefore cannot manipulate objects (set or delete properties for example) since it is possible such operations will result in the allocation of objects. TODO(v8:12612): Deprecate kGCTypeMinorMarkSweep after updating blink.
| Enumerator |
|---|
| kGCTypeScavenge |
| kGCTypeMinorMarkSweep |
| kGCTypeMarkSweepCompact |
| kGCTypeIncrementalMarking |
| kGCTypeProcessWeakCallbacks |
| kGCTypeAll |
◆ IndexFilter
kIncludesIndices allows for integer indices to be collected, while kSkipIndices will exclude integer indices from being collected.
| Enumerator |
|---|
| kIncludeIndices |
| kSkipIndices |
◆ IntegrityLevel
Integrity level for objects.
| Enumerator |
|---|
| kFrozen |
| kSealed |
◆ Intercepted
Interceptor callbacks use this value to indicate whether the request was intercepted or not.
| Enumerator |
|---|
| kNo |
| kYes |
◆ Intrinsic
| Enumerator |
|---|
| kArrayProto_entries |
| kArrayProto_forEach |
| kArrayProto_keys |
| kArrayProto_values |
| kArrayPrototype |
| kAsyncIteratorPrototype |
| kErrorPrototype |
| kIteratorPrototype |
| kMapIteratorPrototype |
| kObjProto_valueOf |
| kSetIteratorPrototype |
◆ JitCodeEventOptions
Option flags passed to the SetJitCodeEventHandler function.
| Enumerator |
|---|
| kJitCodeEventDefault |
| kJitCodeEventEnumExisting |
| kLastJitCodeEventOption |
◆ KeyCollectionMode
Keys/Properties filter enums:
KeyCollectionMode limits the range of collected properties. kOwnOnly limits the collected properties to the given Object only. kIncludesPrototypes will include all keys of the objects's prototype chain as well.
| Enumerator |
|---|
| kOwnOnly |
| kIncludePrototypes |
◆ KeyConversionMode
kConvertToString will convert integer indices to strings. kKeepNumbers will return numbers for integer indices.
| Enumerator |
|---|
| kConvertToString |
| kKeepNumbers |
| kNoNumbers |
◆ LogEventStatus
| Enumerator |
|---|
| kStart |
| kEnd |
| kLog |
◆ MeasureMemoryExecution
Controls how promptly a memory measurement request is executed. By default the measurement is folded with the next scheduled GC which may happen after a while and is forced after some timeout. The kEager mode starts incremental GC right away and is useful for testing. The kLazy mode does not force GC.
| Enumerator |
|---|
| kDefault |
| kEager |
| kLazy |
◆ MeasureMemoryMode
Controls how the default MeasureMemoryDelegate reports the result of the memory measurement to JS. With kSummary only the total size is reported. With kDetailed the result includes the size of each native context.
| Enumerator |
|---|
| kSummary |
| kDetailed |
◆ MemoryPressureLevel
Memory pressure level for the MemoryPressureNotification. kNone hints V8 that there is no memory pressure. kModerate hints V8 to speed up incremental garbage collection at the cost of of higher latency due to garbage collection pauses. kCritical hints V8 to free memory as soon as possible. Garbage collection pauses at this level will be large.
| Enumerator |
|---|
| kNone |
| kModerate |
| kCritical |
◆ MicrotasksPolicy
Policy for running microtasks:
- explicit: microtasks are invoked with the Isolate::PerformMicrotaskCheckpoint() method;
- scoped: microtasks invocation is controlled by MicrotasksScope objects;
- auto: microtasks are invoked when the script call depth decrements to zero.
| Enumerator |
|---|
| kExplicit |
| kScoped |
| kAuto |
◆ ModuleImportPhase
Import phases in import requests.
| Enumerator |
|---|
| kSource |
| kDefer |
| kEvaluation |
◆ NewStringType
A flag describing different modes of string creation.
Aside from performance implications there are no differences between the two creation modes.
| Enumerator | |
|---|---|
| kNormal | Create a new string, always allocating new storage memory. |
| 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. |
◆ PagePermissions
Possible permissions for memory pages.
| Enumerator |
|---|
| kNoAccess |
| kRead |
| kReadWrite |
| kReadWriteExecute |
| kReadExecute |
◆ PersistentContainerCallbackType
| Enumerator |
|---|
| kNotWeak |
| kWeakWithParameter |
| kWeakWithInternalFields |
◆ PromiseHookType
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.
| Enumerator |
|---|
| kInit |
| kResolve |
| kBefore |
| kAfter |
◆ PromiseRejectEvent
| Enumerator |
|---|
| kPromiseRejectWithNoHandler |
| kPromiseHandlerAddedAfterReject |
| kPromiseRejectAfterResolved |
| kPromiseResolveAfterResolved |
◆ PropertyAttribute
PropertyAttribute.
| Enumerator | |
|---|---|
| None | None. |
| ReadOnly | ReadOnly, i.e., not writable. |
| DontEnum | DontEnum, i.e., not enumerable. |
| DontDelete | DontDelete, i.e., not configurable. |
◆ PropertyFilter
Property filter bits. They can be or'ed to build a composite filter.
| Enumerator |
|---|
| ALL_PROPERTIES |
| ONLY_WRITABLE |
| ONLY_ENUMERABLE |
| ONLY_CONFIGURABLE |
| SKIP_STRINGS |
| SKIP_SYMBOLS |
◆ PropertyHandlerFlags
Configuration flags for v8::NamedPropertyHandlerConfiguration or v8::IndexedPropertyHandlerConfiguration.
| Enumerator | |
|---|---|
| kNone | None. |
| kNonMasking | Will not call into interceptor for properties on the receiver or prototype chain, i.e., only call into interceptor for properties that do not exist. Currently only valid for named interceptors. |
| kOnlyInterceptStrings | Will not call into interceptor for symbol lookup. Only meaningful for named interceptors. |
| kHasNoSideEffect | The getter, query, enumerator callbacks do not produce side effects. |
| kInternalNewCallbacksSignatures | This flag is used to distinguish which callbacks were provided - GenericNamedPropertyXXXCallback (old signature) or NamedPropertyXXXCallback (new signature). DO NOT use this flag, it'll be removed once embedders migrate to new callbacks signatures. |
◆ ScriptType
| Enumerator |
|---|
| kClassic |
| kModule |
◆ SideEffectType
Options for marking whether callbacks may trigger JS-observable side effects. Side-effect-free callbacks are allowlisted during debug evaluation with throwOnSideEffect. It applies when calling a Function, FunctionTemplate, or an Accessor callback. For Interceptors, please see PropertyHandlerFlags's kHasNoSideEffect. Callbacks that only cause side effects to the receiver are allowlisted if invoked on receiver objects that are created within the same debug-evaluate call, as these objects are temporary and the side effect does not escape.
| Enumerator |
|---|
| kHasSideEffect |
| kHasNoSideEffect |
| kHasSideEffectToReceiver |
◆ StateTag
| Enumerator |
|---|
| JS |
| GC |
| PARSER |
| BYTECODE_COMPILER |
| COMPILER |
| OTHER |
| EXTERNAL |
| ATOMICS_WAIT |
| IDLE |
| LOGGING |
| IDLE_EXTERNAL |
◆ TaskPriority
| Enumerator | |
|---|---|
| kBestEffort | Best effort tasks are not critical for performance of the application. The platform implementation should preempt such tasks if higher priority tasks arrive. |
| kUserVisible | User visible tasks are long running background tasks that will improve performance and memory usage of the application upon completion. Example: background compilation and garbage collection. |
| kUserBlocking | User blocking tasks are highest priority tasks that block the execution thread (e.g. major garbage collection). They must be finished as soon as possible. |
| kMaxPriority |
◆ WasmAsyncSuccess
◆ WeakCallbackType
Weakness type for weak handles.
| Enumerator | |
|---|---|
| kParameter | Passes a user-defined void* parameter back to the callback. |
| kInternalFields | Passes the first two internal fields of the object back to the callback. |
◆ CurrentValueSerializerFormatVersion()
| constexpr uint32_t v8::CurrentValueSerializerFormatVersion ( ) | constexpr |
|---|
◆ False()
◆ FileDescriptorFromSharedMemoryHandle()
◆ IsExternal()
| constexpr bool v8::IsExternal ( StateTag state) | constexpr |
|---|
◆ IsIdle()
| constexpr bool v8::IsIdle ( StateTag state) | constexpr |
|---|
◆ Just() [1/2]
template
| Maybe< T > v8::Just ( const T & t) | inline |
|---|
◆ Just() [2/2]
template<class T , std::enable_if_t<!std::is_lvalue_reference_v< T > > * = nullptr>
| Maybe< T > v8::Just ( T && t) | inline |
|---|
◆ JustVoid()
| Maybe< void > v8::JustVoid ( ) | inline |
|---|
◆ kAnyCppHeapPointer()
◆ Nothing()
template
| constexpr Maybe< T > v8::Nothing ( ) | inlineconstexpr |
|---|
◆ Null()
◆ operator!=() [1/3]
◆ operator!=() [2/3]
◆ operator!=() [3/3]
◆ operator==() [1/3]
◆ operator==() [2/3]
◆ operator==() [3/3]
◆ RegisterExtension()
| void v8::RegisterExtension | ( | std::unique_ptr< Extension > | ) |
|---|
◆ SharedMemoryHandleFromFileDescriptor()
◆ to_array() [1/2]
template<class T , std::size_t N>
| constexpr std::array< std::remove_cv_t< T >, N > v8::to_array ( T(&&) _a_[N]) | constexpr |
|---|
◆ to_array() [2/2]
template<class T , std::size_t N>
| constexpr std::array< std::remove_cv_t< T >, N > v8::to_array ( T(&) _a_[N]) | constexpr |
|---|
◆ ToExternalPointerTag()
◆ True()
◆ TryHandleWebAssemblyTrapPosix()
| bool v8::TryHandleWebAssemblyTrapPosix | ( | int | sig_code, |
|---|---|---|---|
| siginfo_t * | info, | ||
| void * | context | ||
| ) |
This function determines whether a memory access violation has been an out-of-bounds memory access in WebAssembly. If so, it will modify the context parameter and add a return address where the execution can continue after the signal handling, and return true. Otherwise, false will be returned.
The parameters to this function correspond to those passed to a Posix signal handler. Use this function only on Linux and Mac.
Parameters
| sig_code | The signal code, e.g. SIGSEGV. |
|---|---|
| info | A pointer to the siginfo_t struct provided to the signal handler. |
| context | A pointer to a ucontext_t struct provided to the signal handler. |
◆ TryHandleWebAssemblyTrapWindows()
| bool v8::TryHandleWebAssemblyTrapWindows | ( | EXCEPTION_POINTERS * | exception | ) |
|---|
This function determines whether a memory access violation has been an out-of-bounds memory access in WebAssembly. If so, it will modify the exception parameter and add a return address where the execution can continue after the exception handling, and return true. Otherwise the return value will be false.
The parameter to this function corresponds to the one passed to a Windows vectored exception handler. Use this function only on Windows.
Parameters
| exception | An EXCEPTION_POINTERS* as provided to the exception handler. |
|---|
◆ TryToCopyAndConvertArrayToCppBuffer()
| bool v8::TryToCopyAndConvertArrayToCppBuffer | ( | Local< Array > | src, |
|---|---|---|---|
| T * | dst, | ||
| uint32_t | max_length | ||
| ) |
Copies the contents of this JavaScript array to a C++ buffer with a given max_length. A CTypeInfo is passed as an argument, instructing different rules for conversion (e.g. restricted float/double). The element type T of the destination array must match the C type corresponding to the CTypeInfo (specified by CTypeInfoTraits). If the array length is larger than max_length or the array is of unsupported type, the operation will fail, returning false. Generally, an array which contains objects, undefined, null or anything not convertible to the requested destination type, is considered unsupported. The operation returns true on success. type_info will be used for conversions.