24 #include <type_traits>
28 #include "cppgc/common.h"
55 class ImplementationUtilities;
66 class ObjectOperationDescriptor;
73 class RawOperationDescriptor;
90 template <
class T>
class Local;
93 template <
class T>
class Eternal;
94 template<
class T>
class NonCopyablePersistentTraits;
96 template <
class T,
class M = NonCopyablePersistentTraits<T> >
107 template <
class K,
class V,
class T>
109 template <
class K,
class V,
class T>
112 template<
class T,
class P>
class WeakCallbackObject;
120 class CallHandlerHelper;
125 enum class ArgumentsType;
126 template <ArgumentsType>
128 template <
typename T>
130 class DeferredHandles;
131 class FunctionCallbackArguments;
135 class ExternalString;
137 class LocalEmbedderHeapTracer;
138 class MicrotaskQueue;
139 class PropertyCallbackArguments;
141 class ScopedExternalStringLock;
142 struct ScriptStreamingData;
143 class ThreadLocalTop;
147 class StreamingDecoder;
153 class ConsoleCallArguments;
195 : val_(
reinterpret_cast<T*>(*that)) {
201 static_assert(std::is_base_of<T, S>::value,
"type check");
232 if (a ==
nullptr)
return b ==
nullptr;
233 if (b ==
nullptr)
return false;
241 if (a ==
nullptr)
return b ==
nullptr;
242 if (b ==
nullptr)
return false;
258 return !operator==(that);
263 return !operator==(that);
272 #ifdef V8_ENABLE_CHECKS
275 if (that.IsEmpty())
return Local<T>();
277 return Local<T>(T::Cast(*that));
287 return Local<S>::Cast(*
this);
306 template<
class F>
friend class Local;
323 template <
class F1,
class F2,
class F3>
337 explicit V8_INLINE Local(T* that) : val_(that) {}
343 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
366 : val_(
reinterpret_cast<T*>(*that)) {
367 static_assert(std::is_base_of<T, S>::value,
"type check");
378 out->val_ =
IsEmpty() ?
nullptr :
this->val_;
410 Set(isolate, handle);
422 static const int kInternalFieldsInWeakCallback = 2;
423 static const int kEmbedderFieldsInWeakCallback = 2;
425 template <
typename T>
431 void* embedder_fields[kEmbedderFieldsInWeakCallback],
433 : isolate_(isolate), parameter_(parameter), callback_(callback) {
434 for (
int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
435 embedder_fields_[i] = embedder_fields[i];
455 void* embedder_fields_[kEmbedderFieldsInWeakCallback];
504 return Local<T>::New(isolate, *
this);
511 if (a ==
nullptr)
return b ==
nullptr;
512 if (b ==
nullptr)
return false;
520 if (a ==
nullptr)
return b ==
nullptr;
521 if (b ==
nullptr)
return false;
527 return !operator==(that);
532 return !operator==(that);
547 template <
typename P>
595 template<
class F>
friend class Local;
601 template <
class F1,
class F2,
class F3>
606 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
620 class NonCopyablePersistentTraits {
624 template<
class S,
class M>
627 static_assert(
sizeof(S) < 0,
628 "NonCopyablePersistentTraits::Copy is not instantiable");
641 template<
class S,
class M>
671 static_assert(std::is_base_of<T, S>::value,
"type check");
678 template <
class S,
class M2>
681 static_assert(std::is_base_of<T, S>::value,
"type check");
692 template <
class S,
class M2>
700 template <
class S,
class M2>
711 if (M::kResetInDestructor)
this->Reset();
717 #ifdef V8_ENABLE_CHECKS
720 if (!that.IsEmpty()) T::Cast(*that);
734 template<
class F>
friend class Local;
739 V8_INLINE T* operator*()
const {
return this->val_; }
740 template<
class S,
class M2>
766 static_assert(std::is_base_of<T, S>::value,
"type check");
777 static_assert(std::is_base_of<T, S>::value,
"type check");
809 V8_INLINE T* operator*()
const {
return this->val_; }
820 template <
typename T>
838 template <
typename T>
845 bool IsEmpty()
const {
return val_ ==
nullptr; }
862 if (a ==
nullptr)
return b ==
nullptr;
863 if (b ==
nullptr)
return false;
871 if (a ==
nullptr)
return b ==
nullptr;
872 if (b ==
nullptr)
return false;
878 return !operator==(that);
883 return !operator==(that);
904 enum DestructionMode { kWithDestructor, kWithoutDestructor };
909 TracedReferenceBase() =
default;
912 DestructionMode destruction_mode);
917 template <
typename F>
920 template <
typename F>
922 template <
typename F>
924 template <
typename F>
932 template <
typename T>
955 this->val_ =
this->New(isolate, that.val_, &
this->val_,
957 static_assert(std::is_base_of<T, S>::value,
"type check");
965 *
this = std::move(other);
971 template <
typename S>
974 *
this = std::move(other);
988 template <
typename S>
1060 template <
typename T>
1078 this->val_ =
this->New(isolate, that.val_, &
this->val_,
1080 static_assert(std::is_base_of<T, S>::value,
"type check");
1089 *
this = std::move(other);
1096 template <
typename S>
1099 *
this = std::move(other);
1115 template <
typename S>
1183 return reinterpret_cast<
Isolate*>(isolate_);
1200 void* operator
new(size_t size);
1201 void* operator
new[](size_t size);
1202 void operator
delete(
void*, size_t);
1203 void operator
delete[](
void*, size_t);
1236 return Local<T>(
reinterpret_cast<T*>(slot));
1241 return Escape(value.FromMaybe(
Local<T>()));
1250 void* operator
new(size_t size);
1251 void* operator
new[](size_t size);
1252 void operator
delete(
void*, size_t);
1253 void operator
delete[](
void*, size_t);
1275 void* operator
new(size_t size);
1276 void* operator
new[](size_t size);
1277 void operator
delete(
void*, size_t);
1278 void operator
delete[](
void*, size_t);
1282 int prev_sealed_level_;
1339 bool is_opaque =
false,
bool is_wasm =
false,
1340 bool is_module =
false)
1341 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1342 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1343 (is_module ? kIsModule : 0)) {}
1346 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1349 return (flags_ & kIsSharedCrossOrigin) != 0;
1351 bool IsOpaque()
const {
return (flags_ & kIsOpaque) != 0; }
1352 bool IsWasm()
const {
return (flags_ & kIsWasm) != 0; }
1353 bool IsModule()
const {
return (flags_ & kIsModule) != 0; }
1359 kIsSharedCrossOrigin = 1,
1449 : line_number_(line_number), column_number_(column_number) {}
1580 "Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
1581 "instead of the one that follows. The former will throw a runtime "
1582 "error if called for an export that doesn't exist (as per spec); "
1583 "the latter will crash with a failed CHECK().")
1584 void SetSyntheticModuleExport(
Local<
String> export_name,
1760 "This class takes ownership of source_stream, so use the constructor "
1761 "taking a unique_ptr to make these semantics clearer")
1774 std::unique_ptr<
internal::ScriptStreamingData> impl_;
1788 explicit ScriptStreamingTask(
internal::ScriptStreamingData* data)
1791 internal::ScriptStreamingData* data_;
1925 Local<
String> arguments[], size_t context_extension_count,
2310 size_t* actual_size);
2376 PrivateData* private_;
2401 Isolate* isolate, uint32_t transfer_id);
2408 Isolate* isolate, uint32_t clone_id);
2473 PrivateData* private_;
2882 V8_INLINE bool QuickIsUndefined()
const;
2884 V8_INLINE bool QuickIsNullOrUndefined()
const;
2886 bool FullIsUndefined()
const;
2887 bool FullIsNull()
const;
2888 bool FullIsString()
const;
2909 static void CheckCast(
v8::
Value* obj);
2930 static void CheckCast(
Value* obj);
3029 int Write(
Isolate* isolate, uint16_t* buffer,
int start = 0,
int length = -1,
3033 int length = -1,
int options =
NO_OPTIONS)
const;
3036 int* nchars_ref =
nullptr,
int options =
NO_OPTIONS)
const;
3121 virtual const uint16_t*
data()
const = 0;
3151 virtual const char*
data()
const = 0;
3191 Isolate* isolate,
const char (&literal)[N],
3193 static_assert(N <=
kMaxLength,
"String is too long");
3194 return NewFromUtf8Literal(isolate, literal, type, N - 1);
3200 Isolate* isolate,
const char* data,
3206 Isolate* isolate,
const uint8_t* data,
3212 Isolate* isolate,
const uint16_t* data,
3332 const char* literal,
3335 static void CheckCast(
v8::
Value* obj);
3399 static void CheckCast(
Value* obj);
3437 static void CheckCast(
Data* that);
3451 static void CheckCast(
v8::
Value* obj);
3466 static void CheckCast(
v8::
Value* obj);
3480 static void CheckCast(
v8::
Value* obj);
3494 static void CheckCast(
v8::
Value* obj);
3512 int word_count,
const uint64_t* words);
3549 static void CheckCast(
v8::
Value* obj);
4109 static void CheckCast(
Value* obj);
4110 Local<
Value> SlowGetInternalField(
int index);
4111 void* SlowGetAlignedPointerFromInternalField(
int index);
4137 static void CheckCast(
Value* obj);
4173 static void CheckCast(
Value* obj);
4205 static void CheckCast(
Value* obj);
4209 template<
typename T>
4213 : value_(that.value_) {
4214 static_assert(std::is_base_of<T, S>::value,
"type check");
4217 template <
typename S>
4219 template <
typename S>
4221 template <
typename S>
4236 template <
typename S>
4248 template <
class F,
class G,
class H>
4263 template<
typename T>
4302 friend class debug::ConsoleCallArguments;
4322 template<
typename T>
4414 friend class MacroAssembler;
4521 static void CheckCast(
Value* obj);
4524 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
4526 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0
4567 static void CheckCast(
Value* obj);
4614 static void CheckCast(
Value* obj);
4687 PrivateData* private_;
4712 static void CheckCast(
Value* obj);
4725 template <
typename T>
4731 constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
4734 constexpr T*
data()
const {
return data_; }
4736 constexpr size_t
size()
const {
return size_; }
4773 friend class WasmStreaming;
4775 explicit CompiledWasmModule(std::shared_ptr<
internal::
wasm::NativeModule>,
4776 const char* source_url, size_t url_length);
4778 const std::shared_ptr<
internal::
wasm::NativeModule> native_module_;
4779 const std::string source_url_;
4803 static void CheckCast(
Value* obj);
4814 class WasmStreamingImpl;
4883 std::unique_ptr<WasmStreamingImpl> impl_;
4907 WasmModuleObjectBuilderStreaming(
const WasmModuleObjectBuilderStreaming&) =
4909 WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
4911 WasmModuleObjectBuilderStreaming& operator=(
4912 const WasmModuleObjectBuilderStreaming&) =
delete;
4913 WasmModuleObjectBuilderStreaming& operator=(
4914 WasmModuleObjectBuilderStreaming&&) =
default;
4925 Persistent<Promise, CopyablePersistentTraits<Promise>> promise_;
4929 std::shared_ptr<
internal::
wasm::StreamingDecoder> streaming_decoder_;
4932 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
4934 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
4982 size_t byte_length);
4989 using DeleterCallback =
void (*)(
void* data, size_t length,
4990 void* deleter_data);
5011 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
5013 using BackingStoreDeleterCallback =
void (*)(
void* data, size_t length,
5014 void* deleter_data);
5058 virtual void Free(
void* data, size_t length) = 0;
5072 virtual void*
Reallocate(
void* data, size_t old_length, size_t new_length);
5101 using DeleterCallback =
void (*)(
void* buffer, size_t length,
void* info);
5106 allocation_base_(
nullptr),
5107 allocation_length_(0),
5110 deleter_data_(
nullptr) {}
5115 return allocation_mode_;
5118 void*
Data()
const {
return data_; }
5120 DeleterCallback
Deleter()
const {
return deleter_; }
5124 Contents(
void* data, size_t byte_length,
void* allocation_base,
5125 size_t allocation_length,
5127 void* deleter_data);
5130 size_t byte_length_;
5131 void* allocation_base_;
5132 size_t allocation_length_;
5134 DeleterCallback deleter_;
5135 void* deleter_data_;
5164 "Use the version that takes a BackingStore. "
5165 "See http://crbug.com/v8/9908.")
5195 size_t byte_length);
5205 void* data, size_t byte_length,
v8::
BackingStore::DeleterCallback deleter,
5206 void* deleter_data);
5213 "With v8::BackingStore externalized ArrayBuffers are "
5214 "the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.")
5215 bool IsExternal()
const;
5241 "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5282 static void CheckCast(
Value* obj);
5283 Contents GetContents(
bool externalize);
5287 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
5289 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
5338 static void CheckCast(
Value* obj);
5365 static void CheckCast(
Value* obj);
5375 size_t byte_offset, size_t length);
5377 size_t byte_offset, size_t length);
5382 static void CheckCast(
Value* obj);
5392 size_t byte_offset, size_t length);
5399 Uint8ClampedArray();
5400 static void CheckCast(
Value* obj);
5409 size_t byte_offset, size_t length);
5411 size_t byte_offset, size_t length);
5416 static void CheckCast(
Value* obj);
5426 size_t byte_offset, size_t length);
5428 size_t byte_offset, size_t length);
5433 static void CheckCast(
Value* obj);
5443 size_t byte_offset, size_t length);
5445 size_t byte_offset, size_t length);
5450 static void CheckCast(
Value* obj);
5460 size_t byte_offset, size_t length);
5462 size_t byte_offset, size_t length);
5467 static void CheckCast(
Value* obj);
5477 size_t byte_offset, size_t length);
5479 size_t byte_offset, size_t length);
5484 static void CheckCast(
Value* obj);
5494 size_t byte_offset, size_t length);
5496 size_t byte_offset, size_t length);
5501 static void CheckCast(
Value* obj);
5511 size_t byte_offset, size_t length);
5513 size_t byte_offset, size_t length);
5518 static void CheckCast(
Value* obj);
5527 size_t byte_offset, size_t length);
5529 size_t byte_offset, size_t length);
5534 static void CheckCast(
Value* obj);
5543 size_t byte_offset, size_t length);
5545 size_t byte_offset, size_t length);
5550 static void CheckCast(
Value* obj);
5559 size_t byte_offset, size_t length);
5561 size_t byte_offset, size_t length);
5566 static void CheckCast(
Value* obj);
5587 using DeleterCallback =
void (*)(
void* buffer, size_t length,
void* info);
5592 allocation_base_(
nullptr),
5593 allocation_length_(0),
5596 deleter_data_(
nullptr) {}
5601 return allocation_mode_;
5604 void*
Data()
const {
return data_; }
5606 DeleterCallback
Deleter()
const {
return deleter_; }
5610 Contents(
void* data, size_t byte_length,
void* allocation_base,
5611 size_t allocation_length,
5612 Allocator::
AllocationMode allocation_mode, DeleterCallback deleter,
5613 void* deleter_data);
5616 size_t byte_length_;
5617 void* allocation_base_;
5618 size_t allocation_length_;
5620 DeleterCallback deleter_;
5621 void* deleter_data_;
5646 "Use the version that takes a BackingStore. "
5647 "See http://crbug.com/v8/9908.")
5677 size_t byte_length);
5687 void* data, size_t byte_length,
v8::
BackingStore::DeleterCallback deleter,
5688 void* deleter_data);
5695 "Use the version that takes a BackingStore. "
5696 "See http://crbug.com/v8/9908.")
5706 "With v8::BackingStore externalized SharedArrayBuffers are the same "
5707 "as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.")
5708 bool IsExternal()
const;
5723 "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5766 SharedArrayBuffer();
5767 static void CheckCast(
Value* obj);
5768 Contents GetContents(
bool externalize);
5789 static void CheckCast(
Value* obj);
5805 static void CheckCast(
Value* obj);
5820 static void CheckCast(
Value* obj);
5835 static void CheckCast(
Value* obj);
5851 static void CheckCast(
Value* obj);
5867 static void CheckCast(
Value* obj);
5913 uint32_t backtrack_limit);
5943 static void CheckCast(
Value* obj);
5956 static void CheckCast(
v8::
Value* obj);
5959 #define V8_INTRINSICS_LIST(F)
5960 F(ArrayProto_entries, array_entries_iterator)
5961 F(ArrayProto_forEach, array_for_each_iterator)
5962 F(ArrayProto_keys, array_keys_iterator)
5963 F(ArrayProto_values, array_values_iterator)
5964 F(ErrorPrototype, initial_error_prototype)
5965 F(IteratorPrototype, initial_iterator_prototype)
5966 F(ObjProto_valueOf, object_value_of_function)
5969 #define V8_DECL_INTRINSIC(name, iname) k##name,
5971 #undef V8_DECL_INTRINSIC
6528 static void CheckCast(
Data* that);
6807 deleter
, enumerator
, data
));
6893 static void CheckCast(
Data* that);
6916 static void CheckCast(
Data* that);
6933 AccessorSignature();
6935 static void CheckCast(
Data* that);
6948 Extension(
const char* name,
const char* source =
nullptr,
int dep_count = 0,
6949 const char** deps =
nullptr,
int source_length = -1);
6956 const char*
name()
const {
return name_; }
6972 size_t source_length_;
7023 size_t maximum_heap_size_in_bytes);
7035 uint64_t virtual_memory_limit);
7058 return max_old_generation_size_;
7061 max_old_generation_size_ = limit;
7070 return max_young_generation_size_;
7073 max_young_generation_size_ = limit;
7077 return initial_old_generation_size_;
7080 initial_old_generation_size_ = initial_size;
7084 return initial_young_generation_size_;
7087 initial_young_generation_size_ = initial_size;
7097 code_range_size_ = limit_in_mb * kMB;
7107 max_old_generation_size_ = limit_in_mb * kMB;
7115 static constexpr size_t kMB = 1048576u;
7116 size_t code_range_size_ = 0;
7117 size_t max_old_generation_size_ = 0;
7118 size_t max_young_generation_size_ = 0;
7119 size_t max_zone_pool_size_ = 0;
7120 size_t initial_old_generation_size_ = 0;
7121 size_t initial_young_generation_size_ = 0;
7122 uint32_t* stack_limit_ =
nullptr;
7134 const char* message);
7281 : promise_(promise), event_(event), value_(value) {}
7347 void* data =
nullptr) = 0;
7391 MicrotaskQueue() =
default;
7432 internal::MicrotaskQueue*
const microtask_queue_;
7465 *ModifyCodeGenerationFromStringsCallback)(
Local<
Context> context,
7544 typedef size_t (*NearHeapLimitCallback)(
void* data, size_t current_heap_limit,
7545 size_t initial_heap_limit);
7559 return read_only_space_physical_size_;
7563 size_t read_only_space_size_;
7564 size_t read_only_space_used_size_;
7565 size_t read_only_space_physical_size_;
7601 size_t total_heap_size_;
7602 size_t total_heap_size_executable_;
7603 size_t total_physical_size_;
7604 size_t total_available_size_;
7605 size_t used_heap_size_;
7606 size_t heap_size_limit_;
7607 size_t malloced_memory_;
7608 size_t external_memory_;
7609 size_t peak_malloced_memory_;
7610 bool does_zap_garbage_;
7611 size_t number_of_native_contexts_;
7612 size_t number_of_detached_contexts_;
7613 size_t total_global_handles_size_;
7614 size_t used_global_handles_size_;
7631 const char* space_name_;
7633 size_t space_used_size_;
7634 size_t space_available_size_;
7635 size_t physical_space_size_;
7650 const char* object_type_;
7651 const char* object_sub_type_;
7652 size_t object_count_;
7653 size_t object_size_;
7666 size_t code_and_metadata_size_;
7667 size_t bytecode_and_metadata_size_;
7668 size_t external_script_source_size_;
7804 #if defined(V8_OS_WIN)
7826 uint16_t class_id) {}
7910 const std::vector<std::pair<
void*,
void*> >& embedder_fields) = 0;
8036 void* data_arg =
nullptr)
8053 void* data_arg =
nullptr)
8103 context_sizes_in_bytes,
8104 size_t unattributed_size_in_bytes) = 0;
8280 void* internal_throws_;
8281 void* internal_assert_;
8282 void* internal_dump_;
8303 internal::MicrotaskQueue*
const microtask_queue_;
8715 size_t frames_limit,
SampleInfo* sample_info);
8890 size_t offset_in_bytes, int64_t value,
8891 double timeout_in_ms,
8922 void* data =
nullptr);
8925 typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
8934 GetExternallyAllocatedMemoryInBytesCallback callback);
9325 "Use Isolate::SetModifyCodeGenerationFromStringsCallback instead. "
9326 "See http://crbug.com/v8/10096.")
9327 void SetAllowCodeGenerationFromStringsCallback(
9330 ModifyCodeGenerationFromStringsCallback callback);
9400 bool capture,
int frame_limit = 10,
9487 template <
class K,
class V,
class Traits>
9491 void ReportExternalAllocationLimitReached();
9527 typedef uintptr_t (*ReturnAddressLocationResolver)(
9528 uintptr_t return_addr_location);
9578 const int kBuildConfiguration =
9582 return Initialize(kBuildConfiguration);
9596 ReturnAddressLocationResolver return_address_resolver);
9631 const char* icu_data_file =
nullptr);
9684 static bool TryHandleSignal(
int signal_number,
void* info,
void* context);
9695 #if defined(V8_OS_WIN)
9717 enum BuildConfigurationFeatures {
9718 kPointerCompression = 1 << 0,
9719 k31BitSmis = 1 << 1,
9720 kHeapSandbox = 1 << 2,
9727 static bool Initialize(
int build_config);
9734 bool has_destructor);
9739 static void CopyTracedGlobalReference(
const internal::
Address*
const* from,
9749 static void SetFinalizationCallbackTraced(
9756 template <
class K,
class V,
class T>
9759 static void FromJustIsNothing();
9760 static void ToLocalEmpty();
9761 static void InternalFieldOutOfBounds(
int index);
9804 const intptr_t* external_references =
nullptr,
9943 return has_value_ ? value_ : default_value;
9947 return (
IsJust() == other.IsJust()) &&
9956 Maybe() : has_value_(
false) {}
9957 explicit Maybe(
const T& t) : has_value_(
true), value_(t) {}
9996 Maybe() : is_valid_(
false) {}
9997 explicit Maybe(JustTag) : is_valid_(
true) {}
10141 if (handler ==
nullptr)
return nullptr;
10142 return handler->js_stack_comparable_address_;
10151 void* operator
new(size_t size);
10152 void* operator
new[](size_t size);
10153 void operator
delete(
void*, size_t);
10154 void operator
delete[](
void*, size_t);
10156 void ResetInternal();
10161 void* message_obj_;
10162 void* js_stack_comparable_address_;
10163 bool is_verbose_ : 1;
10164 bool can_continue_ : 1;
10165 bool capture_message_ : 1;
10167 bool has_terminated_ : 1;
10183 : name_count_(name_count), names_(names) { }
10185 const char**
begin()
const {
return &names_[0]; }
10186 const char**
end()
const {
return &names_[name_count_]; }
10189 const int name_count_;
10190 const char** names_;
10264 Isolate* isolate, size_t context_snapshot_index,
10460 return js_stack_comparable_address_;
10467 uintptr_t js_stack_comparable_address_ = 0;
10468 const BackupIncumbentScope* prev_ =
nullptr;
10478 Local<
Value> SlowGetEmbedderData(
int index);
10479 void* SlowGetAlignedPointerFromEmbedderData(
int index);
10568 void Initialize(
Isolate* isolate);
10599 void Initialize(
Isolate* isolate);
10645 const void* stack_base);
10656 size_t code_pages_length,
10659 const void* stack_base);
10685 return New(isolate, that.val_);
10690 return New(isolate, that.val_);
10695 return New(isolate, that.val_);
10700 if (that ==
nullptr)
return Local<T>();
10701 T* that_ptr = that;
10704 reinterpret_cast<
internal::Isolate*>(isolate)
, *p
)));
10711 static_assert(std::is_base_of<T, S>::value,
"type check");
10712 val_ =
reinterpret_cast<T*>(
10713 V8::Eternalize(isolate,
reinterpret_cast<
Value*>(*handle)));
10720 return Local<T>(val_);
10727 return Local<T>(val_);
10733 #ifdef V8_ENABLE_CHECKS
10734 if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
10735 V8::InternalFieldOutOfBounds(index);
10738 return embedder_fields_[index];
10744 if (that ==
nullptr)
return nullptr;
10746 return reinterpret_cast<T*>(
10747 V8::GlobalizeReference(
reinterpret_cast<
internal::Isolate*>(isolate),
10752 template <
class T,
class M>
10753 template <
class S,
class M2>
10755 static_assert(std::is_base_of<T, S>::value,
"type check");
10757 if (that.IsEmpty())
return;
10759 this->val_ =
reinterpret_cast<T*>(
V8::CopyGlobalReference(p));
10760 M::Copy(that,
this);
10766 if (
this->IsEmpty())
return false;
10774 if (
this->IsEmpty())
return;
10783 static_assert(std::is_base_of<T, S>::value,
"type check");
10785 if (other.IsEmpty())
return;
10786 this->val_ = New(isolate, other.val_);
10794 static_assert(std::is_base_of<T, S>::value,
"type check");
10796 if (other.IsEmpty())
return;
10797 this->val_ = New(isolate, other.val_);
10802 template <
typename P>
10808 reinterpret_cast<Callback>(callback), type);
10817 template <
typename P>
10819 return reinterpret_cast<P*>(
10832 if (
this->IsEmpty())
return;
10835 *
reinterpret_cast<uint16_t*>(addr) = class_id;
10842 if (
this->IsEmpty())
return 0;
10845 return *
reinterpret_cast<uint16_t*>(addr);
10850 if (other.val_ !=
nullptr) {
10853 other.val_ =
nullptr;
10860 static_assert(std::is_base_of<T, S>::value,
"type check");
10861 if (
this != &rhs) {
10863 if (rhs.val_ !=
nullptr) {
10864 this->val_ = rhs.val_;
10865 V8::MoveGlobalReference(
10868 rhs.val_ =
nullptr;
10876 DestructionMode destruction_mode) {
10877 if (that ==
nullptr)
return nullptr;
10879 return reinterpret_cast<T*>(
V8::GlobalizeTracedReference(
10880 reinterpret_cast<
internal::Isolate*>(isolate), p,
10882 destruction_mode == kWithDestructor));
10895 static_assert(std::is_base_of<T, S>::value,
"type check");
10897 if (other.IsEmpty())
return;
10898 this->val_ =
this->New(isolate, other.val_, &
this->val_,
10905 static_assert(std::is_base_of<T, S>::value,
"type check");
10906 *
this = std::move(rhs.
template As<T>());
10913 static_assert(std::is_base_of<T, S>::value,
"type check");
10914 *
this = rhs.
template As<T>();
10920 if (
this != &rhs) {
10921 V8::MoveTracedGlobalReference(
10930 if (
this != &rhs) {
10932 if (rhs.val_ !=
nullptr) {
10933 V8::CopyTracedGlobalReference(
10944 static_assert(std::is_base_of<T, S>::value,
"type check");
10946 if (other.IsEmpty())
return;
10947 this->val_ =
this->New(isolate, other.val_, &
this->val_,
10954 static_assert(std::is_base_of<T, S>::value,
"type check");
10955 *
this = std::move(rhs.
template As<T>());
10963 static_assert(std::is_base_of<T, S>::value,
"type check");
10964 *
this = rhs.
template As<T>();
10970 if (
this != &rhs) {
10971 V8::MoveTracedGlobalReference(
10980 if (
this != &rhs) {
10982 if (rhs.val_ !=
nullptr) {
10983 V8::CopyTracedGlobalReference(
10997 *
reinterpret_cast<uint16_t*>(addr) = class_id;
11006 return *
reinterpret_cast<uint16_t*>(addr);
11012 V8::SetFinalizationCallbackTraced(
11013 reinterpret_cast<
internal::
Address*>(
this->val_), parameter, callback);
11016 template <
typename T>
11019 template <
typename T>
11020 template <
typename S>
11022 static_assert(std::is_base_of<T, S>::value,
"type check");
11024 *value_ = GetDefaultValue();
11030 template <
typename T>
11031 template <
typename S>
11033 static_assert(std::is_base_of<T, S>::value,
"type check");
11035 *value_ = GetDefaultValue();
11041 template <
typename T>
11042 template <
typename S>
11044 static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
11047 *value_ = GetDefaultValue();
11053 template<
typename T>
11055 static_assert(std::is_base_of<T,
Number>::value,
"type check");
11059 template<
typename T>
11061 static_assert(std::is_base_of<T,
Integer>::value,
"type check");
11070 template<
typename T>
11072 static_assert(std::is_base_of<T,
Integer>::value,
"type check");
11074 bool fits_into_int32_t = (i & (1U << 31)) == 0;
11076 Set(
static_cast<int32_t>(i));
11082 template<
typename T>
11084 static_assert(std::is_base_of<T,
Boolean>::value,
"type check");
11095 template<
typename T>
11097 static_assert(std::is_base_of<T,
Primitive>::value,
"type check");
11102 template<
typename T>
11104 static_assert(std::is_base_of<T,
Primitive>::value,
"type check");
11109 template<
typename T>
11111 static_assert(std::is_base_of<T,
String>::value,
"type check");
11116 template <
typename T>
11119 return *
reinterpret_cast<
Isolate**>(&value_[-2]);
11122 template <
typename T>
11130 template <
typename T>
11131 template <
typename S>
11133 static_assert(
sizeof(S) < 0,
"incompilable to prevent inadvertent misuse");
11136 template <
typename T>
11142 template <
typename T>
11148 template<
typename T>
11152 #ifdef V8_REVERSE_JSARGS
11153 return Local<Value>(
reinterpret_cast<Value*>(values_ + i));
11160 template<
typename T>
11163 #ifdef V8_REVERSE_JSARGS
11164 return Local<Object>(
reinterpret_cast<Object*>(values_ - 1));
11171 template<
typename T>
11177 template <
typename T>
11183 template <
typename T>
11189 template<
typename T>
11195 template<
typename T>
11201 template<
typename T>
11207 template<
typename T>
11221 : resource_name_(resource_name),
11222 resource_line_offset_(resource_line_offset),
11223 resource_column_offset_(resource_column_offset),
11224 options_
(!resource_is_shared_cross_origin
.IsEmpty() &&
11229 script_id_(script_id),
11230 source_map_url_(source_map_url),
11231 host_defined_options_(host_defined_options) {}
11236 return host_defined_options_;
11240 return resource_line_offset_;
11245 return resource_column_offset_;
11256 : source_string(string),
11263 cached_data(data) {}
11267 : source_string(string), cached_data(data) {}
11271 delete cached_data;
11277 return cached_data;
11281 return resource_options;
11295 #ifdef V8_ENABLE_CHECKS
11302 #ifdef V8_ENABLE_CHECKS
11309 #ifdef V8_ENABLE_CHECKS
11312 return reinterpret_cast<
Signature*>(data);
11316 #ifdef V8_ENABLE_CHECKS
11323 #ifndef V8_ENABLE_CHECKS
11326 A obj = *
reinterpret_cast<A*>(
this);
11335 #ifdef V8_COMPRESS_POINTERS
11338 value = I::DecompressTaggedAnyField(obj,
static_cast<uint32_t>(value));
11346 return SlowGetInternalField(index);
11351 #ifndef V8_ENABLE_CHECKS
11354 A obj = *
reinterpret_cast<A*>(
this);
11364 return reinterpret_cast<
void*>(value);
11367 return SlowGetAlignedPointerFromInternalField(index);
11371 #ifdef V8_ENABLE_CHECKS
11374 return static_cast<
String*>(value);
11390 A obj = *
reinterpret_cast<
const A*>(
this);
11399 result = GetExternalStringResourceSlow();
11401 #ifdef V8_ENABLE_CHECKS
11402 VerifyExternalStringResource(result);
11412 A obj = *
reinterpret_cast<
const A*>(
this);
11423 resource = GetExternalStringResourceBaseSlow(encoding_out);
11425 #ifdef V8_ENABLE_CHECKS
11426 VerifyExternalStringResourceBase(resource, *encoding_out);
11433 #ifdef V8_ENABLE_CHECKS
11434 return FullIsUndefined();
11436 return QuickIsUndefined();
11440 bool Value::QuickIsUndefined()
const {
11443 A obj = *
reinterpret_cast<
const A*>(
this);
11451 #ifdef V8_ENABLE_CHECKS
11452 return FullIsNull();
11454 return QuickIsNull();
11458 bool Value::QuickIsNull()
const {
11461 A obj = *
reinterpret_cast<
const A*>(
this);
11468 #ifdef V8_ENABLE_CHECKS
11469 return FullIsNull() || FullIsUndefined();
11471 return QuickIsNullOrUndefined();
11475 bool Value::QuickIsNullOrUndefined()
const {
11478 A obj = *
reinterpret_cast<
const A*>(
this);
11486 #ifdef V8_ENABLE_CHECKS
11487 return FullIsString();
11489 return QuickIsString();
11493 bool Value::QuickIsString()
const {
11496 A obj = *
reinterpret_cast<
const A*>(
this);
11503 return static_cast<
Value*>(value);
11508 #ifdef V8_ENABLE_CHECKS
11511 return static_cast<
Boolean*>(value);
11516 #ifdef V8_ENABLE_CHECKS
11519 return static_cast<
Name*>(value);
11524 #ifdef V8_ENABLE_CHECKS
11527 return static_cast<
Symbol*>(value);
11532 #ifdef V8_ENABLE_CHECKS
11535 return reinterpret_cast<
Private*>(data);
11540 #ifdef V8_ENABLE_CHECKS
11543 return static_cast<
Number*>(value);
11548 #ifdef V8_ENABLE_CHECKS
11551 return static_cast<
Integer*>(value);
11556 #ifdef V8_ENABLE_CHECKS
11559 return static_cast<
Int32*>(value);
11564 #ifdef V8_ENABLE_CHECKS
11567 return static_cast<
Uint32*>(value);
11571 #ifdef V8_ENABLE_CHECKS
11574 return static_cast<
BigInt*>(value);
11578 #ifdef V8_ENABLE_CHECKS
11581 return static_cast<
Date*>(value);
11586 #ifdef V8_ENABLE_CHECKS
11594 #ifdef V8_ENABLE_CHECKS
11602 #ifdef V8_ENABLE_CHECKS
11609 #ifdef V8_ENABLE_CHECKS
11616 #ifdef V8_ENABLE_CHECKS
11624 #ifdef V8_ENABLE_CHECKS
11627 return static_cast<
RegExp*>(value);
11632 #ifdef V8_ENABLE_CHECKS
11635 return static_cast<
Object*>(value);
11640 #ifdef V8_ENABLE_CHECKS
11643 return static_cast<
Array*>(value);
11648 #ifdef V8_ENABLE_CHECKS
11651 return static_cast<
Map*>(value);
11656 #ifdef V8_ENABLE_CHECKS
11659 return static_cast<
Set*>(value);
11664 #ifdef V8_ENABLE_CHECKS
11667 return static_cast<
Promise*>(value);
11672 #ifdef V8_ENABLE_CHECKS
11675 return static_cast<
Proxy*>(value);
11679 #ifdef V8_ENABLE_CHECKS
11686 #ifdef V8_ENABLE_CHECKS
11694 #ifdef V8_ENABLE_CHECKS
11702 #ifdef V8_ENABLE_CHECKS
11710 #ifdef V8_ENABLE_CHECKS
11718 #ifdef V8_ENABLE_CHECKS
11726 #ifdef V8_ENABLE_CHECKS
11734 #ifdef V8_ENABLE_CHECKS
11742 #ifdef V8_ENABLE_CHECKS
11750 #ifdef V8_ENABLE_CHECKS
11758 #ifdef V8_ENABLE_CHECKS
11766 #ifdef V8_ENABLE_CHECKS
11774 #ifdef V8_ENABLE_CHECKS
11781 #ifdef V8_ENABLE_CHECKS
11788 #ifdef V8_ENABLE_CHECKS
11795 #ifdef V8_ENABLE_CHECKS
11803 #ifdef V8_ENABLE_CHECKS
11806 return static_cast<
DataView*>(value);
11811 #ifdef V8_ENABLE_CHECKS
11819 #ifdef V8_ENABLE_CHECKS
11822 return static_cast<
Function*>(value);
11827 #ifdef V8_ENABLE_CHECKS
11830 return static_cast<
External*>(value);
11834 template<
typename T>
11840 template<
typename T>
11846 template<
typename T>
11852 template<
typename T>
11858 template<
typename T>
11863 template <
typename T>
11929 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
11930 if (data)
internal::PerformCastCheck(data);
11931 return Local<T>(data);
11935 int64_t change_in_bytes) {
11937 int64_t* external_memory =
reinterpret_cast<int64_t*>(
11939 int64_t* external_memory_limit =
reinterpret_cast<int64_t*>(
11941 int64_t* external_memory_low_since_mc =
11942 reinterpret_cast<int64_t*>(
reinterpret_cast<uint8_t*>(
this) +
11947 const int64_t amount =
11948 static_cast<int64_t>(
static_cast<uint64_t>(change_in_bytes) +
11949 static_cast<uint64_t>(*external_memory));
11950 *external_memory = amount;
11952 if (amount < *external_memory_low_since_mc) {
11953 *external_memory_low_since_mc = amount;
11957 if (change_in_bytes <= 0)
return *external_memory;
11959 if (amount > *external_memory_limit) {
11960 ReportExternalAllocationLimitReached();
11962 return *external_memory;
11966 #ifndef V8_ENABLE_CHECKS
11969 A ctx = *
reinterpret_cast<
const A*>(
this);
11975 #ifdef V8_COMPRESS_POINTERS
11979 I::DecompressTaggedAnyField(embedder_data,
static_cast<uint32_t>(value));
11982 *
reinterpret_cast<A*>(
this)
);
11986 return SlowGetEmbedderData(index);
11992 #ifndef V8_ENABLE_CHECKS
11995 A ctx = *
reinterpret_cast<
const A*>(
this);
12001 return reinterpret_cast<
void*>(
12004 return SlowGetAlignedPointerFromEmbedderData(index);
12010 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12011 if (data)
internal::PerformCastCheck(data);
12012 return Local<T>(data);
12017 T* object_ptr = *object;
12019 return AddData(context, *p);
12024 T* object_ptr = *object;
12026 return AddData(*p);