|
using | NativeObject = void * |
|
using | SnapshotObjectId = uint32_t |
|
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) |
|
using | BackingStoreDeleterCallback = void(*)(void *data, size_t length, void *deleter_data) |
|
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(* | AddCrashKeyCallback) (CrashKeyId id, const std::string &value) |
|
typedef void(* | BeforeCallEnteredCallback) (Isolate *) |
|
typedef void(* | CallCompletedCallback) (Isolate *) |
|
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 MaybeLocal< Value >(* | PrepareStackTraceCallback) (Local< Context > context, Local< Value > error, Local< Array > sites) |
|
typedef void(* | PromiseHook) (PromiseHookType type, Local< Promise > promise, Local< Value > parent) |
|
typedef void(* | PromiseRejectCallback) (PromiseRejectMessage message) |
|
typedef void(* | MicrotasksCompletedCallback) (Isolate *) |
|
typedef void(* | MicrotasksCompletedCallbackWithData) (Isolate *, void *) |
|
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 ModifyCodeGenerationFromStringsResult(* | ModifyCodeGenerationFromStringsCallback) (Local< Context > context, Local< Value > 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 bool(* | WasmThreadsEnabledCallback) (Local< Context > context) |
|
typedef Local< String >(* | WasmLoadSourceMapCallback) (Isolate *isolate, const char *name) |
|
typedef bool(* | WasmSimdEnabledCallback) (Local< Context > context) |
|
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(* | 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) |
|
|
enum class | TaskPriority : uint8_t { kBestEffort
, kUserVisible
, kUserBlocking
} |
|
enum | CpuProfilingMode { kLeafNodeLineNumbers
, kCallerLineNumbers
} |
|
enum | CpuProfilingNamingMode { kStandardNaming
, kDebugNaming
} |
|
enum | CpuProfilingLoggingMode { kLazyLogging
, kEagerLogging
} |
|
enum | CodeEventType { kUnknownType
} |
|
enum | PersistentContainerCallbackType { kNotWeak
, kWeakWithParameter
, kWeakWithInternalFields
} |
|
enum class | WeakCallbackType { kParameter
, kInternalFields
, kFinalizer
} |
|
enum | StateTag {
JS
, GC
, PARSER
, BYTECODE_COMPILER
,
COMPILER
, OTHER
, EXTERNAL
, ATOMICS_WAIT
,
IDLE
} |
|
enum class | NewStringType { kNormal
, 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 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 | ConstructorBehavior { kThrow
, kAllow
} |
|
enum class | ArrayBufferCreationMode { kInternalized
, kExternalized
} |
|
enum | Intrinsic |
|
enum | AccessType {
ACCESS_GET
, ACCESS_SET
, ACCESS_HAS
, ACCESS_DELETE
,
ACCESS_KEYS
} |
|
enum class | PropertyHandlerFlags {
kNone = 0
, kAllCanRead = 1
, kNonMasking = 1 << 1
, kOnlyInterceptStrings = 1 << 2
,
kHasNoSideEffect = 1 << 3
} |
|
enum class | CrashKeyId {
kIsolateAddress
, kReadonlySpaceFirstPageAddress
, kMapSpaceFirstPageAddress
, kCodeSpaceFirstPageAddress
,
kDumpType
} |
|
enum class | PromiseHookType { kInit
, kResolve
, kBefore
, kAfter
} |
|
enum | PromiseRejectEvent { kPromiseRejectWithNoHandler = 0
, kPromiseHandlerAddedAfterReject = 1
, kPromiseRejectAfterResolved = 2
, kPromiseResolveAfterResolved = 3
} |
|
enum class | 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 : unsigned { PERFORMANCE_RESPONSE
, PERFORMANCE_ANIMATION
, PERFORMANCE_IDLE
, PERFORMANCE_LOAD
} |
|
enum | JitCodeEventOptions { kJitCodeEventDefault = 0
, kJitCodeEventEnumExisting = 1
} |
|
enum class | MemoryPressureLevel { kNone
, kModerate
, kCritical
} |
|
enum class | MeasureMemoryMode { kSummary
, kDetailed
} |
|
enum class | MeasureMemoryExecution { kDefault
, kEager
, kLazy
} |
|
|
template<typename T1 , typename T2 , typename = std::enable_if_t<std::is_base_of<T2, T1>::value || std::is_base_of<T1, T2>::value>> |
bool | operator== (const JSMember< T1 > &lhs, const JSMember< T2 > &rhs) |
|
template<typename T1 , typename T2 , typename = std::enable_if_t<std::is_base_of<T2, T1>::value || std::is_base_of<T1, T2>::value>> |
bool | operator!= (const JSMember< T1 > &lhs, const JSMember< T2 > &rhs) |
|
template<typename T1 , typename T2 , typename = std::enable_if_t<std::is_base_of<T2, T1>::value || std::is_base_of<T1, T2>::value>> |
bool | operator== (const JSMember< T1 > &lhs, const Local< T2 > &rhs) |
|
template<typename T1 , typename T2 , typename = std::enable_if_t<std::is_base_of<T2, T1>::value || std::is_base_of<T1, T2>::value>> |
bool | operator== (const Local< T1 > &lhs, const JSMember< T2 > rhs) |
|
template<typename T1 , typename T2 > |
bool | operator!= (const JSMember< T1 > &lhs, const T2 &rhs) |
|
template<typename T1 , typename T2 > |
bool | operator!= (const T1 &lhs, const JSMember< T2 > &rhs) |
|
constexpr uint32_t | CurrentValueSerializerFormatVersion () |
|
V8_EXPORT bool | TryHandleWebAssemblyTrapPosix (int sig_code, siginfo_t *info, void *context) |
|
V8_EXPORT bool | TryHandleWebAssemblyTrapWindows (EXCEPTION_POINTERS *exception) |
|
void V8_EXPORT | RegisterExtension (std::unique_ptr< 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 () |
|
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)
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)
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);
}
};
static constexpr int kV8EmbedderWrapperTypeIndex = 0;
static constexpr int kV8EmbedderWrapperObjectIndex = 1;
CustomEmbedderType* embedder_object) {
isolate->set_embedder_wrapper_type_index(
kV8EmbedderWrapperTypeIndex);
isolate->set_embedder_wrapper_object_index(
kV8EmbedderWrapperObjectIndex);
MakeV8CFunction(CustomEmbedderType::FastMethod);
Local<v8::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));
}
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 only void return types are supported. Currently supported argument types:
- pointer to an embedder type
- bool
- int32_t
- uint32_t
- int64_t
- uint64_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. To be supported types:
- float32_t
- float64_t
- arrays of C types
- arrays of embedder types
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.
The v8 JavaScript engine.