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);