25 #include <type_traits>
29 #include "cppgc/common.h"
50 class CallHandlerHelper;
61 class ImplementationUtilities;
71 class ObjectOperationDescriptor;
80 class RawOperationDescriptor;
97 template <
class K,
class V,
class T>
99 template <
class K,
class V,
class T>
101 template<
class T>
class NonCopyablePersistentTraits;
102 template <
class T,
class M = NonCopyablePersistentTraits<T>>
121 template<
class T,
class P>
class WeakCallbackObject;
124 template <
class V,
class T>
131 class BackgroundDeserializeTask;
132 class BasicTracedReferenceExtractor;
133 class ExternalString;
134 class FunctionCallbackArguments;
139 class LocalEmbedderHeapTracer;
140 class MicrotaskQueue;
141 class PropertyCallbackArguments;
143 class ScopedExternalStringLock;
144 class ThreadLocalTop;
145 struct ScriptStreamingData;
146 enum class ArgumentsType;
147 template <ArgumentsType>
149 template <
typename T>
154 class StreamingDecoder;
164 class ConsoleCallArguments;
206 : val_(
reinterpret_cast<T*>(*that)) {
212 static_assert(std::is_base_of<T, S>::value,
"type check");
243 if (a ==
nullptr)
return b ==
nullptr;
244 if (b ==
nullptr)
return false;
252 if (a ==
nullptr)
return b ==
nullptr;
253 if (b ==
nullptr)
return false;
269 return !operator==(that);
274 return !operator==(that);
283 #ifdef V8_ENABLE_CHECKS
286 if (that.IsEmpty())
return Local<T>();
288 return Local<T>(T::Cast(*that));
298 return Local<S>::Cast(*
this);
318 template<
class F>
friend class Local;
335 template <
class F1,
class F2,
class F3>
349 explicit V8_INLINE Local(T* that) : val_(that) {}
355 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
378 : val_(
reinterpret_cast<T*>(*that)) {
379 static_assert(std::is_base_of<T, S>::value,
"type check");
390 out->val_ =
IsEmpty() ?
nullptr :
this->val_;
422 Set(isolate, handle);
434 static const int kInternalFieldsInWeakCallback = 2;
435 static const int kEmbedderFieldsInWeakCallback = 2;
437 template <
typename T>
443 void* embedder_fields[kEmbedderFieldsInWeakCallback],
445 : isolate_(isolate), parameter_(parameter), callback_(callback) {
446 for (
int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
447 embedder_fields_[i] = embedder_fields[i];
467 void* embedder_fields_[kEmbedderFieldsInWeakCallback];
516 return Local<T>::New(isolate, *
this);
523 if (a ==
nullptr)
return b ==
nullptr;
524 if (b ==
nullptr)
return false;
532 if (a ==
nullptr)
return b ==
nullptr;
533 if (b ==
nullptr)
return false;
539 return !operator==(that);
544 return !operator==(that);
559 template <
typename P>
607 template<
class F>
friend class Local;
613 template <
class F1,
class F2,
class F3>
618 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
632 class NonCopyablePersistentTraits {
634 using NonCopyablePersistent =
Persistent<T, NonCopyablePersistentTraits<T>>;
636 template<
class S,
class M>
638 NonCopyablePersistent* dest) {
639 static_assert(
sizeof(S) < 0,
640 "NonCopyablePersistentTraits::Copy is not instantiable");
653 template<
class S,
class M>
655 CopyablePersistent* dest) {
683 static_assert(std::is_base_of<T, S>::value,
"type check");
690 template <
class S,
class M2>
693 static_assert(std::is_base_of<T, S>::value,
"type check");
704 template <
class S,
class M2>
712 template <
class S,
class M2>
723 if (M::kResetInDestructor)
this->Reset();
729 #ifdef V8_ENABLE_CHECKS
732 if (!that.IsEmpty()) T::Cast(*that);
746 template<
class F>
friend class Local;
751 V8_INLINE T* operator*()
const {
return this->val_; }
752 template<
class S,
class M2>
778 static_assert(std::is_base_of<T, S>::value,
"type check");
789 static_assert(std::is_base_of<T, S>::value,
"type check");
813 using MoveOnlyTypeForCPP03 =
void;
821 V8_INLINE T* operator*()
const {
return this->val_; }
832 template <
typename T>
878 reinterpret_cast<std::atomic<
void*>*>(&
val_)->store(
879 new_val, std::memory_order_relaxed);
886 return reinterpret_cast<std::atomic<
const void*>
const*>(&
val_)->load(
887 std::memory_order_relaxed);
895 friend class internal::BasicTracedReferenceExtractor;
896 template <
typename F>
898 template <
typename U>
919 template <
typename T>
934 #ifdef V8_ENABLE_CHECKS
937 return reinterpret_cast<T*>(
val_);
940 #ifdef V8_ENABLE_CHECKS
943 return reinterpret_cast<T*>(
val_);
947 enum DestructionMode { kWithDestructor, kWithoutDestructor };
952 BasicTracedReference() =
default;
955 DestructionMode destruction_mode);
958 template <
typename F>
961 template <
typename F>
963 template <
typename F>
965 template <
typename F>
967 template <
typename F>
975 template <
typename T>
998 this->val_ =
this->New(isolate, that.val_, &
this->val_,
1000 static_assert(std::is_base_of<T, S>::value,
"type check");
1008 *
this = std::move(other);
1014 template <
typename S>
1017 *
this = std::move(other);
1031 template <
typename S>
1103 template <
typename T>
1121 this->val_ =
this->New(isolate, that.val_, &
this->val_,
1123 static_assert(std::is_base_of<T, S>::value,
"type check");
1132 *
this = std::move(other);
1139 template <
typename S>
1142 *
this = std::move(other);
1158 template <
typename S>
1226 return reinterpret_cast<
Isolate*>(isolate_);
1243 void* operator
new(size_t size);
1244 void* operator
new[](size_t size);
1245 void operator
delete(
void*, size_t);
1246 void operator
delete[](
void*, size_t);
1278 return Local<T>(
reinterpret_cast<T*>(slot));
1283 return Escape(value.FromMaybe(
Local<T>()));
1292 void* operator
new(size_t size);
1293 void* operator
new[](size_t size);
1294 void operator
delete(
void*, size_t);
1295 void operator
delete[](
void*, size_t);
1317 void* operator
new(size_t size);
1318 void* operator
new[](size_t size);
1319 void operator
delete(
void*, size_t);
1320 void operator
delete[](
void*, size_t);
1324 int prev_sealed_level_;
1411 bool is_opaque =
false,
bool is_wasm =
false,
1412 bool is_module =
false)
1413 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1414 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1415 (is_module ? kIsModule : 0)) {}
1418 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1421 return (flags_ & kIsSharedCrossOrigin) != 0;
1423 bool IsOpaque()
const {
return (flags_ & kIsOpaque) != 0; }
1424 bool IsWasm()
const {
return (flags_ & kIsWasm) != 0; }
1425 bool IsModule()
const {
return (flags_ & kIsModule) != 0; }
1431 kIsSharedCrossOrigin = 1,
1457 Local<
Value> resource_name,
int resource_line_offset = 0,
1458 int resource_column_offset = 0,
1459 bool resource_is_shared_cross_origin =
false,
int script_id = -1,
1461 bool resource_is_opaque =
false,
bool is_wasm =
false,
1462 bool is_module =
false,
1466 int resource_line_offset = 0,
int resource_column_offset = 0,
1467 bool resource_is_shared_cross_origin =
false,
int script_id = -1,
1469 bool resource_is_opaque =
false,
bool is_wasm =
false,
1470 bool is_module =
false,
1490 int resource_line_offset_;
1491 int resource_column_offset_;
1545 : line_number_(line_number), column_number_(column_number) {}
1593 static void CheckCast(
Data* obj);
1631 int GetModuleRequestsLength()
const;
1638 "Use Module::GetModuleRequests() and ModuleRequest::GetSpecifier().")
1646 "Use Module::GetModuleRequests(), ModuleRequest::GetSourceOffset(), and "
1647 "Module::SourceOffsetToLocation().")
1648 Location GetModuleRequestLocation(
int i)
const;
1681 "Use the version of InstantiateModule that takes a ResolveModuleCallback "
1686 Local<
Context> context, ResolveModuleCallback callback);
1747 using SyntheticModuleEvaluationSteps =
1760 SyntheticModuleEvaluationSteps evaluation_steps);
1775 static void CheckCast(
Data* obj);
1811 class ConsumeCodeCacheTask;
1859 ConsumeCodeCacheTask* consume_cache_task =
nullptr);
1863 ConsumeCodeCacheTask* consume_cache_task =
nullptr);
1880 int resource_line_offset;
1881 int resource_column_offset;
1890 std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
1963 std::unique_ptr<
internal::ScriptStreamingData> impl_;
1977 explicit ScriptStreamingTask(
internal::ScriptStreamingData* data)
1980 internal::ScriptStreamingData* data_;
1997 explicit ConsumeCodeCacheTask(
1998 std::unique_ptr<
internal::BackgroundDeserializeTask> impl);
2000 std::unique_ptr<
internal::BackgroundDeserializeTask> impl_;
2149 Local<
String> arguments[], size_t context_extension_count,
2429 struct CalleeSavedRegisters;
2550 size_t* actual_size);
2616 PrivateData* private_;
2641 Isolate* isolate, uint32_t transfer_id);
2648 Isolate* isolate, uint32_t clone_id);
2713 PrivateData* private_;
3127 V8_INLINE bool QuickIsUndefined()
const;
3129 V8_INLINE bool QuickIsNullOrUndefined()
const;
3131 bool FullIsUndefined()
const;
3132 bool FullIsNull()
const;
3133 bool FullIsString()
const;
3135 static void CheckCast(
Data* that);
3156 static void CheckCast(
v8::
Data* that);
3177 static void CheckCast(
Data* that);
3276 int Write(
Isolate* isolate, uint16_t* buffer,
int start = 0,
int length = -1,
3280 int length = -1,
int options =
NO_OPTIONS)
const;
3283 int* nchars_ref =
nullptr,
int options =
NO_OPTIONS)
const;
3374 virtual const uint16_t*
data()
const = 0;
3387 CheckCachedDataInvariants();
3388 return cached_data_;
3401 void CheckCachedDataInvariants()
const;
3403 const uint16_t* cached_data_ =
nullptr;
3429 virtual const char*
data()
const = 0;
3440 CheckCachedDataInvariants();
3441 return cached_data_;
3454 void CheckCachedDataInvariants()
const;
3456 const char* cached_data_ =
nullptr;
3492 Isolate* isolate,
const char (&literal)[N],
3494 static_assert(N <=
kMaxLength,
"String is too long");
3495 return NewFromUtf8Literal(isolate, literal, type, N - 1);
3501 Isolate* isolate,
const char* data,
3507 Isolate* isolate,
const uint8_t* data,
3513 Isolate* isolate,
const uint16_t* data,
3633 const char* literal,
3636 static void CheckCast(
v8::
Data* that);
3699 static void CheckCast(
Data* that);
3737 static void CheckCast(
Data* that);
3752 static void CheckCast(
v8::
Data* that);
3768 static void CheckCast(
v8::
Data* that);
3782 static void CheckCast(
v8::
Data* that);
3796 static void CheckCast(
v8::
Data* that);
3814 int word_count,
const uint64_t* words);
3851 static void CheckCast(
v8::
Data* that);
3873 using AccessorGetterCallback =
3875 using AccessorNameGetterCallback =
3881 using AccessorNameSetterCallback =
4061 AccessorNameGetterCallback getter,
4062 AccessorNameSetterCallback setter =
nullptr,
4079 AccessorNameGetterCallback getter,
4080 AccessorNameSetterCallback setter =
nullptr,
4325 "Use MaybeLocal<Context> GetCreationContext(const "
4326 "PersistentBase<Object>& object)")
4422 static void CheckCast(
Value* obj);
4423 Local<
Value> SlowGetInternalField(
int index);
4424 void* SlowGetAlignedPointerFromInternalField(
int index);
4451 static void CheckCast(
Value* obj);
4487 static void CheckCast(
Value* obj);
4519 static void CheckCast(
Value* obj);
4523 template<
typename T>
4527 : value_(that.value_) {
4528 static_assert(std::is_base_of<T, S>::value,
"type check");
4531 template <
typename S>
4533 template <
typename S>
4535 template <
typename S>
4550 template <
typename S>
4562 template <
class F,
class G,
class H>
4577 template<
typename T>
4616 friend class debug::ConsoleCallArguments;
4636 template<
typename T>
4728 friend class MacroAssembler;
4837 static void CheckCast(
Value* obj);
4840 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
4842 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0
4883 static void CheckCast(
Value* obj);
4936 static void CheckCast(
Value* obj);
5009 PrivateData* private_;
5034 static void CheckCast(
Value* obj);
5047 template <
typename T>
5053 constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
5056 constexpr T*
data()
const {
return data_; }
5058 constexpr size_t
size()
const {
return size_; }
5095 friend class WasmStreaming;
5097 explicit CompiledWasmModule(std::shared_ptr<
internal::
wasm::NativeModule>,
5098 const char* source_url, size_t url_length);
5100 const std::shared_ptr<
internal::
wasm::NativeModule> native_module_;
5101 const std::string source_url_;
5117 static void CheckCast(
Value* object);
5141 static void CheckCast(
Value* obj);
5152 class WasmStreamingImpl;
5221 std::unique_ptr<WasmStreamingImpl> impl_;
5245 WasmModuleObjectBuilderStreaming(
const WasmModuleObjectBuilderStreaming&) =
5247 WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
5249 WasmModuleObjectBuilderStreaming& operator=(
5250 const WasmModuleObjectBuilderStreaming&) =
delete;
5251 WasmModuleObjectBuilderStreaming& operator=(
5252 WasmModuleObjectBuilderStreaming&&) =
default;
5263 Persistent<Promise, CopyablePersistentTraits<Promise>> promise_;
5267 std::shared_ptr<
internal::
wasm::StreamingDecoder> streaming_decoder_;
5270 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
5272 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
5318 void operator delete(
void* ptr) { ::operator
delete(ptr); }
5327 size_t byte_length);
5334 using DeleterCallback =
void (*)(
void* data, size_t length,
5335 void* deleter_data);
5356 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
5358 using BackingStoreDeleterCallback =
void (*)(
void* data, size_t length,
5359 void* deleter_data);
5403 virtual void Free(
void* data, size_t length) = 0;
5417 virtual void*
Reallocate(
void* data, size_t old_length, size_t new_length);
5473 size_t byte_length);
5483 void* data, size_t byte_length,
v8::
BackingStore::DeleterCallback deleter,
5484 void* deleter_data);
5514 static void CheckCast(
Value* obj);
5518 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
5520 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
5569 static void CheckCast(
Value* obj);
5585 :
static_cast<size_t>(uint64_t{1} << 32);
5597 static void CheckCast(
Value* obj);
5607 size_t byte_offset, size_t length);
5609 size_t byte_offset, size_t length);
5614 static void CheckCast(
Value* obj);
5624 size_t byte_offset, size_t length);
5631 Uint8ClampedArray();
5632 static void CheckCast(
Value* obj);
5641 size_t byte_offset, size_t length);
5643 size_t byte_offset, size_t length);
5648 static void CheckCast(
Value* obj);
5658 size_t byte_offset, size_t length);
5660 size_t byte_offset, size_t length);
5665 static void CheckCast(
Value* obj);
5675 size_t byte_offset, size_t length);
5677 size_t byte_offset, size_t length);
5682 static void CheckCast(
Value* obj);
5692 size_t byte_offset, size_t length);
5694 size_t byte_offset, size_t length);
5699 static void CheckCast(
Value* obj);
5709 size_t byte_offset, size_t length);
5711 size_t byte_offset, size_t length);
5716 static void CheckCast(
Value* obj);
5726 size_t byte_offset, size_t length);
5728 size_t byte_offset, size_t length);
5733 static void CheckCast(
Value* obj);
5743 size_t byte_offset, size_t length);
5745 size_t byte_offset, size_t length);
5750 static void CheckCast(
Value* obj);
5759 size_t byte_offset, size_t length);
5761 size_t byte_offset, size_t length);
5766 static void CheckCast(
Value* obj);
5775 size_t byte_offset, size_t length);
5777 size_t byte_offset, size_t length);
5782 static void CheckCast(
Value* obj);
5791 size_t byte_offset, size_t length);
5793 size_t byte_offset, size_t length);
5798 static void CheckCast(
Value* obj);
5845 size_t byte_length);
5855 void* data, size_t byte_length,
v8::
BackingStore::DeleterCallback deleter,
5856 void* deleter_data);
5871 SharedArrayBuffer();
5872 static void CheckCast(
Value* obj);
5893 static void CheckCast(
Value* obj);
5909 static void CheckCast(
Value* obj);
5924 static void CheckCast(
Value* obj);
5939 static void CheckCast(
Value* obj);
5955 static void CheckCast(
Value* obj);
5971 static void CheckCast(
Value* obj);
6023 uint32_t backtrack_limit);
6053 static void CheckCast(
Value* obj);
6066 static void CheckCast(
v8::
Value* obj);
6069 #define V8_INTRINSICS_LIST(F)
6070 F(ArrayProto_entries, array_entries_iterator)
6071 F(ArrayProto_forEach, array_for_each_iterator)
6072 F(ArrayProto_keys, array_keys_iterator)
6073 F(ArrayProto_values, array_values_iterator)
6074 F(AsyncIteratorPrototype, initial_async_iterator_prototype)
6075 F(ErrorPrototype, initial_error_prototype)
6076 F(IteratorPrototype, initial_iterator_prototype)
6077 F(ObjProto_valueOf, object_value_of_function)
6080 #define V8_DECL_INTRINSIC(name, iname) k##name,
6082 #undef V8_DECL_INTRINSIC
6141 Local<
String> name, AccessorGetterCallback getter,
6142 AccessorSetterCallback setter =
nullptr,
6149 Local<
Name> name, AccessorNameGetterCallback getter,
6150 AccessorNameSetterCallback setter =
nullptr,
6162 Local<
Name> name, AccessorNameGetterCallback getter,
6220 using GenericNamedPropertyGetterCallback =
6244 using GenericNamedPropertySetterCallback =
6269 using GenericNamedPropertyQueryCallback =
6293 using GenericNamedPropertyDeleterCallback =
6302 using GenericNamedPropertyEnumeratorCallback =
6325 using GenericNamedPropertyDefinerCallback =
6348 using GenericNamedPropertyDescriptorCallback =
6354 using IndexedPropertyGetterCallback =
6360 using IndexedPropertySetterCallback =
6367 using IndexedPropertyQueryCallback =
6373 using IndexedPropertyDeleterCallback =
6382 using IndexedPropertyEnumeratorCallback =
6388 using IndexedPropertyDefinerCallback =
6395 using IndexedPropertyDescriptorCallback =
6529 Isolate* isolate, FunctionCallback callback =
nullptr,
6534 const CFunction* c_function =
nullptr, uint16_t instance_type = 0,
6535 uint16_t allowed_receiver_instance_type_range_start = 0,
6536 uint16_t allowed_receiver_instance_type_range_end = 0);
6540 Isolate* isolate, FunctionCallback callback =
nullptr,
6551 Isolate* isolate, FunctionCallback callback,
6653 static void CheckCast(
Data* that);
6693 GenericNamedPropertyGetterCallback getter,
6694 GenericNamedPropertySetterCallback setter,
6695 GenericNamedPropertyQueryCallback query,
6696 GenericNamedPropertyDeleterCallback deleter,
6697 GenericNamedPropertyEnumeratorCallback enumerator,
6698 GenericNamedPropertyDefinerCallback definer,
6699 GenericNamedPropertyDescriptorCallback descriptor,
6714 GenericNamedPropertyGetterCallback getter =
nullptr,
6715 GenericNamedPropertySetterCallback setter =
nullptr,
6716 GenericNamedPropertyQueryCallback query =
nullptr,
6717 GenericNamedPropertyDeleterCallback deleter =
nullptr,
6718 GenericNamedPropertyEnumeratorCallback enumerator =
nullptr,
6732 GenericNamedPropertyGetterCallback getter,
6733 GenericNamedPropertySetterCallback setter,
6734 GenericNamedPropertyDescriptorCallback descriptor,
6735 GenericNamedPropertyDeleterCallback deleter,
6736 GenericNamedPropertyEnumeratorCallback enumerator,
6737 GenericNamedPropertyDefinerCallback definer,
6752 GenericNamedPropertyQueryCallback
query;
6764 IndexedPropertyGetterCallback getter,
6765 IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query,
6766 IndexedPropertyDeleterCallback deleter,
6767 IndexedPropertyEnumeratorCallback enumerator,
6768 IndexedPropertyDefinerCallback definer,
6769 IndexedPropertyDescriptorCallback descriptor,
6784 IndexedPropertyGetterCallback getter =
nullptr,
6785 IndexedPropertySetterCallback setter =
nullptr,
6786 IndexedPropertyQueryCallback query =
nullptr,
6787 IndexedPropertyDeleterCallback deleter =
nullptr,
6788 IndexedPropertyEnumeratorCallback enumerator =
nullptr,
6802 IndexedPropertyGetterCallback getter,
6803 IndexedPropertySetterCallback setter,
6804 IndexedPropertyDescriptorCallback descriptor,
6805 IndexedPropertyDeleterCallback deleter,
6806 IndexedPropertyEnumeratorCallback enumerator,
6807 IndexedPropertyDefinerCallback definer,
6878 Local<
String> name, AccessorGetterCallback getter,
6879 AccessorSetterCallback setter =
nullptr,
6886 Local<
Name> name, AccessorNameGetterCallback getter,
6887 AccessorNameSetterCallback setter =
nullptr,
6925 IndexedPropertyGetterCallback getter,
6926 IndexedPropertySetterCallback setter =
nullptr,
6927 IndexedPropertyQueryCallback query =
nullptr,
6928 IndexedPropertyDeleterCallback deleter =
nullptr,
6929 IndexedPropertyEnumeratorCallback enumerator =
nullptr,
6932 deleter
, enumerator
, data
));
6984 AccessCheckCallback callback,
7030 static void CheckCast(
Data* that);
7053 static void CheckCast(
Data* that);
7070 AccessorSignature();
7072 static void CheckCast(
Data* that);
7085 Extension(
const char* name,
const char* source =
nullptr,
int dep_count = 0,
7086 const char** deps =
nullptr,
int source_length = -1);
7093 const char*
name()
const {
return name_; }
7109 size_t source_length_;
7160 size_t maximum_heap_size_in_bytes);
7172 uint64_t virtual_memory_limit);
7200 return max_old_generation_size_;
7203 max_old_generation_size_ = limit;
7212 return max_young_generation_size_;
7215 max_young_generation_size_ = limit;
7219 return initial_old_generation_size_;
7222 initial_old_generation_size_ = initial_size;
7226 return initial_young_generation_size_;
7229 initial_young_generation_size_ = initial_size;
7233 static constexpr size_t kMB = 1048576u;
7234 size_t code_range_size_ = 0;
7235 size_t max_old_generation_size_ = 0;
7236 size_t max_young_generation_size_ = 0;
7237 size_t initial_old_generation_size_ = 0;
7238 size_t initial_young_generation_size_ = 0;
7239 uint32_t* stack_limit_ =
nullptr;
7245 using FatalErrorCallback =
void (*)(
const char* location,
const char* message);
7247 using OOMErrorCallback =
void (*)(
const char* location,
bool is_heap_oom);
7249 using DcheckErrorCallback =
void (*)(
const char* file,
int line,
7250 const char* message);
7257 using LogEventCallback =
void (*)(
const char* name,
7292 using CounterLookupCallback =
int* (*)(
const char* name);
7294 using CreateHistogramCallback =
void* (*)(
const char* name,
int min,
int max,
7297 using AddHistogramSampleCallback =
void (*)(
void* histogram,
int sample);
7308 using AddCrashKeyCallback =
void (*)(
CrashKeyId id,
const std::string& value);
7311 using BeforeCallEnteredCallback =
void (*)(
Isolate*);
7335 "Use HostImportModuleDynamicallyWithImportAssertionsCallback instead") =
7366 using HostImportModuleDynamicallyWithImportAssertionsCallback =
7382 using HostInitializeImportMetaObjectCallback =
void (*)(
Local<
Context> context,
7430 : promise_(promise), event_(event), value_(value) {}
7445 using MicrotasksCompletedCallbackWithData =
void (*)(
Isolate*,
void*);
7446 using MicrotaskCallback =
void (*)(
void* data);
7493 MicrotaskCallback callback,
7494 void* data =
nullptr) = 0;
7509 MicrotasksCompletedCallbackWithData callback,
void* data =
nullptr) = 0;
7515 MicrotasksCompletedCallbackWithData callback,
void* data =
nullptr) = 0;
7538 MicrotaskQueue() =
default;
7579 internal::MicrotaskQueue*
const microtask_queue_;
7593 using AllowCodeGenerationFromStringsCallback =
bool (*)(
Local<
Context> context,
7609 using ModifyCodeGenerationFromStringsCallback =
7612 using ModifyCodeGenerationFromStringsCallback2 =
7641 using SharedArrayBufferConstructorEnabledCallback =
7688 using InterruptCallback =
void (*)(
Isolate* isolate,
void* data);
7697 using NearHeapLimitCallback = size_t (*)(
void* data, size_t current_heap_limit,
7698 size_t initial_heap_limit);
7712 return read_only_space_physical_size_;
7716 size_t read_only_space_size_;
7717 size_t read_only_space_used_size_;
7718 size_t read_only_space_physical_size_;
7754 size_t total_heap_size_;
7755 size_t total_heap_size_executable_;
7756 size_t total_physical_size_;
7757 size_t total_available_size_;
7758 size_t used_heap_size_;
7759 size_t heap_size_limit_;
7760 size_t malloced_memory_;
7761 size_t external_memory_;
7762 size_t peak_malloced_memory_;
7763 bool does_zap_garbage_;
7764 size_t number_of_native_contexts_;
7765 size_t number_of_detached_contexts_;
7766 size_t total_global_handles_size_;
7767 size_t used_global_handles_size_;
7784 const char* space_name_;
7786 size_t space_used_size_;
7787 size_t space_available_size_;
7788 size_t physical_space_size_;
7803 const char* object_type_;
7804 const char* object_sub_type_;
7805 size_t object_count_;
7806 size_t object_size_;
7819 size_t code_and_metadata_size_;
7820 size_t bytecode_and_metadata_size_;
7821 size_t external_script_source_size_;
7957 #if defined(V8_OS_WIN)
7978 uint16_t class_id) {}
8093 "This call only optimized internal caches which V8 is able to figure out "
8095 void NotifyEmptyEmbedderStack();
8104 const std::vector<std::pair<
void*,
void*> >& embedder_fields) = 0;
8210 void* data_arg =
nullptr)
8227 void* data_arg =
nullptr)
8278 context_sizes_in_bytes,
8279 size_t unattributed_size_in_bytes) = 0;
8424 bool was_execution_allowed_assert_;
8425 bool was_execution_allowed_throws_;
8426 bool was_execution_allowed_dump_;
8445 bool was_execution_allowed_assert_;
8446 bool was_execution_allowed_throws_;
8447 bool was_execution_allowed_dump_;
8468 internal::MicrotaskQueue*
const microtask_queue_;
8637 using UseCounterCallback =
void (*)(
Isolate* isolate,
8712 using AbortOnUncaughtExceptionCallback =
bool (*)(
Isolate*);
8714 AbortOnUncaughtExceptionCallback callback);
8721 "Use the version of SetHostImportModuleDynamicallyCallback that takes a "
8722 "HostImportModuleDynamicallyWithImportAssertionsCallback instead")
8723 void SetHostImportModuleDynamicallyCallback(
8724 HostImportModuleDynamicallyCallback callback);
8731 HostImportModuleDynamicallyWithImportAssertionsCallback callback);
8738 HostInitializeImportMetaObjectCallback callback);
8906 size_t frames_limit,
SampleInfo* sample_info);
8973 return ThrowError(
String::NewFromUtf8Literal(
this, message));
9123 size_t offset_in_bytes, int64_t value,
9124 double timeout_in_ms,
9155 void* data =
nullptr);
9158 using GetExternallyAllocatedMemoryInBytesCallback = size_t (*)();
9167 GetExternallyAllocatedMemoryInBytesCallback callback);
9319 MicrotasksCompletedCallbackWithData callback,
void* data =
nullptr);
9325 MicrotasksCompletedCallbackWithData callback,
void* data =
nullptr);
9477 JitCodeEventHandler event_handler);
9571 ModifyCodeGenerationFromStringsCallback2 callback);
9578 AllowWasmCodeGenerationCallback callback);
9596 SharedArrayBufferConstructorEnabledCallback callback);
9651 bool capture,
int frame_limit = 10,
9738 template <
class K,
class V,
class Traits>
9742 void ReportExternalAllocationLimitReached();
9767 using EntropySource =
bool (*)(
unsigned char* buffer, size_t length);
9782 using ReturnAddressLocationResolver =
9783 uintptr_t (*)(uintptr_t return_addr_location);
9832 const int kBuildConfiguration =
9836 return Initialize(kBuildConfiguration);
9850 ReturnAddressLocationResolver return_address_resolver);
9885 const char* icu_data_file =
nullptr);
9925 #if defined(V8_OS_WIN)
9947 enum BuildConfigurationFeatures {
9948 kPointerCompression = 1 << 0,
9949 k31BitSmis = 1 << 1,
9950 kHeapSandbox = 1 << 2,
9957 static bool Initialize(
int build_config);
9964 bool has_destructor);
9969 static void CopyTracedGlobalReference(
const internal::
Address*
const* from,
9979 static void SetFinalizationCallbackTraced(
9986 template <
class K,
class V,
class T>
9989 static void FromJustIsNothing();
9990 static void ToLocalEmpty();
9991 static void InternalFieldOutOfBounds(
int index);
10035 const intptr_t* external_references =
nullptr,
10174 return has_value_ ? value_ : default_value;
10178 return (
IsJust() == other.IsJust()) &&
10187 Maybe() : has_value_(
false) {}
10188 explicit Maybe(
const T& t) : has_value_(
true), value_(t) {}
10206 return Maybe<T>(t);
10227 Maybe() : is_valid_(
false) {}
10228 explicit Maybe(JustTag) : is_valid_(
true) {}
10367 if (handler ==
nullptr)
return nullptr;
10368 return handler->js_stack_comparable_address_;
10377 void* operator
new(size_t size);
10378 void* operator
new[](size_t size);
10379 void operator
delete(
void*, size_t);
10380 void operator
delete[](
void*, size_t);
10382 void ResetInternal();
10387 void* message_obj_;
10388 void* js_stack_comparable_address_;
10389 bool is_verbose_ : 1;
10390 bool can_continue_ : 1;
10391 bool capture_message_ : 1;
10393 bool has_terminated_ : 1;
10409 : name_count_(name_count), names_(names) { }
10411 const char**
begin()
const {
return &names_[0]; }
10412 const char**
end()
const {
return &names_[name_count_]; }
10415 const int name_count_;
10416 const char** names_;
10490 Isolate* isolate, size_t context_snapshot_index,
10638 using AbortScriptExecutionCallback =
void (*)(
Isolate* isolate,
10701 return js_stack_comparable_address_;
10708 uintptr_t js_stack_comparable_address_ = 0;
10709 const BackupIncumbentScope* prev_ =
nullptr;
10720 static void CheckCast(
Data* obj);
10723 Local<
Value> SlowGetEmbedderData(
int index);
10724 void* SlowGetAlignedPointerFromEmbedderData(
int index);
10812 void Initialize(
Isolate* isolate);
10843 void Initialize(
Isolate* isolate);
10888 size_t code_pages_length,
10891 const void* stack_base);
10910 return New(isolate, that.val_);
10915 return New(isolate, that.val_);
10920 return New(isolate, *that);
10925 if (that ==
nullptr)
return Local<T>();
10926 T* that_ptr = that;
10929 reinterpret_cast<
internal::Isolate*>(isolate)
, *p
)));
10936 static_assert(std::is_base_of<T, S>::value,
"type check");
10937 val_ =
reinterpret_cast<T*>(
10938 V8::Eternalize(isolate,
reinterpret_cast<
Value*>(*handle)));
10945 return Local<T>(val_);
10952 return Local<T>(val_);
10958 #ifdef V8_ENABLE_CHECKS
10959 if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
10960 V8::InternalFieldOutOfBounds(index);
10963 return embedder_fields_[index];
10969 if (that ==
nullptr)
return nullptr;
10971 return reinterpret_cast<T*>(
10972 V8::GlobalizeReference(
reinterpret_cast<
internal::Isolate*>(isolate),
10977 template <
class T,
class M>
10978 template <
class S,
class M2>
10980 static_assert(std::is_base_of<T, S>::value,
"type check");
10982 if (that.IsEmpty())
return;
10984 this->val_ =
reinterpret_cast<T*>(
V8::CopyGlobalReference(p));
10985 M::Copy(that,
this);
10991 if (
this->IsEmpty())
return false;
10999 if (
this->IsEmpty())
return;
11008 static_assert(std::is_base_of<T, S>::value,
"type check");
11010 if (other.IsEmpty())
return;
11011 this->val_ = New(isolate, other.val_);
11019 static_assert(std::is_base_of<T, S>::value,
"type check");
11021 if (other.IsEmpty())
return;
11022 this->val_ = New(isolate, other.val_);
11027 template <
typename P>
11032 #if (__GNUC__
>= 8
) && !defined(__clang__
)
11033 #pragma GCC diagnostic push
11034 #pragma GCC diagnostic ignored "-Wcast-function-type"
11037 reinterpret_cast<Callback>(callback), type);
11038 #if (__GNUC__
>= 8
) && !defined(__clang__
)
11039 #pragma GCC diagnostic pop
11049 template <
typename P>
11051 return reinterpret_cast<P*>(
11064 if (
this->IsEmpty())
return;
11067 *
reinterpret_cast<uint16_t*>(addr) = class_id;
11074 if (
this->IsEmpty())
return 0;
11077 return *
reinterpret_cast<uint16_t*>(addr);
11082 if (other.val_ !=
nullptr) {
11085 other.val_ =
nullptr;
11092 static_assert(std::is_base_of<T, S>::value,
"type check");
11093 if (
this != &rhs) {
11095 if (rhs.val_ !=
nullptr) {
11096 this->val_ = rhs.val_;
11097 V8::MoveGlobalReference(
11100 rhs.val_ =
nullptr;
11108 Isolate* isolate, T* that,
void* slot, DestructionMode destruction_mode) {
11109 if (that ==
nullptr)
return nullptr;
11111 return V8::GlobalizeTracedReference(
11112 reinterpret_cast<
internal::Isolate*>(isolate), p,
11114 destruction_mode == kWithDestructor);
11132 if (a ==
nullptr)
return b ==
nullptr;
11133 if (b ==
nullptr)
return false;
11137 template <
typename U>
11142 if (a ==
nullptr)
return b ==
nullptr;
11143 if (b ==
nullptr)
return false;
11147 template <
typename U>
11155 return !(lhs
== rhs);
11158 template <
typename U>
11161 return !(lhs == rhs);
11164 template <
typename U>
11167 return !(rhs == lhs);
11173 static_assert(std::is_base_of<T, S>::value,
"type check");
11175 if (other.IsEmpty())
return;
11176 this->val_ =
this->New(isolate, other.val_, &
this->val_,
11183 static_assert(std::is_base_of<T, S>::value,
"type check");
11184 *
this = std::move(rhs.
template As<T>());
11191 static_assert(std::is_base_of<T, S>::value,
"type check");
11192 *
this = rhs.
template As<T>();
11198 if (
this != &rhs) {
11199 V8::MoveTracedGlobalReference(
11208 if (
this != &rhs) {
11210 if (rhs.val_ !=
nullptr) {
11211 V8::CopyTracedGlobalReference(
11222 static_assert(std::is_base_of<T, S>::value,
"type check");
11224 if (other.IsEmpty())
return;
11225 this->SetSlotThreadSafe(
11226 this->New(isolate, other.val_, &
this->val_,
11233 static_assert(std::is_base_of<T, S>::value,
"type check");
11234 *
this = std::move(rhs.
template As<T>());
11242 static_assert(std::is_base_of<T, S>::value,
"type check");
11243 *
this = rhs.
template As<T>();
11249 if (
this != &rhs) {
11250 V8::MoveTracedGlobalReference(
11259 if (
this != &rhs) {
11261 if (rhs.val_ !=
nullptr) {
11262 V8::CopyTracedGlobalReference(
11275 *
reinterpret_cast<uint16_t*>(addr) = class_id;
11283 return *
reinterpret_cast<uint16_t*>(addr);
11289 V8::SetFinalizationCallbackTraced(
11290 reinterpret_cast<
internal::
Address*>(
this->val_), parameter, callback);
11293 template <
typename T>
11296 template <
typename T>
11297 template <
typename S>
11299 static_assert(std::is_base_of<T, S>::value,
"type check");
11301 *value_ = GetDefaultValue();
11307 template <
typename T>
11308 template <
typename S>
11310 static_assert(std::is_base_of<T, S>::value,
"type check");
11312 *value_ = GetDefaultValue();
11318 template <
typename T>
11319 template <
typename S>
11321 static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
11324 *value_ = GetDefaultValue();
11330 template<
typename T>
11332 static_assert(std::is_base_of<T,
Number>::value,
"type check");
11336 template<
typename T>
11338 static_assert(std::is_base_of<T,
Integer>::value,
"type check");
11347 template<
typename T>
11349 static_assert(std::is_base_of<T,
Integer>::value,
"type check");
11351 bool fits_into_int32_t = (i & (1U << 31)) == 0;
11353 Set(
static_cast<int32_t>(i));
11359 template<
typename T>
11361 static_assert(std::is_base_of<T,
Boolean>::value,
"type check");
11372 template<
typename T>
11374 static_assert(std::is_base_of<T,
Primitive>::value,
"type check");
11379 template<
typename T>
11381 static_assert(std::is_base_of<T,
Primitive>::value,
"type check");
11386 template<
typename T>
11388 static_assert(std::is_base_of<T,
String>::value,
"type check");
11393 template <
typename T>
11396 return *
reinterpret_cast<
Isolate**>(&value_[-2]);
11399 template <
typename T>
11407 template <
typename T>
11408 template <
typename S>
11410 static_assert(
sizeof(S) < 0,
"incompilable to prevent inadvertent misuse");
11413 template <
typename T>
11419 template <
typename T>
11425 template<
typename T>
11433 template<
typename T>
11440 template<
typename T>
11446 template <
typename T>
11452 template <
typename T>
11458 template<
typename T>
11464 template<
typename T>
11470 template<
typename T>
11476 template<
typename T>
11499 int column_offset,
bool is_shared_cross_origin,
11501 bool is_opaque,
bool is_wasm,
bool is_module,
11504 resource_name_(resource_name),
11505 resource_line_offset_(line_offset),
11506 resource_column_offset_(column_offset),
11507 options_
(is_shared_cross_origin
, is_opaque
, is_wasm
, is_module
),
11508 script_id_(script_id),
11509 source_map_url_(source_map_url),
11510 host_defined_options_(host_defined_options) {}
11513 int line_offset,
int column_offset,
11514 bool is_shared_cross_origin,
int script_id,
11515 Local<
Value> source_map_url,
bool is_opaque,
11516 bool is_wasm,
bool is_module,
11518 : isolate_(isolate),
11519 resource_name_(resource_name),
11520 resource_line_offset_(line_offset),
11521 resource_column_offset_(column_offset),
11522 options_
(is_shared_cross_origin
, is_opaque
, is_wasm
, is_module
),
11523 script_id_(script_id),
11524 source_map_url_(source_map_url),
11525 host_defined_options_(host_defined_options) {}
11530 return host_defined_options_;
11555 ConsumeCodeCacheTask* consume_cache_task)
11556 : source_string(string),
11564 consume_cache_task(consume_cache_task) {}
11567 ConsumeCodeCacheTask* consume_cache_task)
11568 : source_string(string),
11570 consume_cache_task(consume_cache_task) {}
11574 return cached_data.get();
11578 return resource_options;
11589 value
, attributes
);
11593 #ifdef V8_ENABLE_CHECKS
11600 #ifdef V8_ENABLE_CHECKS
11607 #ifdef V8_ENABLE_CHECKS
11610 return reinterpret_cast<
Signature*>(data);
11614 #ifdef V8_ENABLE_CHECKS
11621 #ifndef V8_ENABLE_CHECKS
11624 A obj = *
reinterpret_cast<A*>(
this);
11631 #ifdef V8_COMPRESS_POINTERS
11634 value = I::DecompressTaggedAnyField(obj,
static_cast<uint32_t>(value));
11642 return SlowGetInternalField(index);
11647 #ifndef V8_ENABLE_CHECKS
11650 A obj = *
reinterpret_cast<A*>(
this);
11656 #ifdef V8_HEAP_SANDBOX
11657 offset += I::kEmbedderDataSlotRawPayloadOffset;
11662 return reinterpret_cast<
void*>(value);
11665 return SlowGetAlignedPointerFromInternalField(index);
11669 #ifdef V8_ENABLE_CHECKS
11672 return static_cast<
String*>(data);
11687 A obj = *
reinterpret_cast<
const A*>(
this);
11697 result = GetExternalStringResourceSlow();
11699 #ifdef V8_ENABLE_CHECKS
11700 VerifyExternalStringResource(result);
11710 A obj = *
reinterpret_cast<
const A*>(
this);
11722 resource = GetExternalStringResourceBaseSlow(encoding_out);
11724 #ifdef V8_ENABLE_CHECKS
11725 VerifyExternalStringResourceBase(resource, *encoding_out);
11732 #ifdef V8_ENABLE_CHECKS
11733 return FullIsUndefined();
11735 return QuickIsUndefined();
11739 bool Value::QuickIsUndefined()
const {
11742 A obj = *
reinterpret_cast<
const A*>(
this);
11750 #ifdef V8_ENABLE_CHECKS
11751 return FullIsNull();
11753 return QuickIsNull();
11757 bool Value::QuickIsNull()
const {
11760 A obj = *
reinterpret_cast<
const A*>(
this);
11767 #ifdef V8_ENABLE_CHECKS
11768 return FullIsNull() || FullIsUndefined();
11770 return QuickIsNullOrUndefined();
11774 bool Value::QuickIsNullOrUndefined()
const {
11777 A obj = *
reinterpret_cast<
const A*>(
this);
11785 #ifdef V8_ENABLE_CHECKS
11786 return FullIsString();
11788 return QuickIsString();
11792 bool Value::QuickIsString()
const {
11795 A obj = *
reinterpret_cast<
const A*>(
this);
11802 return static_cast<
Value*>(value);
11807 #ifdef V8_ENABLE_CHECKS
11810 return static_cast<
Value*>(value);
11814 #ifdef V8_ENABLE_CHECKS
11817 return static_cast<
Boolean*>(data);
11821 #ifdef V8_ENABLE_CHECKS
11824 return static_cast<
Name*>(data);
11828 #ifdef V8_ENABLE_CHECKS
11831 return static_cast<
Symbol*>(data);
11835 #ifdef V8_ENABLE_CHECKS
11838 return reinterpret_cast<
Private*>(data);
11842 #ifdef V8_ENABLE_CHECKS
11849 #ifdef V8_ENABLE_CHECKS
11852 return reinterpret_cast<
Module*>(data);
11856 #ifdef V8_ENABLE_CHECKS
11859 return static_cast<
Number*>(data);
11863 #ifdef V8_ENABLE_CHECKS
11866 return static_cast<
Integer*>(data);
11870 #ifdef V8_ENABLE_CHECKS
11873 return static_cast<
Int32*>(data);
11877 #ifdef V8_ENABLE_CHECKS
11880 return static_cast<
Uint32*>(data);
11884 #ifdef V8_ENABLE_CHECKS
11887 return static_cast<
BigInt*>(data);
11891 #ifdef V8_ENABLE_CHECKS
11894 return static_cast<
Context*>(data);
11898 #ifdef V8_ENABLE_CHECKS
11901 return static_cast<
Date*>(value);
11906 #ifdef V8_ENABLE_CHECKS
11914 #ifdef V8_ENABLE_CHECKS
11922 #ifdef V8_ENABLE_CHECKS
11929 #ifdef V8_ENABLE_CHECKS
11936 #ifdef V8_ENABLE_CHECKS
11944 #ifdef V8_ENABLE_CHECKS
11947 return static_cast<
RegExp*>(value);
11952 #ifdef V8_ENABLE_CHECKS
11955 return static_cast<
Object*>(value);
11960 #ifdef V8_ENABLE_CHECKS
11963 return static_cast<
Array*>(value);
11968 #ifdef V8_ENABLE_CHECKS
11971 return static_cast<
Map*>(value);
11976 #ifdef V8_ENABLE_CHECKS
11979 return static_cast<
Set*>(value);
11984 #ifdef V8_ENABLE_CHECKS
11987 return static_cast<
Promise*>(value);
11992 #ifdef V8_ENABLE_CHECKS
11995 return static_cast<
Proxy*>(value);
11999 #ifdef V8_ENABLE_CHECKS
12006 #ifdef V8_ENABLE_CHECKS
12013 #ifdef V8_ENABLE_CHECKS
12021 #ifdef V8_ENABLE_CHECKS
12029 #ifdef V8_ENABLE_CHECKS
12037 #ifdef V8_ENABLE_CHECKS
12045 #ifdef V8_ENABLE_CHECKS
12053 #ifdef V8_ENABLE_CHECKS
12061 #ifdef V8_ENABLE_CHECKS
12069 #ifdef V8_ENABLE_CHECKS
12077 #ifdef V8_ENABLE_CHECKS
12085 #ifdef V8_ENABLE_CHECKS
12093 #ifdef V8_ENABLE_CHECKS
12101 #ifdef V8_ENABLE_CHECKS
12108 #ifdef V8_ENABLE_CHECKS
12115 #ifdef V8_ENABLE_CHECKS
12122 #ifdef V8_ENABLE_CHECKS
12130 #ifdef V8_ENABLE_CHECKS
12133 return static_cast<
DataView*>(value);
12138 #ifdef V8_ENABLE_CHECKS
12146 #ifdef V8_ENABLE_CHECKS
12149 return static_cast<
Function*>(value);
12154 #ifdef V8_ENABLE_CHECKS
12157 return static_cast<
External*>(value);
12161 template<
typename T>
12167 template<
typename T>
12173 template<
typename T>
12179 template<
typename T>
12185 template<
typename T>
12190 template <
typename T>
12256 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12257 if (data)
internal::PerformCastCheck(data);
12258 return Local<T>(data);
12262 #ifndef V8_ENABLE_CHECKS
12265 A ctx = *
reinterpret_cast<
const A*>(
this);
12271 #ifdef V8_COMPRESS_POINTERS
12275 I::DecompressTaggedAnyField(embedder_data,
static_cast<uint32_t>(value));
12278 *
reinterpret_cast<A*>(
this)
);
12282 return SlowGetEmbedderData(index);
12288 #ifndef V8_ENABLE_CHECKS
12291 A ctx = *
reinterpret_cast<
const A*>(
this);
12296 #ifdef V8_HEAP_SANDBOX
12297 value_offset += I::kEmbedderDataSlotRawPayloadOffset;
12300 return reinterpret_cast<
void*>(
12304 return SlowGetAlignedPointerFromEmbedderData(index);
12310 T* data =
reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12311 if (data)
internal::PerformCastCheck(data);
12312 return Local<T>(data);
12317 T* object_ptr = *object;
12319 return AddData(context, *p);
12324 T* object_ptr = *object;
12326 return AddData(*p);