|
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 > |
|
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) |
|
using | FunctionCallback = void(*)(const FunctionCallbackInfo< Value > &info) |
|
using | BackingStoreDeleterCallback = void(*)(void *data, size_t length, void *deleter_data) |
|
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) |
|
using | FatalErrorCallback = void(*)(const char *location, const char *message) |
|
using | OOMErrorCallback = void(*)(const char *location, bool is_heap_oom) |
|
using | DcheckErrorCallback = void(*)(const char *file, int line, const char *message) |
|
using | MessageCallback = void(*)(Local< Message > message, Local< Value > data) |
|
using | LogEventCallback = void(*)(const char *name, int event) |
|
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 | AddCrashKeyCallback = void(*)(CrashKeyId id, const std::string &value) |
|
using | BeforeCallEnteredCallback = void(*)(Isolate *) |
|
using | CallCompletedCallback = void(*)(Isolate *) |
|
using | instead = MaybeLocal< Promise >(*)(Local< Context > context, Local< ScriptOrModule > referrer, Local< String > specifier) |
|
using | HostImportModuleDynamicallyWithImportAssertionsCallback = MaybeLocal< Promise >(*)(Local< Context > context, Local< ScriptOrModule > referrer, Local< String > specifier, Local< FixedArray > import_assertions) |
|
using | HostInitializeImportMetaObjectCallback = void(*)(Local< Context > context, Local< Module > module, Local< Object > meta) |
|
using | PrepareStackTraceCallback = MaybeLocal< Value >(*)(Local< Context > context, Local< Value > error, Local< Array > sites) |
|
using | PromiseHook = void(*)(PromiseHookType type, Local< Promise > promise, Local< Value > parent) |
|
using | PromiseRejectCallback = void(*)(PromiseRejectMessage message) |
|
using | MicrotasksCompletedCallbackWithData = void(*)(Isolate *, void *) |
|
using | MicrotaskCallback = void(*)(void *data) |
|
using | FailedAccessCheckCallback = void(*)(Local< Object > target, AccessType type, Local< Value > data) |
|
using | AllowCodeGenerationFromStringsCallback = bool(*)(Local< Context > context, Local< String > source) |
|
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 | 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 | JitCodeEventHandler = void(*)(const JitCodeEvent *event) |
|
using | SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback |
|
using | DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback |
|
using | EntropySource = bool(*)(unsigned char *buffer, size_t length) |
|
using | ReturnAddressLocationResolver = uintptr_t(*)(uintptr_t return_addr_location) |
|
|
enum | TaskPriority : uint8_t { kBestEffort,
kUserVisible,
kUserBlocking
} |
|
enum | CpuProfilingMode { kLeafNodeLineNumbers,
kCallerLineNumbers
} |
|
enum | CpuProfilingNamingMode { kStandardNaming,
kDebugNaming
} |
|
enum | CpuProfilingLoggingMode { kLazyLogging,
kEagerLogging
} |
|
enum | CpuProfilingStatus { kStarted,
kAlreadyStarted,
kErrorTooManyProfilers
} |
|
enum | CodeEventType { kUnknownType
} |
|
enum | PersistentContainerCallbackType { kNotWeak,
kWeakWithParameter,
kWeakWithInternalFields
} |
|
enum | WeakCallbackType { kParameter,
kInternalFields,
kFinalizer
} |
|
enum | ScriptType { kClassic,
kModule
} |
|
enum | StateTag {
JS,
GC,
PARSER,
BYTECODE_COMPILER,
COMPILER,
OTHER,
EXTERNAL,
ATOMICS_WAIT,
IDLE
} |
|
enum | 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 | SideEffectType { kHasSideEffect,
kHasNoSideEffect,
kHasSideEffectToReceiver
} |
|
enum | KeyCollectionMode { kOwnOnly,
kIncludePrototypes
} |
|
enum | IndexFilter { kIncludeIndices,
kSkipIndices
} |
|
enum | KeyConversionMode { kConvertToString,
kKeepNumbers,
kNoNumbers
} |
|
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 {
kNone = 0,
kAllCanRead = 1,
kNonMasking = 1 << 1,
kOnlyInterceptStrings = 1 << 2,
kHasNoSideEffect = 1 << 3
} |
|
enum | CrashKeyId {
kIsolateAddress,
kReadonlySpaceFirstPageAddress,
kMapSpaceFirstPageAddress,
kCodeSpaceFirstPageAddress,
kDumpType
} |
|
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 : unsigned { PERFORMANCE_RESPONSE,
PERFORMANCE_ANIMATION,
PERFORMANCE_IDLE,
PERFORMANCE_LOAD
} |
|
enum | JitCodeEventOptions { kJitCodeEventDefault = 0,
kJitCodeEventEnumExisting = 1
} |
|
enum | MemoryPressureLevel { kNone,
kModerate,
kCritical
} |
|
enum | MeasureMemoryMode { kSummary,
kDetailed
} |
|
enum | MeasureMemoryExecution { kDefault,
kEager,
kLazy
} |
|
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,
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:
template <typename T, int offset>
assert(offset < wrapper->InternalFieldCount());
return reinterpret_cast<T*>(
}
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 =
kV8EmbedderWrapperObjectIndex + 1);
object_template->
Set(isolate,
"method", method_template);
object_template->
NewInstance(context).ToLocalChecked();
object->SetAlignedPointerInInternalField(
kV8EmbedderWrapperObjectIndex,
reinterpret_cast<void*>(embedder_object));
}
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
- 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:
- 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.