V8 API Reference Guide generated from the header files
|
Typedefs | |
typedef uint32_t | SnapshotObjectId |
typedef uintptr_t | PersistentContainerValue |
template<class T > | |
using | Handle = Local< T > |
template<class T > | |
using | UniquePersistent = Global< T > |
typedef void(* | AccessorGetterCallback) (Local< String > property, const PropertyCallbackInfo< Value > &info) |
typedef void(* | AccessorNameGetterCallback) (Local< Name > property, const PropertyCallbackInfo< Value > &info) |
typedef void(* | AccessorSetterCallback) (Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info) |
typedef void(* | AccessorNameSetterCallback) (Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) |
typedef void(* | FunctionCallback) (const FunctionCallbackInfo< Value > &info) |
typedef void(* | NamedPropertyGetterCallback) (Local< String > property, const PropertyCallbackInfo< Value > &info) |
typedef void(* | NamedPropertySetterCallback) (Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info) |
typedef void(* | NamedPropertyQueryCallback) (Local< String > property, const PropertyCallbackInfo< Integer > &info) |
typedef void(* | NamedPropertyDeleterCallback) (Local< String > property, const PropertyCallbackInfo< Boolean > &info) |
typedef void(* | NamedPropertyEnumeratorCallback) (const PropertyCallbackInfo< Array > &info) |
typedef void(* | GenericNamedPropertyGetterCallback) (Local< Name > property, const PropertyCallbackInfo< Value > &info) |
typedef void(* | GenericNamedPropertySetterCallback) (Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info) |
typedef void(* | GenericNamedPropertyQueryCallback) (Local< Name > property, const PropertyCallbackInfo< Integer > &info) |
typedef void(* | GenericNamedPropertyDeleterCallback) (Local< Name > property, const PropertyCallbackInfo< Boolean > &info) |
typedef void(* | GenericNamedPropertyEnumeratorCallback) (const PropertyCallbackInfo< Array > &info) |
typedef void(* | GenericNamedPropertyDefinerCallback) (Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) |
typedef void(* | GenericNamedPropertyDescriptorCallback) (Local< Name > property, const PropertyCallbackInfo< Value > &info) |
typedef void(* | IndexedPropertyGetterCallback) (uint32_t index, const PropertyCallbackInfo< Value > &info) |
typedef void(* | IndexedPropertySetterCallback) (uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info) |
typedef void(* | IndexedPropertyQueryCallback) (uint32_t index, const PropertyCallbackInfo< Integer > &info) |
typedef void(* | IndexedPropertyDeleterCallback) (uint32_t index, const PropertyCallbackInfo< Boolean > &info) |
typedef void(* | IndexedPropertyEnumeratorCallback) (const PropertyCallbackInfo< Array > &info) |
typedef void(* | IndexedPropertyDefinerCallback) (uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) |
typedef void(* | IndexedPropertyDescriptorCallback) (uint32_t index, const PropertyCallbackInfo< Value > &info) |
typedef bool(* | AccessCheckCallback) (Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) |
typedef void(* | FatalErrorCallback) (const char *location, const char *message) |
typedef void(* | OOMErrorCallback) (const char *location, bool is_heap_oom) |
typedef void(* | DcheckErrorCallback) (const char *file, int line, const char *message) |
typedef void(* | MessageCallback) (Local< Message > message, Local< Value > data) |
typedef void(* | LogEventCallback) (const char *name, int event) |
typedef int *(* | CounterLookupCallback) (const char *name) |
typedef void *(* | CreateHistogramCallback) (const char *name, int min, int max, size_t buckets) |
typedef void(* | AddHistogramSampleCallback) (void *histogram, int sample) |
typedef void(* | BeforeCallEnteredCallback) (Isolate *) |
typedef void(* | CallCompletedCallback) (Isolate *) |
typedef void(* | DeprecatedCallCompletedCallback) () |
typedef MaybeLocal< Promise >(* | HostImportModuleDynamicallyCallback) (Local< Context > context, Local< ScriptOrModule > referrer, Local< String > specifier) |
typedef void(* | HostInitializeImportMetaObjectCallback) (Local< Context > context, Local< Module > module, Local< Object > meta) |
typedef void(* | PromiseHook) (PromiseHookType type, Local< Promise > promise, Local< Value > parent) |
typedef void(* | PromiseRejectCallback) (PromiseRejectMessage message) |
typedef void(* | MicrotasksCompletedCallback) (Isolate *) |
typedef void(* | MicrotaskCallback) (void *data) |
typedef void(* | FailedAccessCheckCallback) (Local< Object > target, AccessType type, Local< Value > data) |
typedef bool(* | AllowCodeGenerationFromStringsCallback) (Local< Context > context, Local< String > source) |
typedef bool(* | ExtensionCallback) (const FunctionCallbackInfo< Value > &) |
typedef bool(* | AllowWasmCodeGenerationCallback) (Local< Context > context, Local< String > source) |
typedef void(* | ApiImplementationCallback) (const FunctionCallbackInfo< Value > &) |
typedef void(* | WasmStreamingCallback) (const FunctionCallbackInfo< Value > &) |
typedef void(* | GCCallback) (GCType type, GCCallbackFlags flags) |
typedef void(* | InterruptCallback) (Isolate *isolate, void *data) |
typedef size_t(* | NearHeapLimitCallback) (void *data, size_t current_heap_limit, size_t initial_heap_limit) |
typedef void(* | FunctionEntryHook) (uintptr_t function, uintptr_t return_addr_location) |
typedef void(* | JitCodeEventHandler) (const JitCodeEvent *event) |
typedef SerializeInternalFieldsCallback | SerializeEmbedderFieldsCallback |
typedef DeserializeInternalFieldsCallback | DeserializeEmbedderFieldsCallback |
typedef bool(* | EntropySource) (unsigned char *buffer, size_t length) |
typedef uintptr_t(* | ReturnAddressLocationResolver) (uintptr_t return_addr_location) |
Enumerations | |
enum | CpuProfilingMode { kLeafNodeLineNumbers, kCallerLineNumbers } |
enum | CodeEventType { kUnknownType } |
enum | PersistentContainerCallbackType { kNotWeak, kWeakWithParameter, kWeakWithInternalFields, kWeak = kWeakWithParameter } |
enum | WeakCallbackType { kParameter, kInternalFields, kFinalizer } |
enum | StateTag { JS, GC, PARSER, BYTECODE_COMPILER, COMPILER, OTHER, EXTERNAL, IDLE } |
enum | NewStringType { NewStringType::kNormal, NewStringType::kInternalized } |
enum | PropertyAttribute { None = 0, ReadOnly = 1 << 0, DontEnum = 1 << 1, DontDelete = 1 << 2 } |
enum | AccessControl { DEFAULT = 0, ALL_CAN_READ = 1, ALL_CAN_WRITE = 1 << 1, PROHIBITS_OVERWRITING = 1 << 2 } |
enum | PropertyFilter { ALL_PROPERTIES = 0, ONLY_WRITABLE = 1, ONLY_ENUMERABLE = 2, ONLY_CONFIGURABLE = 4, SKIP_STRINGS = 8, SKIP_SYMBOLS = 16 } |
enum | SideEffectType { kHasSideEffect, kHasNoSideEffect } |
enum | KeyCollectionMode { kOwnOnly, kIncludePrototypes } |
enum | IndexFilter { kIncludeIndices, kSkipIndices } |
enum | KeyConversionMode { kConvertToString, kKeepNumbers } |
enum | IntegrityLevel { kFrozen, kSealed } |
enum | ConstructorBehavior { kThrow, kAllow } |
enum | ArrayBufferCreationMode { kInternalized, kExternalized } |
enum | Intrinsic |
enum | AccessType { ACCESS_GET, ACCESS_SET, ACCESS_HAS, ACCESS_DELETE, ACCESS_KEYS } |
enum | PropertyHandlerFlags { PropertyHandlerFlags::kNone = 0, PropertyHandlerFlags::kAllCanRead = 1, PropertyHandlerFlags::kNonMasking = 1 << 1, PropertyHandlerFlags::kOnlyInterceptStrings = 1 << 2, PropertyHandlerFlags::kHasNoSideEffect = 1 << 3 } |
enum | PromiseHookType { kInit, kResolve, kBefore, kAfter } |
enum | PromiseRejectEvent { kPromiseRejectWithNoHandler = 0, kPromiseHandlerAddedAfterReject = 1, kPromiseRejectAfterResolved = 2, kPromiseResolveAfterResolved = 3 } |
enum | MicrotasksPolicy { kExplicit, kScoped, kAuto } |
enum | GCType { kGCTypeScavenge = 1 << 0, kGCTypeMarkSweepCompact = 1 << 1, kGCTypeIncrementalMarking = 1 << 2, kGCTypeProcessWeakCallbacks = 1 << 3, kGCTypeAll } |
enum | GCCallbackFlags { kNoGCCallbackFlags = 0, kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1, kGCCallbackFlagForced = 1 << 2, kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3, kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4, kGCCallbackFlagCollectAllExternalMemory = 1 << 5, kGCCallbackScheduleIdleGarbageCollection = 1 << 6 } |
enum | RAILMode { PERFORMANCE_RESPONSE, PERFORMANCE_ANIMATION, PERFORMANCE_IDLE, PERFORMANCE_LOAD } |
enum | JitCodeEventOptions { kJitCodeEventDefault = 0, kJitCodeEventEnumExisting = 1 } |
enum | MemoryPressureLevel { kNone, kModerate, kCritical } |
Functions | |
constexpr uint32_t | CurrentValueSerializerFormatVersion () |
V8_DEPRECATE_SOON ("Implementation detail", class ExternalOneByteStringResourceImpl) | |
void V8_EXPORT | RegisterExtension (Extension *extension) |
V8_INLINE Local< Primitive > | Undefined (Isolate *isolate) |
V8_INLINE Local< Primitive > | Null (Isolate *isolate) |
V8_INLINE Local< Boolean > | True (Isolate *isolate) |
V8_INLINE Local< Boolean > | False (Isolate *isolate) |
template<class T > | |
Maybe< T > | Nothing () |
template<class T > | |
Maybe< T > | Just (const T &t) |
Maybe< void > | JustVoid () |
Profiler support for the V8 JavaScript engine.
Testing 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.
The v8 JavaScript engine.
typedef bool(* v8::AccessCheckCallback) (Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) |
Returns true if the given context should be allowed to access the given object.
typedef void(* v8::AccessorGetterCallback) (Local< String > property, const PropertyCallbackInfo< Value > &info) |
Accessor[Getter|Setter] are used as callback functions when setting|getting a particular property. See Object and ObjectTemplate's method SetAccessor.
typedef bool(* v8::AllowCodeGenerationFromStringsCallback) (Local< Context > context, Local< String > source) |
Callback to check if code generation from strings is allowed. See Context::AllowCodeGenerationFromStrings.
typedef bool(* v8::EntropySource) (unsigned char *buffer, size_t length) |
EntropySource is used as a callback function when v8 needs a source of entropy.
typedef void(* v8::FunctionEntryHook) (uintptr_t function, uintptr_t return_addr_location) |
FunctionEntryHook is the type of the profile entry hook called at entry to any generated function when function-level profiling is enabled.
function | the address of the function that's being entered. |
return_addr_location | points to a location on stack where the machine return address resides. This can be used to identify the caller of function , and/or modified to divert execution when function exits. |
typedef void(* v8::GenericNamedPropertyDefinerCallback) (Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) |
Interceptor for defineProperty requests on an object.
Use info.GetReturnValue()
to indicate whether the request was intercepted or not. If the definer successfully intercepts the request, i.e., if the request should not be further executed, call info.GetReturnValue().Set(value)
. If the definer did not intercept the request, i.e., if the request should be handled as if no interceptor is present, do not not call Set()
.
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, receiver, return value, or whether running in ‘'use strict’mode. See PropertyCallbackInfo`. |
See also ObjectTemplate::SetHandler
.
typedef void(* v8::GenericNamedPropertyDeleterCallback) (Local< Name > property, const PropertyCallbackInfo< Boolean > &info) |
Interceptor for delete requests on an object.
Use info.GetReturnValue()
to indicate whether the request was intercepted or not. If the deleter successfully intercepts the request, i.e., if the request should not be further executed, call info.GetReturnValue().Set(value)
with a boolean value
. The value
is used as the return value of delete
.
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. See PropertyCallbackInfo`. |
delete
, i.e., throw in strict mode instead of returning false, use info.ShouldThrowOnError()
to determine if you are in strict mode.See also ObjectTemplate::SetHandler.
typedef void(* v8::GenericNamedPropertyDescriptorCallback) (Local< Name > property, const PropertyCallbackInfo< Value > &info) |
Interceptor for getOwnPropertyDescriptor requests on an object.
Use info.GetReturnValue().Set()
to set the return value of the intercepted request. The return value must be an object that can be converted to a PropertyDescriptor, e.g., a v8::value
returned from v8::Object::getOwnPropertyDescriptor
.
property | The name of the property for which the request was intercepted. Information about the intercepted request, such as isolate, receiver, return value, or whether running in ‘'use strict’mode. See PropertyCallbackInfo`. |
See also ObjectTemplate::SetHandler
.
typedef void(* v8::GenericNamedPropertyEnumeratorCallback) (const PropertyCallbackInfo< Array > &info) |
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.
typedef void(* v8::GenericNamedPropertyGetterCallback) (Local< Name > property, const PropertyCallbackInfo< Value > &info) |
Interceptor for get requests on an object.
Use info.GetReturnValue().Set()
to set the return value of the intercepted get request.
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. See PropertyCallbackInfo . |
See also ObjectTemplate::SetHandler
.
typedef void(* v8::GenericNamedPropertyQueryCallback) (Local< Name > property, const PropertyCallbackInfo< Integer > &info) |
Intercepts all requests that query the attributes of the property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and defineProperty().
Use info.GetReturnValue().Set(value)
to set the property attributes. The value is an integer encoding a v8::PropertyAttribute
.
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. See PropertyCallbackInfo`. |
hasOwnProperty()
can trigger this interceptor depending on the state of the object.See also ObjectTemplate::SetHandler.
typedef void(* v8::GenericNamedPropertySetterCallback) (Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info) |
Interceptor for set requests on an object.
Use info.GetReturnValue()
to indicate whether the request was intercepted or not. If the setter successfully intercepts the request, i.e., if the request should not be further executed, call info.GetReturnValue().Set(value)
. If the setter did not intercept the request, i.e., if the request should be handled as if no interceptor is present, do not not call Set()
.
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, receiver, return value, or whether running in ‘'use strict’mode. See PropertyCallbackInfo`. |
See also ObjectTemplate::SetHandler.
typedef MaybeLocal<Promise>(* v8::HostImportModuleDynamicallyCallback) (Local< Context > context, Local< ScriptOrModule > referrer, Local< String > specifier) |
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 embedder must compile, instantiate, evaluate the Module, and obtain it's 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.
typedef void(* v8::HostInitializeImportMetaObjectCallback) (Local< Context > context, Local< Module > module, Local< Object > meta) |
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(* v8::IndexedPropertyDefinerCallback) (uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) |
typedef void(* v8::IndexedPropertyDeleterCallback) (uint32_t index, const PropertyCallbackInfo< Boolean > &info) |
typedef void(* v8::IndexedPropertyDescriptorCallback) (uint32_t index, const PropertyCallbackInfo< Value > &info) |
typedef void(* v8::IndexedPropertyEnumeratorCallback) (const PropertyCallbackInfo< Array > &info) |
Returns an array containing the indices of the properties the indexed property getter intercepts.
Note: The values in the array must be uint32_t.
typedef void(* v8::IndexedPropertyGetterCallback) (uint32_t index, const PropertyCallbackInfo< Value > &info) |
typedef void(* v8::IndexedPropertyQueryCallback) (uint32_t index, const PropertyCallbackInfo< Integer > &info) |
typedef void(* v8::IndexedPropertySetterCallback) (uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info) |
typedef void(* v8::JitCodeEventHandler) (const JitCodeEvent *event) |
Callback function passed to SetJitCodeEventHandler.
event | code add, move or removal event. |
typedef void(* v8::NamedPropertyDeleterCallback) (Local< String > property, const PropertyCallbackInfo< Boolean > &info) |
Returns a non-empty handle if the deleter intercepts the request. The return value is true if the property could be deleted and false otherwise.
typedef void(* v8::NamedPropertyEnumeratorCallback) (const PropertyCallbackInfo< Array > &info) |
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.
typedef void(* v8::NamedPropertyGetterCallback) (Local< String > property, const PropertyCallbackInfo< Value > &info) |
NamedProperty[Getter|Setter] are used as interceptors on object. See ObjectTemplate::SetNamedPropertyHandler.
typedef void(* v8::NamedPropertyQueryCallback) (Local< String > property, const PropertyCallbackInfo< Integer > &info) |
Returns a non-empty handle if the interceptor intercepts the request. The result is an integer encoding property attributes (like v8::None, v8::DontEnum, etc.)
typedef void(* v8::NamedPropertySetterCallback) (Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info) |
Returns the value if the setter intercepts the request. Otherwise, returns an empty handle.
typedef size_t(* v8::NearHeapLimitCallback) (void *data, size_t current_heap_limit, size_t initial_heap_limit) |
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.
typedef uintptr_t(* v8::ReturnAddressLocationResolver) (uintptr_t return_addr_location) |
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.
return_addr_location | A location on stack where a machine return address resides. |
enum v8::AccessControl |
Access control specifications.
Some accessors should be accessible across contexts. These accessors have an explicit access control parameter which specifies the kind of cross-context access that should be allowed.
TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused.
enum v8::AccessType |
Access type specification.
enum v8::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.
enum v8::GCCallbackFlags |
GCCallbackFlags is used to notify additional information about the GC callback.
enum v8::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.
|
strong |
kIncludesIndices allows for integer indices to be collected, while kSkipIndices will exclude integer indices from being collected.
|
strong |
Integrity level for objects.
Option flags passed to the SetJitCodeEventHandler function.
|
strong |
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.
|
strong |
kConvertToString will convert integer indices to strings. kKeepNumbers will return numbers for integer indices.
|
strong |
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.
|
strong |
Policy for running microtasks:
|
strong |
A flag describing different modes of string creation.
Aside from performance implications there are no differences between the two creation modes.
|
strong |
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 v8::PropertyFilter |
Property filter bits. They can be or'ed to build a composite filter.
|
strong |
Configuration flags for v8::NamedPropertyHandlerConfiguration or v8::IndexedPropertyHandlerConfiguration.
enum v8::RAILMode |
Option flags passed to the SetRAILMode function. See documentation https://developers.google.com/web/tools/chrome-devtools/ profile/evaluate-performance/rail
|
strong |
Options for marking whether callbacks may trigger JS-observable side effects. Side-effect-free callbacks are whitelisted during debug evaluation with throwOnSideEffect. It applies when calling a Function, FunctionTemplate, or an Accessor's getter callback. For Interceptors, please see PropertyHandlerFlags's kHasNoSideEffect.