25 #include "v8-version.h" 38 #ifdef BUILDING_V8_SHARED 39 # define V8_EXPORT __declspec(dllexport) 41 # define V8_EXPORT __declspec(dllimport) 44 #endif // BUILDING_V8_SHARED 49 #if V8_HAS_ATTRIBUTE_VISIBILITY 50 # ifdef BUILDING_V8_SHARED 51 # define V8_EXPORT __attribute__ ((visibility("default"))) 66 class AccessorSignature;
78 class FunctionTemplate;
80 class ImplementationUtilities;
90 class ObjectOperationDescriptor;
97 class RawOperationDescriptor;
120 template <
class T,
class M = NonCopyablePersistentTraits<T> >
125 template <
class K,
class V,
class T>
127 template <
class K,
class V,
class T>
138 class CallHandlerHelper;
144 class DeferredHandles;
148 class LocalEmbedderHeapTracer;
149 class NeverReadOnlySpaceObject;
151 struct ScriptStreamingData;
153 class PropertyCallbackArguments;
154 class FunctionCallbackArguments;
159 class StreamingDecoder;
165 const int kApiPointerSize =
sizeof(
void*);
166 const int kApiDoubleSize =
sizeof(double);
167 const int kApiIntSize =
sizeof(int);
168 const int kApiInt64Size =
sizeof(int64_t);
171 const int kHeapObjectTag = 1;
172 const int kWeakHeapObjectTag = 3;
173 const int kHeapObjectTagSize = 2;
174 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
177 const int kSmiTag = 0;
178 const int kSmiTagSize = 1;
179 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
181 template <
size_t tagged_ptr_size>
184 template <
int kSmiShiftSize>
185 V8_INLINE internal::Object* IntToSmi(
int value) {
186 int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
187 intptr_t tagged_value =
188 (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag;
189 return reinterpret_cast<internal::Object*>(tagged_value);
195 enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
196 static int SmiShiftSize() {
return kSmiShiftSize; }
197 static int SmiValueSize() {
return kSmiValueSize; }
198 V8_INLINE
static int SmiToInt(
const internal::Object* value) {
199 int shift_bits = kSmiTagSize + kSmiShiftSize;
201 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
203 V8_INLINE
static internal::Object* IntToSmi(
int value) {
204 return internal::IntToSmi<kSmiShiftSize>(value);
206 V8_INLINE
static constexpr
bool IsValidSmi(intptr_t value) {
218 return static_cast<uintptr_t>(value) + 0x40000000U < 0x80000000U;
225 enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
226 static int SmiShiftSize() {
return kSmiShiftSize; }
227 static int SmiValueSize() {
return kSmiValueSize; }
228 V8_INLINE
static int SmiToInt(
const internal::Object* value) {
229 int shift_bits = kSmiTagSize + kSmiShiftSize;
231 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
233 V8_INLINE
static internal::Object* IntToSmi(
int value) {
234 return internal::IntToSmi<kSmiShiftSize>(value);
236 V8_INLINE
static constexpr
bool IsValidSmi(intptr_t value) {
238 return (value == static_cast<int32_t>(value));
242 #if V8_COMPRESS_POINTERS 244 kApiPointerSize == kApiInt64Size,
245 "Pointer compression can be enabled only for 64-bit architectures");
251 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
252 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
253 const int kSmiMinValue = (static_cast<unsigned int>(-1)) << (kSmiValueSize - 1);
254 const int kSmiMaxValue = -(kSmiMinValue + 1);
255 constexpr
bool SmiValuesAre31Bits() {
return kSmiValueSize == 31; }
256 constexpr
bool SmiValuesAre32Bits() {
return kSmiValueSize == 32; }
261 class ConsoleCallArguments;
266 #define TYPE_CHECK(T, S) \ 268 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ 305 V8_INLINE Local() : val_(0) {}
308 : val_(reinterpret_cast<T*>(*that)) {
320 V8_INLINE
bool IsEmpty()
const {
return val_ == 0; }
325 V8_INLINE
void Clear() { val_ = 0; }
327 V8_INLINE T* operator->()
const {
return val_; }
329 V8_INLINE T* operator*()
const {
return val_; }
339 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
340 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
341 if (a == 0)
return b == 0;
342 if (b == 0)
return false;
348 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
349 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
350 if (a == 0)
return b == 0;
351 if (b == 0)
return false;
377 #ifdef V8_ENABLE_CHECKS 380 if (that.IsEmpty())
return Local<T>();
406 template<
class F>
friend class Eternal;
408 template<
class F,
class M>
friend class Persistent;
409 template<
class F>
friend class Local;
416 friend class Context;
417 friend class Isolate;
426 template <
class F1,
class F2,
class F3>
432 explicit V8_INLINE
Local(T* that) : val_(that) {}
433 V8_INLINE
static Local<T>
New(Isolate* isolate, T* that);
438 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS) 441 using Handle = Local<T>;
458 V8_INLINE MaybeLocal() : val_(nullptr) {}
460 V8_INLINE MaybeLocal(Local<S> that)
461 : val_(reinterpret_cast<T*>(*that)) {
465 V8_INLINE
bool IsEmpty()
const {
return val_ ==
nullptr; }
473 out->val_ = IsEmpty() ? nullptr : this->val_;
489 return IsEmpty() ? default_value :
Local<S>(val_);
500 template <
class T>
class Eternal {
502 V8_INLINE Eternal() : val_(nullptr) {}
504 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : val_(nullptr) {
505 Set(isolate, handle);
508 V8_INLINE Local<T> Get(Isolate* isolate)
const;
509 V8_INLINE
bool IsEmpty()
const {
return val_ ==
nullptr; }
510 template<
class S> V8_INLINE
void Set(Isolate* isolate, Local<S> handle);
517 static const int kInternalFieldsInWeakCallback = 2;
518 static const int kEmbedderFieldsInWeakCallback = 2;
520 template <
typename T>
526 void* embedder_fields[kEmbedderFieldsInWeakCallback],
528 : isolate_(isolate), parameter_(parameter), callback_(callback) {
529 for (
int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
530 embedder_fields_[i] = embedder_fields[i];
534 V8_INLINE Isolate* GetIsolate()
const {
return isolate_; }
535 V8_INLINE T* GetParameter()
const {
return parameter_; }
536 V8_INLINE
void* GetInternalField(
int index)
const;
544 void SetSecondPassCallback(Callback callback)
const { *callback_ = callback; }
550 void* embedder_fields_[kEmbedderFieldsInWeakCallback];
559 enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
574 template <
class T>
class PersistentBase {
580 V8_INLINE
void Reset();
586 V8_INLINE
void Reset(Isolate* isolate,
const Local<S>& other);
593 V8_INLINE
void Reset(Isolate* isolate,
const PersistentBase<S>& other);
595 V8_INLINE
bool IsEmpty()
const {
return val_ == NULL; }
596 V8_INLINE
void Empty() { val_ = 0; }
598 V8_INLINE Local<T> Get(Isolate* isolate)
const {
603 V8_INLINE
bool operator==(
const PersistentBase<S>& that)
const {
604 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
605 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
606 if (a == NULL)
return b == NULL;
607 if (b == NULL)
return false;
612 V8_INLINE
bool operator==(
const Local<S>& that)
const {
613 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
614 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
615 if (a == NULL)
return b == NULL;
616 if (b == NULL)
return false;
621 V8_INLINE
bool operator!=(
const PersistentBase<S>& that)
const {
622 return !operator==(that);
626 V8_INLINE
bool operator!=(
const Local<S>& that)
const {
627 return !operator==(that);
637 template <
typename P>
638 V8_INLINE
void SetWeak(P* parameter,
639 typename WeakCallbackInfo<P>::Callback callback,
640 WeakCallbackType type);
652 V8_INLINE P* ClearWeak();
655 V8_INLINE
void ClearWeak() { ClearWeak<void>(); }
679 "Objects are always considered independent. " 680 "Use MarkActive to avoid collecting otherwise dead weak handles.",
681 V8_INLINE
void MarkIndependent());
693 V8_INLINE
bool IsIndependent()
const);
699 V8_INLINE
bool IsWeak()
const;
713 PersistentBase(
const PersistentBase& other) =
delete;
714 void operator=(
const PersistentBase&) =
delete;
717 friend class Isolate;
719 template<
class F>
friend class Local;
720 template<
class F1,
class F2>
friend class Persistent;
723 template<
class F>
friend class PersistentBase;
724 template<
class F>
friend class ReturnValue;
725 template <
class F1,
class F2,
class F3>
726 friend class PersistentValueMapBase;
727 template<
class F1,
class F2>
friend class PersistentValueVector;
730 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
731 V8_INLINE
static T* New(Isolate* isolate, T* that);
744 class NonCopyablePersistentTraits {
746 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
747 static const bool kResetInDestructor =
false;
748 template<
class S,
class M>
749 V8_INLINE
static void Copy(
const Persistent<S, M>& source,
750 NonCopyablePersistent* dest) {
751 Uncompilable<Object>();
754 template<
class O> V8_INLINE
static void Uncompilable() {
755 TYPE_CHECK(O, Primitive);
767 static const bool kResetInDestructor =
true;
768 template<
class S,
class M>
805 template <
class S,
class M2>
819 template <
class S,
class M2>
827 template <
class S,
class M2>
828 V8_INLINE
Persistent& operator=(
const Persistent<S, M2>& that) {
838 if (M::kResetInDestructor) this->
Reset();
844 #ifdef V8_ENABLE_CHECKS 847 if (!that.IsEmpty()) T::Cast(*that);
854 V8_INLINE Persistent<S>& As()
const {
855 return Persistent<S>::Cast(*
this);
859 friend class Isolate;
861 template<
class F>
friend class Local;
862 template<
class F1,
class F2>
friend class Persistent;
863 template<
class F>
friend class ReturnValue;
865 explicit V8_INLINE
Persistent(T* that) : PersistentBase<T>(that) {}
866 V8_INLINE T* operator*()
const {
return this->val_; }
867 template<
class S,
class M2>
868 V8_INLINE
void Copy(
const Persistent<S, M2>& that);
878 class Global :
public PersistentBase<T> {
908 other.val_ =
nullptr;
919 this->val_ = rhs.val_;
932 typedef void MoveOnlyTypeForCPP03;
940 V8_INLINE T* operator*()
const {
return this->val_; }
946 using UniquePersistent = Global<T>;
972 static int NumberOfHandles(Isolate* isolate);
974 V8_INLINE Isolate* GetIsolate()
const {
975 return reinterpret_cast<Isolate*>(isolate_);
984 void Initialize(Isolate* isolate);
986 static internal::Object** CreateHandle(internal::Isolate* isolate,
987 internal::Object* value);
992 void*
operator new(
size_t size);
993 void*
operator new[](
size_t size);
994 void operator delete(
void*, size_t);
995 void operator delete[](
void*, size_t);
998 static internal::Object** CreateHandle(
999 internal::NeverReadOnlySpaceObject* heap_object, internal::Object* value);
1001 internal::Isolate* isolate_;
1002 internal::Object** prev_next_;
1003 internal::Object** prev_limit_;
1006 template<
class F>
friend class Local;
1011 friend class Context;
1030 internal::Object** slot =
1031 Escape(reinterpret_cast<internal::Object**>(*value));
1032 return Local<T>(reinterpret_cast<T*>(slot));
1037 return Escape(value.FromMaybe(
Local<T>()));
1040 EscapableHandleScope(
const EscapableHandleScope&) =
delete;
1041 void operator=(
const EscapableHandleScope&) =
delete;
1046 void*
operator new(
size_t size);
1047 void*
operator new[](
size_t size);
1048 void operator delete(
void*, size_t);
1049 void operator delete[](
void*, size_t);
1051 internal::Object** Escape(internal::Object** escape_value);
1052 internal::Object** escape_slot_;
1071 void*
operator new(
size_t size);
1072 void*
operator new[](
size_t size);
1073 void operator delete(
void*, size_t);
1074 void operator delete[](
void*, size_t);
1076 internal::Isolate*
const isolate_;
1077 internal::Object** prev_limit_;
1078 int prev_sealed_level_;
1129 V8_DEPRECATED(
"Use Isolate version",
1140 bool is_opaque =
false,
bool is_wasm =
false,
1141 bool is_module =
false)
1142 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1143 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1144 (is_module ? kIsModule : 0)) {}
1147 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1149 bool IsSharedCrossOrigin()
const {
1150 return (flags_ & kIsSharedCrossOrigin) != 0;
1152 bool IsOpaque()
const {
return (flags_ & kIsOpaque) != 0; }
1153 bool IsWasm()
const {
return (flags_ & kIsWasm) != 0; }
1154 bool IsModule()
const {
return (flags_ & kIsModule) != 0; }
1156 int Flags()
const {
return flags_; }
1160 kIsSharedCrossOrigin = 1,
1229 int GetLineNumber(
int code_pos);
1231 static const int kNoScriptId = 0;
1246 int GetLineNumber() {
return line_number_; }
1247 int GetColumnNumber() {
return column_number_; }
1249 Location(
int line_number,
int column_number)
1250 : line_number_(line_number), column_number_(column_number) {}
1281 Status GetStatus()
const;
1291 int GetModuleRequestsLength()
const;
1303 Location GetModuleRequestLocation(
int i)
const;
1308 int GetIdentityHash()
const;
1322 ResolveCallback callback);
1399 buffer_policy(BufferNotOwned) {}
1406 BufferPolicy buffer_policy = BufferNotOwned);
1410 const uint8_t* data;
1413 BufferPolicy buffer_policy;
1435 V8_INLINE
const CachedData* GetCachedData()
const;
1491 virtual size_t GetMoreData(
const uint8_t** src) = 0;
1503 virtual bool SetBookmark();
1508 virtual void ResetToBookmark();
1520 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1530 internal::ScriptStreamingData* impl()
const {
return impl_; }
1537 internal::ScriptStreamingData* impl_;
1547 virtual void Run() = 0;
1550 enum CompileOptions {
1551 kNoCompileOptions = 0,
1552 kProduceParserCache,
1553 kConsumeParserCache,
1555 kProduceFullCodeCache,
1564 kNoCacheNoReason = 0,
1565 kNoCacheBecauseCachingDisabled,
1566 kNoCacheBecauseNoResource,
1567 kNoCacheBecauseInlineScript,
1568 kNoCacheBecauseModule,
1569 kNoCacheBecauseStreamingSource,
1570 kNoCacheBecauseInspector,
1571 kNoCacheBecauseScriptTooSmall,
1572 kNoCacheBecauseCacheTooCold,
1573 kNoCacheBecauseV8Extension,
1574 kNoCacheBecauseExtensionModule,
1575 kNoCacheBecausePacScript,
1576 kNoCacheBecauseInDocumentWrite,
1577 kNoCacheBecauseResourceWithNoCacheHandler,
1578 kNoCacheBecauseDeferredProduceCodeCache
1595 Isolate* isolate, Source* source,
1596 CompileOptions options = kNoCompileOptions,
1597 NoCacheReason no_cache_reason = kNoCacheNoReason);
1612 CompileOptions options = kNoCompileOptions,
1613 NoCacheReason no_cache_reason = kNoCacheNoReason);
1626 static ScriptStreamingTask* StartStreamingScript(
1627 Isolate* isolate, StreamedSource* source,
1628 CompileOptions options = kNoCompileOptions);
1659 static uint32_t CachedDataVersionTag();
1669 Isolate* isolate, Source* source,
1670 CompileOptions options = kNoCompileOptions,
1671 NoCacheReason no_cache_reason = kNoCacheNoReason);
1687 CompileOptions options = kNoCompileOptions,
1688 NoCacheReason no_cache_reason = kNoCacheNoReason);
1702 static CachedData* CreateCodeCache(
1711 static CachedData* CreateCodeCacheForFunction(
Local<Function> function);
1715 Isolate* isolate, Source* source, CompileOptions options,
1716 NoCacheReason no_cache_reason);
1730 Isolate* GetIsolate()
const;
1763 int GetStartPosition()
const;
1769 int GetEndPosition()
const;
1774 int ErrorLevel()
const;
1780 int GetStartColumn()
const;
1787 int GetEndColumn()
const;
1794 bool IsSharedCrossOrigin()
const;
1795 bool IsOpaque()
const;
1798 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1800 static const int kNoLineNumberInfo = 0;
1801 static const int kNoColumnInfo = 0;
1802 static const int kNoScriptIdInfo = 0;
1821 kColumnOffset = 1 << 1 | kLineNumber,
1822 kScriptName = 1 << 2,
1823 kFunctionName = 1 << 3,
1825 kIsConstructor = 1 << 5,
1826 kScriptNameOrSourceURL = 1 << 6,
1828 kExposeFramesAcrossSecurityOrigins = 1 << 8,
1829 kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
1830 kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
1836 V8_DEPRECATED(
"Use Isolate version",
1843 int GetFrameCount()
const;
1853 Isolate* isolate,
int frame_limit, StackTraceOptions options = kDetailed);
1868 int GetLineNumber()
const;
1877 int GetColumn()
const;
1885 int GetScriptId()
const;
1910 bool IsEval()
const;
1916 bool IsConstructor()
const;
1921 bool IsWasm()
const;
1948 size_t frames_count;
1950 void* external_callback_entry;
1966 static V8_DEPRECATE_SOON(
"Use the maybe version taking context",
2003 virtual void ThrowDataCloneError(
Local<String> message) = 0;
2038 virtual void* ReallocateBufferMemory(
void* old_buffer,
size_t size,
2039 size_t* actual_size);
2046 virtual void FreeBufferMemory(
void* buffer);
2068 V8_DEPRECATE_SOON(
"Use Release()", std::vector<uint8_t> ReleaseBuffer());
2076 V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
2083 void TransferArrayBuffer(uint32_t transfer_id,
2089 V8_DEPRECATE_SOON(
"Use Delegate::GetSharedArrayBufferId",
2090 void TransferSharedArrayBuffer(
2091 uint32_t transfer_id,
2101 void SetTreatArrayBufferViewsAsHostObjects(
bool mode);
2108 void WriteUint32(uint32_t value);
2109 void WriteUint64(uint64_t value);
2110 void WriteDouble(
double value);
2111 void WriteRawBytes(
const void* source,
size_t length);
2118 PrivateData* private_;
2147 Isolate* isolate, uint32_t transfer_id);
2154 Isolate* isolate, uint32_t clone_id);
2177 void TransferArrayBuffer(uint32_t transfer_id,
2185 void TransferSharedArrayBuffer(uint32_t
id,
2195 void SetSupportsLegacyWireFormat(
bool supports_legacy_wire_format);
2200 void SetExpectInlineWasm(
bool allow_inline_wasm);
2207 uint32_t GetWireFormatVersion()
const;
2214 V8_WARN_UNUSED_RESULT
bool ReadUint32(uint32_t* value);
2215 V8_WARN_UNUSED_RESULT
bool ReadUint64(uint64_t* value);
2216 V8_WARN_UNUSED_RESULT
bool ReadDouble(
double* value);
2217 V8_WARN_UNUSED_RESULT
bool ReadRawBytes(
size_t length,
const void** data);
2224 PrivateData* private_;
2240 V8_INLINE
bool IsUndefined()
const;
2246 V8_INLINE
bool IsNull()
const;
2253 V8_INLINE
bool IsNullOrUndefined()
const;
2258 bool IsTrue()
const;
2263 bool IsFalse()
const;
2268 bool IsName()
const;
2274 V8_INLINE
bool IsString()
const;
2279 bool IsSymbol()
const;
2284 bool IsFunction()
const;
2290 bool IsArray()
const;
2295 bool IsObject()
const;
2300 bool IsBigInt()
const;
2305 bool IsBoolean()
const;
2310 bool IsNumber()
const;
2315 bool IsExternal()
const;
2320 bool IsInt32()
const;
2325 bool IsUint32()
const;
2330 bool IsDate()
const;
2335 bool IsArgumentsObject()
const;
2340 bool IsBigIntObject()
const;
2345 bool IsBooleanObject()
const;
2350 bool IsNumberObject()
const;
2355 bool IsStringObject()
const;
2360 bool IsSymbolObject()
const;
2365 bool IsNativeError()
const;
2370 bool IsRegExp()
const;
2375 bool IsAsyncFunction()
const;
2380 bool IsGeneratorFunction()
const;
2385 bool IsGeneratorObject()
const;
2390 bool IsPromise()
const;
2405 bool IsMapIterator()
const;
2410 bool IsSetIterator()
const;
2415 bool IsWeakMap()
const;
2420 bool IsWeakSet()
const;
2425 bool IsArrayBuffer()
const;
2430 bool IsArrayBufferView()
const;
2435 bool IsTypedArray()
const;
2440 bool IsUint8Array()
const;
2445 bool IsUint8ClampedArray()
const;
2450 bool IsInt8Array()
const;
2455 bool IsUint16Array()
const;
2460 bool IsInt16Array()
const;
2465 bool IsUint32Array()
const;
2470 bool IsInt32Array()
const;
2475 bool IsFloat32Array()
const;
2480 bool IsFloat64Array()
const;
2485 bool IsBigInt64Array()
const;
2490 bool IsBigUint64Array()
const;
2495 bool IsDataView()
const;
2501 bool IsSharedArrayBuffer()
const;
2506 bool IsProxy()
const;
2508 bool IsWebAssemblyCompiledModule()
const;
2513 bool IsModuleNamespaceObject()
const;
2533 V8_DEPRECATE_SOON(
"Use maybe version",
2535 V8_DEPRECATE_SOON(
"Use maybe version",
2537 V8_DEPRECATE_SOON(
"Use maybe version",
2539 V8_DEPRECATE_SOON(
"Use maybe version",
2541 V8_DEPRECATE_SOON(
"Use maybe version",
2543 V8_DEPRECATE_SOON(
"Use maybe version",
2546 inline V8_DEPRECATED(
"Use maybe version",
Local<Boolean> ToBoolean()
const);
2547 inline V8_DEPRECATED(
"Use maybe version",
Local<String> ToString()
const);
2548 inline V8_DEPRECATED(
"Use maybe version",
Local<Object> ToObject()
const);
2549 inline V8_DEPRECATED(
"Use maybe version",
Local<Integer> ToInteger()
const);
2566 V8_DEPRECATED(
"Use maybe version",
bool BooleanValue()
const);
2567 V8_DEPRECATED(
"Use maybe version",
double NumberValue()
const);
2568 V8_DEPRECATED(
"Use maybe version", int64_t IntegerValue()
const);
2569 V8_DEPRECATED(
"Use maybe version", uint32_t Uint32Value()
const);
2570 V8_DEPRECATED(
"Use maybe version", int32_t Int32Value()
const);
2573 V8_DEPRECATED(
"Use maybe version",
bool Equals(
Local<Value> that)
const);
2579 template <
class T> V8_INLINE
static Value* Cast(T* value);
2586 V8_INLINE
bool QuickIsUndefined()
const;
2587 V8_INLINE
bool QuickIsNull()
const;
2588 V8_INLINE
bool QuickIsNullOrUndefined()
const;
2589 V8_INLINE
bool QuickIsString()
const;
2590 bool FullIsUndefined()
const;
2591 bool FullIsNull()
const;
2592 bool FullIsString()
const;
2610 V8_INLINE
static Local<Boolean> New(Isolate* isolate,
bool value);
2629 int GetIdentityHash();
2631 V8_INLINE
static Name* Cast(
Value* obj);
2634 static void CheckCast(
Value* obj);
2662 static constexpr
int kMaxLength = internal::kApiPointerSize == 4
2664 : internal::kSmiMaxValue / 2 - 24;
2667 UNKNOWN_ENCODING = 0x1,
2668 TWO_BYTE_ENCODING = 0x0,
2669 ONE_BYTE_ENCODING = 0x8
2680 V8_DEPRECATED(
"Use Isolate version instead",
int Utf8Length()
const);
2682 int Utf8Length(Isolate* isolate)
const;
2690 bool IsOneByte()
const;
2697 bool ContainsOnlyOneByte()
const;
2726 HINT_MANY_WRITES_EXPECTED = 1,
2727 NO_NULL_TERMINATION = 2,
2728 PRESERVE_ONE_BYTE_NULL = 4,
2732 REPLACE_INVALID_UTF8 = 8
2736 int Write(Isolate* isolate, uint16_t* buffer,
int start = 0,
int length = -1,
2737 int options = NO_OPTIONS)
const;
2738 V8_DEPRECATED(
"Use Isolate* version",
2739 int Write(uint16_t* buffer,
int start = 0,
int length = -1,
2740 int options = NO_OPTIONS)
const);
2742 int WriteOneByte(Isolate* isolate, uint8_t* buffer,
int start = 0,
2743 int length = -1,
int options = NO_OPTIONS)
const;
2744 V8_DEPRECATED(
"Use Isolate* version",
2745 int WriteOneByte(uint8_t* buffer,
int start = 0,
2746 int length = -1,
int options = NO_OPTIONS)
2749 int WriteUtf8(Isolate* isolate,
char* buffer,
int length = -1,
2750 int* nchars_ref = NULL,
int options = NO_OPTIONS)
const;
2751 V8_DEPRECATED(
"Use Isolate* version",
2752 int WriteUtf8(
char* buffer,
int length = -1,
2753 int* nchars_ref = NULL,
int options = NO_OPTIONS)
2764 bool IsExternal()
const;
2769 bool IsExternalOneByte()
const;
2775 virtual bool IsCompressible()
const {
return false; }
2793 friend class internal::Heap;
2815 virtual const uint16_t* data()
const = 0;
2820 virtual size_t length()
const = 0;
2845 virtual const char* data()
const = 0;
2847 virtual size_t length()
const = 0;
2857 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
2858 Encoding* encoding_out)
const;
2864 V8_INLINE ExternalStringResource* GetExternalStringResource()
const;
2870 const ExternalOneByteStringResource* GetExternalOneByteStringResource()
const;
2872 V8_INLINE
static String* Cast(
v8::Value* obj);
2881 static V8_DEPRECATE_SOON(
2882 "Use maybe version",
2883 Local<String> NewFromUtf8(Isolate* isolate,
const char* data,
2889 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
2895 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
2900 static V8_DEPRECATE_SOON(
2901 "Use maybe version",
2902 Local<String> NewFromTwoByte(Isolate* isolate,
const uint16_t* data,
2908 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
2916 static Local<String> Concat(Isolate* isolate, Local<String> left,
2917 Local<String> right);
2918 static V8_DEPRECATED(
"Use Isolate* version",
2919 Local<String> Concat(Local<String> left,
2920 Local<String> right));
2930 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
2931 Isolate* isolate, ExternalStringResource* resource);
2942 bool MakeExternal(ExternalStringResource* resource);
2952 static V8_DEPRECATE_SOON(
2953 "Use maybe version",
2954 Local<String> NewExternal(Isolate* isolate,
2955 ExternalOneByteStringResource* resource));
2956 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
2957 Isolate* isolate, ExternalOneByteStringResource* resource);
2968 bool MakeExternal(ExternalOneByteStringResource* resource);
2973 bool CanMakeExternal();
2978 bool StringEquals(Local<String> str);
2991 char* operator*() {
return str_; }
2992 const char* operator*()
const {
return str_; }
2993 int length()
const {
return length_; }
2997 void operator=(
const Utf8Value&) =
delete;
3014 uint16_t* operator*() {
return str_; }
3015 const uint16_t* operator*()
const {
return str_; }
3016 int length()
const {
return length_; }
3020 void operator=(
const Value&) =
delete;
3029 Encoding encoding)
const;
3033 String::Encoding* encoding_out)
const;
3074 static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
3088 static void CheckCast(
Value* obj);
3126 static void CheckCast(
Data* that);
3135 double Value()
const;
3150 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
3151 int64_t
Value()
const;
3164 int32_t
Value()
const;
3178 uint32_t
Value()
const;
3192 static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
3201 int word_count,
const uint64_t* words);
3209 uint64_t Uint64Value(
bool* lossless =
nullptr)
const;
3216 int64_t Int64Value(
bool* lossless =
nullptr)
const;
3222 int WordCount()
const;
3232 void ToWordsArray(
int* sign_bit,
int* word_count, uint64_t* words)
const;
3263 typedef void (*AccessorNameGetterCallback)(
3268 typedef void (*AccessorSetterCallback)(
3272 typedef void (*AccessorNameSetterCallback)(
3290 ALL_CAN_WRITE = 1 << 1,
3291 PROHIBITS_OVERWRITING = 1 << 2
3300 ONLY_ENUMERABLE = 2,
3301 ONLY_CONFIGURABLE = 4,
3346 V8_DEPRECATE_SOON(
"Use maybe version",
3351 V8_DEPRECATE_SOON(
"Use maybe version",
3376 V8_WARN_UNUSED_RESULT
Maybe<bool> DefineOwnProperty(
3400 V8_DEPRECATE_SOON(
"Use maybe version",
Local<Value> Get(uint32_t index));
3418 V8_DEPRECATE_SOON(
"Use maybe version",
bool Has(
Local<Value> key));
3437 V8_DEPRECATE_SOON(
"Use maybe version",
bool Delete(
Local<Value> key));
3451 AccessorNameGetterCallback getter, AccessorNameSetterCallback setter = 0,
3454 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
3465 V8_WARN_UNUSED_RESULT
Maybe<bool> SetNativeDataProperty(
3467 AccessorNameGetterCallback getter,
3468 AccessorNameSetterCallback setter =
nullptr,
3470 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
3480 V8_WARN_UNUSED_RESULT
Maybe<bool> SetLazyDataProperty(
3484 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
3504 V8_DEPRECATE_SOON(
"Use maybe version",
Local<Array> GetPropertyNames());
3517 V8_DEPRECATE_SOON(
"Use maybe version",
Local<Array> GetOwnPropertyNames());
3571 int InternalFieldCount();
3576 return object.val_->InternalFieldCount();
3590 V8_INLINE
void* GetAlignedPointerFromInternalField(
int index);
3595 return object.val_->GetAlignedPointerFromInternalField(index);
3603 void SetAlignedPointerInInternalField(
int index,
void* value);
3604 void SetAlignedPointerInInternalFields(
int argc,
int indices[],
3616 V8_DEPRECATE_SOON(
"Use maybe version",
3633 V8_DEPRECATE_SOON(
"Use maybe version",
3634 bool HasRealIndexedProperty(uint32_t index));
3635 V8_WARN_UNUSED_RESULT
Maybe<bool> HasRealIndexedProperty(
3637 V8_DEPRECATE_SOON(
"Use maybe version",
3639 V8_WARN_UNUSED_RESULT
Maybe<bool> HasRealNamedCallbackProperty(
3655 GetRealNamedPropertyAttributesInPrototypeChain(
Local<Context> context,
3675 bool HasNamedLookupInterceptor();
3678 bool HasIndexedLookupInterceptor();
3687 int GetIdentityHash();
3704 return object.val_->CreationContext();
3717 bool IsConstructor();
3739 Isolate* GetIsolate();
3758 static void CheckCast(
Value* obj);
3760 void* SlowGetAlignedPointerFromInternalField(
int index);
3769 uint32_t Length()
const;
3775 static Local<Array> New(Isolate* isolate,
int length = 0);
3780 static void CheckCast(
Value* obj);
3789 size_t Size()
const;
3812 V8_INLINE
static Map* Cast(
Value* obj);
3816 static void CheckCast(
Value* obj);
3825 size_t Size()
const;
3844 V8_INLINE
static Set* Cast(
Value* obj);
3848 static void CheckCast(
Value* obj);
3852 template<
typename T>
3856 : value_(that.value_) {
3860 template <
typename S>
3861 V8_INLINE V8_DEPRECATE_SOON(
"Use Global<> instead",
3862 void Set(
const Persistent<S>& handle));
3863 template <
typename S>
3864 V8_INLINE
void Set(
const Global<S>& handle);
3865 template <
typename S>
3866 V8_INLINE
void Set(
const Local<S> handle);
3868 V8_INLINE
void Set(
bool value);
3869 V8_INLINE
void Set(
double i);
3870 V8_INLINE
void Set(int32_t i);
3871 V8_INLINE
void Set(uint32_t i);
3873 V8_INLINE
void SetNull();
3874 V8_INLINE
void SetUndefined();
3875 V8_INLINE
void SetEmptyString();
3877 V8_INLINE Isolate* GetIsolate()
const;
3880 template <
typename S>
3881 V8_INLINE
void Set(S* whatever);
3886 V8_INLINE Local<Value> Get()
const;
3889 template<
class F>
friend class ReturnValue;
3890 template<
class F>
friend class FunctionCallbackInfo;
3891 template<
class F>
friend class PropertyCallbackInfo;
3892 template <
class F,
class G,
class H>
3893 friend class PersistentValueMapBase;
3894 V8_INLINE
void SetInternal(internal::Object* value) { *value_ = value; }
3895 V8_INLINE internal::Object* GetDefaultValue();
3896 V8_INLINE
explicit ReturnValue(internal::Object** slot);
3897 internal::Object** value_;
3907 template<
typename T>
3908 class FunctionCallbackInfo {
3911 V8_INLINE
int Length()
const;
3913 V8_INLINE Local<Value>
operator[](
int i)
const;
3915 V8_INLINE Local<Object>
This()
const;
3926 V8_INLINE Local<Object>
Holder()
const;
3928 V8_INLINE Local<Value>
NewTarget()
const;
3932 V8_INLINE Local<Value>
Data()
const;
3938 static const int kArgsLength = 6;
3941 friend class internal::FunctionCallbackArguments;
3942 friend class internal::CustomArguments<FunctionCallbackInfo>;
3943 friend class debug::ConsoleCallArguments;
3944 static const int kHolderIndex = 0;
3945 static const int kIsolateIndex = 1;
3946 static const int kReturnValueDefaultValueIndex = 2;
3947 static const int kReturnValueIndex = 3;
3948 static const int kDataIndex = 4;
3949 static const int kNewTargetIndex = 5;
3951 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
3952 internal::Object** values,
int length);
3953 internal::Object** implicit_args_;
3954 internal::Object** values_;
3963 template<
typename T>
3964 class PropertyCallbackInfo {
3976 V8_INLINE Local<Value>
Data()
const;
4019 V8_INLINE Local<Object>
This()
const;
4030 V8_INLINE Local<Object>
Holder()
const;
4052 static const int kArgsLength = 7;
4055 friend class MacroAssembler;
4056 friend class internal::PropertyCallbackArguments;
4057 friend class internal::CustomArguments<PropertyCallbackInfo>;
4058 static const int kShouldThrowOnErrorIndex = 0;
4059 static const int kHolderIndex = 1;
4060 static const int kIsolateIndex = 2;
4061 static const int kReturnValueDefaultValueIndex = 3;
4062 static const int kReturnValueIndex = 4;
4063 static const int kDataIndex = 5;
4064 static const int kThisIndex = 6;
4066 V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
4067 internal::Object** args_;
4071 typedef void (*FunctionCallback)(
const FunctionCallbackInfo<Value>& info);
4073 enum class ConstructorBehavior { kThrow, kAllow };
4087 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
4088 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
4089 static V8_DEPRECATE_SOON(
4090 "Use maybe version",
4099 return NewInstance(context, 0,
nullptr);
4109 SideEffectType side_effect_type = SideEffectType::kHasSideEffect)
const;
4111 V8_DEPRECATE_SOON(
"Use maybe version",
4145 int GetScriptLineNumber()
const;
4150 int GetScriptColumnNumber()
const;
4155 int ScriptId()
const;
4165 static const int kLineOffsetNotFound;
4169 static void CheckCast(
Value* obj);
4172 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT 4174 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0 4215 static void CheckCast(
Value* obj);
4249 static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
4253 static void CheckCast(
Value* obj);
4301 bool has_value()
const;
4304 bool has_get()
const;
4306 bool has_set()
const;
4308 void set_enumerable(
bool enumerable);
4309 bool enumerable()
const;
4310 bool has_enumerable()
const;
4312 void set_configurable(
bool configurable);
4313 bool configurable()
const;
4314 bool has_configurable()
const;
4316 bool writable()
const;
4317 bool has_writable()
const;
4320 PrivateData* get_private()
const {
return private_; }
4326 PrivateData* private_;
4351 static void CheckCast(
Value* obj);
4358 typedef std::pair<std::unique_ptr<const uint8_t[]>,
size_t> SerializedModule;
4363 "Use BufferReference.",
4364 typedef std::pair<const uint8_t * COMMA size_t> CallerOwnedBuffer);
4371 const uint8_t* start;
4374 : start(start), size(size) {}
4377 "Use BufferReference directly.",
4379 V8_DEPRECATED(
"Use BufferReference directly.",
4380 inline operator CallerOwnedBuffer());
4396 typedef std::shared_ptr<internal::wasm::NativeModule> SharedModule;
4397 typedef std::pair<std::unique_ptr<const uint8_t[]>,
size_t> OwnedBuffer;
4400 : shared_module_(std::move(shared_module)) {}
4402 : serialized_(std::move(serialized)), wire_bytes_(std::move(bytes)) {}
4404 SharedModule shared_module_;
4405 OwnedBuffer serialized_ = {
nullptr, 0};
4406 OwnedBuffer wire_bytes_ = {
nullptr, 0};
4427 V8_DEPRECATED(
"Use GetWasmWireBytesRef version.",
4434 SerializedModule Serialize();
4450 const uint8_t* start,
4453 const TransferrableModule::OwnedBuffer& buff) {
4454 return {buff.first.get(), buff.second};
4457 WasmCompiledModule();
4458 static void CheckCast(Value* obj);
4462 WasmCompiledModule::BufferReference::BufferReference(
4463 WasmCompiledModule::CallerOwnedBuffer buf)
4464 : BufferReference(buf.first, buf.second) {}
4465 WasmCompiledModule::BufferReference::
4466 operator WasmCompiledModule::CallerOwnedBuffer() {
4467 return {start, size};
4478 class WasmStreamingImpl;
4488 void OnBytesReceived(
const uint8_t* bytes,
size_t size);
4509 static std::shared_ptr<WasmStreaming> Unpack(Isolate* isolate,
4513 std::unique_ptr<WasmStreamingImpl> impl_;
4524 void OnBytesReceived(
const uint8_t*,
size_t size);
4545 Isolate* isolate_ =
nullptr;
4559 std::shared_ptr<internal::wasm::StreamingDecoder> streaming_decoder_;
4562 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 4564 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 4568 enum class ArrayBufferCreationMode {
kInternalized, kExternalized };
4599 virtual void* Allocate(
size_t length) = 0;
4605 virtual void* AllocateUninitialized(
size_t length) = 0;
4611 virtual void Free(
void* data,
size_t length) = 0;
4626 static Allocator* NewDefaultAllocator();
4640 using DeleterCallback = void (*)(
void* buffer,
size_t length,
void* info);
4645 allocation_base_(
nullptr),
4646 allocation_length_(0),
4647 allocation_mode_(Allocator::AllocationMode::kNormal),
4649 deleter_data_(
nullptr) {}
4651 void* AllocationBase()
const {
return allocation_base_; }
4652 size_t AllocationLength()
const {
return allocation_length_; }
4654 return allocation_mode_;
4657 void*
Data()
const {
return data_; }
4658 size_t ByteLength()
const {
return byte_length_; }
4659 DeleterCallback Deleter()
const {
return deleter_; }
4660 void* DeleterData()
const {
return deleter_data_; }
4663 Contents(
void* data,
size_t byte_length,
void* allocation_base,
4664 size_t allocation_length,
4666 void* deleter_data);
4669 size_t byte_length_;
4670 void* allocation_base_;
4671 size_t allocation_length_;
4673 DeleterCallback deleter_;
4674 void* deleter_data_;
4683 size_t ByteLength()
const;
4703 Isolate* isolate,
void* data,
size_t byte_length,
4704 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
4715 bool IsNeuterable()
const;
4749 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4750 static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4754 static void CheckCast(
Value* obj);
4758 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 4760 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2 4777 size_t ByteOffset();
4781 size_t ByteLength();
4792 size_t CopyContents(
void* dest,
size_t byte_length);
4798 bool HasBuffer()
const;
4802 static const int kInternalFieldCount =
4803 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
4804 static const int kEmbedderFieldCount =
4805 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
4809 static void CheckCast(
Value* obj);
4822 static constexpr
size_t kMaxLength = internal::kSmiMaxValue;
4834 static void CheckCast(
Value* obj);
4844 size_t byte_offset,
size_t length);
4846 size_t byte_offset,
size_t length);
4851 static void CheckCast(
Value* obj);
4861 size_t byte_offset,
size_t length);
4869 static void CheckCast(
Value* obj);
4878 size_t byte_offset,
size_t length);
4880 size_t byte_offset,
size_t length);
4885 static void CheckCast(
Value* obj);
4895 size_t byte_offset,
size_t length);
4897 size_t byte_offset,
size_t length);
4902 static void CheckCast(
Value* obj);
4912 size_t byte_offset,
size_t length);
4914 size_t byte_offset,
size_t length);
4919 static void CheckCast(
Value* obj);
4929 size_t byte_offset,
size_t length);
4931 size_t byte_offset,
size_t length);
4936 static void CheckCast(
Value* obj);
4946 size_t byte_offset,
size_t length);
4948 size_t byte_offset,
size_t length);
4953 static void CheckCast(
Value* obj);
4963 size_t byte_offset,
size_t length);
4965 size_t byte_offset,
size_t length);
4970 static void CheckCast(
Value* obj);
4980 size_t byte_offset,
size_t length);
4982 size_t byte_offset,
size_t length);
4987 static void CheckCast(
Value* obj);
4996 size_t byte_offset,
size_t length);
4998 size_t byte_offset,
size_t length);
5003 static void CheckCast(
Value* obj);
5012 size_t byte_offset,
size_t length);
5014 size_t byte_offset,
size_t length);
5019 static void CheckCast(
Value* obj);
5028 size_t byte_offset,
size_t length);
5030 size_t byte_offset,
size_t length);
5035 static void CheckCast(
Value* obj);
5059 using DeleterCallback = void (*)(
void* buffer,
size_t length,
void* info);
5064 allocation_base_(
nullptr),
5065 allocation_length_(0),
5066 allocation_mode_(Allocator::AllocationMode::kNormal),
5068 deleter_data_(
nullptr) {}
5070 void* AllocationBase()
const {
return allocation_base_; }
5071 size_t AllocationLength()
const {
return allocation_length_; }
5073 return allocation_mode_;
5076 void*
Data()
const {
return data_; }
5077 size_t ByteLength()
const {
return byte_length_; }
5078 DeleterCallback Deleter()
const {
return deleter_; }
5079 void* DeleterData()
const {
return deleter_data_; }
5082 Contents(
void* data,
size_t byte_length,
void* allocation_base,
5083 size_t allocation_length,
5085 void* deleter_data);
5088 size_t byte_length_;
5089 void* allocation_base_;
5090 size_t allocation_length_;
5092 DeleterCallback deleter_;
5093 void* deleter_data_;
5101 size_t ByteLength()
const;
5118 Isolate* isolate,
void* data,
size_t byte_length,
5119 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
5157 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
5161 static void CheckCast(
Value* obj);
5170 static V8_DEPRECATE_SOON(
"Use maybe version.",
5179 double ValueOf()
const;
5181 V8_INLINE
static Date* Cast(
Value* obj);
5195 static void DateTimeConfigurationChangeNotification(Isolate* isolate);
5198 static void CheckCast(
Value* obj);
5207 static Local<Value> New(Isolate* isolate,
double value);
5209 double ValueOf()
const;
5214 static void CheckCast(
Value* obj);
5222 static Local<Value> New(Isolate* isolate, int64_t value);
5229 static void CheckCast(
Value* obj);
5239 bool ValueOf()
const;
5244 static void CheckCast(
Value* obj);
5254 static V8_DEPRECATED(
"Use Isolate* version",
5262 static void CheckCast(
Value* obj);
5278 static void CheckCast(
Value* obj);
5294 kIgnoreCase = 1 << 1,
5295 kMultiline = 1 << 2,
5324 Flags GetFlags()
const;
5329 static void CheckCast(
Value* obj);
5341 void*
Value()
const;
5346 #define V8_INTRINSICS_LIST(F) \ 5347 F(ArrayProto_entries, array_entries_iterator) \ 5348 F(ArrayProto_forEach, array_for_each_iterator) \ 5349 F(ArrayProto_keys, array_keys_iterator) \ 5350 F(ArrayProto_values, array_values_iterator) \ 5351 F(ErrorPrototype, initial_error_prototype) \ 5352 F(IteratorPrototype, initial_iterator_prototype) 5355 #define V8_DECL_INTRINSIC(name, iname) k##name, 5356 V8_INTRINSICS_LIST(V8_DECL_INTRINSIC)
5357 #undef V8_DECL_INTRINSIC 5378 V8_INLINE
void Set(Isolate* isolate,
const char* name,
Local<Data> value);
5380 void SetAccessorProperty(
5416 AccessorSetterCallback setter = 0,
5421 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
5423 Local<Name> name, AccessorNameGetterCallback getter,
5424 AccessorNameSetterCallback setter = 0,
5429 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
5436 Local<Name> name, AccessorNameGetterCallback getter,
5438 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
5444 void SetIntrinsicDataProperty(
Local<Name> name, Intrinsic intrinsic,
5799 Isolate* isolate, FunctionCallback callback = 0,
5802 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
5803 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
5813 Isolate* isolate, FunctionCallback callback,
5816 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
5819 V8_DEPRECATE_SOON(
"Use maybe version",
Local<Function> GetFunction());
5837 void SetCallHandler(
5839 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
5842 void SetLength(
int length);
5880 void SetAcceptAnyReceiver(
bool value);
5894 void SetHiddenPrototype(
bool value);
5900 void ReadOnlyPrototype();
5906 void RemovePrototype();
5919 static void CheckCast(
Data* that);
5920 friend class Context;
5954 kHasNoSideEffect = 1 << 3,
5972 enumerator(enumerator),
5974 descriptor(descriptor),
5991 enumerator(enumerator),
6010 enumerator(enumerator),
6012 descriptor(descriptor),
6042 enumerator(enumerator),
6044 descriptor(descriptor),
6061 enumerator(enumerator),
6080 enumerator(enumerator),
6082 descriptor(descriptor),
6116 V8_DEPRECATE_SOON(
"Use maybe version",
Local<Object> NewInstance());
6153 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
6155 Local<Name> name, AccessorNameGetterCallback getter,
6159 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect);
6199 deleter, enumerator, data));
6220 void SetCallAsFunctionHandler(FunctionCallback callback,
6231 void MarkAsUndetectable();
6250 void SetAccessCheckCallbackAndHandler(
6266 void SetInternalFieldCount(
int value);
6271 bool IsImmutableProto();
6277 void SetImmutableProto();
6285 static void CheckCast(
Data* that);
6308 static void CheckCast(
Data* that);
6327 static void CheckCast(
Data* that);
6332 V8_DEPRECATE_SOON(
"Implementation detail",
class)
6333 V8_EXPORT ExternalOneByteStringResourceImpl
6334 : public
String::ExternalOneByteStringResource {
6336 ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
6337 ExternalOneByteStringResourceImpl(
const char* data,
size_t length)
6338 : data_(data), length_(length) {}
6339 const char* data()
const {
return data_; }
6340 size_t length()
const {
return length_; }
6350 class V8_EXPORT Extension {
6354 Extension(
const char* name,
6355 const char* source = 0,
6357 const char** deps = 0,
6358 int source_length = -1);
6359 virtual ~Extension() {
delete source_; }
6360 virtual Local<FunctionTemplate> GetNativeFunctionTemplate(
6361 Isolate* isolate, Local<String> name) {
6362 return Local<FunctionTemplate>();
6365 const char* name()
const {
return name_; }
6366 size_t source_length()
const {
return source_length_; }
6367 const String::ExternalOneByteStringResource* source()
const {
6370 int dependency_count() {
return dep_count_; }
6371 const char** dependencies() {
return deps_; }
6372 void set_auto_enable(
bool value) { auto_enable_ = value; }
6373 bool auto_enable() {
return auto_enable_; }
6376 Extension(
const Extension&) =
delete;
6377 void operator=(
const Extension&) =
delete;
6381 size_t source_length_;
6382 String::ExternalOneByteStringResource* source_;
6389 void V8_EXPORT RegisterExtension(Extension* extension);
6394 V8_INLINE Local<Primitive> Undefined(Isolate* isolate);
6395 V8_INLINE Local<Primitive> Null(Isolate* isolate);
6396 V8_INLINE Local<Boolean> True(Isolate* isolate);
6397 V8_INLINE Local<Boolean> False(Isolate* isolate);
6413 class V8_EXPORT ResourceConstraints {
6415 ResourceConstraints();
6426 void ConfigureDefaults(uint64_t physical_memory,
6427 uint64_t virtual_memory_limit);
6430 V8_DEPRECATE_SOON(
"Use max_semi_space_size_in_kb()",
6431 size_t max_semi_space_size()) {
6432 return max_semi_space_size_in_kb_ / 1024;
6436 V8_DEPRECATE_SOON(
"Use set_max_semi_space_size_in_kb(size_t limit_in_kb)",
6437 void set_max_semi_space_size(
size_t limit_in_mb)) {
6438 max_semi_space_size_in_kb_ = limit_in_mb * 1024;
6442 size_t max_semi_space_size_in_kb()
const {
6443 return max_semi_space_size_in_kb_;
6447 void set_max_semi_space_size_in_kb(
size_t limit_in_kb) {
6448 max_semi_space_size_in_kb_ = limit_in_kb;
6451 size_t max_old_space_size()
const {
return max_old_space_size_; }
6452 void set_max_old_space_size(
size_t limit_in_mb) {
6453 max_old_space_size_ = limit_in_mb;
6455 V8_DEPRECATE_SOON(
"max_executable_size_ is subsumed by max_old_space_size_",
6456 size_t max_executable_size()
const) {
6457 return max_executable_size_;
6459 V8_DEPRECATE_SOON(
"max_executable_size_ is subsumed by max_old_space_size_",
6460 void set_max_executable_size(
size_t limit_in_mb)) {
6461 max_executable_size_ = limit_in_mb;
6463 uint32_t* stack_limit()
const {
return stack_limit_; }
6465 void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
6466 size_t code_range_size()
const {
return code_range_size_; }
6467 void set_code_range_size(
size_t limit_in_mb) {
6468 code_range_size_ = limit_in_mb;
6470 size_t max_zone_pool_size()
const {
return max_zone_pool_size_; }
6471 void set_max_zone_pool_size(
size_t bytes) { max_zone_pool_size_ = bytes; }
6475 size_t max_semi_space_size_in_kb_;
6478 size_t max_old_space_size_;
6479 size_t max_executable_size_;
6480 uint32_t* stack_limit_;
6481 size_t code_range_size_;
6482 size_t max_zone_pool_size_;
6489 typedef void (*FatalErrorCallback)(
const char* location,
const char* message);
6491 typedef void (*OOMErrorCallback)(
const char* location,
bool is_heap_oom);
6493 typedef void (*DcheckErrorCallback)(
const char* file,
int line,
6494 const char* message);
6496 typedef void (*MessageCallback)(Local<Message> message, Local<Value> data);
6500 typedef void (*LogEventCallback)(
const char* name,
int event);
6506 class V8_EXPORT Exception {
6508 static Local<Value> RangeError(Local<String> message);
6509 static Local<Value> ReferenceError(Local<String> message);
6510 static Local<Value> SyntaxError(Local<String> message);
6511 static Local<Value> TypeError(Local<String> message);
6512 static Local<Value> Error(Local<String> message);
6519 static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
6525 static Local<StackTrace> GetStackTrace(Local<Value> exception);
6531 typedef int* (*CounterLookupCallback)(
const char* name);
6533 typedef void* (*CreateHistogramCallback)(
const char* name,
6538 typedef void (*AddHistogramSampleCallback)(
void* histogram,
int sample);
6541 typedef void (*BeforeCallEnteredCallback)(Isolate*);
6542 typedef void (*CallCompletedCallback)(Isolate*);
6564 typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)(
6565 Local<Context> context, Local<ScriptOrModule> referrer,
6566 Local<String> specifier);
6578 typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
6579 Local<Module> module,
6580 Local<Object> meta);
6598 enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
6600 typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
6601 Local<Value> parent);
6604 enum PromiseRejectEvent {
6605 kPromiseRejectWithNoHandler = 0,
6606 kPromiseHandlerAddedAfterReject = 1,
6607 kPromiseRejectAfterResolved = 2,
6608 kPromiseResolveAfterResolved = 3,
6611 class PromiseRejectMessage {
6613 PromiseRejectMessage(Local<Promise> promise, PromiseRejectEvent event,
6614 Local<Value> value, Local<StackTrace> stack_trace)
6615 : promise_(promise),
6618 stack_trace_(stack_trace) {}
6620 V8_INLINE Local<Promise> GetPromise()
const {
return promise_; }
6621 V8_INLINE PromiseRejectEvent GetEvent()
const {
return event_; }
6622 V8_INLINE Local<Value> GetValue()
const {
return value_; }
6625 Local<Promise> promise_;
6626 PromiseRejectEvent event_;
6627 Local<Value> value_;
6628 Local<StackTrace> stack_trace_;
6631 typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
6634 typedef void (*MicrotasksCompletedCallback)(Isolate*);
6635 typedef void (*MicrotaskCallback)(
void* data);
6645 enum class MicrotasksPolicy { kExplicit, kScoped, kAuto };
6657 class V8_EXPORT MicrotasksScope {
6659 enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
6661 MicrotasksScope(Isolate* isolate, Type type);
6667 static void PerformCheckpoint(Isolate* isolate);
6672 static int GetCurrentDepth(Isolate* isolate);
6677 static bool IsRunningMicrotasks(Isolate* isolate);
6680 MicrotasksScope(
const MicrotasksScope&) =
delete;
6681 MicrotasksScope& operator=(
const MicrotasksScope&) =
delete;
6684 internal::Isolate*
const isolate_;
6690 typedef void (*FailedAccessCheckCallback)(Local<Object> target,
6700 typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
6701 Local<String> source);
6704 typedef bool (*ExtensionCallback)(
const FunctionCallbackInfo<Value>&);
6706 typedef bool (*AllowWasmCodeGenerationCallback)(Local<Context> context,
6707 Local<String> source);
6711 typedef void (*ApiImplementationCallback)(
const FunctionCallbackInfo<Value>&);
6714 typedef void (*WasmStreamingCallback)(
const FunctionCallbackInfo<Value>&);
6717 typedef bool (*WasmThreadsEnabledCallback)(Local<Context> context);
6729 kGCTypeScavenge = 1 << 0,
6730 kGCTypeMarkSweepCompact = 1 << 1,
6731 kGCTypeIncrementalMarking = 1 << 2,
6732 kGCTypeProcessWeakCallbacks = 1 << 3,
6733 kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact |
6734 kGCTypeIncrementalMarking | kGCTypeProcessWeakCallbacks
6751 enum GCCallbackFlags {
6752 kNoGCCallbackFlags = 0,
6753 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
6754 kGCCallbackFlagForced = 1 << 2,
6755 kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3,
6756 kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4,
6757 kGCCallbackFlagCollectAllExternalMemory = 1 << 5,
6758 kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
6761 typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
6763 typedef void (*InterruptCallback)(Isolate* isolate,
void* data);
6772 typedef size_t (*NearHeapLimitCallback)(
void* data,
size_t current_heap_limit,
6773 size_t initial_heap_limit);
6781 class V8_EXPORT HeapStatistics {
6784 size_t total_heap_size() {
return total_heap_size_; }
6785 size_t total_heap_size_executable() {
return total_heap_size_executable_; }
6786 size_t total_physical_size() {
return total_physical_size_; }
6787 size_t total_available_size() {
return total_available_size_; }
6788 size_t used_heap_size() {
return used_heap_size_; }
6789 size_t heap_size_limit() {
return heap_size_limit_; }
6790 size_t malloced_memory() {
return malloced_memory_; }
6791 size_t external_memory() {
return external_memory_; }
6792 size_t peak_malloced_memory() {
return peak_malloced_memory_; }
6793 size_t number_of_native_contexts() {
return number_of_native_contexts_; }
6794 size_t number_of_detached_contexts() {
return number_of_detached_contexts_; }
6800 size_t does_zap_garbage() {
return does_zap_garbage_; }
6803 size_t total_heap_size_;
6804 size_t total_heap_size_executable_;
6805 size_t total_physical_size_;
6806 size_t total_available_size_;
6807 size_t used_heap_size_;
6808 size_t heap_size_limit_;
6809 size_t malloced_memory_;
6810 size_t external_memory_;
6811 size_t peak_malloced_memory_;
6812 bool does_zap_garbage_;
6813 size_t number_of_native_contexts_;
6814 size_t number_of_detached_contexts_;
6817 friend class Isolate;
6821 class V8_EXPORT HeapSpaceStatistics {
6823 HeapSpaceStatistics();
6824 const char* space_name() {
return space_name_; }
6825 size_t space_size() {
return space_size_; }
6826 size_t space_used_size() {
return space_used_size_; }
6827 size_t space_available_size() {
return space_available_size_; }
6828 size_t physical_space_size() {
return physical_space_size_; }
6831 const char* space_name_;
6833 size_t space_used_size_;
6834 size_t space_available_size_;
6835 size_t physical_space_size_;
6837 friend class Isolate;
6841 class V8_EXPORT HeapObjectStatistics {
6843 HeapObjectStatistics();
6844 const char* object_type() {
return object_type_; }
6845 const char* object_sub_type() {
return object_sub_type_; }
6846 size_t object_count() {
return object_count_; }
6847 size_t object_size() {
return object_size_; }
6850 const char* object_type_;
6851 const char* object_sub_type_;
6852 size_t object_count_;
6853 size_t object_size_;
6855 friend class Isolate;
6858 class V8_EXPORT HeapCodeStatistics {
6860 HeapCodeStatistics();
6861 size_t code_and_metadata_size() {
return code_and_metadata_size_; }
6862 size_t bytecode_and_metadata_size() {
return bytecode_and_metadata_size_; }
6863 size_t external_script_source_size() {
return external_script_source_size_; }
6866 size_t code_and_metadata_size_;
6867 size_t bytecode_and_metadata_size_;
6868 size_t external_script_source_size_;
6870 friend class Isolate;
6873 class RetainedObjectInfo;
6887 typedef void (*FunctionEntryHook)(uintptr_t
function,
6888 uintptr_t return_addr_location);
6895 struct JitCodeEvent {
6900 CODE_ADD_LINE_POS_INFO,
6901 CODE_START_LINE_INFO_RECORDING,
6902 CODE_END_LINE_INFO_RECORDING
6909 enum PositionType { POSITION, STATEMENT_POSITION };
6917 enum CodeType { BYTE_CODE, JIT_CODE };
6927 Local<UnboundScript> script;
6948 PositionType position_type;
6959 void* new_code_start;
6974 PERFORMANCE_RESPONSE,
6978 PERFORMANCE_ANIMATION,
6990 enum JitCodeEventOptions {
6991 kJitCodeEventDefault = 0,
6993 kJitCodeEventEnumExisting = 1
7002 typedef void (*JitCodeEventHandler)(
const JitCodeEvent* event);
7008 class V8_EXPORT ExternalResourceVisitor {
7010 virtual ~ExternalResourceVisitor() {}
7011 virtual void VisitExternalString(Local<String>
string) {}
7018 class V8_EXPORT PersistentHandleVisitor {
7020 virtual ~PersistentHandleVisitor() {}
7021 virtual void VisitPersistentHandle(Persistent<Value>* value,
7022 uint16_t class_id) {}
7033 enum class MemoryPressureLevel {
kNone, kModerate, kCritical };
7042 class V8_EXPORT EmbedderHeapTracer {
7045 enum EmbedderStackState {
7051 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION };
7055 : force_completion(force_completion_) {}
7057 ForceCompletionAction force_completion;
7060 virtual ~EmbedderHeapTracer() =
default;
7068 virtual void RegisterV8References(
7069 const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
7074 virtual void TracePrologue() = 0;
7089 V8_DEPRECATE_SOON(
"Use void AdvanceTracing(deadline_in_ms)",
7090 virtual bool AdvanceTracing(
7108 virtual bool AdvanceTracing(
double deadline_in_ms);
7114 virtual bool IsTracingDone();
7121 virtual void TraceEpilogue() = 0;
7130 V8_DEPRECATE_SOON(
"Use void EnterFinalPause(EmbedderStackState)",
7131 virtual void EnterFinalPause()) {}
7132 virtual void EnterFinalPause(EmbedderStackState stack_state);
7140 virtual void AbortTracing() = 0;
7151 void FinalizeTracing();
7158 void GarbageCollectionForTesting(EmbedderStackState stack_state);
7164 v8::Isolate* isolate()
const {
return isolate_; }
7169 V8_DEPRECATE_SOON(
"Use IsTracingDone",
7170 virtual size_t NumberOfWrappersToTrace()) {
7175 v8::Isolate* isolate_ =
nullptr;
7177 friend class internal::LocalEmbedderHeapTracer;
7184 struct SerializeInternalFieldsCallback {
7185 typedef StartupData (*CallbackFunction)(Local<Object> holder,
int index,
7187 SerializeInternalFieldsCallback(CallbackFunction
function =
nullptr,
7188 void* data_arg =
nullptr)
7189 : callback(function), data(data_arg) {}
7190 CallbackFunction callback;
7195 typedef SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback;
7201 struct DeserializeInternalFieldsCallback {
7202 typedef void (*CallbackFunction)(Local<Object> holder,
int index,
7203 StartupData payload,
void* data);
7204 DeserializeInternalFieldsCallback(CallbackFunction
function =
nullptr,
7205 void* data_arg =
nullptr)
7206 : callback(function), data(data_arg) {}
7207 void (*callback)(Local<Object> holder,
int index, StartupData payload,
7211 typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
7221 class V8_EXPORT Isolate {
7228 : entry_hook(
nullptr),
7229 code_event_handler(
nullptr),
7230 snapshot_blob(
nullptr),
7231 counter_lookup_callback(
nullptr),
7232 create_histogram_callback(
nullptr),
7233 add_histogram_sample_callback(
nullptr),
7234 array_buffer_allocator(
nullptr),
7235 external_references(
nullptr),
7236 allow_atomics_wait(
true),
7237 only_terminate_in_safe_scope(
false) {}
7279 AddHistogramSampleCallback add_histogram_sample_callback;
7314 explicit Scope(Isolate* isolate) : isolate_(isolate) {
7318 ~
Scope() { isolate_->Exit(); }
7325 Isolate*
const isolate_;
7334 enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
7366 void* internal_throws_;
7367 void* internal_assert_;
7386 internal::Isolate*
const isolate_;
7403 internal::Isolate* isolate_;
7411 enum GarbageCollectionType {
7412 kFullGarbageCollection,
7413 kMinorGarbageCollection
7421 enum UseCounterFeature {
7425 kMarkDequeOverflow = 3,
7426 kStoreBufferOverflow = 4,
7427 kSlotsBufferOverflow = 5,
7433 kRegExpPrototypeStickyGetter = 11,
7434 kRegExpPrototypeToString = 12,
7435 kRegExpPrototypeUnicodeGetter = 13,
7440 kPromiseAccept = 18,
7442 kHtmlCommentInExternalScript = 20,
7444 kSloppyModeBlockScopedFunctionRedefinition = 22,
7445 kForInInitializer = 23,
7446 kArrayProtectorDirtied = 24,
7447 kArraySpeciesModified = 25,
7448 kArrayPrototypeConstructorModified = 26,
7449 kArrayInstanceProtoModified = 27,
7450 kArrayInstanceConstructorModified = 28,
7451 kLegacyFunctionDeclaration = 29,
7452 kRegExpPrototypeSourceGetter = 30,
7453 kRegExpPrototypeOldFlagGetter = 31,
7454 kDecimalWithLeadingZeroInStrictMode = 32,
7455 kLegacyDateParser = 33,
7456 kDefineGetterOrSetterWouldThrow = 34,
7457 kFunctionConstructorReturnedUndefined = 35,
7458 kAssigmentExpressionLHSIsCallInSloppy = 36,
7459 kAssigmentExpressionLHSIsCallInStrict = 37,
7460 kPromiseConstructorReturnedUndefined = 38,
7461 kConstructorNonUndefinedPrimitiveReturn = 39,
7462 kLabeledExpressionStatement = 40,
7463 kLineOrParagraphSeparatorAsLineTerminator = 41,
7464 kIndexAccessor = 42,
7465 kErrorCaptureStackTrace = 43,
7466 kErrorPrepareStackTrace = 44,
7467 kErrorStackTraceLimit = 45,
7468 kWebAssemblyInstantiation = 46,
7469 kDeoptimizerDisableSpeculation = 47,
7470 kArrayPrototypeSortJSArrayModifiedPrototype = 48,
7471 kFunctionTokenOffsetTooLongForToString = 49,
7472 kWasmSharedMemory = 50,
7473 kWasmThreadOpcodes = 51,
7478 kUseCounterFeatureCount
7481 enum MessageErrorLevel {
7482 kMessageLog = (1 << 0),
7483 kMessageDebug = (1 << 1),
7484 kMessageInfo = (1 << 2),
7485 kMessageError = (1 << 3),
7486 kMessageWarning = (1 << 4),
7487 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
7491 typedef void (*UseCounterCallback)(Isolate* isolate,
7492 UseCounterFeature feature);
7508 static Isolate* Allocate();
7513 static void Initialize(Isolate* isolate,
const CreateParams& params);
7524 static Isolate* New(
const CreateParams& params);
7532 static Isolate* GetCurrent();
7543 typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
7544 void SetAbortOnUncaughtExceptionCallback(
7545 AbortOnUncaughtExceptionCallback callback);
7551 void SetHostImportModuleDynamicallyCallback(
7552 HostImportModuleDynamicallyCallback callback);
7558 void SetHostInitializeImportMetaObjectCallback(
7559 HostInitializeImportMetaObjectCallback callback);
7567 void MemoryPressureNotification(MemoryPressureLevel level);
7600 void DumpAndResetStats();
7609 void DiscardThreadSpecificMetadata();
7615 V8_INLINE
void SetData(uint32_t slot,
void* data);
7621 V8_INLINE
void* GetData(uint32_t slot);
7627 V8_INLINE
static uint32_t GetNumberOfDataSlots();
7635 V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(
size_t index);
7640 void GetHeapStatistics(HeapStatistics* heap_statistics);
7645 size_t NumberOfHeapSpaces();
7656 bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
7662 size_t NumberOfTrackedHeapObjectTypes();
7673 bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
7683 bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
7697 void GetStackSample(
const RegisterState& state,
void** frames,
7698 size_t frames_limit, SampleInfo* sample_info);
7714 AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
7720 size_t NumberOfPhantomHandleResetsSinceLastCall();
7726 HeapProfiler* GetHeapProfiler();
7731 void SetIdle(
bool is_idle);
7740 Local<Context> GetCurrentContext();
7743 Local<Context> GetEnteredContext();
7751 Local<Context> GetEnteredOrMicrotaskContext();
7757 Local<Context> GetIncumbentContext();
7765 Local<Value> ThrowException(Local<Value> exception);
7767 typedef void (*GCCallback)(Isolate* isolate, GCType type,
7768 GCCallbackFlags flags);
7769 typedef void (*GCCallbackWithData)(Isolate* isolate, GCType type,
7770 GCCallbackFlags flags,
void* data);
7781 void AddGCPrologueCallback(GCCallbackWithData callback,
void* data =
nullptr,
7782 GCType gc_type_filter = kGCTypeAll);
7783 void AddGCPrologueCallback(GCCallback callback,
7784 GCType gc_type_filter = kGCTypeAll);
7790 void RemoveGCPrologueCallback(GCCallbackWithData,
void* data =
nullptr);
7791 void RemoveGCPrologueCallback(GCCallback callback);
7796 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
7801 enum class AtomicsWaitEvent {
7809 kTerminatedExecution,
7862 typedef void (*AtomicsWaitCallback)(AtomicsWaitEvent event,
7864 size_t offset_in_bytes, int32_t value,
7865 double timeout_in_ms,
7875 void SetAtomicsWaitCallback(AtomicsWaitCallback callback,
void* data);
7886 void AddGCEpilogueCallback(GCCallbackWithData callback,
void* data =
nullptr,
7887 GCType gc_type_filter = kGCTypeAll);
7888 void AddGCEpilogueCallback(GCCallback callback,
7889 GCType gc_type_filter = kGCTypeAll);
7895 void RemoveGCEpilogueCallback(GCCallbackWithData callback,
7896 void* data =
nullptr);
7897 void RemoveGCEpilogueCallback(GCCallback callback);
7899 typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
7907 void SetGetExternallyAllocatedMemoryInBytesCallback(
7908 GetExternallyAllocatedMemoryInBytesCallback callback);
7917 void TerminateExecution();
7927 bool IsExecutionTerminating();
7943 void CancelTerminateExecution();
7953 void RequestInterrupt(InterruptCallback callback,
void* data);
7965 void RequestGarbageCollectionForTesting(GarbageCollectionType type);
7970 void SetEventLogger(LogEventCallback that);
7978 void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
7983 void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
7992 void AddCallCompletedCallback(CallCompletedCallback callback);
7997 void RemoveCallCompletedCallback(CallCompletedCallback callback);
8003 void SetPromiseHook(PromiseHook hook);
8009 void SetPromiseRejectCallback(PromiseRejectCallback callback);
8015 void RunMicrotasks();
8025 void EnqueueMicrotask(MicrotaskCallback callback,
void* data =
nullptr);
8030 void SetMicrotasksPolicy(MicrotasksPolicy policy);
8035 MicrotasksPolicy GetMicrotasksPolicy()
const;
8049 void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
8054 void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
8059 void SetUseCounterCallback(UseCounterCallback callback);
8065 void SetCounterFunction(CounterLookupCallback);
8073 void SetCreateHistogramFunction(CreateHistogramCallback);
8074 void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
8090 bool IdleNotificationDeadline(
double deadline_in_seconds);
8096 void LowMemoryNotification();
8107 int ContextDisposedNotification(
bool dependant_context =
true);
8113 void IsolateInForegroundNotification();
8119 void IsolateInBackgroundNotification();
8126 void EnableMemorySavingsMode();
8131 void DisableMemorySavingsMode();
8140 void SetRAILMode(RAILMode rail_mode);
8146 void IncreaseHeapLimitForDebugging();
8151 void RestoreOriginalHeapLimit();
8157 bool IsHeapLimitIncreasedForDebugging();
8181 void SetJitCodeEventHandler(JitCodeEventOptions options,
8182 JitCodeEventHandler event_handler);
8193 void SetStackLimit(uintptr_t stack_limit);
8208 void GetCodeRange(
void** start,
size_t* length_in_bytes);
8211 void SetFatalErrorHandler(FatalErrorCallback that);
8214 void SetOOMErrorHandler(OOMErrorCallback that);
8221 void AddNearHeapLimitCallback(NearHeapLimitCallback callback,
void* data);
8230 void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
8237 void SetAllowCodeGenerationFromStringsCallback(
8238 AllowCodeGenerationFromStringsCallback callback);
8244 void SetAllowWasmCodeGenerationCallback(
8245 AllowWasmCodeGenerationCallback callback);
8251 void SetWasmModuleCallback(ExtensionCallback callback);
8252 void SetWasmInstanceCallback(ExtensionCallback callback);
8254 void SetWasmCompileStreamingCallback(ApiImplementationCallback callback);
8256 void SetWasmStreamingCallback(WasmStreamingCallback callback);
8258 void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
8275 bool AddMessageListener(MessageCallback that,
8289 bool AddMessageListenerWithErrorLevel(MessageCallback that,
8296 void RemoveMessageListeners(MessageCallback that);
8299 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
8305 void SetCaptureStackTraceForUncaughtExceptions(
8306 bool capture,
int frame_limit = 10,
8314 void VisitExternalResources(ExternalResourceVisitor* visitor);
8320 void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
8329 void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
8336 void VisitWeakHandles(PersistentHandleVisitor* visitor);
8349 void SetAllowAtomicsWait(
bool allow);
8352 ~Isolate() =
delete;
8353 Isolate(
const Isolate&) =
delete;
8354 Isolate& operator=(
const Isolate&) =
delete;
8357 void*
operator new(
size_t size) =
delete;
8358 void*
operator new[](
size_t size) =
delete;
8359 void operator delete(
void*, size_t) =
delete;
8360 void operator delete[](
void*, size_t) =
delete;
8363 template <
class K,
class V,
class Traits>
8366 internal::Object** GetDataFromSnapshotOnce(
size_t index);
8367 void ReportExternalAllocationLimitReached();
8368 void CheckMemoryPressure();
8371 class V8_EXPORT StartupData {
8382 typedef bool (*EntropySource)(
unsigned char* buffer,
size_t length);
8397 typedef uintptr_t (*ReturnAddressLocationResolver)(
8398 uintptr_t return_addr_location);
8404 class V8_EXPORT V8 {
8421 static void SetNativesDataBlob(StartupData* startup_blob);
8422 static void SetSnapshotDataBlob(StartupData* startup_blob);
8425 static void SetDcheckErrorHandler(DcheckErrorCallback that);
8431 static void SetFlagsFromString(
const char* str,
int length);
8436 static void SetFlagsFromCommandLine(
int* argc,
8441 static const char* GetVersion();
8447 static bool Initialize();
8453 static void SetEntropySource(EntropySource source);
8459 static void SetReturnAddressLocationResolver(
8460 ReturnAddressLocationResolver return_address_resolver);
8471 static bool Dispose();
8480 static bool InitializeICU(
const char* icu_data_file =
nullptr);
8494 static bool InitializeICUDefaultLocation(
const char* exec_path,
8495 const char* icu_data_file =
nullptr);
8513 static void InitializeExternalStartupData(
const char* directory_path);
8514 static void InitializeExternalStartupData(
const char* natives_blob,
8515 const char* snapshot_blob);
8520 static void InitializePlatform(Platform* platform);
8526 static void ShutdownPlatform();
8548 static bool TryHandleSignal(
int signal_number,
void* info,
void* context);
8549 #endif // V8_OS_POSIX 8555 V8_DEPRECATE_SOON(
"Use EnableWebAssemblyTrapHandler",
8556 static bool RegisterDefaultSignalHandler());
8564 static bool EnableWebAssemblyTrapHandler(
bool use_v8_signal_handler);
8569 static internal::Object** GlobalizeReference(internal::Isolate* isolate,
8570 internal::Object** handle);
8571 static internal::Object** CopyPersistent(internal::Object** handle);
8572 static void DisposeGlobal(internal::Object** global_handle);
8573 static void MakeWeak(internal::Object** location,
void* data,
8574 WeakCallbackInfo<void>::Callback weak_callback,
8575 WeakCallbackType type);
8576 static void MakeWeak(internal::Object** location,
void* data,
8578 int internal_field_index1,
8580 int internal_field_index2,
8581 WeakCallbackInfo<void>::Callback weak_callback);
8582 static void MakeWeak(internal::Object*** location_addr);
8583 static void* ClearWeak(internal::Object** location);
8584 static void AnnotateStrongRetainer(internal::Object** location,
8586 static Value* Eternalize(Isolate* isolate, Value* handle);
8588 static void RegisterExternallyReferencedObject(internal::Object**
object,
8589 internal::Isolate* isolate);
8591 template <
class K,
class V,
class T>
8592 friend class PersistentValueMapBase;
8594 static void FromJustIsNothing();
8595 static void ToLocalEmpty();
8596 static void InternalFieldOutOfBounds(
int index);
8597 template <
class T>
friend class Local;
8599 friend class MaybeLocal;
8603 friend class WeakCallbackInfo;
8604 template <
class T>
friend class Eternal;
8605 template <
class T>
friend class PersistentBase;
8606 template <
class T,
class M>
friend class Persistent;
8607 friend class Context;
8613 class V8_EXPORT SnapshotCreator {
8615 enum class FunctionCodeHandling { kClear, kKeep };
8625 SnapshotCreator(Isolate* isolate,
8626 const intptr_t* external_references =
nullptr,
8627 StartupData* existing_blob =
nullptr);
8637 SnapshotCreator(
const intptr_t* external_references =
nullptr,
8638 StartupData* existing_blob =
nullptr);
8654 void SetDefaultContext(Local<Context> context,
8655 SerializeInternalFieldsCallback callback =
8656 SerializeInternalFieldsCallback());
8666 size_t AddContext(Local<Context> context,
8667 SerializeInternalFieldsCallback callback =
8668 SerializeInternalFieldsCallback());
8674 size_t AddTemplate(Local<Template> template_obj);
8683 V8_INLINE
size_t AddData(Local<Context> context, Local<T>
object);
8692 V8_INLINE
size_t AddData(Local<T>
object);
8702 StartupData CreateBlob(FunctionCodeHandling function_code_handling);
8705 SnapshotCreator(
const SnapshotCreator&) =
delete;
8706 void operator=(
const SnapshotCreator&) =
delete;
8709 size_t AddData(Local<Context> context, internal::Object*
object);
8710 size_t AddData(internal::Object*
object);
8728 V8_INLINE
bool IsNothing()
const {
return !has_value_; }
8729 V8_INLINE
bool IsJust()
const {
return has_value_; }
8740 V8_WARN_UNUSED_RESULT V8_INLINE
bool To(T* out)
const {
8741 if (V8_LIKELY(IsJust())) *out = value_;
8750 if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
8759 return has_value_ ? value_ : default_value;
8762 V8_INLINE
bool operator==(
const Maybe& other)
const {
8763 return (IsJust() == other.IsJust()) &&
8764 (!IsJust() || FromJust() == other.FromJust());
8767 V8_INLINE
bool operator!=(
const Maybe& other)
const {
8768 return !operator==(other);
8772 Maybe() : has_value_(false) {}
8773 explicit Maybe(
const T& t) : has_value_(true), value_(t) {}
8779 friend Maybe<U> Nothing();
8781 friend Maybe<U> Just(
const U& u);
8785 inline Maybe<T> Nothing() {
8790 inline Maybe<T> Just(
const T& t) {
8798 V8_INLINE
bool IsNothing()
const {
return !is_valid_; }
8799 V8_INLINE
bool IsJust()
const {
return is_valid_; }
8801 V8_INLINE
bool operator==(
const Maybe& other)
const {
8802 return IsJust() == other.IsJust();
8805 V8_INLINE
bool operator!=(
const Maybe& other)
const {
8806 return !operator==(other);
8812 Maybe() : is_valid_(false) {}
8813 explicit Maybe(JustTag) : is_valid_(true) {}
8818 friend Maybe<U> Nothing();
8819 friend Maybe<void> JustVoid();
8822 inline Maybe<void> JustVoid() {
return Maybe<void>(Maybe<void>::JustTag()); }
8827 class V8_EXPORT TryCatch {
8834 explicit TryCatch(Isolate* isolate);
8844 bool HasCaught()
const;
8854 bool CanContinue()
const;
8868 bool HasTerminated()
const;
8877 Local<Value> ReThrow();
8885 Local<Value> Exception()
const;
8891 V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
8892 Local<Context> context)
const;
8901 Local<v8::Message> Message()
const;
8923 void SetVerbose(
bool value);
8928 bool IsVerbose()
const;
8935 void SetCaptureMessage(
bool value);
8948 static void* JSStackComparableAddress(TryCatch* handler) {
8949 if (handler == NULL)
return NULL;
8950 return handler->js_stack_comparable_address_;
8953 TryCatch(
const TryCatch&) =
delete;
8954 void operator=(
const TryCatch&) =
delete;
8959 void*
operator new(
size_t size);
8960 void*
operator new[](
size_t size);
8961 void operator delete(
void*, size_t);
8962 void operator delete[](
void*, size_t);
8964 void ResetInternal();
8966 internal::Isolate* isolate_;
8970 void* js_stack_comparable_address_;
8971 bool is_verbose_ : 1;
8972 bool can_continue_ : 1;
8973 bool capture_message_ : 1;
8975 bool has_terminated_ : 1;
8977 friend class internal::Isolate;
8987 class V8_EXPORT ExtensionConfiguration {
8989 ExtensionConfiguration() : name_count_(0), names_(NULL) { }
8990 ExtensionConfiguration(
int name_count,
const char* names[])
8991 : name_count_(name_count), names_(names) { }
8993 const char** begin()
const {
return &names_[0]; }
8994 const char** end()
const {
return &names_[name_count_]; }
8997 const int name_count_;
8998 const char** names_;
9005 class V8_EXPORT Context {
9019 Local<Object> Global();
9025 void DetachGlobal();
9045 static Local<Context> New(
9046 Isolate* isolate, ExtensionConfiguration* extensions = NULL,
9047 MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
9048 MaybeLocal<Value> global_object = MaybeLocal<Value>(),
9049 DeserializeInternalFieldsCallback internal_fields_deserializer =
9050 DeserializeInternalFieldsCallback());
9071 static MaybeLocal<Context> FromSnapshot(
9072 Isolate* isolate,
size_t context_snapshot_index,
9073 DeserializeInternalFieldsCallback embedder_fields_deserializer =
9074 DeserializeInternalFieldsCallback(),
9075 ExtensionConfiguration* extensions =
nullptr,
9076 MaybeLocal<Value> global_object = MaybeLocal<Value>());
9095 static MaybeLocal<Object> NewRemoteContext(
9096 Isolate* isolate, Local<ObjectTemplate> global_template,
9097 MaybeLocal<Value> global_object = MaybeLocal<Value>());
9103 void SetSecurityToken(Local<Value> token);
9106 void UseDefaultSecurityToken();
9109 Local<Value> GetSecurityToken();
9132 enum EmbedderDataFields { kDebugIdIndex = 0 };
9137 uint32_t GetNumberOfEmbedderDataFields();
9143 V8_INLINE Local<Value> GetEmbedderData(
int index);
9151 Local<Object> GetExtrasBindingObject();
9158 void SetEmbedderData(
int index, Local<Value> value);
9166 V8_INLINE
void* GetAlignedPointerFromEmbedderData(
int index);
9173 void SetAlignedPointerInEmbedderData(
int index,
void* value);
9188 void AllowCodeGenerationFromStrings(
bool allow);
9194 bool IsCodeGenerationFromStringsAllowed();
9201 void SetErrorMessageForCodeGenerationFromStrings(Local<String> message);
9209 V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(
size_t index);
9220 V8_INLINE ~
Scope() { context_->Exit(); }
9241 friend class internal::Isolate;
9253 internal::Object** GetDataFromSnapshotOnce(
size_t index);
9255 void* SlowGetAlignedPointerFromEmbedderData(
int index);
9335 class V8_EXPORT Unlocker {
9340 V8_INLINE
explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
9344 void Initialize(Isolate* isolate);
9346 internal::Isolate* isolate_;
9350 class V8_EXPORT Locker {
9355 V8_INLINE
explicit Locker(Isolate* isolate) { Initialize(isolate); }
9363 static bool IsLocked(Isolate* isolate);
9368 static bool IsActive();
9371 Locker(
const Locker&) =
delete;
9372 void operator=(
const Locker&) =
delete;
9375 void Initialize(Isolate* isolate);
9379 internal::Isolate* isolate_;
9386 namespace internal {
9397 static const int kHeapObjectMapOffset = 0;
9398 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
9399 static const int kStringResourceOffset = 3 * kApiPointerSize;
9401 static const int kOddballKindOffset = 4 * kApiPointerSize + kApiDoubleSize;
9402 static const int kForeignAddressOffset = kApiPointerSize;
9403 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
9404 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
9405 static const int kContextHeaderSize = 2 * kApiPointerSize;
9406 static const int kContextEmbedderDataIndex = 5;
9407 static const int kFullStringRepresentationMask = 0x0f;
9408 static const int kStringEncodingMask = 0x8;
9409 static const int kExternalTwoByteRepresentationTag = 0x02;
9410 static const int kExternalOneByteRepresentationTag = 0x0a;
9412 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
9413 static const int kExternalMemoryOffset = 4 * kApiPointerSize;
9414 static const int kExternalMemoryLimitOffset =
9415 kExternalMemoryOffset + kApiInt64Size;
9416 static const int kExternalMemoryAtLastMarkCompactOffset =
9417 kExternalMemoryLimitOffset + kApiInt64Size;
9418 static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
9419 kApiInt64Size + kApiInt64Size +
9420 kApiPointerSize + kApiPointerSize;
9421 static const int kUndefinedValueRootIndex = 4;
9422 static const int kTheHoleValueRootIndex = 5;
9423 static const int kNullValueRootIndex = 6;
9424 static const int kTrueValueRootIndex = 7;
9425 static const int kFalseValueRootIndex = 8;
9426 static const int kEmptyStringRootIndex = 9;
9428 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
9429 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
9430 static const int kNodeStateMask = 0x7;
9431 static const int kNodeStateIsWeakValue = 2;
9432 static const int kNodeStateIsPendingValue = 3;
9433 static const int kNodeStateIsNearDeathValue = 4;
9434 static const int kNodeIsIndependentShift = 3;
9435 static const int kNodeIsActiveShift = 4;
9437 static const int kFirstNonstringType = 0x80;
9438 static const int kOddballType = 0x83;
9439 static const int kForeignType = 0x87;
9440 static const int kJSSpecialApiObjectType = 0x410;
9441 static const int kJSApiObjectType = 0x420;
9442 static const int kJSObjectType = 0x421;
9444 static const int kUndefinedOddballKind = 5;
9445 static const int kNullOddballKind = 3;
9447 static const uint32_t kNumIsolateDataSlots = 4;
9449 V8_EXPORT
static void CheckInitializedImpl(v8::Isolate* isolate);
9450 V8_INLINE
static void CheckInitialized(v8::Isolate* isolate) {
9451 #ifdef V8_ENABLE_CHECKS 9452 CheckInitializedImpl(isolate);
9456 V8_INLINE
static bool HasHeapObjectTag(
const internal::Object* value) {
9457 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
9461 V8_INLINE
static int SmiValue(
const internal::Object* value) {
9462 return PlatformSmiTagging::SmiToInt(value);
9465 V8_INLINE
static internal::Object* IntToSmi(
int value) {
9466 return PlatformSmiTagging::IntToSmi(value);
9469 V8_INLINE
static constexpr
bool IsValidSmi(intptr_t value) {
9470 return PlatformSmiTagging::IsValidSmi(value);
9473 V8_INLINE
static int GetInstanceType(
const internal::Object* obj) {
9474 typedef internal::Object O;
9475 O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
9476 return ReadField<uint16_t>(map, kMapInstanceTypeOffset);
9479 V8_INLINE
static int GetOddballKind(
const internal::Object* obj) {
9480 typedef internal::Object O;
9481 return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
9484 V8_INLINE
static bool IsExternalTwoByteString(
int instance_type) {
9485 int representation = (instance_type & kFullStringRepresentationMask);
9486 return representation == kExternalTwoByteRepresentationTag;
9489 V8_INLINE
static uint8_t GetNodeFlag(internal::Object** obj,
int shift) {
9490 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9491 return *addr & static_cast<uint8_t>(1U << shift);
9494 V8_INLINE
static void UpdateNodeFlag(internal::Object** obj,
9495 bool value,
int shift) {
9496 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9497 uint8_t mask = static_cast<uint8_t>(1U << shift);
9498 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
9501 V8_INLINE
static uint8_t GetNodeState(internal::Object** obj) {
9502 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9503 return *addr & kNodeStateMask;
9506 V8_INLINE
static void UpdateNodeState(internal::Object** obj,
9508 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9509 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
9512 V8_INLINE
static void SetEmbedderData(v8::Isolate* isolate,
9515 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
9516 kIsolateEmbedderDataOffset + slot * kApiPointerSize;
9517 *reinterpret_cast<void**>(addr) = data;
9520 V8_INLINE
static void* GetEmbedderData(
const v8::Isolate* isolate,
9522 const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
9523 kIsolateEmbedderDataOffset + slot * kApiPointerSize;
9524 return *reinterpret_cast<void* const*>(addr);
9527 V8_INLINE
static internal::Object** GetRoot(v8::Isolate* isolate,
9529 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
9530 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
9533 template <
typename T>
9534 V8_INLINE
static T ReadField(
const internal::Object* ptr,
int offset) {
9535 const uint8_t* addr =
9536 reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
9537 return *reinterpret_cast<const T*>(addr);
9540 template <
typename T>
9541 V8_INLINE
static T ReadEmbedderData(
const v8::Context* context,
int index) {
9542 typedef internal::Object O;
9544 O* ctx = *reinterpret_cast<O* const*>(context);
9545 int embedder_data_offset = I::kContextHeaderSize +
9546 (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
9547 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
9549 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
9550 return I::ReadField<T>(embedder_data, value_offset);
9556 template <
bool PerformCheck>
9559 static void Perform(T* data);
9570 void CastCheck<false>::Perform(T* data) {}
9573 V8_INLINE
void PerformCastCheck(T* data) {
9574 CastCheck<std::is_base_of<Data, T>::value>::Perform(data);
9582 return New(isolate, that.val_);
9587 return New(isolate, that.val_);
9593 if (that == NULL)
return Local<T>();
9595 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
9596 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
9597 reinterpret_cast<internal::Isolate*>(isolate), *p)));
9603 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
9605 val_ = reinterpret_cast<T*>(
9606 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle)));
9610 Local<T> Eternal<T>::Get(Isolate* isolate)
const {
9613 return Local<T>(val_);
9619 if (V8_UNLIKELY(val_ ==
nullptr)) V8::ToLocalEmpty();
9626 #ifdef V8_ENABLE_CHECKS 9627 if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
9628 V8::InternalFieldOutOfBounds(index);
9631 return embedder_fields_[index];
9636 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
9637 if (that == NULL)
return NULL;
9638 internal::Object** p = reinterpret_cast<internal::Object**>(that);
9639 return reinterpret_cast<T*>(
9640 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
9645 template <
class T,
class M>
9646 template <
class S,
class M2>
9647 void Persistent<T, M>::Copy(
const Persistent<S, M2>& that) {
9650 if (that.IsEmpty())
return;
9651 internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
9652 this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
9653 M::Copy(that,
this);
9657 bool PersistentBase<T>::IsIndependent()
const {
9658 typedef internal::Internals I;
9659 if (this->IsEmpty())
return false;
9660 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
9661 I::kNodeIsIndependentShift);
9667 if (this->IsEmpty())
return false;
9668 uint8_t node_state =
9669 I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
9670 return node_state == I::kNodeStateIsNearDeathValue ||
9671 node_state == I::kNodeStateIsPendingValue;
9678 if (this->IsEmpty())
return false;
9679 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
9680 I::kNodeStateIsWeakValue;
9686 if (this->IsEmpty())
return;
9687 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
9697 if (other.IsEmpty())
return;
9698 this->val_ = New(isolate, other.val_);
9705 const PersistentBase<S>& other) {
9708 if (other.IsEmpty())
return;
9709 this->val_ = New(isolate, other.val_);
9714 template <
typename P>
9717 WeakCallbackType type) {
9719 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
9720 reinterpret_cast<Callback>(callback), type);
9725 V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_));
9729 template <
typename P>
9731 return reinterpret_cast<P*>(
9732 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
9737 V8::AnnotateStrongRetainer(reinterpret_cast<internal::Object**>(this->val_),
9743 if (IsEmpty())
return;
9744 V8::RegisterExternallyReferencedObject(
9745 reinterpret_cast<internal::Object**>(this->val_),
9746 reinterpret_cast<internal::Isolate*>(isolate));
9752 if (this->IsEmpty())
return;
9753 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
true,
9754 I::kNodeIsIndependentShift);
9760 if (this->IsEmpty())
return;
9761 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
true,
9762 I::kNodeIsActiveShift);
9769 if (this->IsEmpty())
return;
9770 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
9771 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9772 *reinterpret_cast<uint16_t*>(addr) = class_id;
9779 if (this->IsEmpty())
return 0;
9780 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
9781 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9782 return *reinterpret_cast<uint16_t*>(addr);
9786 template<
typename T>
9789 template<
typename T>
9790 template<
typename S>
9791 void ReturnValue<T>::Set(
const Persistent<S>& handle) {
9793 if (V8_UNLIKELY(handle.IsEmpty())) {
9794 *value_ = GetDefaultValue();
9796 *value_ = *reinterpret_cast<internal::Object**>(*handle);
9800 template <
typename T>
9801 template <
typename S>
9802 void ReturnValue<T>::Set(
const Global<S>& handle) {
9804 if (V8_UNLIKELY(handle.IsEmpty())) {
9805 *value_ = GetDefaultValue();
9807 *value_ = *reinterpret_cast<internal::Object**>(*handle);
9811 template <
typename T>
9812 template <
typename S>
9813 void ReturnValue<T>::Set(
const Local<S> handle) {
9815 if (V8_UNLIKELY(handle.IsEmpty())) {
9816 *value_ = GetDefaultValue();
9818 *value_ = *reinterpret_cast<internal::Object**>(*handle);
9822 template<
typename T>
9823 void ReturnValue<T>::Set(
double i) {
9824 TYPE_CHECK(T, Number);
9825 Set(Number::New(GetIsolate(), i));
9828 template<
typename T>
9829 void ReturnValue<T>::Set(int32_t i) {
9830 TYPE_CHECK(T, Integer);
9831 typedef internal::Internals I;
9832 if (V8_LIKELY(I::IsValidSmi(i))) {
9833 *value_ = I::IntToSmi(i);
9836 Set(Integer::New(GetIsolate(), i));
9839 template<
typename T>
9840 void ReturnValue<T>::Set(uint32_t i) {
9841 TYPE_CHECK(T, Integer);
9843 bool fits_into_int32_t = (i & (1U << 31)) == 0;
9844 if (V8_LIKELY(fits_into_int32_t)) {
9845 Set(static_cast<int32_t>(i));
9848 Set(Integer::NewFromUnsigned(GetIsolate(), i));
9851 template<
typename T>
9852 void ReturnValue<T>::Set(
bool value) {
9853 TYPE_CHECK(T, Boolean);
9854 typedef internal::Internals I;
9857 root_index = I::kTrueValueRootIndex;
9859 root_index = I::kFalseValueRootIndex;
9861 *value_ = *I::GetRoot(GetIsolate(), root_index);
9864 template<
typename T>
9865 void ReturnValue<T>::SetNull() {
9866 TYPE_CHECK(T, Primitive);
9867 typedef internal::Internals I;
9868 *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
9871 template<
typename T>
9872 void ReturnValue<T>::SetUndefined() {
9873 TYPE_CHECK(T, Primitive);
9874 typedef internal::Internals I;
9875 *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
9878 template<
typename T>
9879 void ReturnValue<T>::SetEmptyString() {
9880 TYPE_CHECK(T, String);
9881 typedef internal::Internals I;
9882 *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
9885 template <
typename T>
9886 Isolate* ReturnValue<T>::GetIsolate()
const {
9888 return *reinterpret_cast<Isolate**>(&value_[-2]);
9891 template <
typename T>
9892 Local<Value> ReturnValue<T>::Get()
const {
9893 typedef internal::Internals I;
9894 if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
9895 return Local<Value>(*Undefined(GetIsolate()));
9899 template <
typename T>
9900 template <
typename S>
9901 void ReturnValue<T>::Set(S* whatever) {
9903 TYPE_CHECK(S*, Primitive);
9906 template<
typename T>
9907 internal::Object* ReturnValue<T>::GetDefaultValue() {
9912 template <
typename T>
9913 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
9914 internal::Object** values,
9916 : implicit_args_(implicit_args), values_(values), length_(length) {}
9918 template<
typename T>
9920 if (i < 0 || length_ <= i)
return Local<Value>(*Undefined(GetIsolate()));
9921 return Local<Value>(reinterpret_cast<Value*>(values_ - i));
9925 template<
typename T>
9927 return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
9931 template<
typename T>
9934 &implicit_args_[kHolderIndex]));
9937 template <
typename T>
9940 reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
9943 template <
typename T>
9945 return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
9949 template<
typename T>
9951 return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
9955 template<
typename T>
9961 template<
typename T>
9963 return !NewTarget()->IsUndefined();
9967 template<
typename T>
9981 : resource_name_(resource_name),
9982 resource_line_offset_(resource_line_offset),
9983 resource_column_offset_(resource_column_offset),
9984 options_(!resource_is_shared_cross_origin.IsEmpty() &&
9985 resource_is_shared_cross_origin->IsTrue(),
9986 !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
9987 !is_wasm.IsEmpty() && is_wasm->IsTrue(),
9988 !is_module.IsEmpty() && is_module->IsTrue()),
9989 script_id_(script_id),
9990 source_map_url_(source_map_url),
9991 host_defined_options_(host_defined_options) {}
9993 Local<Value> ScriptOrigin::ResourceName()
const {
return resource_name_; }
9995 Local<PrimitiveArray> ScriptOrigin::HostDefinedOptions()
const {
9996 return host_defined_options_;
9999 Local<Integer> ScriptOrigin::ResourceLineOffset()
const {
10000 return resource_line_offset_;
10004 Local<Integer> ScriptOrigin::ResourceColumnOffset()
const {
10005 return resource_column_offset_;
10009 Local<Integer> ScriptOrigin::ScriptID()
const {
return script_id_; }
10012 Local<Value> ScriptOrigin::SourceMapUrl()
const {
return source_map_url_; }
10014 ScriptCompiler::Source::Source(Local<String>
string,
const ScriptOrigin& origin,
10016 : source_string(string),
10017 resource_name(origin.ResourceName()),
10018 resource_line_offset(origin.ResourceLineOffset()),
10019 resource_column_offset(origin.ResourceColumnOffset()),
10020 resource_options(origin.Options()),
10021 source_map_url(origin.SourceMapUrl()),
10022 host_defined_options(origin.HostDefinedOptions()),
10023 cached_data(data) {}
10025 ScriptCompiler::Source::Source(Local<String>
string,
10027 : source_string(string), cached_data(data) {}
10030 ScriptCompiler::Source::~Source() {
10031 delete cached_data;
10035 const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
10037 return cached_data;
10040 const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions()
const {
10041 return resource_options;
10044 Local<Boolean> Boolean::New(Isolate* isolate,
bool value) {
10045 return value ? True(isolate) : False(isolate);
10048 void Template::Set(Isolate* isolate,
const char* name, Local<Data> value) {
10054 FunctionTemplate* FunctionTemplate::Cast(Data* data) {
10055 #ifdef V8_ENABLE_CHECKS 10058 return reinterpret_cast<FunctionTemplate*>(data);
10061 ObjectTemplate* ObjectTemplate::Cast(Data* data) {
10062 #ifdef V8_ENABLE_CHECKS 10065 return reinterpret_cast<ObjectTemplate*>(data);
10068 Signature* Signature::Cast(Data* data) {
10069 #ifdef V8_ENABLE_CHECKS 10072 return reinterpret_cast<Signature*>(data);
10075 AccessorSignature* AccessorSignature::Cast(Data* data) {
10076 #ifdef V8_ENABLE_CHECKS 10079 return reinterpret_cast<AccessorSignature*>(data);
10083 #ifndef V8_ENABLE_CHECKS 10084 typedef internal::Object O;
10086 O* obj = *reinterpret_cast<O**>(
this);
10089 auto instance_type = I::GetInstanceType(obj);
10090 if (instance_type == I::kJSObjectType ||
10091 instance_type == I::kJSApiObjectType ||
10092 instance_type == I::kJSSpecialApiObjectType) {
10093 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
10094 O* value = I::ReadField<O*>(obj, offset);
10095 O** result = HandleScope::CreateHandle(
10096 reinterpret_cast<internal::NeverReadOnlySpaceObject*>(obj), value);
10097 return Local<Value>(reinterpret_cast<Value*>(result));
10100 return SlowGetInternalField(index);
10105 #ifndef V8_ENABLE_CHECKS 10106 typedef internal::Object O;
10108 O* obj = *reinterpret_cast<O**>(
this);
10111 auto instance_type = I::GetInstanceType(obj);
10112 if (V8_LIKELY(instance_type == I::kJSObjectType ||
10113 instance_type == I::kJSApiObjectType ||
10114 instance_type == I::kJSSpecialApiObjectType)) {
10115 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
10116 return I::ReadField<void*>(obj, offset);
10119 return SlowGetAlignedPointerFromInternalField(index);
10123 #ifdef V8_ENABLE_CHECKS 10126 return static_cast<String*>(value);
10131 typedef internal::Object* S;
10133 I::CheckInitialized(isolate);
10134 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
10140 typedef internal::Object O;
10142 O* obj = *reinterpret_cast<O* const*>(
this);
10145 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
10146 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
10147 result = reinterpret_cast<String::ExternalStringResource*>(value);
10149 result = GetExternalStringResourceSlow();
10151 #ifdef V8_ENABLE_CHECKS 10152 VerifyExternalStringResource(result);
10159 String::Encoding* encoding_out)
const {
10160 typedef internal::Object O;
10162 O* obj = *reinterpret_cast<O* const*>(
this);
10163 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
10164 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
10166 if (type == I::kExternalOneByteRepresentationTag ||
10167 type == I::kExternalTwoByteRepresentationTag) {
10168 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
10169 resource = static_cast<ExternalStringResourceBase*>(value);
10171 resource = GetExternalStringResourceBaseSlow(encoding_out);
10173 #ifdef V8_ENABLE_CHECKS 10174 VerifyExternalStringResourceBase(resource, *encoding_out);
10181 #ifdef V8_ENABLE_CHECKS 10182 return FullIsUndefined();
10184 return QuickIsUndefined();
10188 bool Value::QuickIsUndefined()
const {
10189 typedef internal::Object O;
10191 O* obj = *reinterpret_cast<O* const*>(
this);
10192 if (!I::HasHeapObjectTag(obj))
return false;
10193 if (I::GetInstanceType(obj) != I::kOddballType)
return false;
10194 return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
10199 #ifdef V8_ENABLE_CHECKS 10200 return FullIsNull();
10202 return QuickIsNull();
10206 bool Value::QuickIsNull()
const {
10207 typedef internal::Object O;
10209 O* obj = *reinterpret_cast<O* const*>(
this);
10210 if (!I::HasHeapObjectTag(obj))
return false;
10211 if (I::GetInstanceType(obj) != I::kOddballType)
return false;
10212 return (I::GetOddballKind(obj) == I::kNullOddballKind);
10216 #ifdef V8_ENABLE_CHECKS 10217 return FullIsNull() || FullIsUndefined();
10219 return QuickIsNullOrUndefined();
10223 bool Value::QuickIsNullOrUndefined()
const {
10224 typedef internal::Object O;
10226 O* obj = *reinterpret_cast<O* const*>(
this);
10227 if (!I::HasHeapObjectTag(obj))
return false;
10228 if (I::GetInstanceType(obj) != I::kOddballType)
return false;
10229 int kind = I::GetOddballKind(obj);
10230 return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind;
10234 #ifdef V8_ENABLE_CHECKS 10235 return FullIsString();
10237 return QuickIsString();
10241 bool Value::QuickIsString()
const {
10242 typedef internal::Object O;
10244 O* obj = *reinterpret_cast<O* const*>(
this);
10245 if (!I::HasHeapObjectTag(obj))
return false;
10246 return (I::GetInstanceType(obj) < I::kFirstNonstringType);
10250 template <
class T> Value* Value::Cast(T* value) {
10251 return static_cast<Value*>(value);
10254 Local<Boolean> Value::ToBoolean()
const {
10255 return ToBoolean(Isolate::GetCurrent()->GetCurrentContext())
10256 .FromMaybe(Local<Boolean>());
10259 Local<String> Value::ToString()
const {
10260 return ToString(Isolate::GetCurrent()->GetCurrentContext())
10261 .FromMaybe(Local<String>());
10264 Local<Object> Value::ToObject()
const {
10265 return ToObject(Isolate::GetCurrent()->GetCurrentContext())
10266 .FromMaybe(Local<Object>());
10269 Local<Integer> Value::ToInteger()
const {
10270 return ToInteger(Isolate::GetCurrent()->GetCurrentContext())
10271 .FromMaybe(Local<Integer>());
10274 Boolean* Boolean::Cast(
v8::Value* value) {
10275 #ifdef V8_ENABLE_CHECKS 10278 return static_cast<Boolean*>(value);
10283 #ifdef V8_ENABLE_CHECKS 10286 return static_cast<Name*>(value);
10290 Symbol* Symbol::Cast(
v8::Value* value) {
10291 #ifdef V8_ENABLE_CHECKS 10294 return static_cast<Symbol*>(value);
10298 Private* Private::Cast(Data* data) {
10299 #ifdef V8_ENABLE_CHECKS 10302 return reinterpret_cast<Private*>(data);
10306 Number* Number::Cast(
v8::Value* value) {
10307 #ifdef V8_ENABLE_CHECKS 10310 return static_cast<Number*>(value);
10314 Integer* Integer::Cast(
v8::Value* value) {
10315 #ifdef V8_ENABLE_CHECKS 10318 return static_cast<Integer*>(value);
10323 #ifdef V8_ENABLE_CHECKS 10326 return static_cast<Int32*>(value);
10330 Uint32* Uint32::Cast(
v8::Value* value) {
10331 #ifdef V8_ENABLE_CHECKS 10334 return static_cast<Uint32*>(value);
10337 BigInt* BigInt::Cast(
v8::Value* value) {
10338 #ifdef V8_ENABLE_CHECKS 10341 return static_cast<BigInt*>(value);
10345 #ifdef V8_ENABLE_CHECKS 10348 return static_cast<Date*>(value);
10352 StringObject* StringObject::Cast(
v8::Value* value) {
10353 #ifdef V8_ENABLE_CHECKS 10356 return static_cast<StringObject*>(value);
10360 SymbolObject* SymbolObject::Cast(
v8::Value* value) {
10361 #ifdef V8_ENABLE_CHECKS 10364 return static_cast<SymbolObject*>(value);
10368 NumberObject* NumberObject::Cast(
v8::Value* value) {
10369 #ifdef V8_ENABLE_CHECKS 10372 return static_cast<NumberObject*>(value);
10375 BigIntObject* BigIntObject::Cast(
v8::Value* value) {
10376 #ifdef V8_ENABLE_CHECKS 10379 return static_cast<BigIntObject*>(value);
10382 BooleanObject* BooleanObject::Cast(
v8::Value* value) {
10383 #ifdef V8_ENABLE_CHECKS 10386 return static_cast<BooleanObject*>(value);
10390 RegExp* RegExp::Cast(
v8::Value* value) {
10391 #ifdef V8_ENABLE_CHECKS 10394 return static_cast<RegExp*>(value);
10398 Object* Object::Cast(
v8::Value* value) {
10399 #ifdef V8_ENABLE_CHECKS 10402 return static_cast<Object*>(value);
10407 #ifdef V8_ENABLE_CHECKS 10410 return static_cast<Array*>(value);
10415 #ifdef V8_ENABLE_CHECKS 10418 return static_cast<Map*>(value);
10423 #ifdef V8_ENABLE_CHECKS 10426 return static_cast<Set*>(value);
10430 Promise* Promise::Cast(
v8::Value* value) {
10431 #ifdef V8_ENABLE_CHECKS 10434 return static_cast<Promise*>(value);
10439 #ifdef V8_ENABLE_CHECKS 10442 return static_cast<Proxy*>(value);
10445 WasmCompiledModule* WasmCompiledModule::Cast(
v8::Value* value) {
10446 #ifdef V8_ENABLE_CHECKS 10449 return static_cast<WasmCompiledModule*>(value);
10452 Promise::Resolver* Promise::Resolver::Cast(
v8::Value* value) {
10453 #ifdef V8_ENABLE_CHECKS 10456 return static_cast<Promise::Resolver*>(value);
10460 ArrayBuffer* ArrayBuffer::Cast(
v8::Value* value) {
10461 #ifdef V8_ENABLE_CHECKS 10464 return static_cast<ArrayBuffer*>(value);
10468 ArrayBufferView* ArrayBufferView::Cast(
v8::Value* value) {
10469 #ifdef V8_ENABLE_CHECKS 10472 return static_cast<ArrayBufferView*>(value);
10476 TypedArray* TypedArray::Cast(
v8::Value* value) {
10477 #ifdef V8_ENABLE_CHECKS 10480 return static_cast<TypedArray*>(value);
10484 Uint8Array* Uint8Array::Cast(
v8::Value* value) {
10485 #ifdef V8_ENABLE_CHECKS 10488 return static_cast<Uint8Array*>(value);
10492 Int8Array* Int8Array::Cast(
v8::Value* value) {
10493 #ifdef V8_ENABLE_CHECKS 10496 return static_cast<Int8Array*>(value);
10500 Uint16Array* Uint16Array::Cast(
v8::Value* value) {
10501 #ifdef V8_ENABLE_CHECKS 10504 return static_cast<Uint16Array*>(value);
10508 Int16Array* Int16Array::Cast(
v8::Value* value) {
10509 #ifdef V8_ENABLE_CHECKS 10512 return static_cast<Int16Array*>(value);
10516 Uint32Array* Uint32Array::Cast(
v8::Value* value) {
10517 #ifdef V8_ENABLE_CHECKS 10520 return static_cast<Uint32Array*>(value);
10524 Int32Array* Int32Array::Cast(
v8::Value* value) {
10525 #ifdef V8_ENABLE_CHECKS 10528 return static_cast<Int32Array*>(value);
10532 Float32Array* Float32Array::Cast(
v8::Value* value) {
10533 #ifdef V8_ENABLE_CHECKS 10536 return static_cast<Float32Array*>(value);
10540 Float64Array* Float64Array::Cast(
v8::Value* value) {
10541 #ifdef V8_ENABLE_CHECKS 10544 return static_cast<Float64Array*>(value);
10547 BigInt64Array* BigInt64Array::Cast(
v8::Value* value) {
10548 #ifdef V8_ENABLE_CHECKS 10551 return static_cast<BigInt64Array*>(value);
10554 BigUint64Array* BigUint64Array::Cast(
v8::Value* value) {
10555 #ifdef V8_ENABLE_CHECKS 10558 return static_cast<BigUint64Array*>(value);
10561 Uint8ClampedArray* Uint8ClampedArray::Cast(
v8::Value* value) {
10562 #ifdef V8_ENABLE_CHECKS 10565 return static_cast<Uint8ClampedArray*>(value);
10569 DataView* DataView::Cast(
v8::Value* value) {
10570 #ifdef V8_ENABLE_CHECKS 10573 return static_cast<DataView*>(value);
10577 SharedArrayBuffer* SharedArrayBuffer::Cast(
v8::Value* value) {
10578 #ifdef V8_ENABLE_CHECKS 10581 return static_cast<SharedArrayBuffer*>(value);
10585 Function* Function::Cast(
v8::Value* value) {
10586 #ifdef V8_ENABLE_CHECKS 10589 return static_cast<Function*>(value);
10593 External* External::Cast(
v8::Value* value) {
10594 #ifdef V8_ENABLE_CHECKS 10597 return static_cast<External*>(value);
10601 template<
typename T>
10603 return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
10607 template<
typename T>
10609 return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
10613 template<
typename T>
10615 return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
10619 template<
typename T>
10621 return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
10625 template<
typename T>
10630 template <
typename T>
10633 return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(0);
10638 typedef internal::Object* S;
10640 I::CheckInitialized(isolate);
10641 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
10646 Local<Primitive> Null(Isolate* isolate) {
10647 typedef internal::Object* S;
10648 typedef internal::Internals I;
10649 I::CheckInitialized(isolate);
10650 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
10651 return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
10655 Local<Boolean> True(Isolate* isolate) {
10656 typedef internal::Object* S;
10657 typedef internal::Internals I;
10658 I::CheckInitialized(isolate);
10659 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
10660 return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
10664 Local<Boolean> False(Isolate* isolate) {
10665 typedef internal::Object* S;
10666 typedef internal::Internals I;
10667 I::CheckInitialized(isolate);
10668 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
10669 return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
10673 void Isolate::SetData(uint32_t slot,
void* data) {
10674 typedef internal::Internals I;
10675 I::SetEmbedderData(
this, slot, data);
10679 void* Isolate::GetData(uint32_t slot) {
10680 typedef internal::Internals I;
10681 return I::GetEmbedderData(
this, slot);
10685 uint32_t Isolate::GetNumberOfDataSlots() {
10686 typedef internal::Internals I;
10687 return I::kNumIsolateDataSlots;
10691 MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(
size_t index) {
10692 T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
10693 if (data) internal::PerformCastCheck(data);
10694 return Local<T>(data);
10697 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
10698 int64_t change_in_bytes) {
10699 typedef internal::Internals I;
10700 const int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
10701 int64_t* external_memory = reinterpret_cast<int64_t*>(
10702 reinterpret_cast<uint8_t*>(
this) + I::kExternalMemoryOffset);
10703 int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
10704 reinterpret_cast<uint8_t*>(
this) + I::kExternalMemoryLimitOffset);
10705 int64_t* external_memory_at_last_mc =
10706 reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(
this) +
10707 I::kExternalMemoryAtLastMarkCompactOffset);
10708 const int64_t amount = *external_memory + change_in_bytes;
10710 *external_memory = amount;
10712 int64_t allocation_diff_since_last_mc =
10713 *external_memory_at_last_mc - *external_memory;
10714 allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
10715 ? -allocation_diff_since_last_mc
10716 : allocation_diff_since_last_mc;
10717 if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
10718 CheckMemoryPressure();
10721 if (change_in_bytes < 0) {
10722 *external_memory_limit += change_in_bytes;
10725 if (change_in_bytes > 0 && amount > *external_memory_limit) {
10726 ReportExternalAllocationLimitReached();
10728 return *external_memory;
10731 Local<Value> Context::GetEmbedderData(
int index) {
10732 #ifndef V8_ENABLE_CHECKS 10733 typedef internal::Object O;
10734 typedef internal::Internals I;
10735 auto* context = *reinterpret_cast<internal::NeverReadOnlySpaceObject**>(
this);
10737 HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(
this, index));
10738 return Local<Value>(reinterpret_cast<Value*>(result));
10740 return SlowGetEmbedderData(index);
10745 void* Context::GetAlignedPointerFromEmbedderData(
int index) {
10746 #ifndef V8_ENABLE_CHECKS 10747 typedef internal::Internals I;
10748 return I::ReadEmbedderData<void*>(
this, index);
10750 return SlowGetAlignedPointerFromEmbedderData(index);
10755 MaybeLocal<T> Context::GetDataFromSnapshotOnce(
size_t index) {
10756 T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
10757 if (data) internal::PerformCastCheck(data);
10758 return Local<T>(data);
10762 size_t SnapshotCreator::AddData(Local<Context> context, Local<T>
object) {
10763 T* object_ptr = *object;
10764 internal::Object** p = reinterpret_cast<internal::Object**>(object_ptr);
10765 return AddData(context, *p);
10769 size_t SnapshotCreator::AddData(Local<T>
object) {
10770 T* object_ptr = *object;
10771 internal::Object** p = reinterpret_cast<internal::Object**>(object_ptr);
10772 return AddData(*p);
10793 #endif // INCLUDE_V8_H_ V8_INLINE bool IsNearDeath() const
Definition: v8.h:9665
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:9777
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter=0, IndexedPropertySetterCallback setter=0, IndexedPropertyQueryCallback query=0, IndexedPropertyDeleterCallback deleter=0, IndexedPropertyEnumeratorCallback enumerator=0, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6048
IntegrityLevel
Definition: v8.h:3339
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5649
KeyConversionMode
Definition: v8.h:3334
static V8_INLINE Local< Context > CreationContext(const PersistentBase< Object > &object)
Definition: v8.h:3702
bool only_terminate_in_safe_scope
Definition: v8.h:7304
V8_INLINE bool IsNullOrUndefined() const
Definition: v8.h:10215
WriteOptions
Definition: v8.h:2724
NewStringType
Definition: v8.h:2643
void(* GenericNamedPropertyDefinerCallback)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5598
V8_INLINE void Clear()
Definition: v8.h:325
V8_INLINE bool IsString() const
Definition: v8.h:10233
virtual ~ExternalStringResource()
Definition: v8.h:2810
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:1029
IndexFilter
Definition: v8.h:3328
PropertyAttribute
Definition: v8.h:3244
static V8_INLINE int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8.h:3574
V8_INLINE int Length() const
Definition: v8.h:9968
static V8_INLINE Local< T > Cast(Local< S > that)
Definition: v8.h:376
KeyCollectionMode
Definition: v8.h:3322
V8_INLINE Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:900
V8_INLINE bool IsWeak() const
Definition: v8.h:9676
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:3593
void(* GenericNamedPropertyDeleterCallback)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5566
V8_WARN_UNUSED_RESULT Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect)
virtual ~ExternalOneByteStringResource()
Definition: v8.h:2843
void(* IndexedPropertyDescriptorCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5672
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3260
V8_INLINE bool IsEmpty() const
Definition: v8.h:320
Definition: v8-util.h:162
V8_INLINE Local< Object > Holder() const
Definition: v8.h:9932
V8_INLINE Persistent(Isolate *isolate, Local< S > that)
Definition: v8.h:796
V8_INLINE Local< Value > NewTarget() const
Definition: v8.h:9938
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:10602
V8_INLINE T FromJust() const
Definition: v8.h:8749
V8_INLINE bool ShouldThrowOnError() const
Definition: v8.h:10631
V8_INLINE void SetWeak()
Definition: v8.h:9724
PropertyHandlerFlags
Definition: v8.h:5928
V8_INLINE Local< S > As() const
Definition: v8.h:391
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, v8::NewStringType type, int length=-1)
void(* IndexedPropertyDefinerCallback)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5665
V8_INLINE Global()
Definition: v8.h:883
V8_INLINE Persistent(const Persistent &that)
Definition: v8.h:816
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local< S > *out) const
Definition: v8.h:472
bool(* AccessCheckCallback)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data)
Definition: v8.h:5691
CreateHistogramCallback create_histogram_callback
Definition: v8.h:7278
void(* GenericNamedPropertyQueryCallback)(Local< Name > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5542
V8_DEPRECATE_SOON("Objects are always considered independent. " "Use MarkActive to avoid collecting otherwise dead weak handles.", V8_INLINE void MarkIndependent())
void(* GenericNamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5575
StartupData * snapshot_blob
Definition: v8.h:7263
Definition: v8-platform.h:16
V8_INLINE Local< Value > operator[](int i) const
Definition: v8.h:9919
V8_INLINE Global & operator=(Global< S > &&rhs)
Definition: v8.h:915
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:362
CounterLookupCallback counter_lookup_callback
Definition: v8.h:7270
AccessType
Definition: v8.h:5678
Definition: v8-util.h:426
void(* GenericNamedPropertyDescriptorCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5621
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:338
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5627
V8_INLINE Local< T > ToLocalChecked()
Definition: v8.h:9618
V8_INLINE Local< Value > Data() const
Definition: v8.h:9944
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:10626
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T *out) const
Definition: v8.h:8740
V8_INLINE ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:10158
FunctionEntryHook entry_hook
Definition: v8.h:7247
V8_INLINE Persistent()
Definition: v8.h:789
V8_INLINE void MarkActive()
Definition: v8.h:9758
V8_INLINE Local< Value > Data() const
Definition: v8.h:10608
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5634
V8_WARN_UNUSED_RESULT Maybe< bool > SetAccessor(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=0, MaybeLocal< Value > data=MaybeLocal< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect)
Flags
Definition: v8.h:5291
V8_INLINE Local(Local< S > that)
Definition: v8.h:307
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5659
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5642
bool allow_atomics_wait
Definition: v8.h:7299
const intptr_t * external_references
Definition: v8.h:7293
void Set(Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
Definition: v8-util.h:569
V8_INLINE Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:806
V8_INLINE Global(Isolate *isolate, Local< S > that)
Definition: v8.h:890
V8_INLINE Local< Object > Holder() const
Definition: v8.h:10620
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:9956
SideEffectType
Definition: v8.h:3313
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:9767
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:10104
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:9581
V8_INLINE T FromMaybe(const T &default_value) const
Definition: v8.h:8758
void(* GenericNamedPropertyGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5493
V8_INLINE ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:10139
StackTraceOptions
Definition: v8.h:1819
JitCodeEventHandler code_event_handler
Definition: v8.h:7253
static V8_INLINE Local< String > Empty(Isolate *isolate)
Definition: v8.h:10130
V8_INLINE Global(Global &&other)
Definition: v8.h:907
ArrayBuffer::Allocator * array_buffer_allocator
Definition: v8.h:7285
V8_INLINE bool IsNull() const
Definition: v8.h:10198
V8_INLINE void RegisterExternalReference(Isolate *isolate) const
Definition: v8.h:9742
V8_INLINE Local< Object > This() const
Definition: v8.h:10614
V8_INLINE void AnnotateStrongRetainer(const char *label)
Definition: v8.h:9736
NoCacheReason
Definition: v8.h:1563
V8_INLINE bool IsUndefined() const
Definition: v8.h:10180
V8_INLINE bool IsConstructCall() const
Definition: v8.h:9962
V8_INLINE T ToChecked() const
Definition: v8.h:8734
V8_INLINE Local< S > FromMaybe(Local< S > default_value) const
Definition: v8.h:488
virtual void Dispose()
Definition: v8.h:2786
void(* GenericNamedPropertySetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5517
V8_INLINE Local< Object > This() const
Definition: v8.h:9926
AllocationMode
Definition: v8.h:4618
V8_WARN_UNUSED_RESULT Maybe< bool > SetLazyDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect)
Status
Definition: v8.h:1269
PromiseState
Definition: v8.h:4186
V8_INLINE void Reset()
Definition: v8.h:9685
AccessControl
Definition: v8.h:3287
Definition: v8-util.h:354
Global Pass()
Definition: v8.h:927
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:9950
PropertyFilter
Definition: v8.h:3297
ResourceConstraints constraints
Definition: v8.h:7258
V8_INLINE Local< Value > GetInternalField(int index)
Definition: v8.h:10082
void SetIndexedPropertyHandler(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=0, IndexedPropertyQueryCallback query=0, IndexedPropertyDeleterCallback deleter=0, IndexedPropertyEnumeratorCallback enumerator=0, Local< Value > data=Local< Value >())
Definition: v8.h:6191
V8_INLINE ~Persistent()
Definition: v8.h:837
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter=0, GenericNamedPropertySetterCallback setter=0, GenericNamedPropertyQueryCallback query=0, GenericNamedPropertyDeleterCallback deleter=0, GenericNamedPropertyEnumeratorCallback enumerator=0, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:5978