38 #ifdef BUILDING_V8_SHARED
39 # define V8_EXPORT __declspec(dllexport)
41 # define V8_EXPORT __declspec(dllimport)
49 #if V8_HAS_ATTRIBUTE_VISIBILITY
50 # ifdef BUILDING_V8_SHARED
51 # define V8_EXPORT __attribute__ ((visibility("default")))
80 class ImplementationUtilities;
90 class ObjectOperationDescriptor;
97 class RawOperationDescriptor;
114 template <
class T>
class Local;
117 template <
class T>
class Eternal;
118 template<
class T>
class NonCopyablePersistentTraits;
120 template <
class T,
class M = NonCopyablePersistentTraits<T> >
125 template <
class K,
class V,
class T>
127 template <
class K,
class V,
class T>
130 template<
class T,
class P>
class WeakCallbackObject;
138 class CallHandlerHelper;
144 class DeferredHandles;
148 class LocalEmbedderHeapTracer;
149 class NeverReadOnlySpaceObject;
151 struct ScriptStreamingData;
153 class PropertyCallbackArguments;
154 class FunctionCallbackArguments;
159 class StreamingDecoder;
181 template <size_t tagged_ptr_size>
184 template <
int kSmiShiftSize>
187 intptr_t tagged_value =
188 (
static_cast<intptr_t>(value) << smi_shift_bits) |
kSmiTag;
189 return reinterpret_cast<
internal::Object*>(tagged_value);
194 struct SmiTagging<4> {
201 return static_cast<
int>(
reinterpret_cast<intptr_t>(value)) >> shift_bits;
218 return static_cast<uintptr_t>(value) + 0x40000000U < 0x80000000U;
224 struct SmiTagging<8> {
231 return static_cast<
int>(
reinterpret_cast<intptr_t>(value) >> shift_bits);
238 return (value ==
static_cast<int32_t>(value));
242 #if V8_COMPRESS_POINTERS
245 "Pointer compression can be enabled only for 64-bit architectures");
261 class ConsoleCallArguments;
266 #define TYPE_CHECK(T, S)
268 *(static_cast<T* volatile*>(0
)) = static_cast<S*>(0
);
308 : val_(
reinterpret_cast<T*>(*that)) {
341 if (a == 0)
return b == 0;
342 if (b == 0)
return false;
350 if (a == 0)
return b == 0;
351 if (b == 0)
return false;
363 return !operator==(that);
368 return !operator==(that);
377 #ifdef V8_ENABLE_CHECKS
380 if (that.IsEmpty())
return Local<T>();
382 return Local<T>(T::Cast(*that));
392 return Local<S>::Cast(*
this);
409 template<
class F>
friend class Local;
416 friend class Context;
417 friend class Isolate;
426 template <
class F1,
class F2,
class F3>
432 explicit V8_INLINE Local(T* that) : val_(that) {}
438 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
461 : val_(
reinterpret_cast<T*>(*that)) {
473 out->val_ =
IsEmpty() ?
nullptr :
this->val_;
505 Set(isolate, handle);
517 static const int kInternalFieldsInWeakCallback = 2;
518 static const int kEmbedderFieldsInWeakCallback = 2;
520 template <
typename T>
526 void* embedder_fields[kEmbedderFieldsInWeakCallback],
528 : isolate_(isolate), parameter_(parameter), callback_(callback) {
529 for (
int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
530 embedder_fields_[i] = embedder_fields[i];
550 void* embedder_fields_[kEmbedderFieldsInWeakCallback];
599 return Local<T>::New(isolate, *
this);
606 if (a == NULL)
return b == NULL;
607 if (b == NULL)
return false;
615 if (a == NULL)
return b == NULL;
616 if (b == NULL)
return false;
622 return !operator==(that);
627 return !operator==(that);
637 template <
typename P>
679 "Objects are always considered independent. "
680 "Use MarkActive to avoid collecting otherwise dead weak handles.",
717 friend class Isolate;
719 template<
class F>
friend class Local;
725 template <
class F1,
class F2,
class F3>
730 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
731 V8_INLINE static T* New(Isolate* isolate, T* that);
744 class NonCopyablePersistentTraits {
748 template<
class S,
class M>
768 template<
class S,
class M>
805 template <
class S,
class M2>
819 template <
class S,
class M2>
827 template <
class S,
class M2>
838 if (M::kResetInDestructor)
this->Reset();
844 #ifdef V8_ENABLE_CHECKS
847 if (!that.IsEmpty()) T::Cast(*that);
859 friend class Isolate;
861 template<
class F>
friend class Local;
866 V8_INLINE T* operator*()
const {
return this->val_; }
867 template<
class S,
class M2>
908 other.val_ =
nullptr;
919 this->val_ = rhs.val_;
940 V8_INLINE T* operator*()
const {
return this->val_; }
975 return reinterpret_cast<Isolate*>(isolate_);
992 void* operator
new(size_t size);
993 void* operator
new[](size_t size);
994 void operator
delete(
void*, size_t);
995 void operator
delete[](
void*, size_t);
998 static internal::Object** CreateHandle(
1011 friend class Context;
1031 Escape(
reinterpret_cast<
internal::Object**>(*value));
1032 return Local<T>(
reinterpret_cast<T*>(slot));
1037 return Escape(value.FromMaybe(
Local<T>()));
1046 void* operator
new(size_t size);
1047 void* operator
new[](size_t size);
1048 void operator
delete(
void*, size_t);
1049 void operator
delete[](
void*, size_t);
1071 void* operator
new(size_t size);
1072 void* operator
new[](size_t size);
1073 void operator
delete(
void*, size_t);
1074 void operator
delete[](
void*, size_t);
1078 int prev_sealed_level_;
1136 bool is_opaque =
false,
bool is_wasm =
false,
1137 bool is_module =
false)
1138 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1139 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1140 (is_module ? kIsModule : 0)) {}
1143 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1146 return (flags_ & kIsSharedCrossOrigin) != 0;
1148 bool IsOpaque()
const {
return (flags_ & kIsOpaque) != 0; }
1149 bool IsWasm()
const {
return (flags_ & kIsWasm) != 0; }
1150 bool IsModule()
const {
return (flags_ & kIsModule) != 0; }
1156 kIsSharedCrossOrigin = 1,
1246 : line_number_(line_number), column_number_(column_number) {}
1533 internal::ScriptStreamingData* impl_;
1591 Isolate* isolate,
Source* source,
1665 Isolate* isolate,
Source* source,
1680 Local<Context> context,
Source* source, size_t arguments_count,
1681 Local<
String> arguments[], size_t context_extension_count,
1729 Local<Context> context)
const;
2033 size_t* actual_size);
2084 void TransferSharedArrayBuffer(
2085 uint32_t transfer_id,
2112 PrivateData* private_;
2141 Isolate* isolate, uint32_t transfer_id);
2148 Isolate* isolate, uint32_t clone_id);
2218 PrivateData* private_;
2510 Local<Context> context)
const;
2512 Local<Context> context)
const;
2514 Local<Context> context)
const;
2516 Local<Context> context)
const;
2518 Local<Context> context)
const;
2520 Local<Context> context)
const;
2522 Local<Context> context)
const;
2524 Local<Context> context)
const;
2538 Local<
Int32> ToInt32(Isolate* isolate)
const);
2545 Local<Context> context)
const;
2550 Local<Context> context)
const;
2552 Local<Context> context)
const;
2568 V8_INLINE bool QuickIsUndefined()
const;
2570 V8_INLINE bool QuickIsNullOrUndefined()
const;
2572 bool FullIsUndefined()
const;
2573 bool FullIsNull()
const;
2574 bool FullIsString()
const;
2595 static void CheckCast(
v8::
Value* obj);
2616 static void CheckCast(
Value* obj);
2716 int Write(Isolate* isolate, uint16_t* buffer,
int start = 0,
int length = -1,
2720 int length = -1,
int options =
NO_OPTIONS)
const;
2722 int WriteUtf8(Isolate* isolate,
char* buffer,
int length = -1,
2723 int* nchars_ref = NULL,
int options =
NO_OPTIONS)
const;
2784 virtual const uint16_t*
data()
const = 0;
2814 virtual const char*
data()
const = 0;
2851 "Use maybe version",
2852 Local<
String> NewFromUtf8(Isolate* isolate,
const char* data,
2870 "Use maybe version",
2871 Local<
String> NewFromTwoByte(Isolate* isolate,
const uint16_t* data,
2919 "Use maybe version",
3003 static void CheckCast(
v8::
Value* obj);
3054 static void CheckCast(
Value* obj);
3092 static void CheckCast(
Data* that);
3106 static void CheckCast(
v8::
Value* obj);
3121 static void CheckCast(
v8::
Value* obj);
3135 static void CheckCast(
v8::
Value* obj);
3149 static void CheckCast(
v8::
Value* obj);
3167 int word_count,
const uint64_t* words);
3204 static void CheckCast(
v8::
Value* obj);
3318 bool Set(uint32_t index,
Local<
Value> value));
3472 Local<Context> context);
3485 Local<Context> context);
3524 Local<Context> context);
3600 bool HasRealIndexedProperty(uint32_t index));
3602 Local<Context> context, uint32_t index);
3604 bool HasRealNamedCallbackProperty(
Local<
String> key));
3724 static void CheckCast(
Value* obj);
3725 Local<
Value> SlowGetInternalField(
int index);
3726 void* SlowGetAlignedPointerFromInternalField(
int index);
3746 static void CheckCast(
Value* obj);
3782 static void CheckCast(
Value* obj);
3814 static void CheckCast(
Value* obj);
3818 template<
typename T>
3822 : value_(that.value_) {
3826 template <
typename S>
3829 template <
typename S>
3831 template <
typename S>
3846 template <
typename S>
3858 template <
class F,
class G,
class H>
3873 template<
typename T>
3909 friend class debug::ConsoleCallArguments;
3918 internal::Object** values,
int length);
3929 template<
typename T>
4021 friend class MacroAssembler;
4056 "Use maybe version",
4064 Local<Context> context)
const {
4135 static void CheckCast(
Value* obj);
4138 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
4140 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0
4160 Local<Context> context);
4181 static void CheckCast(
Value* obj);
4219 static void CheckCast(
Value* obj);
4292 PrivateData* private_;
4317 static void CheckCast(
Value* obj);
4329 "Use BufferReference.",
4330 typedef std::pair<
const uint8_t *
COMMA size_t> CallerOwnedBuffer);
4343 "Use BufferReference directly.",
4344 inline BufferReference(CallerOwnedBuffer));
4346 inline operator CallerOwnedBuffer());
4353 class TransferrableModule
final {
4358 TransferrableModule&
operator=(TransferrableModule&& src) =
default;
4359 TransferrableModule&
operator=(
const TransferrableModule& src) =
delete;
4362 typedef std::shared_ptr<
internal::
wasm::NativeModule> SharedModule;
4363 typedef std::pair<std::unique_ptr<
const uint8_t[]>, size_t> OwnedBuffer;
4365 explicit TransferrableModule(SharedModule shared_module)
4366 : shared_module_(std::move(shared_module)) {}
4367 TransferrableModule(OwnedBuffer serialized, OwnedBuffer bytes)
4368 : serialized_(std::move(serialized)), wire_bytes_(std::move(bytes)) {}
4370 SharedModule shared_module_;
4371 OwnedBuffer serialized_ = {
nullptr, 0};
4372 OwnedBuffer wire_bytes_ = {
nullptr, 0};
4387 Isolate* isolate,
const TransferrableModule&);
4416 const uint8_t* start,
4419 const TransferrableModule::OwnedBuffer& buff) {
4420 return {buff.first.get()
, buff.second
};
4423 WasmCompiledModule();
4424 static void CheckCast(
Value* obj);
4444 class WasmStreamingImpl;
4475 static std::shared_ptr<WasmStreaming>
Unpack(Isolate* isolate,
4479 std::unique_ptr<WasmStreamingImpl> impl_;
4503 WasmModuleObjectBuilderStreaming(
const WasmModuleObjectBuilderStreaming&) =
4505 WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
4507 WasmModuleObjectBuilderStreaming& operator=(
4508 const WasmModuleObjectBuilderStreaming&) =
delete;
4509 WasmModuleObjectBuilderStreaming& operator=(
4510 WasmModuleObjectBuilderStreaming&&) =
default;
4511 Isolate* isolate_ =
nullptr;
4521 Persistent<Promise, CopyablePersistentTraits<Promise>> promise_;
4525 std::shared_ptr<
internal::
wasm::StreamingDecoder> streaming_decoder_;
4528 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
4530 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
4577 virtual void Free(
void* data, size_t length) = 0;
4606 using DeleterCallback =
void (*)(
void* buffer, size_t length,
void* info);
4611 allocation_base_(
nullptr),
4612 allocation_length_(0),
4615 deleter_data_(
nullptr) {}
4620 return allocation_mode_;
4623 void*
Data()
const {
return data_; }
4625 DeleterCallback
Deleter()
const {
return deleter_; }
4629 Contents(
void* data, size_t byte_length,
void* allocation_base,
4630 size_t allocation_length,
4632 void* deleter_data);
4635 size_t byte_length_;
4636 void* allocation_base_;
4637 size_t allocation_length_;
4639 DeleterCallback deleter_;
4640 void* deleter_data_;
4669 Isolate* isolate,
void* data, size_t byte_length,
4720 static void CheckCast(
Value* obj);
4724 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
4726 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
4775 static void CheckCast(
Value* obj);
4800 static void CheckCast(
Value* obj);
4810 size_t byte_offset, size_t length);
4812 size_t byte_offset, size_t length);
4817 static void CheckCast(
Value* obj);
4827 size_t byte_offset, size_t length);
4834 Uint8ClampedArray();
4835 static void CheckCast(
Value* obj);
4844 size_t byte_offset, size_t length);
4846 size_t byte_offset, size_t length);
4851 static void CheckCast(
Value* obj);
4861 size_t byte_offset, size_t length);
4863 size_t byte_offset, size_t length);
4868 static void CheckCast(
Value* obj);
4878 size_t byte_offset, size_t length);
4880 size_t byte_offset, size_t length);
4885 static void CheckCast(
Value* obj);
4895 size_t byte_offset, size_t length);
4897 size_t byte_offset, size_t length);
4902 static void CheckCast(
Value* obj);
4912 size_t byte_offset, size_t length);
4914 size_t byte_offset, size_t length);
4919 static void CheckCast(
Value* obj);
4929 size_t byte_offset, size_t length);
4931 size_t byte_offset, size_t length);
4936 static void CheckCast(
Value* obj);
4946 size_t byte_offset, size_t length);
4948 size_t byte_offset, size_t length);
4953 static void CheckCast(
Value* obj);
4962 size_t byte_offset, size_t length);
4964 size_t byte_offset, size_t length);
4969 static void CheckCast(
Value* obj);
4978 size_t byte_offset, size_t length);
4980 size_t byte_offset, size_t length);
4985 static void CheckCast(
Value* obj);
4994 size_t byte_offset, size_t length);
4996 size_t byte_offset, size_t length);
5001 static void CheckCast(
Value* obj);
5025 using DeleterCallback =
void (*)(
void* buffer, size_t length,
void* info);
5030 allocation_base_(
nullptr),
5031 allocation_length_(0),
5034 deleter_data_(
nullptr) {}
5039 return allocation_mode_;
5042 void*
Data()
const {
return data_; }
5044 DeleterCallback
Deleter()
const {
return deleter_; }
5048 Contents(
void* data, size_t byte_length,
void* allocation_base,
5049 size_t allocation_length,
5050 Allocator::
AllocationMode allocation_mode, DeleterCallback deleter,
5051 void* deleter_data);
5054 size_t byte_length_;
5055 void* allocation_base_;
5056 size_t allocation_length_;
5058 DeleterCallback deleter_;
5059 void* deleter_data_;
5084 Isolate* isolate,
void* data, size_t byte_length,
5126 SharedArrayBuffer();
5127 static void CheckCast(
Value* obj);
5137 Local<
Value> New(Isolate* isolate,
double time));
5164 static void CheckCast(
Value* obj);
5180 static void CheckCast(
Value* obj);
5195 static void CheckCast(
Value* obj);
5210 static void CheckCast(
Value* obj);
5226 static void CheckCast(
Value* obj);
5242 static void CheckCast(
Value* obj);
5293 static void CheckCast(
Value* obj);
5307 static void CheckCast(
v8::
Value* obj);
5310 #define V8_INTRINSICS_LIST(F)
5311 F(ArrayProto_entries, array_entries_iterator)
5312 F(ArrayProto_forEach, array_for_each_iterator)
5313 F(ArrayProto_keys, array_keys_iterator)
5314 F(ArrayProto_values, array_values_iterator)
5315 F(ErrorPrototype, initial_error_prototype)
5316 F(IteratorPrototype, initial_iterator_prototype)
5319 #define V8_DECL_INTRINSIC(name, iname) k##name,
5321 #undef V8_DECL_INTRINSIC
5785 Local<Context> context);
5883 static void CheckCast(
Data* that);
5884 friend class Context;
6163 deleter
, enumerator
, data
));
6249 static void CheckCast(
Data* that);
6272 static void CheckCast(
Data* that);
6289 AccessorSignature();
6291 static void CheckCast(
Data* that);
6300 ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
6302 : data_(data), length_(length) {}
6303 const char*
data()
const {
return data_; }
6318 Extension(
const char* name,
6319 const char* source = 0,
6321 const char** deps = 0,
6322 int source_length = -1);
6323 virtual ~Extension() {
delete source_; }
6329 const char* name()
const {
return name_; }
6330 size_t source_length()
const {
return source_length_; }
6334 int dependency_count() {
return dep_count_; }
6335 const char** dependencies() {
return deps_; }
6336 void set_auto_enable(
bool value) { auto_enable_ = value; }
6337 bool auto_enable() {
return auto_enable_; }
6340 Extension(
const Extension&) =
delete;
6341 void operator=(
const Extension&) =
delete;
6345 size_t source_length_;
6353 void V8_EXPORT RegisterExtension(Extension* extension);
6379 ResourceConstraints();
6390 void ConfigureDefaults(uint64_t physical_memory,
6391 uint64_t virtual_memory_limit);
6395 size_t max_semi_space_size()) {
6396 return max_semi_space_size_in_kb_ / 1024;
6401 void set_max_semi_space_size(size_t limit_in_mb)) {
6402 max_semi_space_size_in_kb_ = limit_in_mb * 1024;
6406 size_t max_semi_space_size_in_kb()
const {
6407 return max_semi_space_size_in_kb_;
6411 void set_max_semi_space_size_in_kb(size_t limit_in_kb) {
6412 max_semi_space_size_in_kb_ = limit_in_kb;
6415 size_t max_old_space_size()
const {
return max_old_space_size_; }
6416 void set_max_old_space_size(size_t limit_in_mb) {
6417 max_old_space_size_ = limit_in_mb;
6420 size_t max_executable_size()
const) {
6421 return max_executable_size_;
6424 void set_max_executable_size(size_t limit_in_mb)) {
6425 max_executable_size_ = limit_in_mb;
6427 uint32_t* stack_limit()
const {
return stack_limit_; }
6429 void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
6430 size_t code_range_size()
const {
return code_range_size_; }
6431 void set_code_range_size(size_t limit_in_mb) {
6432 code_range_size_ = limit_in_mb;
6434 size_t max_zone_pool_size()
const {
return max_zone_pool_size_; }
6435 void set_max_zone_pool_size(size_t bytes) { max_zone_pool_size_ = bytes; }
6439 size_t max_semi_space_size_in_kb_;
6442 size_t max_old_space_size_;
6443 size_t max_executable_size_;
6444 uint32_t* stack_limit_;
6445 size_t code_range_size_;
6446 size_t max_zone_pool_size_;
6453 typedef void (*FatalErrorCallback)(
const char* location,
const char* message);
6455 typedef void (*OOMErrorCallback)(
const char* location,
bool is_heap_oom);
6457 typedef void (*DcheckErrorCallback)(
const char* file,
int line,
6458 const char* message);
6464 typedef void (*LogEventCallback)(
const char* name,
int event);
6495 typedef int* (*CounterLookupCallback)(
const char* name);
6497 typedef void* (*CreateHistogramCallback)(
const char* name,
6502 typedef void (*AddHistogramSampleCallback)(
void* histogram,
int sample);
6505 typedef void (*BeforeCallEnteredCallback)(Isolate*);
6506 typedef void (*CallCompletedCallback)(Isolate*);
6542 typedef void (*HostInitializeImportMetaObjectCallback)(
Local<Context> context,
6562 enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
6564 typedef void (*PromiseHook)(PromiseHookType type,
Local<
Promise> promise,
6568 enum PromiseRejectEvent {
6569 kPromiseRejectWithNoHandler = 0,
6570 kPromiseHandlerAddedAfterReject = 1,
6571 kPromiseRejectAfterResolved = 2,
6572 kPromiseResolveAfterResolved = 3,
6575 class PromiseRejectMessage {
6577 PromiseRejectMessage(
Local<
Promise> promise, PromiseRejectEvent event,
6579 : promise_(promise),
6582 stack_trace_(stack_trace) {}
6585 V8_INLINE PromiseRejectEvent GetEvent()
const {
return event_; }
6590 PromiseRejectEvent event_;
6595 typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
6598 typedef void (*MicrotasksCompletedCallback)(Isolate*);
6599 typedef void (*MicrotaskCallback)(
void* data);
6609 enum class MicrotasksPolicy { kExplicit, kScoped, kAuto };
6623 enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
6625 MicrotasksScope(Isolate* isolate, Type type);
6631 static void PerformCheckpoint(Isolate* isolate);
6636 static int GetCurrentDepth(Isolate* isolate);
6641 static bool IsRunningMicrotasks(Isolate* isolate);
6644 MicrotasksScope(
const MicrotasksScope&) =
delete;
6645 MicrotasksScope& operator=(
const MicrotasksScope&) =
delete;
6654 typedef void (*FailedAccessCheckCallback)(
Local<
Object> target,
6664 typedef bool (*AllowCodeGenerationFromStringsCallback)(
Local<Context> context,
6670 typedef bool (*AllowWasmCodeGenerationCallback)(
Local<Context> context,
6681 typedef bool (*WasmThreadsEnabledCallback)(
Local<Context> context);
6693 kGCTypeScavenge = 1 << 0,
6694 kGCTypeMarkSweepCompact = 1 << 1,
6695 kGCTypeIncrementalMarking = 1 << 2,
6696 kGCTypeProcessWeakCallbacks = 1 << 3,
6697 kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact |
6698 kGCTypeIncrementalMarking | kGCTypeProcessWeakCallbacks
6715 enum GCCallbackFlags {
6716 kNoGCCallbackFlags = 0,
6717 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
6718 kGCCallbackFlagForced = 1 << 2,
6719 kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3,
6720 kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4,
6721 kGCCallbackFlagCollectAllExternalMemory = 1 << 5,
6722 kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
6725 typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
6727 typedef void (*InterruptCallback)(Isolate* isolate,
void* data);
6736 typedef size_t (*NearHeapLimitCallback)(
void* data, size_t current_heap_limit,
6737 size_t initial_heap_limit);
6748 size_t total_heap_size() {
return total_heap_size_; }
6749 size_t total_heap_size_executable() {
return total_heap_size_executable_; }
6750 size_t total_physical_size() {
return total_physical_size_; }
6751 size_t total_available_size() {
return total_available_size_; }
6752 size_t used_heap_size() {
return used_heap_size_; }
6753 size_t heap_size_limit() {
return heap_size_limit_; }
6754 size_t malloced_memory() {
return malloced_memory_; }
6755 size_t external_memory() {
return external_memory_; }
6756 size_t peak_malloced_memory() {
return peak_malloced_memory_; }
6757 size_t number_of_native_contexts() {
return number_of_native_contexts_; }
6758 size_t number_of_detached_contexts() {
return number_of_detached_contexts_; }
6764 size_t does_zap_garbage() {
return does_zap_garbage_; }
6767 size_t total_heap_size_;
6768 size_t total_heap_size_executable_;
6769 size_t total_physical_size_;
6770 size_t total_available_size_;
6771 size_t used_heap_size_;
6772 size_t heap_size_limit_;
6773 size_t malloced_memory_;
6774 size_t external_memory_;
6775 size_t peak_malloced_memory_;
6776 bool does_zap_garbage_;
6777 size_t number_of_native_contexts_;
6778 size_t number_of_detached_contexts_;
6781 friend class Isolate;
6787 HeapSpaceStatistics();
6788 const char* space_name() {
return space_name_; }
6789 size_t space_size() {
return space_size_; }
6790 size_t space_used_size() {
return space_used_size_; }
6791 size_t space_available_size() {
return space_available_size_; }
6792 size_t physical_space_size() {
return physical_space_size_; }
6795 const char* space_name_;
6797 size_t space_used_size_;
6798 size_t space_available_size_;
6799 size_t physical_space_size_;
6801 friend class Isolate;
6807 HeapObjectStatistics();
6808 const char* object_type() {
return object_type_; }
6809 const char* object_sub_type() {
return object_sub_type_; }
6810 size_t object_count() {
return object_count_; }
6811 size_t object_size() {
return object_size_; }
6814 const char* object_type_;
6815 const char* object_sub_type_;
6816 size_t object_count_;
6817 size_t object_size_;
6819 friend class Isolate;
6824 HeapCodeStatistics();
6825 size_t code_and_metadata_size() {
return code_and_metadata_size_; }
6826 size_t bytecode_and_metadata_size() {
return bytecode_and_metadata_size_; }
6827 size_t external_script_source_size() {
return external_script_source_size_; }
6830 size_t code_and_metadata_size_;
6831 size_t bytecode_and_metadata_size_;
6832 size_t external_script_source_size_;
6834 friend class Isolate;
6851 typedef void (*FunctionEntryHook)(uintptr_t function,
6852 uintptr_t return_addr_location);
6859 struct JitCodeEvent {
6864 CODE_ADD_LINE_POS_INFO,
6865 CODE_START_LINE_INFO_RECORDING,
6866 CODE_END_LINE_INFO_RECORDING
6873 enum PositionType { POSITION, STATEMENT_POSITION };
6881 enum CodeType { BYTE_CODE, JIT_CODE };
6923 void* new_code_start;
6938 PERFORMANCE_RESPONSE,
6942 PERFORMANCE_ANIMATION,
6954 enum JitCodeEventOptions {
6955 kJitCodeEventDefault = 0,
6957 kJitCodeEventEnumExisting = 1
6966 typedef void (*JitCodeEventHandler)(
const JitCodeEvent* event);
6972 class V8_EXPORT ExternalResourceVisitor {
6974 virtual ~ExternalResourceVisitor() {}
6975 virtual void VisitExternalString(
Local<
String> string) {}
6982 class V8_EXPORT PersistentHandleVisitor {
6984 virtual ~PersistentHandleVisitor() {}
6986 uint16_t class_id) {}
6997 enum class MemoryPressureLevel { kNone, kModerate, kCritical };
7009 enum EmbedderStackState {
7015 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION };
7024 virtual ~EmbedderHeapTracer() =
default;
7032 virtual void RegisterV8References(
7033 const std::vector<std::pair<
void*,
void*> >& embedder_fields) = 0;
7038 virtual void TracePrologue() = 0;
7054 virtual bool AdvanceTracing(
7072 virtual bool AdvanceTracing(
double deadline_in_ms);
7078 virtual bool IsTracingDone();
7085 virtual void TraceEpilogue() = 0;
7095 virtual void EnterFinalPause()) {}
7096 virtual void EnterFinalPause(EmbedderStackState stack_state);
7104 virtual void AbortTracing() = 0;
7115 void FinalizeTracing();
7122 void GarbageCollectionForTesting(EmbedderStackState stack_state);
7128 v8::Isolate* isolate()
const {
return isolate_; }
7134 virtual size_t NumberOfWrappersToTrace()) {
7139 v8::Isolate* isolate_ =
nullptr;
7141 friend class internal::LocalEmbedderHeapTracer;
7148 struct SerializeInternalFieldsCallback {
7149 typedef StartupData (*CallbackFunction)(
Local<
Object> holder,
int index,
7151 SerializeInternalFieldsCallback(CallbackFunction function =
nullptr,
7152 void* data_arg =
nullptr)
7153 : callback(function), data(data_arg) {}
7154 CallbackFunction callback;
7159 typedef SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback;
7165 struct DeserializeInternalFieldsCallback {
7166 typedef void (*CallbackFunction)(
Local<
Object> holder,
int index,
7167 StartupData payload,
void* data);
7168 DeserializeInternalFieldsCallback(CallbackFunction function =
nullptr,
7169 void* data_arg =
nullptr)
7170 : callback(function), data(data_arg) {}
7171 void (*callback)(
Local<
Object> holder,
int index, StartupData payload,
7175 typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
7278 explicit Scope(Isolate* isolate) : isolate_(isolate) {
7289 Isolate*
const isolate_;
7330 void* internal_throws_;
7331 void* internal_assert_;
7375 enum GarbageCollectionType {
7376 kFullGarbageCollection,
7377 kMinorGarbageCollection
7385 enum UseCounterFeature {
7389 kMarkDequeOverflow = 3,
7390 kStoreBufferOverflow = 4,
7391 kSlotsBufferOverflow = 5,
7397 kRegExpPrototypeStickyGetter = 11,
7398 kRegExpPrototypeToString = 12,
7399 kRegExpPrototypeUnicodeGetter = 13,
7404 kPromiseAccept = 18,
7406 kHtmlCommentInExternalScript = 20,
7408 kSloppyModeBlockScopedFunctionRedefinition = 22,
7409 kForInInitializer = 23,
7410 kArrayProtectorDirtied = 24,
7411 kArraySpeciesModified = 25,
7412 kArrayPrototypeConstructorModified = 26,
7413 kArrayInstanceProtoModified = 27,
7414 kArrayInstanceConstructorModified = 28,
7415 kLegacyFunctionDeclaration = 29,
7416 kRegExpPrototypeSourceGetter = 30,
7417 kRegExpPrototypeOldFlagGetter = 31,
7418 kDecimalWithLeadingZeroInStrictMode = 32,
7419 kLegacyDateParser = 33,
7420 kDefineGetterOrSetterWouldThrow = 34,
7421 kFunctionConstructorReturnedUndefined = 35,
7422 kAssigmentExpressionLHSIsCallInSloppy = 36,
7423 kAssigmentExpressionLHSIsCallInStrict = 37,
7424 kPromiseConstructorReturnedUndefined = 38,
7425 kConstructorNonUndefinedPrimitiveReturn = 39,
7426 kLabeledExpressionStatement = 40,
7427 kLineOrParagraphSeparatorAsLineTerminator = 41,
7428 kIndexAccessor = 42,
7429 kErrorCaptureStackTrace = 43,
7430 kErrorPrepareStackTrace = 44,
7431 kErrorStackTraceLimit = 45,
7432 kWebAssemblyInstantiation = 46,
7433 kDeoptimizerDisableSpeculation = 47,
7434 kArrayPrototypeSortJSArrayModifiedPrototype = 48,
7435 kFunctionTokenOffsetTooLongForToString = 49,
7436 kWasmSharedMemory = 50,
7437 kWasmThreadOpcodes = 51,
7442 kUseCounterFeatureCount
7445 enum MessageErrorLevel {
7446 kMessageLog = (1 << 0),
7447 kMessageDebug = (1 << 1),
7448 kMessageInfo = (1 << 2),
7449 kMessageError = (1 << 3),
7450 kMessageWarning = (1 << 4),
7451 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
7455 typedef void (*UseCounterCallback)(Isolate* isolate,
7456 UseCounterFeature feature);
7472 static Isolate* Allocate();
7477 static void Initialize(Isolate* isolate,
const CreateParams& params);
7496 static Isolate* GetCurrent();
7507 typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
7508 void SetAbortOnUncaughtExceptionCallback(
7509 AbortOnUncaughtExceptionCallback callback);
7515 void SetHostImportModuleDynamicallyCallback(
7516 HostImportModuleDynamicallyCallback callback);
7522 void SetHostInitializeImportMetaObjectCallback(
7523 HostInitializeImportMetaObjectCallback callback);
7531 void MemoryPressureNotification(MemoryPressureLevel level);
7564 void DumpAndResetStats();
7573 void DiscardThreadSpecificMetadata();
7579 V8_INLINE void SetData(uint32_t slot,
void* data);
7591 V8_INLINE static uint32_t GetNumberOfDataSlots();
7604 void GetHeapStatistics(HeapStatistics* heap_statistics);
7609 size_t NumberOfHeapSpaces();
7620 bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
7626 size_t NumberOfTrackedHeapObjectTypes();
7637 bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
7647 bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
7661 void GetStackSample(
const RegisterState& state,
void** frames,
7662 size_t frames_limit,
SampleInfo* sample_info);
7678 AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
7684 size_t NumberOfPhantomHandleResetsSinceLastCall();
7695 void SetIdle(
bool is_idle);
7704 Local<Context> GetCurrentContext();
7707 Local<Context> GetEnteredContext();
7715 Local<Context> GetEnteredOrMicrotaskContext();
7721 Local<Context> GetIncumbentContext();
7731 typedef void (*GCCallback)(Isolate* isolate, GCType type,
7732 GCCallbackFlags flags);
7733 typedef void (*GCCallbackWithData)(Isolate* isolate, GCType type,
7734 GCCallbackFlags flags,
void* data);
7745 void AddGCPrologueCallback(GCCallbackWithData callback,
void* data =
nullptr,
7746 GCType gc_type_filter = kGCTypeAll);
7747 void AddGCPrologueCallback(GCCallback callback,
7748 GCType gc_type_filter = kGCTypeAll);
7754 void RemoveGCPrologueCallback(GCCallbackWithData,
void* data =
nullptr);
7755 void RemoveGCPrologueCallback(GCCallback callback);
7760 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
7765 enum class AtomicsWaitEvent {
7773 kTerminatedExecution,
7826 typedef void (*AtomicsWaitCallback)(AtomicsWaitEvent event,
7828 size_t offset_in_bytes, int32_t value,
7829 double timeout_in_ms,
7839 void SetAtomicsWaitCallback(AtomicsWaitCallback callback,
void* data);
7850 void AddGCEpilogueCallback(GCCallbackWithData callback,
void* data =
nullptr,
7851 GCType gc_type_filter = kGCTypeAll);
7852 void AddGCEpilogueCallback(GCCallback callback,
7853 GCType gc_type_filter = kGCTypeAll);
7859 void RemoveGCEpilogueCallback(GCCallbackWithData callback,
7860 void* data =
nullptr);
7861 void RemoveGCEpilogueCallback(GCCallback callback);
7863 typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
7871 void SetGetExternallyAllocatedMemoryInBytesCallback(
7872 GetExternallyAllocatedMemoryInBytesCallback callback);
7881 void TerminateExecution();
7891 bool IsExecutionTerminating();
7907 void CancelTerminateExecution();
7917 void RequestInterrupt(InterruptCallback callback,
void* data);
7929 void RequestGarbageCollectionForTesting(GarbageCollectionType type);
7934 void SetEventLogger(LogEventCallback that);
7942 void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
7947 void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
7956 void AddCallCompletedCallback(CallCompletedCallback callback);
7961 void RemoveCallCompletedCallback(CallCompletedCallback callback);
7967 void SetPromiseHook(PromiseHook hook);
7973 void SetPromiseRejectCallback(PromiseRejectCallback callback);
7979 void RunMicrotasks();
7989 void EnqueueMicrotask(MicrotaskCallback callback,
void* data =
nullptr);
7994 void SetMicrotasksPolicy(MicrotasksPolicy policy);
7999 MicrotasksPolicy GetMicrotasksPolicy()
const;
8013 void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
8018 void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
8023 void SetUseCounterCallback(UseCounterCallback callback);
8029 void SetCounterFunction(CounterLookupCallback);
8037 void SetCreateHistogramFunction(CreateHistogramCallback);
8038 void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
8054 bool IdleNotificationDeadline(
double deadline_in_seconds);
8060 void LowMemoryNotification();
8071 int ContextDisposedNotification(
bool dependant_context =
true);
8077 void IsolateInForegroundNotification();
8083 void IsolateInBackgroundNotification();
8090 void EnableMemorySavingsMode();
8095 void DisableMemorySavingsMode();
8104 void SetRAILMode(RAILMode rail_mode);
8110 void IncreaseHeapLimitForDebugging();
8115 void RestoreOriginalHeapLimit();
8121 bool IsHeapLimitIncreasedForDebugging();
8145 void SetJitCodeEventHandler(JitCodeEventOptions options,
8146 JitCodeEventHandler event_handler);
8157 void SetStackLimit(uintptr_t stack_limit);
8172 void GetCodeRange(
void** start, size_t* length_in_bytes);
8175 void SetFatalErrorHandler(FatalErrorCallback that);
8178 void SetOOMErrorHandler(OOMErrorCallback that);
8185 void AddNearHeapLimitCallback(NearHeapLimitCallback callback,
void* data);
8194 void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
8201 void SetAllowCodeGenerationFromStringsCallback(
8202 AllowCodeGenerationFromStringsCallback callback);
8208 void SetAllowWasmCodeGenerationCallback(
8209 AllowWasmCodeGenerationCallback callback);
8215 void SetWasmModuleCallback(ExtensionCallback callback);
8216 void SetWasmInstanceCallback(ExtensionCallback callback);
8218 void SetWasmCompileStreamingCallback(ApiImplementationCallback callback);
8220 void SetWasmStreamingCallback(WasmStreamingCallback callback);
8222 void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
8239 bool AddMessageListener(MessageCallback that,
8253 bool AddMessageListenerWithErrorLevel(MessageCallback that,
8260 void RemoveMessageListeners(MessageCallback that);
8263 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
8269 void SetCaptureStackTraceForUncaughtExceptions(
8270 bool capture,
int frame_limit = 10,
8278 void VisitExternalResources(ExternalResourceVisitor* visitor);
8284 void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
8293 void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
8300 void VisitWeakHandles(PersistentHandleVisitor* visitor);
8313 void SetAllowAtomicsWait(
bool allow);
8316 ~Isolate() =
delete;
8317 Isolate(
const Isolate&) =
delete;
8318 Isolate& operator=(
const Isolate&) =
delete;
8321 void* operator
new(size_t size) =
delete;
8322 void* operator
new[](size_t size) =
delete;
8323 void operator
delete(
void*, size_t) =
delete;
8324 void operator
delete[](
void*, size_t) =
delete;
8327 template <
class K,
class V,
class Traits>
8330 internal::Object** GetDataFromSnapshotOnce(size_t index);
8331 void ReportExternalAllocationLimitReached();
8332 void CheckMemoryPressure();
8346 typedef bool (*EntropySource)(
unsigned char* buffer, size_t length);
8361 typedef uintptr_t (*ReturnAddressLocationResolver)(
8362 uintptr_t return_addr_location);
8385 static void SetNativesDataBlob(StartupData* startup_blob);
8386 static void SetSnapshotDataBlob(StartupData* startup_blob);
8389 static void SetDcheckErrorHandler(DcheckErrorCallback that);
8395 static void SetFlagsFromString(
const char* str,
int length);
8400 static void SetFlagsFromCommandLine(
int* argc,
8405 static const char* GetVersion();
8411 static bool Initialize();
8417 static void SetEntropySource(EntropySource source);
8423 static void SetReturnAddressLocationResolver(
8424 ReturnAddressLocationResolver return_address_resolver);
8435 static bool Dispose();
8444 static bool InitializeICU(
const char* icu_data_file =
nullptr);
8458 static bool InitializeICUDefaultLocation(
const char* exec_path,
8459 const char* icu_data_file =
nullptr);
8477 static void InitializeExternalStartupData(
const char* directory_path);
8478 static void InitializeExternalStartupData(
const char* natives_blob,
8479 const char* snapshot_blob);
8484 static void InitializePlatform(
Platform* platform);
8490 static void ShutdownPlatform();
8512 static bool TryHandleSignal(
int signal_number,
void* info,
void* context);
8520 static bool RegisterDefaultSignalHandler());
8528 static bool EnableWebAssemblyTrapHandler(
bool use_v8_signal_handler);
8536 static void DisposeGlobal(
internal::Object** global_handle);
8537 static void MakeWeak(
internal::Object** location,
void* data,
8540 static void MakeWeak(
internal::Object** location,
void* data,
8542 int internal_field_index1,
8544 int internal_field_index2,
8546 static void MakeWeak(
internal::Object*** location_addr);
8547 static void* ClearWeak(
internal::Object** location);
8548 static void AnnotateStrongRetainer(
internal::Object** location,
8550 static Value* Eternalize(Isolate* isolate,
Value* handle);
8552 static void RegisterExternallyReferencedObject(
internal::Object** object,
8555 template <
class K,
class V,
class T>
8558 static void FromJustIsNothing();
8559 static void ToLocalEmpty();
8560 static void InternalFieldOutOfBounds(
int index);
8561 template <
class T>
friend class Local;
8568 template <
class T>
friend class Eternal;
8570 template <
class T,
class M>
friend class Persistent;
8571 friend class Context;
8579 enum class FunctionCodeHandling { kClear, kKeep };
8589 SnapshotCreator(Isolate* isolate,
8590 const intptr_t* external_references =
nullptr,
8591 StartupData* existing_blob =
nullptr);
8601 SnapshotCreator(
const intptr_t* external_references =
nullptr,
8602 StartupData* existing_blob =
nullptr);
8609 Isolate* GetIsolate();
8618 void SetDefaultContext(
Local<Context> context,
8619 SerializeInternalFieldsCallback callback =
8620 SerializeInternalFieldsCallback());
8630 size_t AddContext(
Local<Context> context,
8631 SerializeInternalFieldsCallback callback =
8632 SerializeInternalFieldsCallback());
8666 StartupData CreateBlob(FunctionCodeHandling function_code_handling);
8669 SnapshotCreator(
const SnapshotCreator&) =
delete;
8670 void operator=(
const SnapshotCreator&) =
delete;
8673 size_t AddData(
Local<Context> context,
internal::Object* object);
8674 size_t AddData(
internal::Object* object);
8723 return has_value_ ? value_ : default_value;
8727 return (
IsJust() == other.IsJust()) &&
8736 Maybe() : has_value_(
false) {}
8737 explicit Maybe(
const T& t) : has_value_(
true), value_(t) {}
8749 inline Maybe<T> Nothing() {
8754 inline Maybe<T> Just(
const T& t) {
8762 V8_INLINE bool IsNothing()
const {
return !is_valid_; }
8763 V8_INLINE bool IsJust()
const {
return is_valid_; }
8765 V8_INLINE bool operator==(
const Maybe& other)
const {
8766 return IsJust() == other.IsJust();
8769 V8_INLINE bool operator!=(
const Maybe& other)
const {
8770 return !operator==(other);
8776 Maybe() : is_valid_(
false) {}
8777 explicit Maybe(JustTag) : is_valid_(
true) {}
8782 friend Maybe<U> Nothing();
8783 friend Maybe<
void> JustVoid();
8786 inline Maybe<
void> JustVoid() {
return Maybe<
void>(Maybe<
void>::JustTag()); }
8798 explicit TryCatch(Isolate* isolate);
8808 bool HasCaught()
const;
8818 bool CanContinue()
const;
8832 bool HasTerminated()
const;
8856 Local<Context> context)
const;
8887 void SetVerbose(
bool value);
8892 bool IsVerbose()
const;
8899 void SetCaptureMessage(
bool value);
8912 static void* JSStackComparableAddress(TryCatch* handler) {
8913 if (handler == NULL)
return NULL;
8914 return handler->js_stack_comparable_address_;
8917 TryCatch(
const TryCatch&) =
delete;
8918 void operator=(
const TryCatch&) =
delete;
8923 void* operator
new(size_t size);
8924 void* operator
new[](size_t size);
8925 void operator
delete(
void*, size_t);
8926 void operator
delete[](
void*, size_t);
8928 void ResetInternal();
8934 void* js_stack_comparable_address_;
8935 bool is_verbose_ : 1;
8936 bool can_continue_ : 1;
8937 bool capture_message_ : 1;
8939 bool has_terminated_ : 1;
8951 class V8_EXPORT ExtensionConfiguration {
8953 ExtensionConfiguration() : name_count_(0), names_(NULL) { }
8954 ExtensionConfiguration(
int name_count,
const char* names[])
8955 : name_count_(name_count), names_(names) { }
8957 const char** begin()
const {
return &names_[0]; }
8958 const char** end()
const {
return &names_[name_count_]; }
8961 const int name_count_;
8962 const char** names_;
8989 void DetachGlobal();
9009 static Local<Context> New(
9010 Isolate* isolate, ExtensionConfiguration* extensions = NULL,
9013 DeserializeInternalFieldsCallback internal_fields_deserializer =
9014 DeserializeInternalFieldsCallback());
9036 Isolate* isolate, size_t context_snapshot_index,
9037 DeserializeInternalFieldsCallback embedder_fields_deserializer =
9038 DeserializeInternalFieldsCallback(),
9039 ExtensionConfiguration* extensions =
nullptr,
9070 void UseDefaultSecurityToken();
9090 Isolate* GetIsolate();
9096 enum EmbedderDataFields { kDebugIdIndex = 0 };
9101 uint32_t GetNumberOfEmbedderDataFields();
9122 void SetEmbedderData(
int index,
Local<
Value> value);
9130 V8_INLINE void* GetAlignedPointerFromEmbedderData(
int index);
9137 void SetAlignedPointerInEmbedderData(
int index,
void* value);
9152 void AllowCodeGenerationFromStrings(
bool allow);
9158 bool IsCodeGenerationFromStringsAllowed();
9165 void SetErrorMessageForCodeGenerationFromStrings(
Local<
String> message);
9187 Local<Context> context_;
9207 Local<Context> backup_incumbent_context_;
9217 internal::Object** GetDataFromSnapshotOnce(size_t index);
9219 void* SlowGetAlignedPointerFromEmbedderData(
int index);
9304 V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
9308 void Initialize(Isolate* isolate);
9319 V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
9327 static bool IsLocked(Isolate* isolate);
9332 static bool IsActive();
9335 Locker(
const Locker&) =
delete;
9336 void operator=(
const Locker&) =
delete;
9339 void Initialize(Isolate* isolate);
9415 #ifdef V8_ENABLE_CHECKS
9416 CheckInitializedImpl(isolate);
9455 return *addr &
static_cast<uint8_t>(1U << shift);
9459 bool value,
int shift) {
9461 uint8_t mask =
static_cast<uint8_t>(1U << shift);
9462 *addr =
static_cast<uint8_t>((*addr & ~mask) | (value << shift));
9479 uint8_t* addr =
reinterpret_cast<uint8_t*>(isolate) +
9481 *
reinterpret_cast<
void**>(addr) = data;
9486 const uint8_t* addr =
reinterpret_cast<
const uint8_t*>(isolate) +
9488 return *
reinterpret_cast<
void*
const*>(addr);
9497 template <
typename T>
9499 const uint8_t* addr =
9501 return *
reinterpret_cast<
const T*>(addr);
9504 template <
typename T>
9508 O* ctx = *
reinterpret_cast<O*
const*>(context);
9514 return I::ReadField<T>(embedder_data, value_offset);
9520 template <
bool PerformCheck>
9546 return New(isolate, that.val_);
9551 return New(isolate, that.val_);
9556 Local<T>
Local<T>::New(Isolate* isolate, T* that) {
9557 if (that == NULL)
return Local<T>();
9561 reinterpret_cast<
internal::Isolate*>(isolate)
, *p
)));
9569 val_ =
reinterpret_cast<T*>(
9570 V8::Eternalize(isolate,
reinterpret_cast<
Value*>(*handle)));
9577 return Local<T>(val_);
9583 if (
V8_UNLIKELY(val_ ==
nullptr)) V8::ToLocalEmpty();
9584 return Local<T>(val_);
9590 #ifdef V8_ENABLE_CHECKS
9591 if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
9592 V8::InternalFieldOutOfBounds(index);
9595 return embedder_fields_[index];
9601 if (that == NULL)
return NULL;
9603 return reinterpret_cast<T*>(
9604 V8::GlobalizeReference(
reinterpret_cast<
internal::Isolate*>(isolate),
9609 template <
class T,
class M>
9610 template <
class S,
class M2>
9614 if (that.IsEmpty())
return;
9616 this->val_ =
reinterpret_cast<T*>(V8::CopyPersistent(p));
9617 M::Copy(that,
this);
9623 if (
this->IsEmpty())
return false;
9631 if (
this->IsEmpty())
return false;
9632 uint8_t node_state =
9642 if (
this->IsEmpty())
return false;
9650 if (
this->IsEmpty())
return;
9651 V8::DisposeGlobal(
reinterpret_cast<
internal::Object**>(
this->val_));
9661 if (other.IsEmpty())
return;
9662 this->val_ = New(isolate, other.val_);
9672 if (other.IsEmpty())
return;
9673 this->val_ = New(isolate, other.val_);
9678 template <
typename P>
9683 V8::MakeWeak(
reinterpret_cast<
internal::Object**>(
this->val_), parameter,
9684 reinterpret_cast<Callback>(callback), type);
9689 V8::MakeWeak(
reinterpret_cast<
internal::Object***>(&
this->val_));
9693 template <
typename P>
9695 return reinterpret_cast<P*>(
9696 V8::ClearWeak(
reinterpret_cast<
internal::Object**>(
this->val_)));
9701 V8::AnnotateStrongRetainer(
reinterpret_cast<
internal::Object**>(
this->val_),
9708 V8::RegisterExternallyReferencedObject(
9709 reinterpret_cast<
internal::Object**>(
this->val_),
9710 reinterpret_cast<
internal::Isolate*>(isolate));
9716 if (
this->IsEmpty())
return;
9724 if (
this->IsEmpty())
return;
9733 if (
this->IsEmpty())
return;
9736 *
reinterpret_cast<uint16_t*>(addr) = class_id;
9743 if (
this->IsEmpty())
return 0;
9746 return *
reinterpret_cast<uint16_t*>(addr);
9750 template<
typename T>
9753 template<
typename T>
9754 template<
typename S>
9758 *value_ = GetDefaultValue();
9760 *value_ = *
reinterpret_cast<
internal::Object**>(*handle);
9764 template <
typename T>
9765 template <
typename S>
9769 *value_ = GetDefaultValue();
9771 *value_ = *
reinterpret_cast<
internal::Object**>(*handle);
9775 template <
typename T>
9776 template <
typename S>
9780 *value_ = GetDefaultValue();
9782 *value_ = *
reinterpret_cast<
internal::Object**>(*handle);
9786 template<
typename T>
9792 template<
typename T>
9803 template<
typename T>
9807 bool fits_into_int32_t = (i & (1U << 31)) == 0;
9809 Set(
static_cast<int32_t>(i));
9815 template<
typename T>
9828 template<
typename T>
9835 template<
typename T>
9842 template<
typename T>
9849 template <
typename T>
9852 return *
reinterpret_cast<Isolate**>(&value_[-2]);
9855 template <
typename T>
9863 template <
typename T>
9864 template <
typename S>
9870 template<
typename T>
9876 template <
typename T>
9882 template<
typename T>
9889 template<
typename T>
9895 template<
typename T>
9901 template <
typename T>
9907 template <
typename T>
9913 template<
typename T>
9919 template<
typename T>
9925 template<
typename T>
9931 template<
typename T>
9945 : resource_name_(resource_name),
9946 resource_line_offset_(resource_line_offset),
9947 resource_column_offset_(resource_column_offset),
9948 options_
(!resource_is_shared_cross_origin
.IsEmpty() &&
9953 script_id_(script_id),
9954 source_map_url_(source_map_url),
9955 host_defined_options_(host_defined_options) {}
9960 return host_defined_options_;
9964 return resource_line_offset_;
9969 return resource_column_offset_;
9980 : source_string(string),
9987 cached_data(data) {}
9991 : source_string(string), cached_data(data) {}
10001 return cached_data;
10005 return resource_options;
10019 #ifdef V8_ENABLE_CHECKS
10026 #ifdef V8_ENABLE_CHECKS
10033 #ifdef V8_ENABLE_CHECKS
10036 return reinterpret_cast<
Signature*>(data);
10040 #ifdef V8_ENABLE_CHECKS
10047 #ifndef V8_ENABLE_CHECKS
10050 O* obj = *
reinterpret_cast<O**>(
this);
10060 reinterpret_cast<
internal::NeverReadOnlySpaceObject*>(obj), value);
10064 return SlowGetInternalField(index);
10069 #ifndef V8_ENABLE_CHECKS
10072 O* obj = *
reinterpret_cast<O**>(
this);
10083 return SlowGetAlignedPointerFromInternalField(index);
10087 #ifdef V8_ENABLE_CHECKS
10090 return static_cast<
String*>(value);
10106 O* obj = *
reinterpret_cast<O*
const*>(
this);
10113 result = GetExternalStringResourceSlow();
10115 #ifdef V8_ENABLE_CHECKS
10116 VerifyExternalStringResource(result);
10126 O* obj = *
reinterpret_cast<O*
const*>(
this);
10135 resource = GetExternalStringResourceBaseSlow(encoding_out);
10137 #ifdef V8_ENABLE_CHECKS
10138 VerifyExternalStringResourceBase(resource, *encoding_out);
10145 #ifdef V8_ENABLE_CHECKS
10146 return FullIsUndefined();
10148 return QuickIsUndefined();
10152 bool Value::QuickIsUndefined()
const {
10155 O* obj = *
reinterpret_cast<O*
const*>(
this);
10163 #ifdef V8_ENABLE_CHECKS
10164 return FullIsNull();
10166 return QuickIsNull();
10170 bool Value::QuickIsNull()
const {
10173 O* obj = *
reinterpret_cast<O*
const*>(
this);
10180 #ifdef V8_ENABLE_CHECKS
10181 return FullIsNull() || FullIsUndefined();
10183 return QuickIsNullOrUndefined();
10187 bool Value::QuickIsNullOrUndefined()
const {
10190 O* obj = *
reinterpret_cast<O*
const*>(
this);
10198 #ifdef V8_ENABLE_CHECKS
10199 return FullIsString();
10201 return QuickIsString();
10205 bool Value::QuickIsString()
const {
10208 O* obj = *
reinterpret_cast<O*
const*>(
this);
10215 return static_cast<
Value*>(value);
10220 #ifdef V8_ENABLE_CHECKS
10223 return static_cast<
Boolean*>(value);
10228 #ifdef V8_ENABLE_CHECKS
10231 return static_cast<
Name*>(value);
10236 #ifdef V8_ENABLE_CHECKS
10239 return static_cast<
Symbol*>(value);
10244 #ifdef V8_ENABLE_CHECKS
10247 return reinterpret_cast<
Private*>(data);
10252 #ifdef V8_ENABLE_CHECKS
10255 return static_cast<
Number*>(value);
10260 #ifdef V8_ENABLE_CHECKS
10263 return static_cast<
Integer*>(value);
10268 #ifdef V8_ENABLE_CHECKS
10271 return static_cast<
Int32*>(value);
10276 #ifdef V8_ENABLE_CHECKS
10279 return static_cast<
Uint32*>(value);
10283 #ifdef V8_ENABLE_CHECKS
10286 return static_cast<
BigInt*>(value);
10290 #ifdef V8_ENABLE_CHECKS
10293 return static_cast<
Date*>(value);
10298 #ifdef V8_ENABLE_CHECKS
10306 #ifdef V8_ENABLE_CHECKS
10314 #ifdef V8_ENABLE_CHECKS
10321 #ifdef V8_ENABLE_CHECKS
10328 #ifdef V8_ENABLE_CHECKS
10336 #ifdef V8_ENABLE_CHECKS
10339 return static_cast<
RegExp*>(value);
10344 #ifdef V8_ENABLE_CHECKS
10347 return static_cast<
Object*>(value);
10352 #ifdef V8_ENABLE_CHECKS
10355 return static_cast<
Array*>(value);
10360 #ifdef V8_ENABLE_CHECKS
10363 return static_cast<
Map*>(value);
10368 #ifdef V8_ENABLE_CHECKS
10371 return static_cast<
Set*>(value);
10376 #ifdef V8_ENABLE_CHECKS
10379 return static_cast<
Promise*>(value);
10384 #ifdef V8_ENABLE_CHECKS
10387 return static_cast<
Proxy*>(value);
10391 #ifdef V8_ENABLE_CHECKS
10398 #ifdef V8_ENABLE_CHECKS
10406 #ifdef V8_ENABLE_CHECKS
10414 #ifdef V8_ENABLE_CHECKS
10422 #ifdef V8_ENABLE_CHECKS
10430 #ifdef V8_ENABLE_CHECKS
10438 #ifdef V8_ENABLE_CHECKS
10446 #ifdef V8_ENABLE_CHECKS
10454 #ifdef V8_ENABLE_CHECKS
10462 #ifdef V8_ENABLE_CHECKS
10470 #ifdef V8_ENABLE_CHECKS
10478 #ifdef V8_ENABLE_CHECKS
10486 #ifdef V8_ENABLE_CHECKS
10493 #ifdef V8_ENABLE_CHECKS
10500 #ifdef V8_ENABLE_CHECKS
10507 #ifdef V8_ENABLE_CHECKS
10515 #ifdef V8_ENABLE_CHECKS
10518 return static_cast<
DataView*>(value);
10523 #ifdef V8_ENABLE_CHECKS
10531 #ifdef V8_ENABLE_CHECKS
10534 return static_cast<
Function*>(value);
10539 #ifdef V8_ENABLE_CHECKS
10542 return static_cast<
External*>(value);
10546 template<
typename T>
10552 template<
typename T>
10558 template<
typename T>
10564 template<
typename T>
10570 template<
typename T>
10575 template <
typename T>
10618 void Isolate::SetData(uint32_t slot,
void* data) {
10624 void* Isolate::GetData(uint32_t slot) {
10630 uint32_t Isolate::GetNumberOfDataSlots() {
10636 MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
10637 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
10638 if (data)
internal::PerformCastCheck(data);
10639 return Local<T>(data);
10642 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
10643 int64_t change_in_bytes) {
10645 const int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
10646 int64_t* external_memory =
reinterpret_cast<int64_t*>(
10648 int64_t* external_memory_limit =
reinterpret_cast<int64_t*>(
10650 int64_t* external_memory_at_last_mc =
10651 reinterpret_cast<int64_t*>(
reinterpret_cast<uint8_t*>(
this) +
10653 const int64_t amount = *external_memory + change_in_bytes;
10655 *external_memory = amount;
10657 int64_t allocation_diff_since_last_mc =
10658 *external_memory_at_last_mc - *external_memory;
10659 allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
10660 ? -allocation_diff_since_last_mc
10661 : allocation_diff_since_last_mc;
10662 if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
10663 CheckMemoryPressure();
10666 if (change_in_bytes < 0) {
10667 *external_memory_limit += change_in_bytes;
10670 if (change_in_bytes > 0 && amount > *external_memory_limit) {
10671 ReportExternalAllocationLimitReached();
10673 return *external_memory;
10676 Local<
Value> Context::GetEmbedderData(
int index) {
10677 #ifndef V8_ENABLE_CHECKS
10680 auto* context = *
reinterpret_cast<
internal::NeverReadOnlySpaceObject**>(
this);
10685 return SlowGetEmbedderData(index);
10690 void* Context::GetAlignedPointerFromEmbedderData(
int index) {
10691 #ifndef V8_ENABLE_CHECKS
10695 return SlowGetAlignedPointerFromEmbedderData(index);
10700 MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
10701 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
10702 if (data)
internal::PerformCastCheck(data);
10703 return Local<T>(data);
10707 size_t SnapshotCreator::AddData(
Local<Context> context,
Local<T> object) {
10708 T* object_ptr = *object;
10710 return AddData(context, *p);
10714 size_t SnapshotCreator::AddData(
Local<T> object) {
10715 T* object_ptr = *object;
10717 return AddData(*p);