5#ifndef INCLUDE_V8_CONTEXT_H_
6#define INCLUDE_V8_CONTEXT_H_
20class GarbageCollected;
39 : name_count_(name_count), names_(names) {}
41 const char**
begin()
const {
return &names_[0]; }
42 const char**
end()
const {
return &names_[name_count_]; }
45 const int name_count_;
169 Isolate* isolate,
size_t context_snapshot_index,
322 V8_INLINE void* GetAlignedPointerFromEmbedderData(
Isolate* isolate,
int index,
324 V8_INLINE void* GetAlignedPointerFromEmbedderData(
int index,
326 template <typename T>
327 requires std::is_base_of_v<
cppgc::GarbageCollected<T>, T>
337 return static_cast<T*
>(GetAlignedPointerFromEmbedderData(
344 template <
typename T>
345 requires std::is_base_of_v<cppgc::GarbageCollected<T>, T>
459 friend class internal::Isolate;
461 uintptr_t JSStackComparableAddressPrivate()
const {
462 return js_stack_comparable_address_;
466 uintptr_t js_stack_comparable_address_ = 0;
478 static void CheckCast(
Data* obj);
484 void* SlowGetAlignedPointerFromEmbedderData(
int index,
491#ifndef V8_ENABLE_CHECKS
496 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
498 I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
499 A value = I::ReadRawField<A>(embedder_data, value_offset);
500#ifdef V8_COMPRESS_POINTERS
503 value = I::DecompressTaggedField(embedder_data,
static_cast<uint32_t
>(value));
506 auto* isolate = I::GetCurrentIsolate();
509 return SlowGetEmbedderData(index);
514#ifndef V8_ENABLE_CHECKS
519 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
521 I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
522 A value = I::ReadRawField<A>(embedder_data, value_offset);
523#ifdef V8_COMPRESS_POINTERS
526 value = I::DecompressTaggedField(embedder_data,
static_cast<uint32_t
>(value));
529 auto* isolate = I::GetCurrentIsolate();
532 return SlowGetEmbedderDataV2(index);
538#if !defined(V8_ENABLE_CHECKS)
543 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
544 int value_offset = I::kEmbedderDataArrayHeaderSize +
545 (I::kEmbedderDataSlotSize * index) +
546 I::kEmbedderDataSlotExternalPointerOffset;
547 return reinterpret_cast<void*
>(I::ReadExternalPointerField(
550 return SlowGetAlignedPointerFromEmbedderData(index, tag);
556#if !defined(V8_ENABLE_CHECKS)
561 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
562 int value_offset = I::kEmbedderDataArrayHeaderSize +
563 (I::kEmbedderDataSlotSize * index) +
564 I::kEmbedderDataSlotExternalPointerOffset;
565 Isolate* isolate = I::GetCurrentIsolateForSandbox();
566 return reinterpret_cast<void*
>(I::ReadExternalPointerField(
569 return SlowGetAlignedPointerFromEmbedderData(index, tag);
584#ifdef V8_ENABLE_CHECKS
587 return static_cast<Context*
>(data);
Definition: v8-context.h:449
BackupIncumbentScope(Local< Context > backup_incumbent_context)
Definition: v8-context.h:231
virtual bool FreezeEmbedderObjectAndGetChildren(Local< Object > obj, LocalVector< Object > &children_out)=0
Definition: v8-context.h:433
Scope(Local< Context > context)
Definition: v8-context.h:435
~Scope()
Definition: v8-context.h:438
Definition: v8-context.h:53
Local< Data > GetEmbedderDataV2(int index)
Definition: v8-context.h:513
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
void SetAlignedPointerInEmbedderData(int index, T *value, CppHeapPointerTag tag)
Definition: v8-context.h:346
static Context * Cast(Data *data)
Definition: v8-context.h:583
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:574
void SetErrorMessageForCodeGenerationFromStrings(Local< String > message)
EmbedderDataFields
Definition: v8-context.h:273
uint32_t GetNumberOfEmbedderDataFields()
Local< Value > GetEmbedderData(int index)
Definition: v8-context.h:490
void SetMicrotaskQueue(MicrotaskQueue *queue)
void UseDefaultSecurityToken()
void * GetAlignedPointerFromEmbedderData(Isolate *isolate, int index, EmbedderDataTypeTag tag)
Definition: v8-context.h:536
void(*)(Isolate *isolate, Local< Context > context) AbortScriptExecutionCallback
Definition: v8-context.h:406
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:413
void SetEmbedderDataV2(int index, Local< Data > value)
void SetAlignedPointerInEmbedderData(int index, void *value, EmbedderDataTypeTag tag)
Definition: v8-context.h:35
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8-context.h:38
ExtensionConfiguration()
Definition: v8-context.h:37
const char ** begin() const
Definition: v8-context.h:41
const char ** end() const
Definition: v8-context.h:42
Definition: v8-function.h:27
Definition: v8-isolate.h:292
Definition: v8-local-handle.h:594
Definition: v8-local-handle.h:366
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:448
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-microtask-queue.h:53
Definition: v8-object.h:267
Definition: v8-script.h:433
Definition: v8-value.h:32
Definition: v8-internal.h:975
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1850
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1804
static constexpr InternalRepresentationType kEmpty
Definition: v8-internal.h:1805
Definition: allocation.h:38
uintptr_t Address
Definition: v8-internal.h:38
void PerformCastCheck(T *data)
Definition: v8-internal.h:1565
Definition: libplatform.h:15
internal::ExternalPointerTag ToExternalPointerTag(v8::EmbedderDataTypeTag api_tag)
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:36
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:34
Definition: v8-snapshot.h:116
Definition: v8-snapshot.h:106
Definition: v8-snapshot.h:91
#define V8_EXPORT
Definition: v8config.h:867
#define V8_INLINE
Definition: v8config.h:511
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:624
#define V8_NODISCARD
Definition: v8config.h:703