24 #include <type_traits>
28 #include "cppgc/common.h"
56 class ImplementationUtilities;
67 class ObjectOperationDescriptor;
74 class RawOperationDescriptor;
91 template <
class T>
class Local;
94 template <
class T>
class Eternal;
95 template<
class T>
class NonCopyablePersistentTraits;
97 template <
class T,
class M = NonCopyablePersistentTraits<T> >
108 template <
class K,
class V,
class T>
110 template <
class K,
class V,
class T>
113 template<
class T,
class P>
class WeakCallbackObject;
121 class CallHandlerHelper;
126 enum class ArgumentsType;
127 template <ArgumentsType>
129 template <
typename T>
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;
157 class ConsoleCallArguments;
199 : val_(
reinterpret_cast<T*>(*that)) {
205 static_assert(std::is_base_of<T, S>::value,
"type check");
236 if (a ==
nullptr)
return b ==
nullptr;
237 if (b ==
nullptr)
return false;
245 if (a ==
nullptr)
return b ==
nullptr;
246 if (b ==
nullptr)
return false;
262 return !operator==(that);
267 return !operator==(that);
276 #ifdef V8_ENABLE_CHECKS
279 if (that.IsEmpty())
return Local<T>();
281 return Local<T>(T::Cast(*that));
291 return Local<S>::Cast(*
this);
310 template<
class F>
friend class Local;
327 template <
class F1,
class F2,
class F3>
341 explicit V8_INLINE Local(T* that) : val_(that) {}
347 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
370 : val_(
reinterpret_cast<T*>(*that)) {
371 static_assert(std::is_base_of<T, S>::value,
"type check");
382 out->val_ =
IsEmpty() ?
nullptr :
this->val_;
414 Set(isolate, handle);
426 static const int kInternalFieldsInWeakCallback = 2;
427 static const int kEmbedderFieldsInWeakCallback = 2;
429 template <
typename T>
435 void* embedder_fields[kEmbedderFieldsInWeakCallback],
437 : isolate_(isolate), parameter_(parameter), callback_(callback) {
438 for (
int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
439 embedder_fields_[i] = embedder_fields[i];
459 void* embedder_fields_[kEmbedderFieldsInWeakCallback];
508 return Local<T>::New(isolate, *
this);
515 if (a ==
nullptr)
return b ==
nullptr;
516 if (b ==
nullptr)
return false;
524 if (a ==
nullptr)
return b ==
nullptr;
525 if (b ==
nullptr)
return false;
531 return !operator==(that);
536 return !operator==(that);
551 template <
typename P>
599 template<
class F>
friend class Local;
605 template <
class F1,
class F2,
class F3>
610 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
624 class NonCopyablePersistentTraits {
628 template<
class S,
class M>
631 static_assert(
sizeof(S) < 0,
632 "NonCopyablePersistentTraits::Copy is not instantiable");
645 template<
class S,
class M>
675 static_assert(std::is_base_of<T, S>::value,
"type check");
682 template <
class S,
class M2>
685 static_assert(std::is_base_of<T, S>::value,
"type check");
696 template <
class S,
class M2>
704 template <
class S,
class M2>
715 if (M::kResetInDestructor)
this->Reset();
721 #ifdef V8_ENABLE_CHECKS
724 if (!that.IsEmpty()) T::Cast(*that);
738 template<
class F>
friend class Local;
743 V8_INLINE T* operator*()
const {
return this->val_; }
744 template<
class S,
class M2>
770 static_assert(std::is_base_of<T, S>::value,
"type check");
781 static_assert(std::is_base_of<T, S>::value,
"type check");
813 V8_INLINE T* operator*()
const {
return this->val_; }
824 template <
typename T>
842 template <
typename T>
849 bool IsEmpty()
const {
return val_ ==
nullptr; }
866 if (a ==
nullptr)
return b ==
nullptr;
867 if (b ==
nullptr)
return false;
875 if (a ==
nullptr)
return b ==
nullptr;
876 if (b ==
nullptr)
return false;
882 return !operator==(that);
887 return !operator==(that);
912 reinterpret_cast<std::atomic<T*>*>(&val_)->store(new_val,
913 std::memory_order_relaxed);
920 return reinterpret_cast<std::atomic<
const T*>
const*>(&val_)->load(
921 std::memory_order_relaxed);
925 enum DestructionMode { kWithDestructor, kWithoutDestructor };
930 TracedReferenceBase() =
default;
933 DestructionMode destruction_mode);
938 template <
typename F>
941 template <
typename F>
943 template <
typename F>
945 template <
typename F>
953 template <
typename T>
976 this->val_ =
this->New(isolate, that.val_, &
this->val_,
978 static_assert(std::is_base_of<T, S>::value,
"type check");
986 *
this = std::move(other);
992 template <
typename S>
995 *
this = std::move(other);
1009 template <
typename S>
1081 template <
typename T>
1099 this->val_ =
this->New(isolate, that.val_, &
this->val_,
1101 static_assert(std::is_base_of<T, S>::value,
"type check");
1110 *
this = std::move(other);
1117 template <
typename S>
1120 *
this = std::move(other);
1136 template <
typename S>
1182 return this->GetSlotThreadSafe() ==
nullptr;
1212 return reinterpret_cast<
Isolate*>(isolate_);
1229 void* operator
new(size_t size);
1230 void* operator
new[](size_t size);
1231 void operator
delete(
void*, size_t);
1232 void operator
delete[](
void*, size_t);
1265 return Local<T>(
reinterpret_cast<T*>(slot));
1270 return Escape(value.FromMaybe(
Local<T>()));
1279 void* operator
new(size_t size);
1280 void* operator
new[](size_t size);
1281 void operator
delete(
void*, size_t);
1282 void operator
delete[](
void*, size_t);
1304 void* operator
new(size_t size);
1305 void* operator
new[](size_t size);
1306 void operator
delete(
void*, size_t);
1307 void operator
delete[](
void*, size_t);
1311 int prev_sealed_level_;
1368 bool is_opaque =
false,
bool is_wasm =
false,
1369 bool is_module =
false)
1370 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1371 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1372 (is_module ? kIsModule : 0)) {}
1375 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1378 return (flags_ & kIsSharedCrossOrigin) != 0;
1380 bool IsOpaque()
const {
return (flags_ & kIsOpaque) != 0; }
1381 bool IsWasm()
const {
return (flags_ & kIsWasm) != 0; }
1382 bool IsModule()
const {
return (flags_ & kIsModule) != 0; }
1388 kIsSharedCrossOrigin = 1,
1478 : line_number_(line_number), column_number_(column_number) {}
1626 "Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
1627 "instead of the one that follows. The former will throw a runtime "
1628 "error if called for an export that doesn't exist (as per spec); "
1629 "the latter will crash with a failed CHECK().")
1630 void SetSyntheticModuleExport(
Local<
String> export_name,
1806 "This class takes ownership of source_stream, so use the constructor "
1807 "taking a unique_ptr to make these semantics clearer")
1820 std::unique_ptr<
internal::ScriptStreamingData> impl_;
1834 explicit ScriptStreamingTask(
internal::ScriptStreamingData* data)
1837 internal::ScriptStreamingData* data_;
1971 Local<
String> arguments[], size_t context_extension_count,
2356 size_t* actual_size);
2422 PrivateData* private_;
2447 Isolate* isolate, uint32_t transfer_id);
2454 Isolate* isolate, uint32_t clone_id);
2519 PrivateData* private_;
2928 V8_INLINE bool QuickIsUndefined()
const;
2930 V8_INLINE bool QuickIsNullOrUndefined()
const;
2932 bool FullIsUndefined()
const;
2933 bool FullIsNull()
const;
2934 bool FullIsString()
const;
2955 static void CheckCast(
v8::
Value* obj);
2976 static void CheckCast(
Value* obj);
3075 int Write(
Isolate* isolate, uint16_t* buffer,
int start = 0,
int length = -1,
3079 int length = -1,
int options =
NO_OPTIONS)
const;
3082 int* nchars_ref =
nullptr,
int options =
NO_OPTIONS)
const;
3167 virtual const uint16_t*
data()
const = 0;
3197 virtual const char*
data()
const = 0;
3237 Isolate* isolate,
const char (&literal)[N],
3239 static_assert(N <=
kMaxLength,
"String is too long");
3240 return NewFromUtf8Literal(isolate, literal, type, N - 1);
3246 Isolate* isolate,
const char* data,
3252 Isolate* isolate,
const uint8_t* data,
3258 Isolate* isolate,
const uint16_t* data,
3378 const char* literal,
3381 static void CheckCast(
v8::
Value* obj);
3445 static void CheckCast(
Value* obj);
3483 static void CheckCast(
Data* that);
3497 static void CheckCast(
v8::
Value* obj);
3512 static void CheckCast(
v8::
Value* obj);
3526 static void CheckCast(
v8::
Value* obj);
3540 static void CheckCast(
v8::
Value* obj);
3558 int word_count,
const uint64_t* words);
3595 static void CheckCast(
v8::
Value* obj);
4155 static void CheckCast(
Value* obj);
4156 Local<
Value> SlowGetInternalField(
int index);
4157 void* SlowGetAlignedPointerFromInternalField(
int index);
4183 static void CheckCast(
Value* obj);
4219 static void CheckCast(
Value* obj);
4251 static void CheckCast(
Value* obj);
4255 template<
typename T>
4259 : value_(that.value_) {
4260 static_assert(std::is_base_of<T, S>::value,
"type check");
4263 template <
typename S>
4265 template <
typename S>
4267 template <
typename S>
4282 template <
typename S>
4294 template <
class F,
class G,
class H>
4309 template<
typename T>
4348 friend class debug::ConsoleCallArguments;
4368 template<
typename T>
4460 friend class MacroAssembler;
4567 static void CheckCast(
Value* obj);
4570 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
4572 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0
4613 static void CheckCast(
Value* obj);
4660 static void CheckCast(
Value* obj);
4733 PrivateData* private_;
4758 static void CheckCast(
Value* obj);
4771 template <
typename T>
4777 constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
4780 constexpr T*
data()
const {
return data_; }
4782 constexpr size_t
size()
const {
return size_; }
4819 friend class WasmStreaming;
4821 explicit CompiledWasmModule(std::shared_ptr<
internal::
wasm::NativeModule>,
4822 const char* source_url, size_t url_length);
4824 const std::shared_ptr<
internal::
wasm::NativeModule> native_module_;
4825 const std::string source_url_;
4849 static void CheckCast(
Value* obj);
4860 class WasmStreamingImpl;
4929 std::unique_ptr<WasmStreamingImpl> impl_;
4953 WasmModuleObjectBuilderStreaming(
const WasmModuleObjectBuilderStreaming&) =
4955 WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
4957 WasmModuleObjectBuilderStreaming& operator=(
4958 const WasmModuleObjectBuilderStreaming&) =
delete;
4959 WasmModuleObjectBuilderStreaming& operator=(
4960 WasmModuleObjectBuilderStreaming&&) =
default;
4971 Persistent<Promise, CopyablePersistentTraits<Promise>> promise_;
4975 std::shared_ptr<
internal::
wasm::StreamingDecoder> streaming_decoder_;
4978 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
4980 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
5028 size_t byte_length);
5035 using DeleterCallback =
void (*)(
void* data, size_t length,
5036 void* deleter_data);
5057 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
5059 using BackingStoreDeleterCallback =
void (*)(
void* data, size_t length,
5060 void* deleter_data);
5104 virtual void Free(
void* data, size_t length) = 0;
5118 virtual void*
Reallocate(
void* data, size_t old_length, size_t new_length);
5147 using DeleterCallback =
void (*)(
void* buffer, size_t length,
void* info);
5152 allocation_base_(
nullptr),
5153 allocation_length_(0),
5156 deleter_data_(
nullptr) {}
5161 return allocation_mode_;
5164 void*
Data()
const {
return data_; }
5166 DeleterCallback
Deleter()
const {
return deleter_; }
5170 Contents(
void* data, size_t byte_length,
void* allocation_base,
5171 size_t allocation_length,
5173 void* deleter_data);
5176 size_t byte_length_;
5177 void* allocation_base_;
5178 size_t allocation_length_;
5180 DeleterCallback deleter_;
5181 void* deleter_data_;
5210 "Use the version that takes a BackingStore. "
5211 "See http://crbug.com/v8/9908.")
5241 size_t byte_length);
5251 void* data, size_t byte_length,
v8::
BackingStore::DeleterCallback deleter,
5252 void* deleter_data);
5259 "With v8::BackingStore externalized ArrayBuffers are "
5260 "the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.")
5261 bool IsExternal()
const;
5287 "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5328 static void CheckCast(
Value* obj);
5329 Contents GetContents(
bool externalize);
5333 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
5335 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
5384 static void CheckCast(
Value* obj);
5400 :
static_cast<size_t>(uint64_t{1} << 32);
5412 static void CheckCast(
Value* obj);
5422 size_t byte_offset, size_t length);
5424 size_t byte_offset, size_t length);
5429 static void CheckCast(
Value* obj);
5439 size_t byte_offset, size_t length);
5446 Uint8ClampedArray();
5447 static void CheckCast(
Value* obj);
5456 size_t byte_offset, size_t length);
5458 size_t byte_offset, size_t length);
5463 static void CheckCast(
Value* obj);
5473 size_t byte_offset, size_t length);
5475 size_t byte_offset, size_t length);
5480 static void CheckCast(
Value* obj);
5490 size_t byte_offset, size_t length);
5492 size_t byte_offset, size_t length);
5497 static void CheckCast(
Value* obj);
5507 size_t byte_offset, size_t length);
5509 size_t byte_offset, size_t length);
5514 static void CheckCast(
Value* obj);
5524 size_t byte_offset, size_t length);
5526 size_t byte_offset, size_t length);
5531 static void CheckCast(
Value* obj);
5541 size_t byte_offset, size_t length);
5543 size_t byte_offset, size_t length);
5548 static void CheckCast(
Value* obj);
5558 size_t byte_offset, size_t length);
5560 size_t byte_offset, size_t length);
5565 static void CheckCast(
Value* obj);
5574 size_t byte_offset, size_t length);
5576 size_t byte_offset, size_t length);
5581 static void CheckCast(
Value* obj);
5590 size_t byte_offset, size_t length);
5592 size_t byte_offset, size_t length);
5597 static void CheckCast(
Value* obj);
5606 size_t byte_offset, size_t length);
5608 size_t byte_offset, size_t length);
5613 static void CheckCast(
Value* obj);
5634 using DeleterCallback =
void (*)(
void* buffer, size_t length,
void* info);
5639 allocation_base_(
nullptr),
5640 allocation_length_(0),
5643 deleter_data_(
nullptr) {}
5648 return allocation_mode_;
5651 void*
Data()
const {
return data_; }
5653 DeleterCallback
Deleter()
const {
return deleter_; }
5657 Contents(
void* data, size_t byte_length,
void* allocation_base,
5658 size_t allocation_length,
5659 Allocator::
AllocationMode allocation_mode, DeleterCallback deleter,
5660 void* deleter_data);
5663 size_t byte_length_;
5664 void* allocation_base_;
5665 size_t allocation_length_;
5667 DeleterCallback deleter_;
5668 void* deleter_data_;
5693 "Use the version that takes a BackingStore. "
5694 "See http://crbug.com/v8/9908.")
5724 size_t byte_length);
5734 void* data, size_t byte_length,
v8::
BackingStore::DeleterCallback deleter,
5735 void* deleter_data);
5742 "Use the version that takes a BackingStore. "
5743 "See http://crbug.com/v8/9908.")
5753 "With v8::BackingStore externalized SharedArrayBuffers are the same "
5754 "as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.")
5755 bool IsExternal()
const;
5770 "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5813 SharedArrayBuffer();
5814 static void CheckCast(
Value* obj);
5815 Contents GetContents(
bool externalize);
5836 static void CheckCast(
Value* obj);
5852 static void CheckCast(
Value* obj);
5867 static void CheckCast(
Value* obj);
5882 static void CheckCast(
Value* obj);
5898 static void CheckCast(
Value* obj);
5914 static void CheckCast(
Value* obj);
5960 uint32_t backtrack_limit);
5990 static void CheckCast(
Value* obj);
6003 static void CheckCast(
v8::
Value* obj);
6006 #define V8_INTRINSICS_LIST(F)
6007 F(ArrayProto_entries, array_entries_iterator)
6008 F(ArrayProto_forEach, array_for_each_iterator)
6009 F(ArrayProto_keys, array_keys_iterator)
6010 F(ArrayProto_values, array_values_iterator)
6011 F(AsyncIteratorPrototype, initial_async_iterator_prototype)
6012 F(ErrorPrototype, initial_error_prototype)
6013 F(IteratorPrototype, initial_iterator_prototype)
6014 F(ObjProto_valueOf, object_value_of_function)
6017 #define V8_DECL_INTRINSIC(name, iname) k##name,
6019 #undef V8_DECL_INTRINSIC
6575 static void CheckCast(
Data* that);
6854 deleter
, enumerator
, data
));
6940 static void CheckCast(
Data* that);
6963 static void CheckCast(
Data* that);
6980 AccessorSignature();
6982 static void CheckCast(
Data* that);
6995 Extension(
const char* name,
const char* source =
nullptr,
int dep_count = 0,
6996 const char** deps =
nullptr,
int source_length = -1);
7003 const char*
name()
const {
return name_; }
7019 size_t source_length_;
7070 size_t maximum_heap_size_in_bytes);
7082 uint64_t virtual_memory_limit);
7105 return max_old_generation_size_;
7108 max_old_generation_size_ = limit;
7117 return max_young_generation_size_;
7120 max_young_generation_size_ = limit;
7124 return initial_old_generation_size_;
7127 initial_old_generation_size_ = initial_size;
7131 return initial_young_generation_size_;
7134 initial_young_generation_size_ = initial_size;
7144 code_range_size_ = limit_in_mb * kMB;
7154 max_old_generation_size_ = limit_in_mb * kMB;
7162 static constexpr size_t kMB = 1048576u;
7163 size_t code_range_size_ = 0;
7164 size_t max_old_generation_size_ = 0;
7165 size_t max_young_generation_size_ = 0;
7166 size_t max_zone_pool_size_ = 0;
7167 size_t initial_old_generation_size_ = 0;
7168 size_t initial_young_generation_size_ = 0;
7169 uint32_t* stack_limit_ =
nullptr;
7181 const char* message);
7327 : promise_(promise), event_(event), value_(value) {}
7393 void* data =
nullptr) = 0;
7437 MicrotaskQueue() =
default;
7478 internal::MicrotaskQueue*
const microtask_queue_;
7511 *ModifyCodeGenerationFromStringsCallback)(
Local<
Context> context,
7590 typedef size_t (*NearHeapLimitCallback)(
void* data, size_t current_heap_limit,
7591 size_t initial_heap_limit);
7605 return read_only_space_physical_size_;
7609 size_t read_only_space_size_;
7610 size_t read_only_space_used_size_;
7611 size_t read_only_space_physical_size_;
7647 size_t total_heap_size_;
7648 size_t total_heap_size_executable_;
7649 size_t total_physical_size_;
7650 size_t total_available_size_;
7651 size_t used_heap_size_;
7652 size_t heap_size_limit_;
7653 size_t malloced_memory_;
7654 size_t external_memory_;
7655 size_t peak_malloced_memory_;
7656 bool does_zap_garbage_;
7657 size_t number_of_native_contexts_;
7658 size_t number_of_detached_contexts_;
7659 size_t total_global_handles_size_;
7660 size_t used_global_handles_size_;
7677 const char* space_name_;
7679 size_t space_used_size_;
7680 size_t space_available_size_;
7681 size_t physical_space_size_;
7696 const char* object_type_;
7697 const char* object_sub_type_;
7698 size_t object_count_;
7699 size_t object_size_;
7712 size_t code_and_metadata_size_;
7713 size_t bytecode_and_metadata_size_;
7714 size_t external_script_source_size_;
7850 #if defined(V8_OS_WIN)
7872 uint16_t class_id) {}
7956 const std::vector<std::pair<
void*,
void*> >& embedder_fields) = 0;
8082 void* data_arg =
nullptr)
8099 void* data_arg =
nullptr)
8150 context_sizes_in_bytes,
8151 size_t unattributed_size_in_bytes) = 0;
8327 void* internal_throws_;
8328 void* internal_assert_;
8329 void* internal_dump_;
8350 internal::MicrotaskQueue*
const microtask_queue_;
8765 size_t frames_limit,
SampleInfo* sample_info);
8939 size_t offset_in_bytes, int64_t value,
8940 double timeout_in_ms,
8971 void* data =
nullptr);
8974 typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
8983 GetExternallyAllocatedMemoryInBytesCallback callback);
9393 "Use Isolate::SetModifyCodeGenerationFromStringsCallback instead. "
9394 "See http://crbug.com/v8/10096.")
9395 void SetAllowCodeGenerationFromStringsCallback(
9398 ModifyCodeGenerationFromStringsCallback callback);
9468 bool capture,
int frame_limit = 10,
9555 template <
class K,
class V,
class Traits>
9559 void ReportExternalAllocationLimitReached();
9599 typedef uintptr_t (*ReturnAddressLocationResolver)(
9600 uintptr_t return_addr_location);
9650 const int kBuildConfiguration =
9654 return Initialize(kBuildConfiguration);
9668 ReturnAddressLocationResolver return_address_resolver);
9703 const char* icu_data_file =
nullptr);
9756 static bool TryHandleSignal(
int signal_number,
void* info,
void* context);
9767 #if defined(V8_OS_WIN)
9789 enum BuildConfigurationFeatures {
9790 kPointerCompression = 1 << 0,
9791 k31BitSmis = 1 << 1,
9792 kHeapSandbox = 1 << 2,
9799 static bool Initialize(
int build_config);
9806 bool has_destructor);
9811 static void CopyTracedGlobalReference(
const internal::
Address*
const* from,
9821 static void SetFinalizationCallbackTraced(
9828 template <
class K,
class V,
class T>
9831 static void FromJustIsNothing();
9832 static void ToLocalEmpty();
9833 static void InternalFieldOutOfBounds(
int index);
9876 const intptr_t* external_references =
nullptr,
10015 return has_value_ ? value_ : default_value;
10019 return (
IsJust() == other.IsJust()) &&
10028 Maybe() : has_value_(
false) {}
10029 explicit Maybe(
const T& t) : has_value_(
true), value_(t) {}
10047 return Maybe<T>(t);
10068 Maybe() : is_valid_(
false) {}
10069 explicit Maybe(JustTag) : is_valid_(
true) {}
10208 if (handler ==
nullptr)
return nullptr;
10209 return handler->js_stack_comparable_address_;
10218 void* operator
new(size_t size);
10219 void* operator
new[](size_t size);
10220 void operator
delete(
void*, size_t);
10221 void operator
delete[](
void*, size_t);
10223 void ResetInternal();
10228 void* message_obj_;
10229 void* js_stack_comparable_address_;
10230 bool is_verbose_ : 1;
10231 bool can_continue_ : 1;
10232 bool capture_message_ : 1;
10234 bool has_terminated_ : 1;
10250 : name_count_(name_count), names_(names) { }
10252 const char**
begin()
const {
return &names_[0]; }
10253 const char**
end()
const {
return &names_[name_count_]; }
10256 const int name_count_;
10257 const char** names_;
10331 Isolate* isolate, size_t context_snapshot_index,
10527 return js_stack_comparable_address_;
10534 uintptr_t js_stack_comparable_address_ = 0;
10535 const BackupIncumbentScope* prev_ =
nullptr;
10545 Local<
Value> SlowGetEmbedderData(
int index);
10546 void* SlowGetAlignedPointerFromEmbedderData(
int index);
10635 void Initialize(
Isolate* isolate);
10666 void Initialize(
Isolate* isolate);
10712 const void* stack_base);
10723 size_t code_pages_length,
10726 const void* stack_base);
10752 return New(isolate, that.val_);
10757 return New(isolate, that.val_);
10762 return New(isolate, that.val_);
10767 if (that ==
nullptr)
return Local<T>();
10768 T* that_ptr = that;
10771 reinterpret_cast<
internal::Isolate*>(isolate)
, *p
)));
10778 static_assert(std::is_base_of<T, S>::value,
"type check");
10779 val_ =
reinterpret_cast<T*>(
10780 V8::Eternalize(isolate,
reinterpret_cast<
Value*>(*handle)));
10787 return Local<T>(val_);
10794 return Local<T>(val_);
10800 #ifdef V8_ENABLE_CHECKS
10801 if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
10802 V8::InternalFieldOutOfBounds(index);
10805 return embedder_fields_[index];
10811 if (that ==
nullptr)
return nullptr;
10813 return reinterpret_cast<T*>(
10814 V8::GlobalizeReference(
reinterpret_cast<
internal::Isolate*>(isolate),
10819 template <
class T,
class M>
10820 template <
class S,
class M2>
10822 static_assert(std::is_base_of<T, S>::value,
"type check");
10824 if (that.IsEmpty())
return;
10826 this->val_ =
reinterpret_cast<T*>(
V8::CopyGlobalReference(p));
10827 M::Copy(that,
this);
10833 if (
this->IsEmpty())
return false;
10841 if (
this->IsEmpty())
return;
10850 static_assert(std::is_base_of<T, S>::value,
"type check");
10852 if (other.IsEmpty())
return;
10853 this->val_ = New(isolate, other.val_);
10861 static_assert(std::is_base_of<T, S>::value,
"type check");
10863 if (other.IsEmpty())
return;
10864 this->val_ = New(isolate, other.val_);
10869 template <
typename P>
10874 #if (__GNUC__
>= 8
) && !defined(__clang__
)
10875 #pragma GCC diagnostic push
10876 #pragma GCC diagnostic ignored "-Wcast-function-type"
10879 reinterpret_cast<Callback>(callback), type);
10880 #if (__GNUC__
>= 8
) && !defined(__clang__
)
10881 #pragma GCC diagnostic pop
10891 template <
typename P>
10893 return reinterpret_cast<P*>(
10906 if (
this->IsEmpty())
return;
10909 *
reinterpret_cast<uint16_t*>(addr) = class_id;
10916 if (
this->IsEmpty())
return 0;
10919 return *
reinterpret_cast<uint16_t*>(addr);
10924 if (other.val_ !=
nullptr) {
10927 other.val_ =
nullptr;
10934 static_assert(std::is_base_of<T, S>::value,
"type check");
10935 if (
this != &rhs) {
10937 if (rhs.val_ !=
nullptr) {
10938 this->val_ = rhs.val_;
10939 V8::MoveGlobalReference(
10942 rhs.val_ =
nullptr;
10950 DestructionMode destruction_mode) {
10951 if (that ==
nullptr)
return nullptr;
10953 return reinterpret_cast<T*>(
V8::GlobalizeTracedReference(
10954 reinterpret_cast<
internal::Isolate*>(isolate), p,
10956 destruction_mode == kWithDestructor));
10969 static_assert(std::is_base_of<T, S>::value,
"type check");
10971 if (other.IsEmpty())
return;
10972 this->val_ =
this->New(isolate, other.val_, &
this->val_,
10979 static_assert(std::is_base_of<T, S>::value,
"type check");
10980 *
this = std::move(rhs.
template As<T>());
10987 static_assert(std::is_base_of<T, S>::value,
"type check");
10988 *
this = rhs.
template As<T>();
10994 if (
this != &rhs) {
10995 V8::MoveTracedGlobalReference(
11004 if (
this != &rhs) {
11006 if (rhs.val_ !=
nullptr) {
11007 V8::CopyTracedGlobalReference(
11018 static_assert(std::is_base_of<T, S>::value,
"type check");
11020 if (other.IsEmpty())
return;
11021 this->SetSlotThreadSafe(
11022 this->New(isolate, other.val_, &
this->val_,
11029 static_assert(std::is_base_of<T, S>::value,
"type check");
11030 *
this = std::move(rhs.
template As<T>());
11038 static_assert(std::is_base_of<T, S>::value,
"type check");
11039 *
this = rhs.
template As<T>();
11045 if (
this != &rhs) {
11046 V8::MoveTracedGlobalReference(
11055 if (
this != &rhs) {
11057 if (rhs.val_ !=
nullptr) {
11058 V8::CopyTracedGlobalReference(
11072 *
reinterpret_cast<uint16_t*>(addr) = class_id;
11081 return *
reinterpret_cast<uint16_t*>(addr);
11087 V8::SetFinalizationCallbackTraced(
11088 reinterpret_cast<
internal::
Address*>(
this->val_), parameter, callback);
11091 template <
typename T>
11094 template <
typename T>
11095 template <
typename S>
11097 static_assert(std::is_base_of<T, S>::value,
"type check");
11099 *value_ = GetDefaultValue();
11105 template <
typename T>
11106 template <
typename S>
11108 static_assert(std::is_base_of<T, S>::value,
"type check");
11110 *value_ = GetDefaultValue();
11116 template <
typename T>
11117 template <
typename S>
11119 static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
11122 *value_ = GetDefaultValue();
11128 template<
typename T>
11130 static_assert(std::is_base_of<T,
Number>::value,
"type check");
11134 template<
typename T>
11136 static_assert(std::is_base_of<T,
Integer>::value,
"type check");
11145 template<
typename T>
11147 static_assert(std::is_base_of<T,
Integer>::value,
"type check");
11149 bool fits_into_int32_t = (i & (1U << 31)) == 0;
11151 Set(
static_cast<int32_t>(i));
11157 template<
typename T>
11159 static_assert(std::is_base_of<T,
Boolean>::value,
"type check");
11170 template<
typename T>
11172 static_assert(std::is_base_of<T,
Primitive>::value,
"type check");
11177 template<
typename T>
11179 static_assert(std::is_base_of<T,
Primitive>::value,
"type check");
11184 template<
typename T>
11186 static_assert(std::is_base_of<T,
String>::value,
"type check");
11191 template <
typename T>
11194 return *
reinterpret_cast<
Isolate**>(&value_[-2]);
11197 template <
typename T>
11205 template <
typename T>
11206 template <
typename S>
11208 static_assert(
sizeof(S) < 0,
"incompilable to prevent inadvertent misuse");
11211 template <
typename T>
11217 template <
typename T>
11223 template<
typename T>
11227 #ifdef V8_REVERSE_JSARGS
11228 return Local<Value>(
reinterpret_cast<Value*>(values_ + i));
11235 template<
typename T>
11238 #ifdef V8_REVERSE_JSARGS
11239 return Local<Object>(
reinterpret_cast<Object*>(values_ - 1));
11246 template<
typename T>
11252 template <
typename T>
11258 template <
typename T>
11264 template<
typename T>
11270 template<
typename T>
11276 template<
typename T>
11282 template<
typename T>
11296 : resource_name_(resource_name),
11297 resource_line_offset_(resource_line_offset),
11298 resource_column_offset_(resource_column_offset),
11299 options_
(!resource_is_shared_cross_origin
.IsEmpty() &&
11304 script_id_(script_id),
11305 source_map_url_(source_map_url),
11306 host_defined_options_(host_defined_options) {}
11311 return host_defined_options_;
11315 return resource_line_offset_;
11320 return resource_column_offset_;
11331 : source_string(string),
11338 cached_data(data) {}
11342 : source_string(string), cached_data(data) {}
11346 delete cached_data;
11352 return cached_data;
11356 return resource_options;
11370 #ifdef V8_ENABLE_CHECKS
11377 #ifdef V8_ENABLE_CHECKS
11384 #ifdef V8_ENABLE_CHECKS
11387 return reinterpret_cast<
Signature*>(data);
11391 #ifdef V8_ENABLE_CHECKS
11398 #ifndef V8_ENABLE_CHECKS
11401 A obj = *
reinterpret_cast<A*>(
this);
11410 #ifdef V8_COMPRESS_POINTERS
11413 value = I::DecompressTaggedAnyField(obj,
static_cast<uint32_t>(value));
11421 return SlowGetInternalField(index);
11426 #ifndef V8_ENABLE_CHECKS
11429 A obj = *
reinterpret_cast<A*>(
this);
11439 return reinterpret_cast<
void*>(value);
11442 return SlowGetAlignedPointerFromInternalField(index);
11446 #ifdef V8_ENABLE_CHECKS
11449 return static_cast<
String*>(value);
11465 A obj = *
reinterpret_cast<
const A*>(
this);
11474 result = GetExternalStringResourceSlow();
11476 #ifdef V8_ENABLE_CHECKS
11477 VerifyExternalStringResource(result);
11487 A obj = *
reinterpret_cast<
const A*>(
this);
11498 resource = GetExternalStringResourceBaseSlow(encoding_out);
11500 #ifdef V8_ENABLE_CHECKS
11501 VerifyExternalStringResourceBase(resource, *encoding_out);
11508 #ifdef V8_ENABLE_CHECKS
11509 return FullIsUndefined();
11511 return QuickIsUndefined();
11515 bool Value::QuickIsUndefined()
const {
11518 A obj = *
reinterpret_cast<
const A*>(
this);
11526 #ifdef V8_ENABLE_CHECKS
11527 return FullIsNull();
11529 return QuickIsNull();
11533 bool Value::QuickIsNull()
const {
11536 A obj = *
reinterpret_cast<
const A*>(
this);
11543 #ifdef V8_ENABLE_CHECKS
11544 return FullIsNull() || FullIsUndefined();
11546 return QuickIsNullOrUndefined();
11550 bool Value::QuickIsNullOrUndefined()
const {
11553 A obj = *
reinterpret_cast<
const A*>(
this);
11561 #ifdef V8_ENABLE_CHECKS
11562 return FullIsString();
11564 return QuickIsString();
11568 bool Value::QuickIsString()
const {
11571 A obj = *
reinterpret_cast<
const A*>(
this);
11578 return static_cast<
Value*>(value);
11583 #ifdef V8_ENABLE_CHECKS
11586 return static_cast<
Boolean*>(value);
11591 #ifdef V8_ENABLE_CHECKS
11594 return static_cast<
Name*>(value);
11599 #ifdef V8_ENABLE_CHECKS
11602 return static_cast<
Symbol*>(value);
11607 #ifdef V8_ENABLE_CHECKS
11610 return reinterpret_cast<
Private*>(data);
11615 #ifdef V8_ENABLE_CHECKS
11618 return static_cast<
Number*>(value);
11623 #ifdef V8_ENABLE_CHECKS
11626 return static_cast<
Integer*>(value);
11631 #ifdef V8_ENABLE_CHECKS
11634 return static_cast<
Int32*>(value);
11639 #ifdef V8_ENABLE_CHECKS
11642 return static_cast<
Uint32*>(value);
11646 #ifdef V8_ENABLE_CHECKS
11649 return static_cast<
BigInt*>(value);
11653 #ifdef V8_ENABLE_CHECKS
11656 return static_cast<
Date*>(value);
11661 #ifdef V8_ENABLE_CHECKS
11669 #ifdef V8_ENABLE_CHECKS
11677 #ifdef V8_ENABLE_CHECKS
11684 #ifdef V8_ENABLE_CHECKS
11691 #ifdef V8_ENABLE_CHECKS
11699 #ifdef V8_ENABLE_CHECKS
11702 return static_cast<
RegExp*>(value);
11707 #ifdef V8_ENABLE_CHECKS
11710 return static_cast<
Object*>(value);
11715 #ifdef V8_ENABLE_CHECKS
11718 return static_cast<
Array*>(value);
11723 #ifdef V8_ENABLE_CHECKS
11726 return static_cast<
Map*>(value);
11731 #ifdef V8_ENABLE_CHECKS
11734 return static_cast<
Set*>(value);
11739 #ifdef V8_ENABLE_CHECKS
11742 return static_cast<
Promise*>(value);
11747 #ifdef V8_ENABLE_CHECKS
11750 return static_cast<
Proxy*>(value);
11754 #ifdef V8_ENABLE_CHECKS
11761 #ifdef V8_ENABLE_CHECKS
11769 #ifdef V8_ENABLE_CHECKS
11777 #ifdef V8_ENABLE_CHECKS
11785 #ifdef V8_ENABLE_CHECKS
11793 #ifdef V8_ENABLE_CHECKS
11801 #ifdef V8_ENABLE_CHECKS
11809 #ifdef V8_ENABLE_CHECKS
11817 #ifdef V8_ENABLE_CHECKS
11825 #ifdef V8_ENABLE_CHECKS
11833 #ifdef V8_ENABLE_CHECKS
11841 #ifdef V8_ENABLE_CHECKS
11849 #ifdef V8_ENABLE_CHECKS
11856 #ifdef V8_ENABLE_CHECKS
11863 #ifdef V8_ENABLE_CHECKS
11870 #ifdef V8_ENABLE_CHECKS
11878 #ifdef V8_ENABLE_CHECKS
11881 return static_cast<
DataView*>(value);
11886 #ifdef V8_ENABLE_CHECKS
11894 #ifdef V8_ENABLE_CHECKS
11897 return static_cast<
Function*>(value);
11902 #ifdef V8_ENABLE_CHECKS
11905 return static_cast<
External*>(value);
11909 template<
typename T>
11915 template<
typename T>
11921 template<
typename T>
11927 template<
typename T>
11933 template<
typename T>
11938 template <
typename T>
12004 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12005 if (data)
internal::PerformCastCheck(data);
12006 return Local<T>(data);
12010 #ifndef V8_ENABLE_CHECKS
12013 A ctx = *
reinterpret_cast<
const A*>(
this);
12019 #ifdef V8_COMPRESS_POINTERS
12023 I::DecompressTaggedAnyField(embedder_data,
static_cast<uint32_t>(value));
12026 *
reinterpret_cast<A*>(
this)
);
12030 return SlowGetEmbedderData(index);
12036 #ifndef V8_ENABLE_CHECKS
12039 A ctx = *
reinterpret_cast<
const A*>(
this);
12045 return reinterpret_cast<
void*>(
12048 return SlowGetAlignedPointerFromEmbedderData(index);
12054 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12055 if (data)
internal::PerformCastCheck(data);
12056 return Local<T>(data);
12061 T* object_ptr = *object;
12063 return AddData(context, *p);
12068 T* object_ptr = *object;
12070 return AddData(*p);