v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8 Namespace Reference

Namespaces

namespace  api_internal
 
namespace  base
 
namespace  debug
 
namespace  internal
 
namespace  metrics
 
namespace  platform
 

Data Structures

class  AccessorSignature
 
class  ActivityControl
 
class  AllocationProfile
 
struct  AnyCType
 
class  Array
 
class  ArrayBuffer
 
class  ArrayBufferView
 
class  BackingStore
 
class  BasicTracedReference
 
class  BigInt
 
class  BigInt64Array
 
class  BigIntObject
 
class  BigUint64Array
 
class  Boolean
 
class  BooleanObject
 
class  CFunction
 
class  CFunctionInfo
 
class  CodeEvent
 
class  CodeEventHandler
 
class  CompiledWasmModule
 
class  Context
 
class  ConvertableToTraceFormat
 
struct  CopyablePersistentTraits
 
class  CppHeap
 
struct  CppHeapCreateParams
 
class  CpuProfile
 
struct  CpuProfileDeoptFrame
 
struct  CpuProfileDeoptInfo
 
class  CpuProfileNode
 
class  CpuProfiler
 
class  CpuProfilingOptions
 
struct  CpuProfilingResult
 
class  CTypeInfo
 
class  CTypeInfoBuilder
 
class  CustomSpaceStatisticsReceiver
 
class  Data
 
class  DataView
 
class  Date
 
class  DefaultGlobalMapTraits
 
class  DefaultPersistentValueMapTraits
 
class  DefaultPersistentValueVectorTraits
 
struct  DeserializeInternalFieldsCallback
 
class  DiscardedSamplesDelegate
 
class  EmbedderGraph
 
class  EmbedderHeapTracer
 
class  EmbedderRootsHandler
 
class  EmbedderStateScope
 
class  EscapableHandleScope
 
class  Eternal
 
class  Exception
 
class  Extension
 
class  ExtensionConfiguration
 
class  External
 
class  ExternalResourceVisitor
 
struct  FastApiArrayBuffer
 
struct  FastApiArrayBufferView
 
struct  FastApiCallbackOptions
 
struct  FastApiTypedArray
 
struct  FastApiTypedArrayBase
 
class  FixedArray
 
class  Float32Array
 
class  Float64Array
 
class  Function
 
class  FunctionCallbackInfo
 
class  FunctionTemplate
 
class  Global
 
class  GlobalValueMap
 
class  HandleScope
 
class  HeapCodeStatistics
 
class  HeapGraphEdge
 
class  HeapGraphNode
 
class  HeapObjectStatistics
 
class  HeapProfiler
 
class  HeapSnapshot
 
class  HeapSpaceStatistics
 
class  HeapStatistics
 
struct  HeapStatsUpdate
 
class  HighAllocationThroughputObserver
 
class  IdleTask
 
struct  IndexedPropertyHandlerConfiguration
 
class  Int16Array
 
class  Int32
 
class  Int32Array
 
class  Int8Array
 
class  Integer
 
class  Isolate
 
struct  JitCodeEvent
 
class  JobDelegate
 
class  JobHandle
 
class  JobTask
 
struct  JSEntryStub
 
struct  JSEntryStubs
 
class  JSON
 
class  JSVisitor
 
class  Local
 
class  Location
 
class  Locker
 
class  Map
 
class  Maybe
 
class  Maybe< void >
 
class  MaybeLocal
 
class  MeasureMemoryDelegate
 
struct  MemoryRange
 
class  MemorySpan
 
class  Message
 
class  MicrotaskQueue
 
class  MicrotasksScope
 
struct  ModifyCodeGenerationFromStringsResult
 
class  Module
 
class  ModuleRequest
 
class  Name
 
struct  NamedPropertyHandlerConfiguration
 
class  NonCopyablePersistentTraits
 
class  Number
 
class  NumberObject
 
class  Object
 
class  ObjectTemplate
 
class  OutputStream
 
struct  OwnedBuffer
 
class  PageAllocator
 
class  Persistent
 
class  PersistentBase
 
class  PersistentHandleVisitor
 
class  PersistentValueMap
 
class  PersistentValueMapBase
 
class  PersistentValueVector
 
class  Platform
 
class  Primitive
 
class  PrimitiveArray
 
class  Private
 
class  Promise
 
class  PromiseRejectMessage
 
class  PropertyCallbackInfo
 
class  PropertyDescriptor
 
class  Proxy
 
class  RegExp
 
struct  RegisterState
 
class  ResourceConstraints
 
class  ReturnValue
 
struct  SampleInfo
 
class  Script
 
class  ScriptCompiler
 
class  ScriptOrigin
 
class  ScriptOriginOptions
 
class  ScriptOrModule
 
class  SealHandleScope
 
struct  SerializeInternalFieldsCallback
 
class  Set
 
class  SharedArrayBuffer
 
class  SharedMemoryStatistics
 
class  Signature
 
class  SnapshotCreator
 
class  StackFrame
 
class  StackTrace
 
class  StartupData
 
class  StdGlobalValueMap
 
class  StdMapTraits
 
class  StdPersistentValueMap
 
class  String
 
class  StringObject
 
class  Symbol
 
class  SymbolObject
 
class  Task
 
class  TaskRunner
 
class  Template
 
class  Traced
 
class  TracedReference
 
class  TracedReferenceBase
 
class  TracingController
 
class  TryCatch
 
class  TypedArray
 
class  Uint16Array
 
class  Uint32
 
class  Uint32Array
 
class  Uint8Array
 
class  Uint8ClampedArray
 
class  UnboundModuleScript
 
class  UnboundScript
 
class  Unlocker
 
class  Unwinder
 
class  V8
 
class  Value
 
class  ValueDeserializer
 
class  ValueSerializer
 
class  VirtualAddressSpace
 
class  WasmMemoryObject
 
class  WasmModuleObject
 
class  WasmModuleObjectBuilderStreaming
 
class  WasmStreaming
 
class  WeakCallbackInfo
 
struct  WrapperDescriptor
 
class  ZoneBackingAllocator
 

Typedefs

using BackingStoreDeleterCallback = void(*)(void *data, size_t length, void *deleter_data)
 
using JitCodeEventHandler = void(*)(const JitCodeEvent *event)
 
using GCCallback = void(*)(GCType type, GCCallbackFlags flags)
 
using InterruptCallback = void(*)(Isolate *isolate, void *data)
 
using NearHeapLimitCallback = size_t(*)(void *data, size_t current_heap_limit, size_t initial_heap_limit)
 
using CounterLookupCallback = int *(*)(const char *name)
 
using CreateHistogramCallback = void *(*)(const char *name, int min, int max, size_t buckets)
 
using AddHistogramSampleCallback = void(*)(void *histogram, int sample)
 
using FatalErrorCallback = void(*)(const char *location, const char *message)
 
using OOMErrorCallback = void(*)(const char *location, bool is_heap_oom)
 
using MessageCallback = void(*)(Local< Message > message, Local< Value > data)
 
using LogEventCallback = void(*)(const char *name, int status)
 
using AddCrashKeyCallback = void(*)(CrashKeyId id, const std::string &value)
 
using BeforeCallEnteredCallback = void(*)(Isolate *)
 
using CallCompletedCallback = void(*)(Isolate *)
 
using AllowCodeGenerationFromStringsCallback = bool(*)(Local< Context > context, Local< String > source)
 
using FailedAccessCheckCallback = void(*)(Local< Object > target, AccessType type, Local< Value > data)
 
using ModifyCodeGenerationFromStringsCallback = ModifyCodeGenerationFromStringsResult(*)(Local< Context > context, Local< Value > source)
 
using ModifyCodeGenerationFromStringsCallback2 = ModifyCodeGenerationFromStringsResult(*)(Local< Context > context, Local< Value > source, bool is_code_like)
 
using ExtensionCallback = bool(*)(const FunctionCallbackInfo< Value > &)
 
using AllowWasmCodeGenerationCallback = bool(*)(Local< Context > context, Local< String > source)
 
using ApiImplementationCallback = void(*)(const FunctionCallbackInfo< Value > &)
 
using WasmStreamingCallback = void(*)(const FunctionCallbackInfo< Value > &)
 
using WasmLoadSourceMapCallback = Local< String >(*)(Isolate *isolate, const char *name)
 
using WasmSimdEnabledCallback = bool(*)(Local< Context > context)
 
using WasmExceptionsEnabledCallback = bool(*)(Local< Context > context)
 
using WasmDynamicTieringEnabledCallback = bool(*)(Local< Context > context)
 
using SharedArrayBufferConstructorEnabledCallback = bool(*)(Local< Context > context)
 
using HostImportModuleDynamicallyWithImportAssertionsCallback = MaybeLocal< Promise >(*)(Local< Context > context, Local< ScriptOrModule > referrer, Local< String > specifier, Local< FixedArray > import_assertions)
 
using HostImportModuleDynamicallyCallback = MaybeLocal< Promise >(*)(Local< Context > context, Local< Data > host_defined_options, Local< Value > resource_name, Local< String > specifier, Local< FixedArray > import_assertions)
 
using HostInitializeImportMetaObjectCallback = void(*)(Local< Context > context, Local< Module > module, Local< Object > meta)
 
using HostCreateShadowRealmContextCallback = MaybeLocal< Context >(*)(Local< Context > initiator_context)
 
using PrepareStackTraceCallback = MaybeLocal< Value >(*)(Local< Context > context, Local< Value > error, Local< Array > sites)
 
using CFunctionBuilder = internal::CFunctionBuilder
 
using FunctionCallback = void(*)(const FunctionCallbackInfo< Value > &info)
 
using EntropySource = bool(*)(unsigned char *buffer, size_t length)
 
using ReturnAddressLocationResolver = uintptr_t(*)(uintptr_t return_addr_location)
 
using DcheckErrorCallback = void(*)(const char *file, int line, const char *message)
 
template<class T >
using Handle = Local< T >
 
using MicrotasksCompletedCallbackWithData = void(*)(Isolate *, void *)
 
using MicrotaskCallback = void(*)(void *data)
 
using AccessorGetterCallback = void(*)(Local< String > property, const PropertyCallbackInfo< Value > &info)
 
using AccessorNameGetterCallback = void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
 
using AccessorSetterCallback = void(*)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
 
using AccessorNameSetterCallback = void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
 
template<class T >
using UniquePersistent = Global< T >
 
using PlatformSharedMemoryHandle = intptr_t
 
using NativeObject = void *
 
using SnapshotObjectId = uint32_t
 
using ProfilerId = uint32_t
 
using PromiseHook = void(*)(PromiseHookType type, Local< Promise > promise, Local< Value > parent)
 
using PromiseRejectCallback = void(*)(PromiseRejectMessage message)
 
using SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback
 
using DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback
 
using GenericNamedPropertyGetterCallback = void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
 
using GenericNamedPropertySetterCallback = void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
 
using GenericNamedPropertyQueryCallback = void(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info)
 
using GenericNamedPropertyDeleterCallback = void(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info)
 
using GenericNamedPropertyEnumeratorCallback = void(*)(const PropertyCallbackInfo< Array > &info)
 
using GenericNamedPropertyDefinerCallback = void(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
 
using GenericNamedPropertyDescriptorCallback = void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
 
using IndexedPropertyGetterCallback = void(*)(uint32_t index, const PropertyCallbackInfo< Value > &info)
 
using IndexedPropertySetterCallback = void(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
 
using IndexedPropertyQueryCallback = void(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
 
using IndexedPropertyDeleterCallback = void(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
 
using IndexedPropertyEnumeratorCallback = void(*)(const PropertyCallbackInfo< Array > &info)
 
using IndexedPropertyDefinerCallback = void(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
 
using IndexedPropertyDescriptorCallback = void(*)(uint32_t index, const PropertyCallbackInfo< Value > &info)
 
using AccessCheckCallback = bool(*)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data)
 
typedef uintptr_t PersistentContainerValue
 

Enumerations

enum class  ArrayBufferCreationMode { kInternalized , kExternalized }
 
enum  JitCodeEventOptions { kJitCodeEventDefault = 0 , kJitCodeEventEnumExisting = 1 }
 
enum  GCType {
  kGCTypeScavenge = 1 << 0 , kGCTypeMinorMarkCompact = 1 << 1 , kGCTypeMarkSweepCompact = 1 << 2 , kGCTypeIncrementalMarking = 1 << 3 ,
  kGCTypeProcessWeakCallbacks = 1 << 4 , kGCTypeAll
}
 
enum  GCCallbackFlags {
  kNoGCCallbackFlags = 0 , kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1 , kGCCallbackFlagForced = 1 << 2 , kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3 ,
  kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4 , kGCCallbackFlagCollectAllExternalMemory = 1 << 5 , kGCCallbackScheduleIdleGarbageCollection = 1 << 6
}
 
enum  LogEventStatus : int { kStart = 0 , kEnd = 1 , kStamp = 2 }
 
enum class  CrashKeyId {
  kIsolateAddress , kReadonlySpaceFirstPageAddress , kMapSpaceFirstPageAddress , kCodeSpaceFirstPageAddress ,
  kDumpType
}
 
enum  AccessType {
  ACCESS_GET , ACCESS_SET , ACCESS_HAS , ACCESS_DELETE ,
  ACCESS_KEYS
}
 
enum class  EmbedderStateTag : uint8_t { EMPTY = 0 , OTHER = 1 }
 
enum  RAILMode : unsigned { PERFORMANCE_RESPONSE , PERFORMANCE_ANIMATION , PERFORMANCE_IDLE , PERFORMANCE_LOAD }
 
enum class  MemoryPressureLevel { kNone , kModerate , kCritical }
 
enum class  MicrotasksPolicy { kExplicit , kScoped , kAuto }
 
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 class  SideEffectType { kHasSideEffect , kHasNoSideEffect , kHasSideEffectToReceiver }
 
enum class  KeyCollectionMode { kOwnOnly , kIncludePrototypes }
 
enum class  IndexFilter { kIncludeIndices , kSkipIndices }
 
enum class  KeyConversionMode { kConvertToString , kKeepNumbers , kNoNumbers }
 
enum class  IntegrityLevel { kFrozen , kSealed }
 
enum class  TaskPriority : uint8_t { kBestEffort , kUserVisible , kUserBlocking }
 
enum class  PagePermissions {
  kNoAccess , kRead , kReadWrite , kReadWriteExecute ,
  kReadExecute
}
 
enum class  NewStringType { kNormal , kInternalized }
 
enum  CpuProfilingMode { kLeafNodeLineNumbers , kCallerLineNumbers }
 
enum  CpuProfilingNamingMode { kStandardNaming , kDebugNaming }
 
enum  CpuProfilingLoggingMode { kLazyLogging , kEagerLogging }
 
enum class  CpuProfilingStatus { kStarted , kAlreadyStarted , kErrorTooManyProfilers }
 
enum  CodeEventType { kUnknownType }
 
enum class  PromiseHookType { kInit , kResolve , kBefore , kAfter }
 
enum  PromiseRejectEvent { kPromiseRejectWithNoHandler = 0 , kPromiseHandlerAddedAfterReject = 1 , kPromiseRejectAfterResolved = 2 , kPromiseResolveAfterResolved = 3 }
 
enum class  ScriptType { kClassic , kModule }
 
enum class  MeasureMemoryMode { kSummary , kDetailed }
 
enum class  MeasureMemoryExecution { kDefault , kEager , kLazy }
 
enum  Intrinsic
 
enum class  ConstructorBehavior { kThrow , kAllow }
 
enum class  PropertyHandlerFlags {
  kNone = 0 , kAllCanRead = 1 , kNonMasking = 1 << 1 , kOnlyInterceptStrings = 1 << 2 ,
  kHasNoSideEffect = 1 << 3
}
 
enum  StateTag : int {
  JS , GC , PARSER , BYTECODE_COMPILER ,
  COMPILER , OTHER , EXTERNAL , ATOMICS_WAIT ,
  IDLE
}
 
enum  PersistentContainerCallbackType { kNotWeak , kWeakWithParameter , kWeakWithInternalFields }
 
enum class  WeakCallbackType { kParameter , kInternalFields , V8_ENUM_DEPRECATED }
 

Functions

void V8_EXPORT RegisterExtension (std::unique_ptr< Extension >)
 
template<const CTypeInfo * type_info, typename T >
 V8_DEPRECATED ("Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()") bool V8_EXPORT V8_WARN_UNUSED_RESULT TryCopyAndConvertArrayToCppBuffer(Local< Array > src
 
template<>
 V8_DEPRECATED ("Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()") inline bool V8_WARN_UNUSED_RESULT TryCopyAndConvertArrayToCppBuffer< &kTypeInfoInt32
 
 int32_t (Local< Array > src, int32_t *dst, uint32_t max_length)
 
template<>
 V8_DEPRECATED ("Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()") inline bool V8_WARN_UNUSED_RESULT TryCopyAndConvertArrayToCppBuffer< &kTypeInfoFloat64
 
 double (Local< Array > src, double *dst, uint32_t max_length)
 
template<CTypeInfo::Identifier type_info_id, typename T >
bool V8_EXPORT V8_WARN_UNUSED_RESULT TryToCopyAndConvertArrayToCppBuffer (Local< Array > src, T *dst, uint32_t max_length)
 
template<class T >
Maybe< T > Nothing ()
 
template<class T >
Maybe< T > Just (const T &t)
 
Maybe< void > JustVoid ()
 
PlatformSharedMemoryHandle SharedMemoryHandleFromFileDescriptor (int fd)
 
int FileDescriptorFromSharedMemoryHandle (PlatformSharedMemoryHandle handle)
 
V8_INLINE Local< PrimitiveUndefined (Isolate *isolate)
 
V8_INLINE Local< PrimitiveNull (Isolate *isolate)
 
V8_INLINE Local< BooleanTrue (Isolate *isolate)
 
V8_INLINE Local< BooleanFalse (Isolate *isolate)
 
V8_INLINE bool operator== (const TracedReferenceBase &lhs, const TracedReferenceBase &rhs)
 
template<typename U >
V8_INLINE bool operator== (const TracedReferenceBase &lhs, const v8::Local< U > &rhs)
 
template<typename U >
V8_INLINE bool operator== (const v8::Local< U > &lhs, const TracedReferenceBase &rhs)
 
V8_INLINE bool operator!= (const TracedReferenceBase &lhs, const TracedReferenceBase &rhs)
 
template<typename U >
V8_INLINE bool operator!= (const TracedReferenceBase &lhs, const v8::Local< U > &rhs)
 
template<typename U >
V8_INLINE bool operator!= (const v8::Local< U > &lhs, const TracedReferenceBase &rhs)
 
constexpr uint32_t CurrentValueSerializerFormatVersion ()
 
V8_EXPORT bool TryHandleWebAssemblyTrapPosix (int sig_code, siginfo_t *info, void *context)
 
V8_EXPORT bool TryHandleWebAssemblyTrapWindows (EXCEPTION_POINTERS *exception)
 

Variables

T * dst
 
T uint32_t max_length
 

Detailed Description

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);
v8::FunctionTemplate::New(isolate, SlowCallback, data,
signature, length, constructor_behavior
side_effect_type,
&v8::CFunction::Make(FastMethod));
static CFunction Make(F *func)
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:

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:

void FastMethodWithFallback(int param, FastApiCallbackOptions& options);

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:

// Helper method with a check for field count.
template <typename T, int offset>
inline T* GetInternalField(v8::Local<v8::Object> wrapper) {
assert(offset < wrapper->InternalFieldCount());
return reinterpret_cast<T*>(
wrapper->GetAlignedPointerFromInternalField(offset));
}
class CustomEmbedderType {
public:
// Returns the raw C object from a wrapper JS object.
static CustomEmbedderType* Unwrap(v8::Local<v8::Object> wrapper) {
return GetInternalField<CustomEmbedderType,
kV8EmbedderWrapperObjectIndex>(wrapper);
}
static void FastMethod(v8::Local<v8::Object> receiver_obj, int param) {
CustomEmbedderType* receiver = static_cast<CustomEmbedderType*>(
receiver_obj->GetAlignedPointerFromInternalField(
kV8EmbedderWrapperObjectIndex));
// Type checks are already done by the optimized code.
// Then call some performance-critical method like:
// receiver->Method(param);
}
static void SlowMethod(
CustomEmbedderType* receiver = Unwrap(instance);
// TODO: Do type checks and extract {param}.
receiver->Method(param);
}
};
// TODO(mslekova): Clean-up these constants
// The constants kV8EmbedderWrapperTypeIndex and
// kV8EmbedderWrapperObjectIndex describe the offsets for the type info
// struct and the native object, when expressed as internal field indices
// within a JSObject. The existance of this helper function assumes that
// all embedder objects have their JSObject-side type info at the same
// offset, but this is not a limitation of the API itself. For a detailed
// use case, see the third example.
static constexpr int kV8EmbedderWrapperTypeIndex = 0;
static constexpr int kV8EmbedderWrapperObjectIndex = 1;
// The following setup function can be templatized based on
// the {embedder_object} argument.
void SetupCustomEmbedderObject(v8::Isolate* isolate,
CustomEmbedderType* embedder_object) {
isolate->set_embedder_wrapper_type_index(
kV8EmbedderWrapperTypeIndex);
isolate->set_embedder_wrapper_object_index(
kV8EmbedderWrapperObjectIndex);
v8::CFunction c_func =
MakeV8CFunction(CustomEmbedderType::FastMethod);
Local<v8::FunctionTemplate> method_template =
isolate, CustomEmbedderType::SlowMethod, v8::Local<v8::Value>(),
object_template->SetInternalFieldCount(
kV8EmbedderWrapperObjectIndex + 1);
object_template->Set(isolate, "method", method_template);
// Instantiate the wrapper JS object.
object_template->NewInstance(context).ToLocalChecked();
object->SetAlignedPointerInInternalField(
kV8EmbedderWrapperObjectIndex,
reinterpret_cast<void*>(embedder_object));
// TODO: Expose {object} where it's necessary.
}
V8_INLINE Local< Object > Holder() const
static V8_INLINE Local< T > Cast(Local< S > that)
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);
v8::CFunction fast_method_2args_c_func =
MakeV8CFunction(FastMethod_2Args);
v8::CFunction fast_method_3args_c_func =
MakeV8CFunction(FastMethod_3Args);
const v8::CFunction fast_method_overloads[] = {fast_method_2args_c_func,
fast_method_3args_c_func};
Local<v8::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.

Typedef Documentation

◆ AccessCheckCallback

using AccessCheckCallback = bool (*)(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.

Definition at line 368 of file v8-template.h.

◆ AccessorGetterCallback

using AccessorGetterCallback = void (*)(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.

Definition at line 153 of file v8-object.h.

◆ AccessorNameGetterCallback

using AccessorNameGetterCallback = void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info)

Definition at line 155 of file v8-object.h.

◆ AccessorNameSetterCallback

using AccessorNameSetterCallback = void (*)(Local<Name> property, Local<Value> value, const PropertyCallbackInfo<void>& info)

Definition at line 161 of file v8-object.h.

◆ AccessorSetterCallback

using AccessorSetterCallback = void (*)(Local<String> property, Local<Value> value, const PropertyCallbackInfo<void>& info)

Definition at line 158 of file v8-object.h.

◆ AddCrashKeyCallback

using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value)

Definition at line 238 of file v8-callbacks.h.

◆ AddHistogramSampleCallback

using AddHistogramSampleCallback = void (*)(void* histogram, int sample)

Definition at line 213 of file v8-callbacks.h.

◆ AllowCodeGenerationFromStringsCallback

using AllowCodeGenerationFromStringsCallback = bool (*)(Local<Context> context, Local<String> source)

Callback to check if code generation from strings is allowed. See Context::AllowCodeGenerationFromStrings.

Definition at line 250 of file v8-callbacks.h.

◆ AllowWasmCodeGenerationCallback

using AllowWasmCodeGenerationCallback = bool (*)(Local<Context> context, Local<String> source)

Definition at line 293 of file v8-callbacks.h.

◆ ApiImplementationCallback

Definition at line 298 of file v8-callbacks.h.

◆ BackingStoreDeleterCallback

using BackingStoreDeleterCallback = void (*)(void* data, size_t length, void* deleter_data)

Definition at line 107 of file v8-array-buffer.h.

◆ BeforeCallEnteredCallback

using BeforeCallEnteredCallback = void (*)(Isolate*)

Definition at line 241 of file v8-callbacks.h.

◆ CallCompletedCallback

using CallCompletedCallback = void (*)(Isolate*)

Definition at line 242 of file v8-callbacks.h.

◆ CFunctionBuilder

◆ CounterLookupCallback

using CounterLookupCallback = int* (*)(const char* name)

Callback function passed to SetUnhandledExceptionCallback.

Definition at line 208 of file v8-callbacks.h.

◆ CreateHistogramCallback

using CreateHistogramCallback = void* (*)(const char* name, int min, int max, size_t buckets)

Definition at line 210 of file v8-callbacks.h.

◆ DcheckErrorCallback

using DcheckErrorCallback = void (*)(const char* file, int line, const char* message)

Definition at line 52 of file v8-initialization.h.

◆ DeserializeEmbedderFieldsCallback

◆ EntropySource

using EntropySource = bool (*)(unsigned char* buffer, size_t length)

EntropySource is used as a callback function when v8 needs a source of entropy.

Definition at line 34 of file v8-initialization.h.

◆ ExtensionCallback

using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&)

Definition at line 291 of file v8-callbacks.h.

◆ FailedAccessCheckCallback

using FailedAccessCheckCallback = void (*)(Local<Object> target, AccessType type, Local<Value> data)

Definition at line 275 of file v8-callbacks.h.

◆ FatalErrorCallback

using FatalErrorCallback = void (*)(const char* location, const char* message)

Definition at line 217 of file v8-callbacks.h.

◆ FunctionCallback

using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info)

Definition at line 251 of file v8-function-callback.h.

◆ GCCallback

using GCCallback = void (*)(GCType type, GCCallbackFlags flags)

Definition at line 184 of file v8-callbacks.h.

◆ GenericNamedPropertyDefinerCallback

using GenericNamedPropertyDefinerCallback = void (*)(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().

Parameters
propertyThe name of the property for which the request was intercepted.
descThe property descriptor which is used to define the property if the request is not intercepted.
infoInformation about the intercepted request, such as isolate, receiver, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`.

See also ObjectTemplate::SetHandler.

Definition at line 291 of file v8-template.h.

◆ GenericNamedPropertyDeleterCallback

using GenericNamedPropertyDeleterCallback = void (*)(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.

Parameters
propertyThe name of the property for which the request was intercepted.
infoInformation about the intercepted request, such as isolate, receiver, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`.
Note
If you need to mimic the behavior of 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.

Definition at line 259 of file v8-template.h.

◆ GenericNamedPropertyDescriptorCallback

using GenericNamedPropertyDescriptorCallback = void (*)(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.

Parameters
propertyThe 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
If GetOwnPropertyDescriptor is intercepted, it will always return true, i.e., indicate that the property was found.

See also ObjectTemplate::SetHandler.

Definition at line 314 of file v8-template.h.

◆ GenericNamedPropertyEnumeratorCallback

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.

Definition at line 268 of file v8-template.h.

◆ GenericNamedPropertyGetterCallback

using GenericNamedPropertyGetterCallback = void (*)(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.

Parameters
propertyThe name of the property for which the request was intercepted.
infoInformation about the intercepted request, such as isolate, receiver, return value, or whether running in 'use strict' mode. See PropertyCallbackInfo.
void GetterCallback(
info.GetReturnValue().Set(v8_num(42));
}
templ->InstanceTemplate()->SetHandler(
LocalContext env;
env->Global()
->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
.ToLocalChecked()
->NewInstance(env.local())
.ToLocalChecked())
.FromJust();
v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a");
CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
V8_INLINE ReturnValue< T > GetReturnValue() const

See also ObjectTemplate::SetHandler.

Definition at line 186 of file v8-template.h.

◆ GenericNamedPropertyQueryCallback

using GenericNamedPropertyQueryCallback = void (*)(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.

Parameters
propertyThe name of the property for which the request was intercepted.
infoInformation 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.

Definition at line 235 of file v8-template.h.

◆ GenericNamedPropertySetterCallback

using GenericNamedPropertySetterCallback = void (*)(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().

Parameters
propertyThe name of the property for which the request was intercepted.
valueThe value which the property will have if the request is not intercepted.
infoInformation about the intercepted request, such as isolate, receiver, return value, or whether running in ‘'use strict’mode. SeePropertyCallbackInfo`.

See also ObjectTemplate::SetHandler.

Definition at line 210 of file v8-template.h.

◆ Handle

template<class T >
using Handle = Local<T>

Definition at line 331 of file v8-local-handle.h.

◆ 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.

Definition at line 381 of file v8-callbacks.h.

◆ HostImportModuleDynamicallyCallback

using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)( Local<Context> context, Local<Data> host_defined_options, Local<Value> resource_name, Local<String> specifier, Local<FixedArray> import_assertions)

Definition at line 351 of file v8-callbacks.h.

◆ HostImportModuleDynamicallyWithImportAssertionsCallback

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_assertions are import assertions 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::GetImportAssertions(), this array does not contain the source Locations of the assertions.

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.

Definition at line 346 of file v8-callbacks.h.

◆ HostInitializeImportMetaObjectCallback

using HostInitializeImportMetaObjectCallback = void (*)(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.

Definition at line 366 of file v8-callbacks.h.

◆ IndexedPropertyDefinerCallback

using IndexedPropertyDefinerCallback = void (*)(uint32_t index, const PropertyDescriptor& desc, const PropertyCallbackInfo<Value>& info)

See v8::GenericNamedPropertyDefinerCallback.

Definition at line 354 of file v8-template.h.

◆ IndexedPropertyDeleterCallback

using IndexedPropertyDeleterCallback = void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info)

See v8::GenericNamedPropertyDeleterCallback.

Definition at line 339 of file v8-template.h.

◆ IndexedPropertyDescriptorCallback

using IndexedPropertyDescriptorCallback = void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info)

◆ 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.

Definition at line 348 of file v8-template.h.

◆ IndexedPropertyGetterCallback

using IndexedPropertyGetterCallback = void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info)

See v8::GenericNamedPropertyGetterCallback.

Definition at line 320 of file v8-template.h.

◆ IndexedPropertyQueryCallback

using IndexedPropertyQueryCallback = void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info)

See v8::GenericNamedPropertyQueryCallback.

Definition at line 333 of file v8-template.h.

◆ IndexedPropertySetterCallback

using IndexedPropertySetterCallback = void (*)(uint32_t index, Local<Value> value, const PropertyCallbackInfo<Value>& info)

See v8::GenericNamedPropertySetterCallback.

Definition at line 326 of file v8-template.h.

◆ InterruptCallback

using InterruptCallback = void (*)(Isolate* isolate, void* data)

Definition at line 186 of file v8-callbacks.h.

◆ JitCodeEventHandler

using JitCodeEventHandler = void (*)(const JitCodeEvent* event)

Callback function passed to SetJitCodeEventHandler.

Parameters
eventcode add, move or removal event.

Definition at line 138 of file v8-callbacks.h.

◆ LogEventCallback

using LogEventCallback = void (*)(const char* name, int status)

Definition at line 226 of file v8-callbacks.h.

◆ MessageCallback

using MessageCallback = void (*)(Local<Message> message, Local<Value> data)

Definition at line 221 of file v8-callbacks.h.

◆ MicrotaskCallback

using MicrotaskCallback = void (*)(void* data)

Definition at line 14 of file v8-microtask.h.

◆ MicrotasksCompletedCallbackWithData

using MicrotasksCompletedCallbackWithData = void (*)(Isolate*, void*)

Definition at line 13 of file v8-microtask.h.

◆ ModifyCodeGenerationFromStringsCallback

Callback to check if codegen is allowed from a source object, and convert the source to string if necessary. See: ModifyCodeGenerationFromStrings.

Definition at line 282 of file v8-callbacks.h.

◆ ModifyCodeGenerationFromStringsCallback2

Definition at line 285 of file v8-callbacks.h.

◆ NativeObject

using NativeObject = void*

Definition at line 29 of file v8-profiler.h.

◆ NearHeapLimitCallback

using NearHeapLimitCallback = size_t (*)(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.

Definition at line 195 of file v8-callbacks.h.

◆ OOMErrorCallback

using OOMErrorCallback = void (*)(const char* location, bool is_heap_oom)

Definition at line 219 of file v8-callbacks.h.

◆ PersistentContainerValue

typedef uintptr_t PersistentContainerValue

Definition at line 28 of file v8-util.h.

◆ PlatformSharedMemoryHandle

using PlatformSharedMemoryHandle = intptr_t

Definition at line 516 of file v8-platform.h.

◆ PrepareStackTraceCallback

using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context, Local<Value> error, Local<Array> sites)

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

Definition at line 391 of file v8-callbacks.h.

◆ ProfilerId

using ProfilerId = uint32_t

Definition at line 31 of file v8-profiler.h.

◆ PromiseHook

using PromiseHook = void (*)(PromiseHookType type, Local<Promise> promise, Local<Value> parent)

Definition at line 143 of file v8-promise.h.

◆ PromiseRejectCallback

using PromiseRejectCallback = void (*)(PromiseRejectMessage message)

Definition at line 170 of file v8-promise.h.

◆ ReturnAddressLocationResolver

using ReturnAddressLocationResolver = uintptr_t (*)(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.

Parameters
return_addr_locationA 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.

Definition at line 49 of file v8-initialization.h.

◆ SerializeEmbedderFieldsCallback

◆ SharedArrayBufferConstructorEnabledCallback

Definition at line 317 of file v8-callbacks.h.

◆ SnapshotObjectId

using SnapshotObjectId = uint32_t

Definition at line 30 of file v8-profiler.h.

◆ UniquePersistent

template<class T >
using UniquePersistent = Global<T>

Definition at line 435 of file v8-persistent-handle.h.

◆ WasmDynamicTieringEnabledCallback

using WasmDynamicTieringEnabledCallback = bool (*)(Local<Context> context)

Definition at line 314 of file v8-callbacks.h.

◆ WasmExceptionsEnabledCallback

using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context)

Definition at line 311 of file v8-callbacks.h.

◆ WasmLoadSourceMapCallback

using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate, const char* name)

Definition at line 304 of file v8-callbacks.h.

◆ WasmSimdEnabledCallback

using WasmSimdEnabledCallback = bool (*)(Local<Context> context)

Definition at line 308 of file v8-callbacks.h.

◆ WasmStreamingCallback

Definition at line 301 of file v8-callbacks.h.

Enumeration Type Documentation

◆ 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.

Enumerator
DEFAULT 
ALL_CAN_READ 
ALL_CAN_WRITE 
PROHIBITS_OVERWRITING 

Definition at line 174 of file v8-object.h.

◆ AccessType

enum AccessType

Access type specification.

Enumerator
ACCESS_GET 
ACCESS_SET 
ACCESS_HAS 
ACCESS_DELETE 
ACCESS_KEYS 

Definition at line 265 of file v8-callbacks.h.

◆ ArrayBufferCreationMode

enum class ArrayBufferCreationMode
strong
Enumerator
kInternalized 
kExternalized 

Definition at line 25 of file v8-array-buffer.h.

◆ 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 

Definition at line 1122 of file v8-profiler.h.

◆ ConstructorBehavior

enum class ConstructorBehavior
strong
Enumerator
kThrow 
kAllow 

Definition at line 372 of file v8-template.h.

◆ CpuProfilingLoggingMode

Enumerator
kLazyLogging 
kEagerLogging 

Definition at line 259 of file v8-profiler.h.

◆ CpuProfilingMode

Enumerator
kLeafNodeLineNumbers 
kCallerLineNumbers 

Definition at line 240 of file v8-profiler.h.

◆ CpuProfilingNamingMode

Enumerator
kStandardNaming 
kDebugNaming 

Definition at line 251 of file v8-profiler.h.

◆ CpuProfilingStatus

enum class CpuProfilingStatus
strong
Enumerator
kStarted 
kAlreadyStarted 
kErrorTooManyProfilers 

Definition at line 271 of file v8-profiler.h.

◆ CrashKeyId

enum class CrashKeyId
strong
Enumerator
kIsolateAddress 
kReadonlySpaceFirstPageAddress 
kMapSpaceFirstPageAddress 
kCodeSpaceFirstPageAddress 
kDumpType 

Definition at line 230 of file v8-callbacks.h.

◆ EmbedderStateTag

enum class EmbedderStateTag : uint8_t
strong
Enumerator
EMPTY 
OTHER 

Definition at line 21 of file v8-embedder-state-scope.h.

◆ 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 

Definition at line 174 of file v8-callbacks.h.

◆ GCType

enum 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.

Enumerator
kGCTypeScavenge 
kGCTypeMinorMarkCompact 
kGCTypeMarkSweepCompact 
kGCTypeIncrementalMarking 
kGCTypeProcessWeakCallbacks 
kGCTypeAll 

Definition at line 149 of file v8-callbacks.h.

◆ IndexFilter

enum class IndexFilter
strong

kIncludesIndices allows for integer indices to be collected, while kSkipIndices will exclude integer indices from being collected.

Enumerator
kIncludeIndices 
kSkipIndices 

Definition at line 222 of file v8-object.h.

◆ IntegrityLevel

enum class IntegrityLevel
strong

Integrity level for objects.

Enumerator
kFrozen 
kSealed 

Definition at line 233 of file v8-object.h.

◆ Intrinsic

enum Intrinsic

Definition at line 36 of file v8-template.h.

◆ JitCodeEventOptions

Option flags passed to the SetJitCodeEventHandler function.

Enumerator
kJitCodeEventDefault 
kJitCodeEventEnumExisting 

Definition at line 127 of file v8-callbacks.h.

◆ KeyCollectionMode

enum class KeyCollectionMode
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.

Enumerator
kOwnOnly 
kIncludePrototypes 

Definition at line 216 of file v8-object.h.

◆ KeyConversionMode

enum class KeyConversionMode
strong

kConvertToString will convert integer indices to strings. kKeepNumbers will return numbers for integer indices.

Enumerator
kConvertToString 
kKeepNumbers 
kNoNumbers 

Definition at line 228 of file v8-object.h.

◆ LogEventStatus

enum LogEventStatus : int
Enumerator
kStart 
kEnd 
kStamp 

Definition at line 225 of file v8-callbacks.h.

◆ MeasureMemoryExecution

enum class MeasureMemoryExecution
strong

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 

Definition at line 42 of file v8-statistics.h.

◆ MeasureMemoryMode

enum class MeasureMemoryMode
strong

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 

Definition at line 33 of file v8-statistics.h.

◆ MemoryPressureLevel

enum class MemoryPressureLevel
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.

Enumerator
kNone 
kModerate 
kCritical 

Definition at line 195 of file v8-isolate.h.

◆ MicrotasksPolicy

enum class MicrotasksPolicy
strong

Policy for running microtasks:

Enumerator
kExplicit 
kScoped 
kAuto 

Definition at line 24 of file v8-microtask.h.

◆ NewStringType

enum class NewStringType
strong

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.

Definition at line 106 of file v8-primitive.h.

◆ PagePermissions

enum class PagePermissions
strong

Possible permissions for memory pages.

Enumerator
kNoAccess 
kRead 
kReadWrite 
kReadWriteExecute 
kReadExecute 

Definition at line 569 of file v8-platform.h.

◆ PersistentContainerCallbackType

Enumerator
kNotWeak 
kWeakWithParameter 
kWeakWithInternalFields 

Definition at line 30 of file v8-util.h.

◆ PromiseHookType

enum class PromiseHookType
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.

Enumerator
kInit 
kResolve 
kBefore 
kAfter 

Definition at line 141 of file v8-promise.h.

◆ PromiseRejectEvent

Enumerator
kPromiseRejectWithNoHandler 
kPromiseHandlerAddedAfterReject 
kPromiseRejectAfterResolved 
kPromiseResolveAfterResolved 

Definition at line 147 of file v8-promise.h.

◆ PropertyAttribute

PropertyAttribute.

Enumerator
None 

None.

ReadOnly 

ReadOnly, i.e., not writable.

DontEnum 

DontEnum, i.e., not enumerable.

DontDelete 

DontDelete, i.e., not configurable.

Definition at line 137 of file v8-object.h.

◆ 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 

Definition at line 184 of file v8-object.h.

◆ PropertyHandlerFlags

enum class PropertyHandlerFlags
strong

Configuration flags for v8::NamedPropertyHandlerConfiguration or v8::IndexedPropertyHandlerConfiguration.

Enumerator
kNone 

None.

kAllCanRead 

See ALL_CAN_READ above.

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.

Definition at line 617 of file v8-template.h.

◆ RAILMode

enum RAILMode : unsigned

Option flags passed to the SetRAILMode function. See documentation https://developers.google.com/web/tools/chrome-devtools/ profile/evaluate-performance/rail

Enumerator
PERFORMANCE_RESPONSE 
PERFORMANCE_ANIMATION 
PERFORMANCE_IDLE 
PERFORMANCE_LOAD 

Definition at line 170 of file v8-isolate.h.

◆ ScriptType

enum class ScriptType
strong
Enumerator
kClassic 
kModule 

Definition at line 329 of file v8-script.h.

◆ SideEffectType

enum class SideEffectType
strong

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 

Definition at line 203 of file v8-object.h.

◆ StateTag

enum StateTag : int
Enumerator
JS 
GC 
PARSER 
BYTECODE_COMPILER 
COMPILER 
OTHER 
EXTERNAL 
ATOMICS_WAIT 
IDLE 

Definition at line 36 of file v8-unwinder.h.

◆ TaskPriority

enum class TaskPriority : uint8_t
strong
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.

Definition at line 21 of file v8-platform.h.

◆ WeakCallbackType

enum class WeakCallbackType
strong

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.

V8_ENUM_DEPRECATED 

Passes a user-defined void* parameter back to the callback. Will do so before the object is actually reclaimed, allowing it to be resurrected. In this case it is not possible to set a second-pass callback.

Definition at line 57 of file v8-weak-callback-info.h.

Function Documentation

◆ CurrentValueSerializerFormatVersion()

constexpr uint32_t CurrentValueSerializerFormatVersion ( )
constexpr

Definition at line 20 of file v8-value-serializer-version.h.

◆ double()

double ( Local< Array src,
double *  dst,
uint32_t  max_length 
)

Definition at line 904 of file v8-fast-api-calls.h.

◆ False()

V8_INLINE Local< Boolean > False ( Isolate isolate)

Definition at line 852 of file v8-primitive.h.

Referenced by Boolean::New().

◆ FileDescriptorFromSharedMemoryHandle()

int FileDescriptorFromSharedMemoryHandle ( PlatformSharedMemoryHandle  handle)
inline

Definition at line 560 of file v8-platform.h.

◆ int32_t()

int32_t ( Local< Array src,
int32_t *  dst,
uint32_t  max_length 
)

◆ Just()

template<class T >
Maybe< T > Just ( const T &  t)
inline

Definition at line 101 of file v8-maybe.h.

◆ JustVoid()

Maybe< void > JustVoid ( )
inline

Definition at line 133 of file v8-maybe.h.

◆ Nothing()

template<class T >
Maybe< T > Nothing ( )
inline

Definition at line 96 of file v8-maybe.h.

◆ Null()

V8_INLINE Local< Primitive > Null ( Isolate isolate)

Definition at line 836 of file v8-primitive.h.

◆ operator!=() [1/3]

V8_INLINE bool operator!= ( const TracedReferenceBase lhs,
const TracedReferenceBase rhs 
)

Definition at line 332 of file v8-traced-handle.h.

◆ operator!=() [2/3]

template<typename U >
V8_INLINE bool operator!= ( const TracedReferenceBase lhs,
const v8::Local< U > &  rhs 
)

Definition at line 338 of file v8-traced-handle.h.

◆ operator!=() [3/3]

template<typename U >
V8_INLINE bool operator!= ( const v8::Local< U > &  lhs,
const TracedReferenceBase rhs 
)

Definition at line 344 of file v8-traced-handle.h.

◆ operator==() [1/3]

V8_INLINE bool operator== ( const TracedReferenceBase lhs,
const TracedReferenceBase rhs 
)

Definition at line 307 of file v8-traced-handle.h.

◆ operator==() [2/3]

template<typename U >
V8_INLINE bool operator== ( const TracedReferenceBase lhs,
const v8::Local< U > &  rhs 
)

Definition at line 317 of file v8-traced-handle.h.

◆ operator==() [3/3]

template<typename U >
V8_INLINE bool operator== ( const v8::Local< U > &  lhs,
const TracedReferenceBase rhs 
)

Definition at line 327 of file v8-traced-handle.h.

◆ RegisterExtension()

void V8_EXPORT RegisterExtension ( std::unique_ptr< Extension )

◆ SharedMemoryHandleFromFileDescriptor()

PlatformSharedMemoryHandle SharedMemoryHandleFromFileDescriptor ( int  fd)
inline

Definition at line 557 of file v8-platform.h.

◆ True()

V8_INLINE Local< Boolean > True ( Isolate isolate)

Definition at line 844 of file v8-primitive.h.

Referenced by Boolean::New().

◆ TryHandleWebAssemblyTrapPosix()

V8_EXPORT bool 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_codeThe signal code, e.g. SIGSEGV.
infoA pointer to the siginfo_t struct provided to the signal handler.
contextA pointer to a ucontext_t struct provided to the signal handler.

◆ TryHandleWebAssemblyTrapWindows()

V8_EXPORT bool 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
exceptionAn EXCEPTION_POINTERS* as provided to the exception handler.

◆ TryToCopyAndConvertArrayToCppBuffer()

template<CTypeInfo::Identifier type_info_id, typename T >
bool V8_EXPORT V8_WARN_UNUSED_RESULT TryToCopyAndConvertArrayToCppBuffer ( Local< Array src,
T *  dst,
uint32_t  max_length 
)

◆ Undefined()

V8_INLINE Local< Primitive > Undefined ( Isolate isolate)

Definition at line 828 of file v8-primitive.h.

Referenced by ReturnValue< T >::Get(), and FunctionCallbackInfo< T >::operator[]().

◆ V8_DEPRECATED() [1/3]

template<const CTypeInfo * type_info, typename T >
V8_DEPRECATED ( "Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()"  )

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.

◆ V8_DEPRECATED() [2/3]

template<>
V8_DEPRECATED ( "Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()"  ) &

◆ V8_DEPRECATED() [3/3]

template<>
V8_DEPRECATED ( "Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()"  ) &

Variable Documentation

◆ dst

T* dst

Definition at line 888 of file v8-fast-api-calls.h.

◆ max_length

T uint32_t max_length

Definition at line 889 of file v8-fast-api-calls.h.