5#ifndef INCLUDE_V8_CONTEXT_H_
6#define INCLUDE_V8_CONTEXT_H_
29#ifndef V8_EMBEDDER_DATA_ARRAY_SIZE
31#define V8_EMBEDDER_DATA_ARRAY_SIZE 5
41 : name_count_(name_count), names_(names) {}
43 const char**
begin()
const {
return &names_[0]; }
44 const char**
end()
const {
return &names_[name_count_]; }
47 const int name_count_;
171 Isolate* isolate,
size_t context_snapshot_index,
315 V8_INLINE void* GetAlignedPointerFromEmbedderData(
Isolate* isolate,
int index,
317 void* GetAlignedPointerFromEmbedderData(
int index,
319 template <typename T>
320 requires
cppgc::IsGarbageCollectedTypeV<T>
324 void SetAlignedPointerInEmbedderDataV2(
int index,
void* value,
327 template <typename T>
328 requires(!std::is_void_v<T>) &&
cppgc::IsGarbageCollectedTypeV<T>
329 void SetAlignedPointerInEmbedderDataV2(
int index, T* value,
331 SetAlignedPointerInEmbedderDataInternalV2(index,
static_cast<void*
>(value),
436 friend class internal::Isolate;
438 uintptr_t JSStackComparableAddressPrivate()
const {
439 return js_stack_comparable_address_;
443 uintptr_t js_stack_comparable_address_ = 0;
455 static void CheckCast(
Data* obj);
462 void SetAlignedPointerInEmbedderDataInternalV2(
int index,
void* value,
469#ifndef V8_ENABLE_CHECKS
474 I::kNativeContextEmbedderDataOffset + (I::kEmbedderDataSlotSize * index);
475#ifdef V8_COMPRESS_POINTERS
480 uint32_t compressed = I::ReadRawField<uint32_t>(ctx, value_offset);
481 A value = I::DecompressTaggedField(ctx, compressed);
483 A value = I::ReadRawField<A>(ctx, value_offset);
486 auto* isolate = I::GetCurrentIsolate();
489 return SlowGetEmbedderData(index);
494#ifndef V8_ENABLE_CHECKS
499 I::kNativeContextEmbedderDataOffset + (I::kEmbedderDataSlotSize * index);
500#ifdef V8_COMPRESS_POINTERS
505 uint32_t compressed = I::ReadRawField<uint32_t>(ctx, value_offset);
506 A value = I::DecompressTaggedField(ctx, compressed);
508 A value = I::ReadRawField<A>(ctx, value_offset);
511 auto* isolate = I::GetCurrentIsolate();
514 return SlowGetEmbedderDataV2(index);
524 requires cppgc::IsGarbageCollectedTypeV<T>
527#if !defined(V8_ENABLE_CHECKS)
531 int value_offset = I::kNativeContextEmbedderDataOffset +
532 (I::kEmbedderDataSlotSize * index) +
533 I::kEmbedderDataSlotCppHeapPointerOffset;
534 return internal::ReadCppHeapPointerField<T>(isolate, ctx, value_offset,
537 return static_cast<T*
>(SlowGetAlignedPointerFromEmbedderData(index, tag));
552#ifdef V8_ENABLE_CHECKS
555 return static_cast<Context*
>(data);
Definition: v8-context.h:426
BackupIncumbentScope(Local< Context > backup_incumbent_context)
Definition: v8-context.h:233
virtual bool FreezeEmbedderObjectAndGetChildren(Local< Object > obj, LocalVector< Object > &children_out)=0
Definition: v8-context.h:410
Scope(Local< Context > context)
Definition: v8-context.h:412
~Scope()
Definition: v8-context.h:415
Definition: v8-context.h:55
Local< Data > GetEmbedderDataV2(int index)
Definition: v8-context.h:493
static MaybeLocal< Object > NewRemoteContext(Isolate *isolate, Local< ObjectTemplate > global_template, MaybeLocal< Value > global_object=MaybeLocal< Value >())
void SetErrorMessageForWasmCodeGeneration(Local< String > message)
void SetPromiseHooks(Local< Function > init_hook, Local< Function > before_hook, Local< Function > after_hook, Local< Function > resolve_hook)
void SetSecurityToken(Local< Value > token)
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=nullptr, MaybeLocal< ObjectTemplate > global_template=MaybeLocal< ObjectTemplate >(), MaybeLocal< Value > global_object=MaybeLocal< Value >(), DeserializeInternalFieldsCallback internal_fields_deserializer=DeserializeInternalFieldsCallback(), MicrotaskQueue *microtask_queue=nullptr, DeserializeContextDataCallback context_data_deserializer=DeserializeContextDataCallback(), DeserializeAPIWrapperCallback api_wrapper_deserializer=DeserializeAPIWrapperCallback())
void SetTemporalHostSystemUTCEpochNanosecondsCallback(TemporalHostSystemUTCEpochNanosecondsCallback callback)
bool IsCodeGenerationFromStringsAllowed() const
static Context * Cast(Data *data)
Definition: v8-context.h:551
MicrotaskQueue * GetMicrotaskQueue()
void SetAbortScriptExecution(AbortScriptExecutionCallback callback)
Maybe< void > DeepFreeze(DeepFreezeDelegate *delegate=nullptr)
bool HasTemplateLiteralObject(Local< Value > object)
void AllowCodeGenerationFromStrings(bool allow)
Local< Value > GetSecurityToken()
MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
Definition: v8-context.h:542
void SetErrorMessageForCodeGenerationFromStrings(Local< String > message)
EmbedderDataFields
Definition: v8-context.h:275
uint32_t GetNumberOfEmbedderDataFields()
Local< Value > GetEmbedderData(int index)
Definition: v8-context.h:468
void SetMicrotaskQueue(MicrotaskQueue *queue)
void SetEmbedderDataV3(int index, Local< Data > value)
void UseDefaultSecurityToken()
void * GetAlignedPointerFromEmbedderData(Isolate *isolate, int index, EmbedderDataTypeTag tag)
Definition: v8-context.h:518
void(*)(Isolate *isolate, Local< Context > context) AbortScriptExecutionCallback
Definition: v8-context.h:383
static MaybeLocal< Context > FromSnapshot(Isolate *isolate, size_t context_snapshot_index, DeserializeInternalFieldsCallback internal_fields_deserializer=DeserializeInternalFieldsCallback(), ExtensionConfiguration *extensions=nullptr, MaybeLocal< Value > global_object=MaybeLocal< Value >(), MicrotaskQueue *microtask_queue=nullptr, DeserializeContextDataCallback context_data_deserializer=DeserializeContextDataCallback(), DeserializeAPIWrapperCallback api_wrapper_deserializer=DeserializeAPIWrapperCallback())
int64_t(*)(Local< Context > context) TemporalHostSystemUTCEpochNanosecondsCallback
Definition: v8-context.h:390
Definition: v8-context.h:37
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8-context.h:40
ExtensionConfiguration()
Definition: v8-context.h:39
const char ** begin() const
Definition: v8-context.h:43
const char ** end() const
Definition: v8-context.h:44
Definition: v8-function.h:27
Definition: v8-isolate.h:299
Definition: v8-local-handle.h:584
Definition: v8-local-handle.h:356
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:438
Definition: v8-local-handle.h:724
Definition: v8-maybe.h:39
Definition: v8-microtask-queue.h:44
Definition: v8-object.h:269
Definition: v8-script.h:432
Definition: v8-value.h:32
Definition: v8-internal.h:965
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1836
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1790
static constexpr InternalRepresentationType kEmpty
Definition: v8-internal.h:1791
Definition: allocation.h:39
uintptr_t Address
Definition: v8-internal.h:38
void PerformCastCheck(T *data)
Definition: v8-internal.h:1551
Definition: libplatform.h:15
internal::TagRange< CppHeapPointerTag > CppHeapPointerTagRange
Definition: v8-sandbox.h:97
CppHeapPointerTag
Definition: v8-sandbox.h:28
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:37
Definition: v8-snapshot.h:116
Definition: v8-snapshot.h:106
Definition: v8-snapshot.h:91
#define V8_EXPORT
Definition: v8config.h:875
#define V8_INLINE
Definition: v8config.h:519
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:632
#define V8_NODISCARD
Definition: v8config.h:711