|
using | async_id_t = double |
|
using | CounterMap = std::unordered_map<std::string, Counter*> |
|
using | BackingStoreDeleterCallback |
|
using | JitCodeEventHandler = void (*)(const JitCodeEvent* event) |
|
using | GCCallback = void (*)(GCType type, GCCallbackFlags flags) |
|
using | InterruptCallback = void (*)(Isolate* isolate, void* data) |
|
using | PrintCurrentStackTraceFilterCallback |
|
using | NearHeapLimitCallback |
|
using | CounterLookupCallback = int* (*)(const char* name) |
|
using | CreateHistogramCallback |
|
using | AddHistogramSampleCallback = void (*)(void* histogram, int sample) |
|
using | FatalErrorCallback = void (*)(const char* location, const char* message) |
|
using | OOMErrorCallback |
|
using | MessageCallback = void (*)(Local<Message> message, Local<Value> data) |
|
using | LogEventCallback |
|
using | AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value) |
|
using | BeforeCallEnteredCallback = void (*)(Isolate*) |
|
using | CallCompletedCallback = void (*)(Isolate*) |
|
using | ModifyCodeGenerationFromStringsCallback |
|
using | ModifyCodeGenerationFromStringsCallback2 |
|
using | FailedAccessCheckCallback |
|
using | ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&) |
|
using | AllowWasmCodeGenerationCallback |
|
using | ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&) |
|
using | WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&) |
|
using | WasmAsyncResolvePromiseCallback |
|
using | WasmLoadSourceMapCallback |
|
using | WasmImportedStringsEnabledCallback = bool (*)(Local<Context> context) |
|
using | SharedArrayBufferConstructorEnabledCallback |
|
using | JavaScriptCompileHintsMagicEnabledCallback |
|
using | WasmJSPIEnabledCallback = bool (*)(Local<Context> context) |
|
using | HostImportModuleDynamicallyCallback |
|
using | HostImportModuleWithPhaseDynamicallyCallback |
|
using | CompileHintCallback = bool (*)(int, void*) |
|
using | HostInitializeImportMetaObjectCallback |
|
using | HostCreateShadowRealmContextCallback |
|
using | IsJSApiWrapperNativeErrorCallback |
|
using | PrepareStackTraceCallback |
|
using | ExceptionPropagationCallback |
|
using | CFunctionBuilder = internal::CFunctionBuilder |
|
using | FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info) |
|
using | EntropySource = bool (*)(unsigned char* buffer, size_t length) |
|
using | ReturnAddressLocationResolver |
|
using | DcheckErrorCallback |
|
using | V8FatalErrorCallback |
|
using | StackState = cppgc::EmbedderStackState |
|
template<class T > |
using | Handle = Local<T> |
|
using | MicrotasksCompletedCallbackWithData = void (*)(Isolate*, void*) |
|
using | MicrotaskCallback = void (*)(void* data) |
|
using | AccessorNameGetterCallback |
|
using | AccessorNameSetterCallback |
|
template<class T > |
using | UniquePersistent = Global<T> |
|
using | PlatformSharedMemoryHandle = intptr_t |
|
using | NativeObject = void* |
|
using | SnapshotObjectId = uint32_t |
|
using | ProfilerId = uint32_t |
|
using | PromiseHook |
|
using | PromiseRejectCallback = void (*)(PromiseRejectMessage message) |
|
using | NamedPropertyGetterCallback |
|
using | NamedPropertySetterCallback |
|
using | NamedPropertyQueryCallback |
|
using | NamedPropertyDeleterCallback |
|
using | NamedPropertyEnumeratorCallback |
|
using | NamedPropertyDefinerCallback |
|
using | NamedPropertyDescriptorCallback |
|
using | IndexedPropertyGetterCallbackV2 |
|
using | IndexedPropertySetterCallbackV2 |
|
using | IndexedPropertyQueryCallbackV2 |
|
using | IndexedPropertyDeleterCallbackV2 |
|
using | IndexedPropertyEnumeratorCallback |
|
using | IndexedPropertyDefinerCallbackV2 |
|
using | IndexedPropertyDescriptorCallbackV2 |
|
using | AccessCheckCallback |
|
typedef uintptr_t | PersistentContainerValue |
|
|
enum class | JSApiInstanceType : uint16_t {
kGenericApiObject = 0
, kEventTarget
, kNode
, kElement
,
kHTMLElement
, kHTMLDivElement
} |
|
enum class | ModuleType { kJavaScript
, kJSON
, kWebAssembly
, kInvalid
} |
|
enum class | ArrayBufferCreationMode { kInternalized
, kExternalized
} |
|
enum class | BackingStoreInitializationMode { kZeroInitialized
, kUninitialized
} |
|
enum class | BackingStoreOnFailureMode { kReturnNull
, kOutOfMemory
} |
|
enum | JitCodeEventOptions { kJitCodeEventDefault = 0
, kJitCodeEventEnumExisting = 1
, kLastJitCodeEventOption = kJitCodeEventEnumExisting
} |
|
enum | GCType {
kGCTypeScavenge = 1 << 0
, kGCTypeMinorMarkSweep = 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
, kLog = 2
} |
|
enum class | CrashKeyId {
kIsolateAddress
, kReadonlySpaceFirstPageAddress
, V8_ENUM_DEPRECATE_SOON =("Map space got removed")
, kOldSpaceFirstPageAddress
,
kCodeRangeBaseAddress
, kCodeSpaceFirstPageAddress
, kDumpType
, kSnapshotChecksumCalculated
,
kSnapshotChecksumExpected
} |
|
enum | AccessType {
ACCESS_GET
, ACCESS_SET
, ACCESS_HAS
, ACCESS_DELETE
,
ACCESS_KEYS
} |
|
enum class | WasmAsyncSuccess { kSuccess
, kFail
} |
|
enum class | ModuleImportPhase { kSource
, kEvaluation
} |
|
enum class | EmbedderStateTag : uint8_t { EMPTY = 0
, OTHER = 1
} |
|
enum class | ExceptionContext : uint32_t {
kUnknown
, kConstructor
, kOperation
, kAttributeGet
,
kAttributeSet
, kIndexedQuery
, kIndexedGetter
, kIndexedDescriptor
,
kIndexedSetter
, kIndexedDefiner
, kIndexedDeleter
, kNamedQuery
,
kNamedGetter
, kNamedDescriptor
, kNamedSetter
, kNamedDefiner
,
kNamedDeleter
, kNamedEnumerator
} |
|
enum class | MemoryPressureLevel { kNone
, kModerate
, kCritical
} |
|
enum class | ContextDependants { kNoDependants
, kSomeDependants
} |
|
enum class | MicrotasksPolicy { kExplicit
, kScoped
, kAuto
} |
|
enum | PropertyAttribute { None = 0
, ReadOnly = 1 << 0
, DontEnum = 1 << 1
, DontDelete = 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
, kMaxPriority = kUserBlocking
} |
|
enum class | BlockingType { kMayBlock
, kWillBlock
} |
|
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 | CppHeapPointerTag : uint16_t {
kFirstTag = 0
, kNullTag = 0
, kDefaultTag = 0x7000
, kZappedEntryTag = 0x7ffd
,
kEvacuationEntryTag = 0x7ffe
, kFreeEntryTag = 0x7fff
, kLastTag = 0x7fff
} |
|
enum class | ScriptType { kClassic
, kModule
} |
|
enum class | MeasureMemoryMode { kSummary
, kDetailed
} |
|
enum class | MeasureMemoryExecution { kDefault
, kEager
, kLazy
} |
|
enum | Intrinsic |
|
enum class | Intercepted : uint8_t { kNo = 0
, kYes = 1
} |
|
enum class | ConstructorBehavior { kThrow
, kAllow
} |
|
enum class | PropertyHandlerFlags {
kNone = 0
, kNonMasking = 1
, kOnlyInterceptStrings = 1 << 1
, kHasNoSideEffect = 1 << 2
,
kInternalNewCallbacksSignatures = 1 << 10
} |
|
enum | StateTag : uint16_t {
JS
, GC
, PARSER
, BYTECODE_COMPILER
,
COMPILER
, OTHER
, EXTERNAL
, ATOMICS_WAIT
,
IDLE
, LOGGING
} |
|
enum | PersistentContainerCallbackType { kNotWeak
, kWeakWithParameter
, kWeakWithInternalFields
} |
|
enum class | WeakCallbackType { kParameter
, kInternalFields
} |
|
|
template<typename T , internal::ExternalPointerTag tag> |
T | ToCData (i::Isolate *isolate, v8::internal::Tagged< v8::internal::Object > obj) |
|
template<internal::ExternalPointerTag tag> |
v8::internal::Address | ToCData (i::Isolate *isolate, v8::internal::Tagged< v8::internal::Object > obj) |
|
template<internal::ExternalPointerTag tag, typename T > |
v8::internal::DirectHandle< i::UnionOf< i::Smi, i::Foreign > > | FromCData (v8::internal::Isolate *isolate, T obj) |
|
template<internal::ExternalPointerTag tag> |
v8::internal::DirectHandle< i::UnionOf< i::Smi, i::Foreign > > | FromCData (v8::internal::Isolate *isolate, v8::internal::Address obj) |
|
template<typename T > |
void | CopySmiElementsToTypedBuffer (T *dst, uint32_t length, i::Tagged< i::FixedArray > elements) |
|
template<typename T > |
void | CopyDoubleElementsToTypedBuffer (T *dst, uint32_t length, i::Tagged< i::FixedDoubleArray > elements) |
|
template<CTypeInfo::Identifier type_info_id, typename T > |
bool | CopyAndConvertArrayToCppBuffer (Local< Array > src, T *dst, uint32_t max_length) |
|
template<const CTypeInfo * type_info, typename T > |
bool V8_EXPORT | TryCopyAndConvertArrayToCppBuffer (Local< Array > src, T *dst, uint32_t max_length) |
|
template<CTypeInfo::Identifier type_info_id, typename T > |
bool V8_EXPORT | TryToCopyAndConvertArrayToCppBuffer (Local< Array > src, T *dst, uint32_t max_length) |
|
static ScriptOrigin | GetScriptOriginForScript (i::Isolate *i_isolate, i::DirectHandle< i::Script > script) |
|
void | RegisterExtension (std::unique_ptr< Extension > extension) |
|
static i::DirectHandle< i::EmbedderDataArray > | EmbedderDataFor (Context *context, int index, bool can_grow, const char *location) |
|
template<typename Getter , typename Setter , typename Data > |
static Maybe< bool > | ObjectSetAccessor (Local< Context > context, Object *self, Local< Name > name, Getter getter, Setter setter, Data data, PropertyAttribute attributes, bool replace_on_access, SideEffectType getter_side_effect_type, SideEffectType setter_side_effect_type) |
|
static bool | Unaligned (const uint16_t *chars) |
|
static const uint16_t * | Align (const uint16_t *chars) |
|
template<typename CharType > |
static int | WriteHelper (i::Isolate *i_isolate, const String *string, CharType *buffer, int start, int length, int options) |
|
template<typename CharType > |
static void | WriteHelperV2 (i::Isolate *i_isolate, const String *string, CharType *buffer, uint32_t offset, uint32_t length, int flags) |
|
static V8_INLINE bool | InternalFieldOK (i::DirectHandle< i::JSReceiver > obj, int index, const char *location) |
|
template<typename ObjectType > |
static i::DirectHandle< ObjectType > | CreateEnvironment (i::Isolate *i_isolate, v8::ExtensionConfiguration *extensions, v8::MaybeLocal< ObjectTemplate > maybe_global_template, v8::MaybeLocal< Value > maybe_global_proxy, size_t context_snapshot_index, i::DeserializeEmbedderFieldsCallback embedder_fields_deserializer, v8::MicrotaskQueue *microtask_queue) |
|
Local< Context > | NewContext (v8::Isolate *external_isolate, v8::ExtensionConfiguration *extensions, v8::MaybeLocal< ObjectTemplate > global_template, v8::MaybeLocal< Value > global_object, size_t context_snapshot_index, i::DeserializeEmbedderFieldsCallback embedder_fields_deserializer, v8::MicrotaskQueue *microtask_queue) |
|
| REGEXP_FLAG_ASSERT_EQ (kNone) |
|
| REGEXP_FLAG_ASSERT_EQ (kGlobal) |
|
| REGEXP_FLAG_ASSERT_EQ (kIgnoreCase) |
|
| REGEXP_FLAG_ASSERT_EQ (kMultiline) |
|
| REGEXP_FLAG_ASSERT_EQ (kSticky) |
|
| REGEXP_FLAG_ASSERT_EQ (kUnicode) |
|
| REGEXP_FLAG_ASSERT_EQ (kHasIndices) |
|
| REGEXP_FLAG_ASSERT_EQ (kLinear) |
|
| REGEXP_FLAG_ASSERT_EQ (kUnicodeSets) |
|
static void | CallGCCallbackWithoutData (Isolate *v8_isolate, GCType type, GCCallbackFlags flags, void *data) |
|
| CALLBACK_SETTER (ModifyCodeGenerationFromStringsCallback, ModifyCodeGenerationFromStringsCallback2, modify_code_gen_callback) CALLBACK_SETTER(AllowWasmCodeGenerationCallback |
|
allow_wasm_code_gen_callback | CALLBACK_SETTER (WasmStreamingCallback, WasmStreamingCallback, wasm_streaming_callback) CALLBACK_SETTER(WasmAsyncResolvePromiseCallback |
|
allow_wasm_code_gen_callback wasm_async_resolve_promise_callback | CALLBACK_SETTER (WasmLoadSourceMapCallback, WasmLoadSourceMapCallback, wasm_load_source_map_callback) CALLBACK_SETTER(WasmImportedStringsEnabledCallback |
|
allow_wasm_code_gen_callback wasm_async_resolve_promise_callback wasm_imported_strings_enabled_callback | CALLBACK_SETTER (WasmJSPIEnabledCallback, WasmJSPIEnabledCallback, wasm_jspi_enabled_callback) CALLBACK_SETTER(SharedArrayBufferConstructorEnabledCallback |
|
allow_wasm_code_gen_callback wasm_async_resolve_promise_callback wasm_imported_strings_enabled_callback sharedarraybuffer_constructor_enabled_callback | CALLBACK_SETTER (JavaScriptCompileHintsMagicEnabledCallback, JavaScriptCompileHintsMagicEnabledCallback, compile_hints_magic_enabled_callback) CALLBACK_SETTER(IsJSApiWrapperNativeErrorCallback |
|
static i::CpuProfile * | ToInternal (const CpuProfile *profile) |
|
static i::HeapGraphEdge * | ToInternal (const HeapGraphEdge *edge) |
|
static i::HeapEntry * | ToInternal (const HeapGraphNode *entry) |
|
static i::HeapSnapshot * | ToInternal (const HeapSnapshot *snapshot) |
|
template<internal::ExternalPointerTag tag, typename T > |
v8::internal::DirectHandle< v8::internal::UnionOf< v8::internal::Smi, v8::internal::Foreign > > | FromCData (v8::internal::Isolate *isolate, T obj) |
|
template<internal::ExternalPointerTag tag> |
v8::internal::DirectHandle< v8::internal::UnionOf< v8::internal::Smi, v8::internal::Foreign > > | FromCData (v8::internal::Isolate *isolate, v8::internal::Address obj) |
|
template<class T > |
v8::Local< T > | ToApiHandle (v8::internal::DirectHandle< v8::internal::Object > obj) |
|
template<class T > |
bool | ToLocal (v8::internal::MaybeDirectHandle< v8::internal::Object > maybe, Local< T > *local) |
|
| ASSERT_TRIVIALLY_COPYABLE (api_internal::IndirectHandleBase) |
|
| ASSERT_TRIVIALLY_COPYABLE (LocalBase< Object >) |
|
| ASSERT_TRIVIALLY_COPYABLE (Local< Object >) |
|
| ASSERT_TRIVIALLY_COPYABLE (internal::LocalUnchecked< Object >) |
|
| ASSERT_TRIVIALLY_COPYABLE (MaybeLocal< Object >) |
|
std::unique_ptr< Platform > | MakePredictablePlatform (std::unique_ptr< Platform > platform) |
|
std::unique_ptr< Platform > | MakeDelayedTasksPlatform (std::unique_ptr< Platform > platform, int64_t random_seed) |
|
static int | LengthWithoutIncompleteUtf8 (char *buffer, int len) |
|
static bool | WaitOnFD (int fd, int read_timeout, int total_timeout, const struct timeval &start_time) |
|
static bool | TimeIsOut (const struct timeval &start_time, const int &total_time) |
|
static bool | GetTimeouts (const v8::FunctionCallbackInfo< v8::Value > &info, int *read_timeout, int *total_timeout) |
|
static void | ExecSubprocess (int *exec_error_fds, int *stdout_fds, const ExecArgs &exec_args) |
|
static bool | ChildLaunchedOK (Isolate *isolate, int *exec_error_fds) |
|
static Local< Value > | GetStdout (Isolate *isolate, int child_fd, const struct timeval &start_time, int read_timeout, int total_timeout) |
|
static bool | WaitForChild (Isolate *isolate, int pid, ZombieProtector &child_waiter, const struct timeval &start_time, int read_timeout, int total_timeout) |
|
static bool | CheckItsADirectory (Isolate *isolate, char *directory) |
|
static bool | mkdirp (Isolate *isolate, char *directory, mode_t mask) |
|
void | CreateFastCAPIObject (const FunctionCallbackInfo< Value > &info) |
|
void | CreateLeafInterfaceObject (const FunctionCallbackInfo< Value > &info) |
|
void | WriteToFile (FILE *file, const v8::FunctionCallbackInfo< v8::Value > &info, int first_arg_index=0) |
|
void | WriteAndFlush (FILE *file, const v8::FunctionCallbackInfo< v8::Value > &info) |
|
Local< FunctionTemplate > | NewDOMFunctionTemplate (Isolate *isolate, JSApiInstanceType instance_type) |
|
static void | PrintMessageCallback (Local< Message > message, Local< Value > error) |
|
void | Dummy (char *arg) |
|
bool | ends_with (const char *input, const char *suffix) |
|
void | GetCalleeSavedRegistersFromEntryFrame (void *fp, RegisterState *register_state) |
|
i::Address | Load (i::Address address) |
|
internal::Address | Load (internal::Address address) |
|
static i::DirectHandle< i::FunctionTemplateInfo > | NewFunctionTemplate (i::Isolate *i_isolate, FunctionCallback func, bool has_prototype, SideEffectType side_effect_type=SideEffectType::kHasSideEffect) |
|
static i::DirectHandle< i::ObjectTemplateInfo > | NewObjectTemplate (i::Isolate *i_isolate) |
|
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) |
|
template<class T , std::enable_if_t<!std::is_lvalue_reference_v< T > > * = nullptr> |
Maybe< T > | Just (T &&t) |
|
Maybe< void > | JustVoid () |
|
template<class T , std::size_t N> |
constexpr std::array< std::remove_cv_t< T >, N > | to_array (T(&a)[N]) |
|
template<class T , std::size_t N> |
constexpr std::array< std::remove_cv_t< T >, N > | to_array (T(&&a)[N]) |
|
enum | V8_DEPRECATE_SOON ("This enum is no longer used and will be removed in V8 12.9.") AccessControl |
|
PlatformSharedMemoryHandle | SharedMemoryHandleFromFileDescriptor (int fd) |
|
int | FileDescriptorFromSharedMemoryHandle (PlatformSharedMemoryHandle handle) |
|
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) |
|
constexpr CppHeapPointerTagRange | kAnyCppHeapPointer (CppHeapPointerTag::kFirstTag, CppHeapPointerTag::kLastTag) |
|
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) |
|
This file provides additional API on top of the default one for making API calls, which come from embedder C++ functions. The functions are being called directly from optimized code, doing all the necessary typechecks in the compiler itself, instead of on the embedder side. Hence the "fast" in the name. Example usage might look like:
void FastMethod(int param, bool another_param);
signature, length, constructor_behavior
side_effect_type,
static CFunction Make(F *func, CFunctionInfo::Int64Representation int64_rep=CFunctionInfo::Int64Representation::kNumber)
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:
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>
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);
}
};
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));
}
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);
MakeV8CFunction(FastMethod_2Args);
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.