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,
331 V8_INLINE void* GetAlignedPointerFromEmbedderData(
Isolate* isolate,
int index,
333 void* GetAlignedPointerFromEmbedderData(
int index,
335 template <typename T>
336 requires
cppgc::IsGarbageCollectedTypeV<T>
340 V8_DEPRECATED("Use SetAlignedPointerInEmbedderDataV2 instead")
341 void SetAlignedPointerInEmbedderData(
int index,
void* value,
344 template <typename T>
345 requires(!std::is_void_v<T>) &&
cppgc::IsGarbageCollectedTypeV<T>
346 V8_DEPRECATED("Use SetAlignedPointerInEmbedderDataV2 instead")
347 void SetAlignedPointerInEmbedderData(
int index, T* value,
349 SetAlignedPointerInEmbedderDataInternal(index,
static_cast<void*
>(value),
356 template <
typename T>
357 requires(!std::is_void_v<T>) && cppgc::IsGarbageCollectedTypeV<T>
360 SetAlignedPointerInEmbedderDataInternalV2(index,
static_cast<void*
>(value),
465 friend class internal::Isolate;
467 uintptr_t JSStackComparableAddressPrivate()
const {
468 return js_stack_comparable_address_;
472 uintptr_t js_stack_comparable_address_ = 0;
484 static void CheckCast(
Data* obj);
491 void SetAlignedPointerInEmbedderDataInternal(
int index,
void* value,
493 void SetAlignedPointerInEmbedderDataInternalV2(
int index,
void* value,
500#ifndef V8_ENABLE_CHECKS
505 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
507 I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
508#ifdef V8_COMPRESS_POINTERS
513 uint32_t compressed = I::ReadRawField<uint32_t>(embedder_data, value_offset);
514 A value = I::DecompressTaggedField(embedder_data, compressed);
516 A value = I::ReadRawField<A>(embedder_data, value_offset);
519 auto* isolate = I::GetCurrentIsolate();
522 return SlowGetEmbedderData(index);
527#ifndef V8_ENABLE_CHECKS
532 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
534 I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
535#ifdef V8_COMPRESS_POINTERS
540 uint32_t compressed = I::ReadRawField<uint32_t>(embedder_data, value_offset);
541 A value = I::DecompressTaggedField(embedder_data, compressed);
543 A value = I::ReadRawField<A>(embedder_data, value_offset);
546 auto* isolate = I::GetCurrentIsolate();
549 return SlowGetEmbedderDataV2(index);
559 requires cppgc::IsGarbageCollectedTypeV<T>
562#if !defined(V8_ENABLE_CHECKS)
567 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
568 int value_offset = I::kEmbedderDataArrayHeaderSize +
569 (I::kEmbedderDataSlotSize * index) +
570 I::kEmbedderDataSlotCppHeapPointerOffset;
571 return internal::ReadCppHeapPointerField<T>(
574 return static_cast<T*
>(SlowGetAlignedPointerFromEmbedderData(index, tag));
589#ifdef V8_ENABLE_CHECKS
592 return static_cast<Context*
>(data);
Definition: v8-context.h:455
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:439
Scope(Local< Context > context)
Definition: v8-context.h:441
~Scope()
Definition: v8-context.h:444
Definition: v8-context.h:55
Local< Data > GetEmbedderDataV2(int index)
Definition: v8-context.h:526
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:588
void SetAlignedPointerInEmbedderDataV2(int index, T *value, CppHeapPointerTag tag)
Definition: v8-context.h:358
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:579
void SetErrorMessageForCodeGenerationFromStrings(Local< String > message)
EmbedderDataFields
Definition: v8-context.h:275
uint32_t GetNumberOfEmbedderDataFields()
Local< Value > GetEmbedderData(int index)
Definition: v8-context.h:499
void SetMicrotaskQueue(MicrotaskQueue *queue)
void UseDefaultSecurityToken()
void * GetAlignedPointerFromEmbedderData(Isolate *isolate, int index, EmbedderDataTypeTag tag)
Definition: v8-context.h:553
void(*)(Isolate *isolate, Local< Context > context) AbortScriptExecutionCallback
Definition: v8-context.h:412
void SetAlignedPointerInEmbedderDataV2(int index, void *value, EmbedderDataTypeTag tag)
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:419
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:305
Definition: v8-local-handle.h:590
Definition: v8-local-handle.h:359
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:441
Definition: v8-local-handle.h:730
Definition: v8-maybe.h:39
Definition: v8-microtask-queue.h:44
Definition: v8-object.h:265
Definition: v8-script.h:433
Definition: v8-value.h:32
Definition: v8-internal.h:969
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1838
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1792
static constexpr InternalRepresentationType kEmpty
Definition: v8-internal.h:1793
Definition: allocation.h:39
uintptr_t Address
Definition: v8-internal.h:38
void PerformCastCheck(T *data)
Definition: v8-internal.h:1553
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_DEPRECATED(message)
Definition: v8config.h:624
#define V8_NODISCARD
Definition: v8config.h:711