v8  7.4.288(node12.0.0)
V8 is Google's open source JavaScript engine
v8.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
15 #ifndef INCLUDE_V8_H_
16 #define INCLUDE_V8_H_
17 
18 #include <stddef.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 #include <memory>
22 #include <utility>
23 #include <vector>
24 
25 #include "v8-internal.h" // NOLINT(build/include)
26 #include "v8-version.h" // NOLINT(build/include)
27 #include "v8config.h" // NOLINT(build/include)
28 
29 // We reserve the V8_* prefix for macros defined in V8 public API and
30 // assume there are no name conflicts with the embedder's code.
31 
35 namespace v8 {
36 
37 class AccessorSignature;
38 class Array;
39 class ArrayBuffer;
40 class BigInt;
41 class BigIntObject;
42 class Boolean;
43 class BooleanObject;
44 class Context;
45 class Data;
46 class Date;
47 class External;
48 class Function;
49 class FunctionTemplate;
50 class HeapProfiler;
51 class ImplementationUtilities;
52 class Int32;
53 class Integer;
54 class Isolate;
55 template <class T>
56 class Maybe;
57 class MicrotaskQueue;
58 class Name;
59 class Number;
60 class NumberObject;
61 class Object;
62 class ObjectOperationDescriptor;
63 class ObjectTemplate;
64 class Platform;
65 class Primitive;
66 class Promise;
67 class PropertyDescriptor;
68 class Proxy;
69 class RawOperationDescriptor;
70 class Script;
71 class SharedArrayBuffer;
72 class Signature;
73 class StartupData;
74 class StackFrame;
75 class StackTrace;
76 class String;
77 class StringObject;
78 class Symbol;
79 class SymbolObject;
80 class PrimitiveArray;
81 class Private;
82 class Uint32;
83 class Utils;
84 class Value;
85 class WasmModuleObject;
86 template <class T> class Local;
87 template <class T>
88 class MaybeLocal;
89 template <class T> class Eternal;
90 template<class T> class NonCopyablePersistentTraits;
91 template<class T> class PersistentBase;
92 template <class T, class M = NonCopyablePersistentTraits<T> >
93 class Persistent;
94 template <class T>
95 class Global;
96 template <class T>
98 template<class K, class V, class T> class PersistentValueMap;
99 template <class K, class V, class T>
101 template <class K, class V, class T>
102 class GlobalValueMap;
103 template<class V, class T> class PersistentValueVector;
104 template<class T, class P> class WeakCallbackObject;
105 class FunctionTemplate;
106 class ObjectTemplate;
107 template<typename T> class FunctionCallbackInfo;
108 template<typename T> class PropertyCallbackInfo;
109 class StackTrace;
110 class StackFrame;
111 class Isolate;
112 class CallHandlerHelper;
114 template<typename T> class ReturnValue;
115 
116 namespace internal {
117 class Arguments;
118 class DeferredHandles;
119 class Heap;
120 class HeapObject;
121 class Isolate;
122 class LocalEmbedderHeapTracer;
123 class MicrotaskQueue;
124 class NeverReadOnlySpaceObject;
125 struct ScriptStreamingData;
126 template<typename T> class CustomArguments;
127 class PropertyCallbackArguments;
128 class FunctionCallbackArguments;
129 class GlobalHandles;
130 class ScopedExternalStringLock;
131 
132 namespace wasm {
133 class NativeModule;
134 class StreamingDecoder;
135 } // namespace wasm
136 
137 } // namespace internal
138 
139 namespace debug {
140 class ConsoleCallArguments;
141 } // namespace debug
142 
143 // --- Handles ---
144 
145 #define TYPE_CHECK(T, S) \
146  while (false) { \
147  *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
148  }
149 
181 template <class T>
182 class Local {
183  public:
184  V8_INLINE Local() : val_(nullptr) {}
185  template <class S>
187  : val_(reinterpret_cast<T*>(*that)) {
193  TYPE_CHECK(T, S);
194  }
195 
199  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
200 
204  V8_INLINE void Clear() { val_ = nullptr; }
205 
206  V8_INLINE T* operator->() const { return val_; }
207 
208  V8_INLINE T* operator*() const { return val_; }
209 
216  template <class S>
217  V8_INLINE bool operator==(const Local<S>& that) const {
218  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
219  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
220  if (a == nullptr) return b == nullptr;
221  if (b == nullptr) return false;
222  return *a == *b;
223  }
224 
225  template <class S> V8_INLINE bool operator==(
226  const PersistentBase<S>& that) const {
227  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
228  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
229  if (a == nullptr) return b == nullptr;
230  if (b == nullptr) return false;
231  return *a == *b;
232  }
233 
240  template <class S>
241  V8_INLINE bool operator!=(const Local<S>& that) const {
242  return !operator==(that);
243  }
244 
245  template <class S> V8_INLINE bool operator!=(
246  const Persistent<S>& that) const {
247  return !operator==(that);
248  }
249 
255  template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
256 #ifdef V8_ENABLE_CHECKS
257  // If we're going to perform the type check then we have to check
258  // that the handle isn't empty before doing the checked cast.
259  if (that.IsEmpty()) return Local<T>();
260 #endif
261  return Local<T>(T::Cast(*that));
262  }
263 
269  template <class S>
271  return Local<S>::Cast(*this);
272  }
273 
279  V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that);
280  V8_INLINE static Local<T> New(Isolate* isolate,
281  const PersistentBase<T>& that);
282  V8_INLINE static Local<T> New(Isolate* isolate, const TracedGlobal<T>& that);
283 
284  private:
285  friend class Utils;
286  template<class F> friend class Eternal;
287  template<class F> friend class PersistentBase;
288  template<class F, class M> friend class Persistent;
289  template<class F> friend class Local;
290  template <class F>
291  friend class MaybeLocal;
292  template<class F> friend class FunctionCallbackInfo;
293  template<class F> friend class PropertyCallbackInfo;
294  friend class String;
295  friend class Object;
296  friend class Context;
297  friend class Isolate;
298  friend class Private;
299  template<class F> friend class internal::CustomArguments;
300  friend Local<Primitive> Undefined(Isolate* isolate);
301  friend Local<Primitive> Null(Isolate* isolate);
302  friend Local<Boolean> True(Isolate* isolate);
303  friend Local<Boolean> False(Isolate* isolate);
304  friend class HandleScope;
305  friend class EscapableHandleScope;
306  template <class F1, class F2, class F3>
308  template<class F1, class F2> friend class PersistentValueVector;
309  template <class F>
310  friend class ReturnValue;
311  template <class F>
312  friend class TracedGlobal;
313 
314  explicit V8_INLINE Local(T* that) : val_(that) {}
315  V8_INLINE static Local<T> New(Isolate* isolate, T* that);
316  T* val_;
317 };
318 
319 
320 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
321 // Handle is an alias for Local for historical reasons.
322 template <class T>
323 using Handle = Local<T>;
324 #endif
325 
326 
337 template <class T>
338 class MaybeLocal {
339  public:
340  V8_INLINE MaybeLocal() : val_(nullptr) {}
341  template <class S>
343  : val_(reinterpret_cast<T*>(*that)) {
344  TYPE_CHECK(T, S);
345  }
346 
347  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
348 
353  template <class S>
355  out->val_ = IsEmpty() ? nullptr : this->val_;
356  return !IsEmpty();
357  }
358 
364 
369  template <class S>
370  V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
371  return IsEmpty() ? default_value : Local<S>(val_);
372  }
373 
374  private:
375  T* val_;
376 };
377 
382 template <class T> class Eternal {
383  public:
384  V8_INLINE Eternal() : val_(nullptr) {}
385  template <class S>
386  V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : val_(nullptr) {
387  Set(isolate, handle);
388  }
389  // Can only be safely called if already set.
390  V8_INLINE Local<T> Get(Isolate* isolate) const;
391  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
392  template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
393 
394  private:
395  T* val_;
396 };
397 
398 
399 static const int kInternalFieldsInWeakCallback = 2;
400 static const int kEmbedderFieldsInWeakCallback = 2;
401 
402 template <typename T>
404  public:
405  typedef void (*Callback)(const WeakCallbackInfo<T>& data);
406 
407  WeakCallbackInfo(Isolate* isolate, T* parameter,
408  void* embedder_fields[kEmbedderFieldsInWeakCallback],
409  Callback* callback)
410  : isolate_(isolate), parameter_(parameter), callback_(callback) {
411  for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
412  embedder_fields_[i] = embedder_fields[i];
413  }
414  }
415 
416  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
417  V8_INLINE T* GetParameter() const { return parameter_; }
418  V8_INLINE void* GetInternalField(int index) const;
419 
420  // When first called, the embedder MUST Reset() the Global which triggered the
421  // callback. The Global itself is unusable for anything else. No v8 other api
422  // calls may be called in the first callback. Should additional work be
423  // required, the embedder must set a second pass callback, which will be
424  // called after all the initial callbacks are processed.
425  // Calling SetSecondPassCallback on the second pass will immediately crash.
426  void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
427 
428  private:
429  Isolate* isolate_;
430  T* parameter_;
431  Callback* callback_;
432  void* embedder_fields_[kEmbedderFieldsInWeakCallback];
433 };
434 
435 
436 // kParameter will pass a void* parameter back to the callback, kInternalFields
437 // will pass the first two internal fields back to the callback, kFinalizer
438 // will pass a void* parameter back, but is invoked before the object is
439 // actually collected, so it can be resurrected. In the last case, it is not
440 // possible to request a second pass callback.
442 
456 template <class T> class PersistentBase {
457  public:
462  V8_INLINE void Reset();
467  template <class S>
468  V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
469 
474  template <class S>
475  V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
476 
477  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
478  V8_INLINE void Empty() { val_ = 0; }
479 
480  V8_INLINE Local<T> Get(Isolate* isolate) const {
481  return Local<T>::New(isolate, *this);
482  }
483 
484  template <class S>
485  V8_INLINE bool operator==(const PersistentBase<S>& that) const {
486  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
487  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
488  if (a == nullptr) return b == nullptr;
489  if (b == nullptr) return false;
490  return *a == *b;
491  }
492 
493  template <class S>
494  V8_INLINE bool operator==(const Local<S>& that) const {
495  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
496  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
497  if (a == nullptr) return b == nullptr;
498  if (b == nullptr) return false;
499  return *a == *b;
500  }
501 
502  template <class S>
503  V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
504  return !operator==(that);
505  }
506 
507  template <class S>
508  V8_INLINE bool operator!=(const Local<S>& that) const {
509  return !operator==(that);
510  }
511 
519  template <typename P>
520  V8_INLINE void SetWeak(P* parameter,
521  typename WeakCallbackInfo<P>::Callback callback,
522  WeakCallbackType type);
523 
531  V8_INLINE void SetWeak();
532 
533  template<typename P>
534  V8_INLINE P* ClearWeak();
535 
536  // TODO(dcarney): remove this.
537  V8_INLINE void ClearWeak() { ClearWeak<void>(); }
538 
545  V8_INLINE void AnnotateStrongRetainer(const char* label);
546 
553  "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
554  V8_INLINE void RegisterExternalReference(Isolate* isolate) const);
555 
563  "Weak objects are always considered independent. "
564  "Use TracedGlobal when trying to use EmbedderHeapTracer. "
565  "Use a strong handle when trying to keep an object alive.",
566  V8_INLINE void MarkIndependent());
567 
575  V8_DEPRECATE_SOON("Use TracedGlobal.", V8_INLINE void MarkActive());
576 
577  V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const);
578 
580  V8_DEPRECATED("Garbage collection internal state should not be relied on.",
581  V8_INLINE bool IsNearDeath() const);
582 
584  V8_INLINE bool IsWeak() const;
585 
589  V8_INLINE void SetWrapperClassId(uint16_t class_id);
590 
595  V8_INLINE uint16_t WrapperClassId() const;
596 
597  PersistentBase(const PersistentBase& other) = delete; // NOLINT
598  void operator=(const PersistentBase&) = delete;
599 
600  private:
601  friend class Isolate;
602  friend class Utils;
603  template<class F> friend class Local;
604  template<class F1, class F2> friend class Persistent;
605  template <class F>
606  friend class Global;
607  template<class F> friend class PersistentBase;
608  template<class F> friend class ReturnValue;
609  template <class F1, class F2, class F3>
611  template<class F1, class F2> friend class PersistentValueVector;
612  friend class Object;
613 
614  explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
615  V8_INLINE static T* New(Isolate* isolate, T* that);
616 
617  T* val_;
618 };
619 
620 
627 template<class T>
628 class NonCopyablePersistentTraits {
629  public:
631  static const bool kResetInDestructor = false;
632  template<class S, class M>
633  V8_INLINE static void Copy(const Persistent<S, M>& source,
634  NonCopyablePersistent* dest) {
635  Uncompilable<Object>();
636  }
637  // TODO(dcarney): come up with a good compile error here.
638  template<class O> V8_INLINE static void Uncompilable() {
639  TYPE_CHECK(O, Primitive);
640  }
641 };
642 
643 
648 template<class T>
651  static const bool kResetInDestructor = true;
652  template<class S, class M>
653  static V8_INLINE void Copy(const Persistent<S, M>& source,
654  CopyablePersistent* dest) {
655  // do nothing, just allow copy
656  }
657 };
658 
659 
668 template <class T, class M> class Persistent : public PersistentBase<T> {
669  public:
679  template <class S>
681  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
682  TYPE_CHECK(T, S);
683  }
689  template <class S, class M2>
691  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
692  TYPE_CHECK(T, S);
693  }
700  V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(nullptr) {
701  Copy(that);
702  }
703  template <class S, class M2>
705  Copy(that);
706  }
708  Copy(that);
709  return *this;
710  }
711  template <class S, class M2>
713  Copy(that);
714  return *this;
715  }
722  if (M::kResetInDestructor) this->Reset();
723  }
724 
725  // TODO(dcarney): this is pretty useless, fix or remove
726  template <class S>
727  V8_INLINE static Persistent<T>& Cast(const Persistent<S>& that) { // NOLINT
728 #ifdef V8_ENABLE_CHECKS
729  // If we're going to perform the type check then we have to check
730  // that the handle isn't empty before doing the checked cast.
731  if (!that.IsEmpty()) T::Cast(*that);
732 #endif
733  return reinterpret_cast<Persistent<T>&>(const_cast<Persistent<S>&>(that));
734  }
735 
736  // TODO(dcarney): this is pretty useless, fix or remove
737  template <class S>
738  V8_INLINE Persistent<S>& As() const { // NOLINT
739  return Persistent<S>::Cast(*this);
740  }
741 
742  private:
743  friend class Isolate;
744  friend class Utils;
745  template<class F> friend class Local;
746  template<class F1, class F2> friend class Persistent;
747  template<class F> friend class ReturnValue;
748 
749  explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {}
750  V8_INLINE T* operator*() const { return this->val_; }
751  template<class S, class M2>
752  V8_INLINE void Copy(const Persistent<S, M2>& that);
753 };
754 
755 
761 template <class T>
762 class Global : public PersistentBase<T> {
763  public:
767  V8_INLINE Global() : PersistentBase<T>(nullptr) {}
768 
774  template <class S>
776  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
777  TYPE_CHECK(T, S);
778  }
779 
785  template <class S>
786  V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
787  : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
788  TYPE_CHECK(T, S);
789  }
790 
794  V8_INLINE Global(Global&& other);
795 
796  V8_INLINE ~Global() { this->Reset(); }
797 
801  template <class S>
803 
807  Global Pass() { return static_cast<Global&&>(*this); } // NOLINT
808 
809  /*
810  * For compatibility with Chromium's base::Bind (base::Passed).
811  */
812  typedef void MoveOnlyTypeForCPP03;
813 
814  Global(const Global&) = delete;
815  void operator=(const Global&) = delete;
816 
817  private:
818  template <class F>
819  friend class ReturnValue;
820  V8_INLINE T* operator*() const { return this->val_; }
821 };
822 
823 
824 // UniquePersistent is an alias for Global for historical reason.
825 template <class T>
827 
839 template <typename T>
840 class V8_EXPORT TracedGlobal {
841  public:
845  TracedGlobal() = default;
846  ~TracedGlobal() { Reset(); }
847 
854  template <class S>
855  TracedGlobal(Isolate* isolate, Local<S> that)
856  : val_(New(isolate, *that, &val_)) {
857  TYPE_CHECK(T, S);
858  }
859 
864 
868  template <class S>
869  V8_INLINE TracedGlobal& operator=(TracedGlobal<S>&& rhs);
870 
874  TracedGlobal(const TracedGlobal&) = delete;
875  void operator=(const TracedGlobal&) = delete;
876 
881  bool IsEmpty() const { return val_ == nullptr; }
882 
887  V8_INLINE void Reset();
888 
893  template <class S>
894  V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
895 
899  Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
900 
901  template <class S>
903  return reinterpret_cast<TracedGlobal<S>&>(
904  const_cast<TracedGlobal<T>&>(*this));
905  }
906 
907  template <class S>
908  V8_INLINE bool operator==(const TracedGlobal<S>& that) const {
909  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
910  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
911  if (a == nullptr) return b == nullptr;
912  if (b == nullptr) return false;
913  return *a == *b;
914  }
915 
916  template <class S>
917  V8_INLINE bool operator==(const Local<S>& that) const {
918  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
919  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
920  if (a == nullptr) return b == nullptr;
921  if (b == nullptr) return false;
922  return *a == *b;
923  }
924 
925  template <class S>
926  V8_INLINE bool operator!=(const TracedGlobal<S>& that) const {
927  return !operator==(that);
928  }
929 
930  template <class S>
931  V8_INLINE bool operator!=(const Local<S>& that) const {
932  return !operator==(that);
933  }
934 
938  V8_INLINE void SetWrapperClassId(uint16_t class_id);
939 
944  V8_INLINE uint16_t WrapperClassId() const;
945 
956  V8_INLINE void SetFinalizationCallback(
957  void* parameter, WeakCallbackInfo<void>::Callback callback);
958 
959  private:
960  V8_INLINE static T* New(Isolate* isolate, T* that, T** slot);
961 
962  T* operator*() const { return this->val_; }
963 
964  T* val_ = nullptr;
965 
966  friend class EmbedderHeapTracer;
967  template <typename F>
968  friend class Local;
969  friend class Object;
970  template <typename F>
971  friend class ReturnValue;
972 };
973 
989  public:
990  explicit HandleScope(Isolate* isolate);
991 
992  ~HandleScope();
993 
997  static int NumberOfHandles(Isolate* isolate);
998 
1000  return reinterpret_cast<Isolate*>(isolate_);
1001  }
1002 
1003  HandleScope(const HandleScope&) = delete;
1004  void operator=(const HandleScope&) = delete;
1005 
1006  protected:
1007  V8_INLINE HandleScope() = default;
1008 
1009  void Initialize(Isolate* isolate);
1010 
1011  static internal::Address* CreateHandle(internal::Isolate* isolate,
1012  internal::Address value);
1013 
1014  private:
1015  // Declaring operator new and delete as deleted is not spec compliant.
1016  // Therefore declare them private instead to disable dynamic alloc
1017  void* operator new(size_t size);
1018  void* operator new[](size_t size);
1019  void operator delete(void*, size_t);
1020  void operator delete[](void*, size_t);
1021 
1022  internal::Isolate* isolate_;
1023  internal::Address* prev_next_;
1024  internal::Address* prev_limit_;
1025 
1026  // Local::New uses CreateHandle with an Isolate* parameter.
1027  template<class F> friend class Local;
1028 
1029  // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
1030  // a HeapObject in their shortcuts.
1031  friend class Object;
1032  friend class Context;
1033 };
1034 
1035 
1041  public:
1042  explicit EscapableHandleScope(Isolate* isolate);
1043  V8_INLINE ~EscapableHandleScope() = default;
1044 
1049  template <class T>
1051  internal::Address* slot =
1052  Escape(reinterpret_cast<internal::Address*>(*value));
1053  return Local<T>(reinterpret_cast<T*>(slot));
1054  }
1055 
1056  template <class T>
1058  return Escape(value.FromMaybe(Local<T>()));
1059  }
1060 
1061  EscapableHandleScope(const EscapableHandleScope&) = delete;
1062  void operator=(const EscapableHandleScope&) = delete;
1063 
1064  private:
1065  // Declaring operator new and delete as deleted is not spec compliant.
1066  // Therefore declare them private instead to disable dynamic alloc
1067  void* operator new(size_t size);
1068  void* operator new[](size_t size);
1069  void operator delete(void*, size_t);
1070  void operator delete[](void*, size_t);
1071 
1072  internal::Address* Escape(internal::Address* escape_value);
1073  internal::Address* escape_slot_;
1074 };
1075 
1082  public:
1083  explicit SealHandleScope(Isolate* isolate);
1084  ~SealHandleScope();
1085 
1086  SealHandleScope(const SealHandleScope&) = delete;
1087  void operator=(const SealHandleScope&) = delete;
1088 
1089  private:
1090  // Declaring operator new and delete as deleted is not spec compliant.
1091  // Therefore declare them private instead to disable dynamic alloc
1092  void* operator new(size_t size);
1093  void* operator new[](size_t size);
1094  void operator delete(void*, size_t);
1095  void operator delete[](void*, size_t);
1096 
1097  internal::Isolate* const isolate_;
1098  internal::Address* prev_limit_;
1099  int prev_sealed_level_;
1100 };
1101 
1102 
1103 // --- Special objects ---
1104 
1105 
1110  private:
1111  Data();
1112 };
1113 
1121  public:
1126  Local<Value> GetResourceName();
1127 
1132  Local<PrimitiveArray> GetHostDefinedOptions();
1133 };
1134 
1144  public:
1145  static Local<PrimitiveArray> New(Isolate* isolate, int length);
1146  int Length() const;
1147  void Set(Isolate* isolate, int index, Local<Primitive> item);
1148  Local<Primitive> Get(Isolate* isolate, int index);
1149 };
1150 
1155  public:
1156  V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
1157  bool is_opaque = false, bool is_wasm = false,
1158  bool is_module = false)
1159  : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1160  (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1161  (is_module ? kIsModule : 0)) {}
1163  : flags_(flags &
1164  (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1165 
1166  bool IsSharedCrossOrigin() const {
1167  return (flags_ & kIsSharedCrossOrigin) != 0;
1168  }
1169  bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
1170  bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
1171  bool IsModule() const { return (flags_ & kIsModule) != 0; }
1172 
1173  int Flags() const { return flags_; }
1174 
1175  private:
1176  enum {
1177  kIsSharedCrossOrigin = 1,
1178  kIsOpaque = 1 << 1,
1179  kIsWasm = 1 << 2,
1180  kIsModule = 1 << 3
1181  };
1182  const int flags_;
1183 };
1184 
1189  public:
1191  Local<Value> resource_name,
1192  Local<Integer> resource_line_offset = Local<Integer>(),
1193  Local<Integer> resource_column_offset = Local<Integer>(),
1194  Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(),
1195  Local<Integer> script_id = Local<Integer>(),
1196  Local<Value> source_map_url = Local<Value>(),
1197  Local<Boolean> resource_is_opaque = Local<Boolean>(),
1198  Local<Boolean> is_wasm = Local<Boolean>(),
1199  Local<Boolean> is_module = Local<Boolean>(),
1200  Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1201 
1208  V8_INLINE ScriptOriginOptions Options() const { return options_; }
1209 
1210  private:
1211  Local<Value> resource_name_;
1212  Local<Integer> resource_line_offset_;
1213  Local<Integer> resource_column_offset_;
1214  ScriptOriginOptions options_;
1215  Local<Integer> script_id_;
1216  Local<Value> source_map_url_;
1217  Local<PrimitiveArray> host_defined_options_;
1218 };
1219 
1224  public:
1228  Local<Script> BindToCurrentContext();
1229 
1230  int GetId();
1231  Local<Value> GetScriptName();
1232 
1236  Local<Value> GetSourceURL();
1240  Local<Value> GetSourceMappingURL();
1241 
1246  int GetLineNumber(int code_pos);
1247 
1248  static const int kNoScriptId = 0;
1249 };
1250 
1255  // Only used as a container for code caching.
1256 };
1257 
1262  public:
1263  int GetLineNumber() { return line_number_; }
1264  int GetColumnNumber() { return column_number_; }
1265 
1266  Location(int line_number, int column_number)
1267  : line_number_(line_number), column_number_(column_number) {}
1268 
1269  private:
1270  int line_number_;
1271  int column_number_;
1272 };
1273 
1278  public:
1286  enum Status {
1292  kErrored
1293  };
1294 
1298  Status GetStatus() const;
1299 
1303  Local<Value> GetException() const;
1304 
1308  int GetModuleRequestsLength() const;
1309 
1314  Local<String> GetModuleRequest(int i) const;
1315 
1320  Location GetModuleRequestLocation(int i) const;
1321 
1325  int GetIdentityHash() const;
1326 
1327  typedef MaybeLocal<Module> (*ResolveCallback)(Local<Context> context,
1328  Local<String> specifier,
1329  Local<Module> referrer);
1330 
1338  V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(Local<Context> context,
1339  ResolveCallback callback);
1340 
1350 
1356  Local<Value> GetModuleNamespace();
1357 
1364  Local<UnboundModuleScript> GetUnboundModuleScript();
1365 };
1366 
1372  public:
1377  Local<Context> context, Local<String> source,
1378  ScriptOrigin* origin = nullptr);
1379 
1386 
1390  Local<UnboundScript> GetUnboundScript();
1391 };
1392 
1393 
1398  public:
1409  BufferOwned
1410  };
1411 
1413  : data(nullptr),
1414  length(0),
1415  rejected(false),
1416  buffer_policy(BufferNotOwned) {}
1417 
1418  // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
1419  // data and guarantees that it stays alive until the CachedData object is
1420  // destroyed. If the policy is BufferOwned, the given data will be deleted
1421  // (with delete[]) when the CachedData object is destroyed.
1422  CachedData(const uint8_t* data, int length,
1423  BufferPolicy buffer_policy = BufferNotOwned);
1424  ~CachedData();
1425  // TODO(marja): Async compilation; add constructors which take a callback
1426  // which will be called when V8 no longer needs the data.
1427  const uint8_t* data;
1428  int length;
1429  bool rejected;
1431 
1432  // Prevent copying.
1433  CachedData(const CachedData&) = delete;
1434  CachedData& operator=(const CachedData&) = delete;
1435  };
1436 
1440  class Source {
1441  public:
1442  // Source takes ownership of CachedData.
1443  V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1444  CachedData* cached_data = nullptr);
1445  V8_INLINE Source(Local<String> source_string,
1446  CachedData* cached_data = nullptr);
1447  V8_INLINE ~Source();
1448 
1449  // Ownership of the CachedData or its buffers is *not* transferred to the
1450  // caller. The CachedData object is alive as long as the Source object is
1451  // alive.
1452  V8_INLINE const CachedData* GetCachedData() const;
1453 
1454  V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
1455 
1456  // Prevent copying.
1457  Source(const Source&) = delete;
1458  Source& operator=(const Source&) = delete;
1459 
1460  private:
1461  friend class ScriptCompiler;
1462 
1463  Local<String> source_string;
1464 
1465  // Origin information
1466  Local<Value> resource_name;
1467  Local<Integer> resource_line_offset;
1468  Local<Integer> resource_column_offset;
1469  ScriptOriginOptions resource_options;
1470  Local<Value> source_map_url;
1471  Local<PrimitiveArray> host_defined_options;
1472 
1473  // Cached data from previous compilation (if a kConsume*Cache flag is
1474  // set), or hold newly generated cache data (kProduce*Cache flags) are
1475  // set when calling a compile method.
1476  CachedData* cached_data;
1477  };
1478 
1484  public:
1485  virtual ~ExternalSourceStream() = default;
1486 
1508  virtual size_t GetMoreData(const uint8_t** src) = 0;
1509 
1520  virtual bool SetBookmark();
1521 
1525  virtual void ResetToBookmark();
1526  };
1527 
1535  public:
1536  enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1537 
1538  StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
1539  ~StreamedSource();
1540 
1541  internal::ScriptStreamingData* impl() const { return impl_.get(); }
1542 
1543  // Prevent copying.
1544  StreamedSource(const StreamedSource&) = delete;
1545  StreamedSource& operator=(const StreamedSource&) = delete;
1546 
1547  private:
1548  std::unique_ptr<internal::ScriptStreamingData> impl_;
1549  };
1550 
1556  public:
1557  void Run();
1558 
1559  private:
1560  friend class ScriptCompiler;
1561 
1562  explicit ScriptStreamingTask(internal::ScriptStreamingData* data)
1563  : data_(data) {}
1564 
1565  internal::ScriptStreamingData* data_;
1566  };
1567 
1569  kNoCompileOptions = 0,
1571  kEagerCompile
1572  };
1573 
1578  kNoCacheNoReason = 0,
1592  kNoCacheBecauseDeferredProduceCodeCache
1593  };
1594 
1608  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript(
1609  Isolate* isolate, Source* source,
1610  CompileOptions options = kNoCompileOptions,
1611  NoCacheReason no_cache_reason = kNoCacheNoReason);
1612 
1625  Local<Context> context, Source* source,
1626  CompileOptions options = kNoCompileOptions,
1627  NoCacheReason no_cache_reason = kNoCacheNoReason);
1628 
1640  static ScriptStreamingTask* StartStreamingScript(
1641  Isolate* isolate, StreamedSource* source,
1642  CompileOptions options = kNoCompileOptions);
1643 
1652  Local<Context> context, StreamedSource* source,
1653  Local<String> full_source_string, const ScriptOrigin& origin);
1654 
1673  static uint32_t CachedDataVersionTag();
1674 
1682  static V8_WARN_UNUSED_RESULT MaybeLocal<Module> CompileModule(
1683  Isolate* isolate, Source* source,
1684  CompileOptions options = kNoCompileOptions,
1685  NoCacheReason no_cache_reason = kNoCacheNoReason);
1686 
1697  static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
1698  Local<Context> context, Source* source, size_t arguments_count,
1699  Local<String> arguments[], size_t context_extension_count,
1700  Local<Object> context_extensions[],
1701  CompileOptions options = kNoCompileOptions,
1702  NoCacheReason no_cache_reason = kNoCacheNoReason);
1703 
1709  static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script);
1710 
1716  static CachedData* CreateCodeCache(
1717  Local<UnboundModuleScript> unbound_module_script);
1718 
1725  static CachedData* CreateCodeCacheForFunction(Local<Function> function);
1726 
1727  private:
1728  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
1729  Isolate* isolate, Source* source, CompileOptions options,
1730  NoCacheReason no_cache_reason);
1731 };
1732 
1733 
1738  public:
1739  Local<String> Get() const;
1740 
1744  Isolate* GetIsolate() const;
1745 
1747  Local<Context> context) const;
1748 
1753  ScriptOrigin GetScriptOrigin() const;
1754 
1759  Local<Value> GetScriptResourceName() const;
1760 
1766  Local<StackTrace> GetStackTrace() const;
1767 
1771  V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
1772 
1777  int GetStartPosition() const;
1778 
1783  int GetEndPosition() const;
1784 
1788  int ErrorLevel() const;
1789 
1794  int GetStartColumn() const;
1795  V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const;
1796 
1801  int GetEndColumn() const;
1802  V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
1803 
1808  bool IsSharedCrossOrigin() const;
1809  bool IsOpaque() const;
1810 
1811  // TODO(1245381): Print to a string instead of on a FILE.
1812  static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1813 
1814  static const int kNoLineNumberInfo = 0;
1815  static const int kNoColumnInfo = 0;
1816  static const int kNoScriptIdInfo = 0;
1817 };
1818 
1819 
1826  public:
1834  kLineNumber = 1,
1835  kColumnOffset = 1 << 1 | kLineNumber,
1836  kScriptName = 1 << 2,
1837  kFunctionName = 1 << 3,
1838  kIsEval = 1 << 4,
1839  kIsConstructor = 1 << 5,
1840  kScriptNameOrSourceURL = 1 << 6,
1841  kScriptId = 1 << 7,
1842  kExposeFramesAcrossSecurityOrigins = 1 << 8,
1843  kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
1844  kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
1845  };
1846 
1850  Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
1851 
1855  int GetFrameCount() const;
1856 
1864  static Local<StackTrace> CurrentStackTrace(
1865  Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
1866 };
1867 
1868 
1873  public:
1880  int GetLineNumber() const;
1881 
1889  int GetColumn() const;
1890 
1897  int GetScriptId() const;
1898 
1903  Local<String> GetScriptName() const;
1904 
1911  Local<String> GetScriptNameOrSourceURL() const;
1912 
1916  Local<String> GetFunctionName() const;
1917 
1922  bool IsEval() const;
1923 
1928  bool IsConstructor() const;
1929 
1933  bool IsWasm() const;
1934 };
1935 
1936 
1937 // A StateTag represents a possible state of the VM.
1938 enum StateTag {
1947 };
1948 
1949 // A RegisterState represents the current state of registers used
1950 // by the sampling profiler API.
1952  RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {}
1953  void* pc; // Instruction pointer.
1954  void* sp; // Stack pointer.
1955  void* fp; // Frame pointer.
1956 };
1957 
1958 // The output structure filled up by GetStackSample API function.
1959 struct SampleInfo {
1960  size_t frames_count; // Number of frames collected.
1961  StateTag vm_state; // Current VM state.
1962  void* external_callback_entry; // External callback address if VM is
1963  // executing an external callback.
1964 };
1965 
1966 struct MemoryRange {
1967  const void* start = nullptr;
1968  size_t length_in_bytes = 0;
1969 };
1970 
1971 struct JSEntryStub {
1973 };
1974 
1975 struct UnwindState {
1979 };
1980 
1985  public:
1995  Local<Context> context, Local<String> json_string);
1996 
2004  static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify(
2005  Local<Context> context, Local<Value> json_object,
2006  Local<String> gap = Local<String>());
2007 };
2008 
2014  public:
2016  public:
2017  virtual ~Delegate() = default;
2018 
2024  virtual void ThrowDataCloneError(Local<String> message) = 0;
2025 
2031  virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
2032 
2043  virtual Maybe<uint32_t> GetSharedArrayBufferId(
2044  Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
2045 
2046  virtual Maybe<uint32_t> GetWasmModuleTransferId(
2047  Isolate* isolate, Local<WasmModuleObject> module);
2059  virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
2060  size_t* actual_size);
2061 
2067  virtual void FreeBufferMemory(void* buffer);
2068  };
2069 
2070  explicit ValueSerializer(Isolate* isolate);
2071  ValueSerializer(Isolate* isolate, Delegate* delegate);
2072  ~ValueSerializer();
2073 
2077  void WriteHeader();
2078 
2083  Local<Value> value);
2084 
2091  V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
2092 
2098  void TransferArrayBuffer(uint32_t transfer_id,
2099  Local<ArrayBuffer> array_buffer);
2100 
2101 
2109  void SetTreatArrayBufferViewsAsHostObjects(bool mode);
2110 
2116  void WriteUint32(uint32_t value);
2117  void WriteUint64(uint64_t value);
2118  void WriteDouble(double value);
2119  void WriteRawBytes(const void* source, size_t length);
2120 
2121  private:
2122  ValueSerializer(const ValueSerializer&) = delete;
2123  void operator=(const ValueSerializer&) = delete;
2124 
2125  struct PrivateData;
2126  PrivateData* private_;
2127 };
2128 
2134  public:
2136  public:
2137  virtual ~Delegate() = default;
2138 
2144  virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
2145 
2150  virtual MaybeLocal<WasmModuleObject> GetWasmModuleFromId(
2151  Isolate* isolate, uint32_t transfer_id);
2152 
2157  virtual MaybeLocal<SharedArrayBuffer> GetSharedArrayBufferFromId(
2158  Isolate* isolate, uint32_t clone_id);
2159  };
2160 
2161  ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
2162  ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size,
2163  Delegate* delegate);
2164  ~ValueDeserializer();
2165 
2170  V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context);
2171 
2176 
2181  void TransferArrayBuffer(uint32_t transfer_id,
2182  Local<ArrayBuffer> array_buffer);
2183 
2189  void TransferSharedArrayBuffer(uint32_t id,
2190  Local<SharedArrayBuffer> shared_array_buffer);
2191 
2199  void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
2200 
2204  void SetExpectInlineWasm(bool allow_inline_wasm);
2205 
2211  uint32_t GetWireFormatVersion() const;
2212 
2218  V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value);
2219  V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value);
2220  V8_WARN_UNUSED_RESULT bool ReadDouble(double* value);
2221  V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);
2222 
2223  private:
2224  ValueDeserializer(const ValueDeserializer&) = delete;
2225  void operator=(const ValueDeserializer&) = delete;
2226 
2227  struct PrivateData;
2228  PrivateData* private_;
2229 };
2230 
2231 
2232 // --- Value ---
2233 
2234 
2238 class V8_EXPORT Value : public Data {
2239  public:
2244  V8_INLINE bool IsUndefined() const;
2245 
2250  V8_INLINE bool IsNull() const;
2251 
2257  V8_INLINE bool IsNullOrUndefined() const;
2258 
2262  bool IsTrue() const;
2263 
2267  bool IsFalse() const;
2268 
2272  bool IsName() const;
2273 
2278  V8_INLINE bool IsString() const;
2279 
2283  bool IsSymbol() const;
2284 
2288  bool IsFunction() const;
2289 
2294  bool IsArray() const;
2295 
2299  bool IsObject() const;
2300 
2304  bool IsBigInt() const;
2305 
2309  bool IsBoolean() const;
2310 
2314  bool IsNumber() const;
2315 
2319  bool IsExternal() const;
2320 
2324  bool IsInt32() const;
2325 
2329  bool IsUint32() const;
2330 
2334  bool IsDate() const;
2335 
2339  bool IsArgumentsObject() const;
2340 
2344  bool IsBigIntObject() const;
2345 
2349  bool IsBooleanObject() const;
2350 
2354  bool IsNumberObject() const;
2355 
2359  bool IsStringObject() const;
2360 
2364  bool IsSymbolObject() const;
2365 
2369  bool IsNativeError() const;
2370 
2374  bool IsRegExp() const;
2375 
2379  bool IsAsyncFunction() const;
2380 
2384  bool IsGeneratorFunction() const;
2385 
2389  bool IsGeneratorObject() const;
2390 
2394  bool IsPromise() const;
2395 
2399  bool IsMap() const;
2400 
2404  bool IsSet() const;
2405 
2409  bool IsMapIterator() const;
2410 
2414  bool IsSetIterator() const;
2415 
2419  bool IsWeakMap() const;
2420 
2424  bool IsWeakSet() const;
2425 
2429  bool IsArrayBuffer() const;
2430 
2434  bool IsArrayBufferView() const;
2435 
2439  bool IsTypedArray() const;
2440 
2444  bool IsUint8Array() const;
2445 
2449  bool IsUint8ClampedArray() const;
2450 
2454  bool IsInt8Array() const;
2455 
2459  bool IsUint16Array() const;
2460 
2464  bool IsInt16Array() const;
2465 
2469  bool IsUint32Array() const;
2470 
2474  bool IsInt32Array() const;
2475 
2479  bool IsFloat32Array() const;
2480 
2484  bool IsFloat64Array() const;
2485 
2489  bool IsBigInt64Array() const;
2490 
2494  bool IsBigUint64Array() const;
2495 
2499  bool IsDataView() const;
2500 
2505  bool IsSharedArrayBuffer() const;
2506 
2510  bool IsProxy() const;
2511 
2512  bool IsWebAssemblyCompiledModule() const;
2513 
2517  bool IsModuleNamespaceObject() const;
2518 
2520  Local<Context> context) const;
2521  V8_DEPRECATE_SOON("ToBoolean can never throw. Use Local version.",
2523  Local<Context> context) const);
2525  Local<Context> context) const;
2527  Local<Context> context) const;
2529  Local<Context> context) const;
2531  Local<Context> context) const;
2533  Local<Context> context) const;
2535  Local<Context> context) const;
2537 
2538  Local<Boolean> ToBoolean(Isolate* isolate) const;
2539  V8_DEPRECATE_SOON("Use maybe version",
2540  Local<Number> ToNumber(Isolate* isolate) const);
2541  V8_DEPRECATE_SOON("Use maybe version",
2542  Local<String> ToString(Isolate* isolate) const);
2543  V8_DEPRECATE_SOON("Use maybe version",
2544  Local<Object> ToObject(Isolate* isolate) const);
2545  V8_DEPRECATE_SOON("Use maybe version",
2546  Local<Integer> ToInteger(Isolate* isolate) const);
2547  V8_DEPRECATE_SOON("Use maybe version",
2548  Local<Int32> ToInt32(Isolate* isolate) const);
2549 
2555  Local<Context> context) const;
2556 
2557  bool BooleanValue(Isolate* isolate) const;
2558 
2559  V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.",
2560  V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
2561  Local<Context> context) const);
2562  V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
2564  Local<Context> context) const;
2566  Local<Context> context) const;
2567  V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
2568 
2571  Local<Value> that) const;
2572  bool StrictEquals(Local<Value> that) const;
2573  bool SameValue(Local<Value> that) const;
2574 
2575  template <class T> V8_INLINE static Value* Cast(T* value);
2576 
2577  Local<String> TypeOf(Isolate*);
2578 
2579  Maybe<bool> InstanceOf(Local<Context> context, Local<Object> object);
2580 
2581  private:
2582  V8_INLINE bool QuickIsUndefined() const;
2583  V8_INLINE bool QuickIsNull() const;
2584  V8_INLINE bool QuickIsNullOrUndefined() const;
2585  V8_INLINE bool QuickIsString() const;
2586  bool FullIsUndefined() const;
2587  bool FullIsNull() const;
2588  bool FullIsString() const;
2589 };
2590 
2591 
2595 class V8_EXPORT Primitive : public Value { };
2596 
2597 
2602 class V8_EXPORT Boolean : public Primitive {
2603  public:
2604  bool Value() const;
2605  V8_INLINE static Boolean* Cast(v8::Value* obj);
2606  V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value);
2607 
2608  private:
2609  static void CheckCast(v8::Value* obj);
2610 };
2611 
2612 
2616 class V8_EXPORT Name : public Primitive {
2617  public:
2625  int GetIdentityHash();
2626 
2627  V8_INLINE static Name* Cast(Value* obj);
2628 
2629  private:
2630  static void CheckCast(Value* obj);
2631 };
2632 
2639 enum class NewStringType {
2643  kNormal,
2644 
2651 };
2652 
2656 class V8_EXPORT String : public Name {
2657  public:
2658  static constexpr int kMaxLength = internal::kApiTaggedSize == 4
2659  ? (1 << 28) - 16
2660  : internal::kSmiMaxValue / 2 - 24;
2661 
2662  enum Encoding {
2663  UNKNOWN_ENCODING = 0x1,
2664  TWO_BYTE_ENCODING = 0x0,
2665  ONE_BYTE_ENCODING = 0x8
2666  };
2670  int Length() const;
2671 
2676  int Utf8Length(Isolate* isolate) const;
2677 
2684  bool IsOneByte() const;
2685 
2691  bool ContainsOnlyOneByte() const;
2692 
2719  NO_OPTIONS = 0,
2720  HINT_MANY_WRITES_EXPECTED = 1,
2721  NO_NULL_TERMINATION = 2,
2722  PRESERVE_ONE_BYTE_NULL = 4,
2723  // Used by WriteUtf8 to replace orphan surrogate code units with the
2724  // unicode replacement character. Needs to be set to guarantee valid UTF-8
2725  // output.
2726  REPLACE_INVALID_UTF8 = 8
2727  };
2728 
2729  // 16-bit character codes.
2730  int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
2731  int options = NO_OPTIONS) const;
2732  // One byte characters.
2733  int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
2734  int length = -1, int options = NO_OPTIONS) const;
2735  // UTF-8 encoded characters.
2736  int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
2737  int* nchars_ref = nullptr, int options = NO_OPTIONS) const;
2738 
2742  V8_INLINE static Local<String> Empty(Isolate* isolate);
2743 
2747  bool IsExternal() const;
2748 
2752  bool IsExternalOneByte() const;
2753 
2755  public:
2756  virtual ~ExternalStringResourceBase() = default;
2757 
2763  virtual bool IsCacheable() const { return true; }
2764 
2765  protected:
2766  ExternalStringResourceBase() = default;
2767 
2774  virtual void Dispose() { delete this; }
2775 
2787  virtual void Lock() const {}
2788 
2792  virtual void Unlock() const {}
2793 
2794  // Disallow copying and assigning.
2796  void operator=(const ExternalStringResourceBase&) = delete;
2797 
2798  private:
2799  friend class internal::Heap;
2800  friend class v8::String;
2801  friend class internal::ScopedExternalStringLock;
2802  };
2803 
2811  : public ExternalStringResourceBase {
2812  public:
2817  ~ExternalStringResource() override = default;
2818 
2822  virtual const uint16_t* data() const = 0;
2823 
2827  virtual size_t length() const = 0;
2828 
2829  protected:
2830  ExternalStringResource() = default;
2831  };
2832 
2844  : public ExternalStringResourceBase {
2845  public:
2850  ~ExternalOneByteStringResource() override = default;
2852  virtual const char* data() const = 0;
2854  virtual size_t length() const = 0;
2855  protected:
2856  ExternalOneByteStringResource() = default;
2857  };
2858 
2864  V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
2865  Encoding* encoding_out) const;
2866 
2871  V8_INLINE ExternalStringResource* GetExternalStringResource() const;
2872 
2877  const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
2878 
2879  V8_INLINE static String* Cast(v8::Value* obj);
2880 
2881  // TODO(dcarney): remove with deprecation of New functions.
2883  kNormalString = static_cast<int>(v8::NewStringType::kNormal),
2884  kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
2885  };
2886 
2888  static V8_DEPRECATED(
2889  "Use maybe version",
2890  Local<String> NewFromUtf8(Isolate* isolate, const char* data,
2891  NewStringType type = kNormalString,
2892  int length = -1));
2893 
2896  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
2897  Isolate* isolate, const char* data, v8::NewStringType type,
2898  int length = -1);
2899 
2902  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
2903  Isolate* isolate, const uint8_t* data, v8::NewStringType type,
2904  int length = -1);
2905 
2907  static V8_DEPRECATE_SOON(
2908  "Use maybe version",
2909  Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
2910  NewStringType type = kNormalString,
2911  int length = -1));
2912 
2915  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
2916  Isolate* isolate, const uint16_t* data, v8::NewStringType type,
2917  int length = -1);
2918 
2923  static Local<String> Concat(Isolate* isolate, Local<String> left,
2924  Local<String> right);
2925 
2934  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
2935  Isolate* isolate, ExternalStringResource* resource);
2936 
2946  bool MakeExternal(ExternalStringResource* resource);
2947 
2956  static V8_DEPRECATE_SOON(
2957  "Use maybe version",
2958  Local<String> NewExternal(Isolate* isolate,
2959  ExternalOneByteStringResource* resource));
2960  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
2961  Isolate* isolate, ExternalOneByteStringResource* resource);
2962 
2972  bool MakeExternal(ExternalOneByteStringResource* resource);
2973 
2977  bool CanMakeExternal();
2978 
2982  bool StringEquals(Local<String> str);
2983 
2992  public:
2993  Utf8Value(Isolate* isolate, Local<v8::Value> obj);
2994  ~Utf8Value();
2995  char* operator*() { return str_; }
2996  const char* operator*() const { return str_; }
2997  int length() const { return length_; }
2998 
2999  // Disallow copying and assigning.
3000  Utf8Value(const Utf8Value&) = delete;
3001  void operator=(const Utf8Value&) = delete;
3002 
3003  private:
3004  char* str_;
3005  int length_;
3006  };
3007 
3015  public:
3016  Value(Isolate* isolate, Local<v8::Value> obj);
3017  ~Value();
3018  uint16_t* operator*() { return str_; }
3019  const uint16_t* operator*() const { return str_; }
3020  int length() const { return length_; }
3021 
3022  // Disallow copying and assigning.
3023  Value(const Value&) = delete;
3024  void operator=(const Value&) = delete;
3025 
3026  private:
3027  uint16_t* str_;
3028  int length_;
3029  };
3030 
3031  private:
3032  void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
3033  Encoding encoding) const;
3034  void VerifyExternalStringResource(ExternalStringResource* val) const;
3035  ExternalStringResource* GetExternalStringResourceSlow() const;
3036  ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
3037  String::Encoding* encoding_out) const;
3038 
3039  static void CheckCast(v8::Value* obj);
3040 };
3041 
3042 
3046 class V8_EXPORT Symbol : public Name {
3047  public:
3051  Local<Value> Name() const;
3052 
3056  static Local<Symbol> New(Isolate* isolate,
3057  Local<String> name = Local<String>());
3058 
3066  static Local<Symbol> For(Isolate *isolate, Local<String> name);
3067 
3072  static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
3073 
3074  // Well-known symbols
3075  static Local<Symbol> GetAsyncIterator(Isolate* isolate);
3076  static Local<Symbol> GetHasInstance(Isolate* isolate);
3077  static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
3078  static Local<Symbol> GetIterator(Isolate* isolate);
3079  static Local<Symbol> GetMatch(Isolate* isolate);
3080  static Local<Symbol> GetReplace(Isolate* isolate);
3081  static Local<Symbol> GetSearch(Isolate* isolate);
3082  static Local<Symbol> GetSplit(Isolate* isolate);
3083  static Local<Symbol> GetToPrimitive(Isolate* isolate);
3084  static Local<Symbol> GetToStringTag(Isolate* isolate);
3085  static Local<Symbol> GetUnscopables(Isolate* isolate);
3086 
3087  V8_INLINE static Symbol* Cast(Value* obj);
3088 
3089  private:
3090  Symbol();
3091  static void CheckCast(Value* obj);
3092 };
3093 
3094 
3100 class V8_EXPORT Private : public Data {
3101  public:
3105  Local<Value> Name() const;
3106 
3110  static Local<Private> New(Isolate* isolate,
3111  Local<String> name = Local<String>());
3112 
3122  static Local<Private> ForApi(Isolate* isolate, Local<String> name);
3123 
3124  V8_INLINE static Private* Cast(Data* data);
3125 
3126  private:
3127  Private();
3128 
3129  static void CheckCast(Data* that);
3130 };
3131 
3132 
3136 class V8_EXPORT Number : public Primitive {
3137  public:
3138  double Value() const;
3139  static Local<Number> New(Isolate* isolate, double value);
3140  V8_INLINE static Number* Cast(v8::Value* obj);
3141  private:
3142  Number();
3143  static void CheckCast(v8::Value* obj);
3144 };
3145 
3146 
3150 class V8_EXPORT Integer : public Number {
3151  public:
3152  static Local<Integer> New(Isolate* isolate, int32_t value);
3153  static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
3154  int64_t Value() const;
3155  V8_INLINE static Integer* Cast(v8::Value* obj);
3156  private:
3157  Integer();
3158  static void CheckCast(v8::Value* obj);
3159 };
3160 
3161 
3165 class V8_EXPORT Int32 : public Integer {
3166  public:
3167  int32_t Value() const;
3168  V8_INLINE static Int32* Cast(v8::Value* obj);
3169 
3170  private:
3171  Int32();
3172  static void CheckCast(v8::Value* obj);
3173 };
3174 
3175 
3179 class V8_EXPORT Uint32 : public Integer {
3180  public:
3181  uint32_t Value() const;
3182  V8_INLINE static Uint32* Cast(v8::Value* obj);
3183 
3184  private:
3185  Uint32();
3186  static void CheckCast(v8::Value* obj);
3187 };
3188 
3192 class V8_EXPORT BigInt : public Primitive {
3193  public:
3194  static Local<BigInt> New(Isolate* isolate, int64_t value);
3195  static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
3203  static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
3204  int word_count, const uint64_t* words);
3205 
3212  uint64_t Uint64Value(bool* lossless = nullptr) const;
3213 
3219  int64_t Int64Value(bool* lossless = nullptr) const;
3220 
3225  int WordCount() const;
3226 
3235  void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
3236 
3237  V8_INLINE static BigInt* Cast(v8::Value* obj);
3238 
3239  private:
3240  BigInt();
3241  static void CheckCast(v8::Value* obj);
3242 };
3243 
3249  None = 0,
3251  ReadOnly = 1 << 0,
3253  DontEnum = 1 << 1,
3255  DontDelete = 1 << 2
3256 };
3257 
3263 typedef void (*AccessorGetterCallback)(
3264  Local<String> property,
3265  const PropertyCallbackInfo<Value>& info);
3267  Local<Name> property,
3268  const PropertyCallbackInfo<Value>& info);
3269 
3270 
3271 typedef void (*AccessorSetterCallback)(
3272  Local<String> property,
3273  Local<Value> value,
3274  const PropertyCallbackInfo<void>& info);
3276  Local<Name> property,
3277  Local<Value> value,
3278  const PropertyCallbackInfo<void>& info);
3279 
3280 
3291  DEFAULT = 0,
3293  ALL_CAN_WRITE = 1 << 1,
3295 };
3296 
3307 };
3308 
3319 enum class SideEffectType {
3323 };
3324 
3333 
3339 
3345 
3350 
3354 class V8_EXPORT Object : public Value {
3355  public:
3356  V8_DEPRECATE_SOON("Use maybe version",
3357  bool Set(Local<Value> key, Local<Value> value));
3363  Local<Value> key, Local<Value> value);
3364 
3365  V8_DEPRECATE_SOON("Use maybe version",
3366  bool Set(uint32_t index, Local<Value> value));
3367  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
3368  Local<Value> value);
3369 
3370  // Implements CreateDataProperty (ECMA-262, 7.3.4).
3371  //
3372  // Defines a configurable, writable, enumerable property with the given value
3373  // on the object unless the property already exists and is not configurable
3374  // or the object is not extensible.
3375  //
3376  // Returns true on success.
3377  V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
3378  Local<Name> key,
3379  Local<Value> value);
3380  V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
3381  uint32_t index,
3382  Local<Value> value);
3383 
3384  // Implements DefineOwnProperty.
3385  //
3386  // In general, CreateDataProperty will be faster, however, does not allow
3387  // for specifying attributes.
3388  //
3389  // Returns true on success.
3390  V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
3391  Local<Context> context, Local<Name> key, Local<Value> value,
3392  PropertyAttribute attributes = None);
3393 
3394  // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4.
3395  //
3396  // The defineProperty function is used to add an own property or
3397  // update the attributes of an existing own property of an object.
3398  //
3399  // Both data and accessor descriptors can be used.
3400  //
3401  // In general, CreateDataProperty is faster, however, does not allow
3402  // for specifying attributes or an accessor descriptor.
3403  //
3404  // The PropertyDescriptor can change when redefining a property.
3405  //
3406  // Returns true on success.
3407  V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
3408  Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
3409 
3410  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
3412  Local<Value> key);
3413 
3414  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
3416  uint32_t index);
3417 
3423  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetPropertyAttributes(
3424  Local<Context> context, Local<Value> key);
3425 
3429  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
3430  Local<Context> context, Local<Name> key);
3431 
3448  Local<Value> key);
3449 
3451  Local<Value> key);
3452 
3453  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
3454 
3456  uint32_t index);
3457 
3461  V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
3462  Local<Context> context, Local<Name> name,
3464  AccessorNameSetterCallback setter = nullptr,
3466  AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
3467  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
3468  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
3469 
3470  void SetAccessorProperty(Local<Name> name, Local<Function> getter,
3471  Local<Function> setter = Local<Function>(),
3472  PropertyAttribute attribute = None,
3473  AccessControl settings = DEFAULT);
3474 
3479  V8_WARN_UNUSED_RESULT Maybe<bool> SetNativeDataProperty(
3480  Local<Context> context, Local<Name> name,
3482  AccessorNameSetterCallback setter = nullptr,
3483  Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
3484  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
3485  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
3486 
3495  V8_WARN_UNUSED_RESULT Maybe<bool> SetLazyDataProperty(
3496  Local<Context> context, Local<Name> name,
3498  PropertyAttribute attributes = None,
3499  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
3500  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
3501 
3508  Maybe<bool> HasPrivate(Local<Context> context, Local<Private> key);
3509  Maybe<bool> SetPrivate(Local<Context> context, Local<Private> key,
3510  Local<Value> value);
3511  Maybe<bool> DeletePrivate(Local<Context> context, Local<Private> key);
3512  MaybeLocal<Value> GetPrivate(Local<Context> context, Local<Private> key);
3513 
3520  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
3521  Local<Context> context);
3522  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
3523  Local<Context> context, KeyCollectionMode mode,
3524  PropertyFilter property_filter, IndexFilter index_filter,
3526 
3532  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
3533  Local<Context> context);
3534 
3541  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
3542  Local<Context> context, PropertyFilter filter,
3544 
3550  Local<Value> GetPrototype();
3551 
3557  V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
3558  Local<Value> prototype);
3559 
3564  Local<Object> FindInstanceInPrototypeChain(Local<FunctionTemplate> tmpl);
3565 
3571  V8_WARN_UNUSED_RESULT MaybeLocal<String> ObjectProtoToString(
3572  Local<Context> context);
3573 
3577  Local<String> GetConstructorName();
3578 
3582  Maybe<bool> SetIntegrityLevel(Local<Context> context, IntegrityLevel level);
3583 
3585  int InternalFieldCount();
3586 
3589  const PersistentBase<Object>& object) {
3590  return object.val_->InternalFieldCount();
3591  }
3592 
3595  return object.val_->InternalFieldCount();
3596  }
3597 
3599  V8_INLINE Local<Value> GetInternalField(int index);
3600 
3602  void SetInternalField(int index, Local<Value> value);
3603 
3609  V8_INLINE void* GetAlignedPointerFromInternalField(int index);
3610 
3613  const PersistentBase<Object>& object, int index) {
3614  return object.val_->GetAlignedPointerFromInternalField(index);
3615  }
3616 
3619  const TracedGlobal<Object>& object, int index) {
3620  return object.val_->GetAlignedPointerFromInternalField(index);
3621  }
3622 
3628  void SetAlignedPointerInInternalField(int index, void* value);
3629  void SetAlignedPointerInInternalFields(int argc, int indices[],
3630  void* values[]);
3631 
3637  V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
3638  Local<Name> key);
3639  V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
3640  uint32_t index);
3654  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
3655  Local<Name> key);
3656  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty(
3657  Local<Context> context, uint32_t index);
3658  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty(
3659  Local<Context> context, Local<Name> key);
3660 
3665  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(
3666  Local<Context> context, Local<Name> key);
3667 
3674  GetRealNamedPropertyAttributesInPrototypeChain(Local<Context> context,
3675  Local<Name> key);
3676 
3682  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty(
3683  Local<Context> context, Local<Name> key);
3684 
3690  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
3691  Local<Context> context, Local<Name> key);
3692 
3694  bool HasNamedLookupInterceptor();
3695 
3697  bool HasIndexedLookupInterceptor();
3698 
3706  int GetIdentityHash();
3707 
3712  // TODO(dcarney): take an isolate and optionally bail out?
3713  Local<Object> Clone();
3714 
3718  Local<Context> CreationContext();
3719 
3722  const PersistentBase<Object>& object) {
3723  return object.val_->CreationContext();
3724  }
3725 
3731  bool IsCallable();
3732 
3736  bool IsConstructor();
3737 
3743  Local<Value> recv,
3744  int argc,
3745  Local<Value> argv[]);
3746 
3752  V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsConstructor(
3753  Local<Context> context, int argc, Local<Value> argv[]);
3754 
3758  Isolate* GetIsolate();
3759 
3769  MaybeLocal<Array> PreviewEntries(bool* is_key_value);
3770 
3771  static Local<Object> New(Isolate* isolate);
3772 
3781  static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
3782  Local<Name>* names, Local<Value>* values,
3783  size_t length);
3784 
3785  V8_INLINE static Object* Cast(Value* obj);
3786 
3787  private:
3788  Object();
3789  static void CheckCast(Value* obj);
3790  Local<Value> SlowGetInternalField(int index);
3791  void* SlowGetAlignedPointerFromInternalField(int index);
3792 };
3793 
3794 
3798 class V8_EXPORT Array : public Object {
3799  public:
3800  uint32_t Length() const;
3801 
3806  static Local<Array> New(Isolate* isolate, int length = 0);
3807 
3812  static Local<Array> New(Isolate* isolate, Local<Value>* elements,
3813  size_t length);
3814  V8_INLINE static Array* Cast(Value* obj);
3815  private:
3816  Array();
3817  static void CheckCast(Value* obj);
3818 };
3819 
3820 
3824 class V8_EXPORT Map : public Object {
3825  public:
3826  size_t Size() const;
3827  void Clear();
3829  Local<Value> key);
3831  Local<Value> key,
3832  Local<Value> value);
3834  Local<Value> key);
3836  Local<Value> key);
3837 
3842  Local<Array> AsArray() const;
3843 
3847  static Local<Map> New(Isolate* isolate);
3848 
3849  V8_INLINE static Map* Cast(Value* obj);
3850 
3851  private:
3852  Map();
3853  static void CheckCast(Value* obj);
3854 };
3855 
3856 
3860 class V8_EXPORT Set : public Object {
3861  public:
3862  size_t Size() const;
3863  void Clear();
3865  Local<Value> key);
3867  Local<Value> key);
3869  Local<Value> key);
3870 
3874  Local<Array> AsArray() const;
3875 
3879  static Local<Set> New(Isolate* isolate);
3880 
3881  V8_INLINE static Set* Cast(Value* obj);
3882 
3883  private:
3884  Set();
3885  static void CheckCast(Value* obj);
3886 };
3887 
3888 
3889 template<typename T>
3890 class ReturnValue {
3891  public:
3892  template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
3893  : value_(that.value_) {
3894  TYPE_CHECK(T, S);
3895  }
3896  // Local setters
3897  template <typename S>
3898  V8_INLINE V8_DEPRECATED("Use Global<> instead",
3899  void Set(const Persistent<S>& handle));
3900  template <typename S>
3901  V8_INLINE void Set(const Global<S>& handle);
3902  template <typename S>
3903  V8_INLINE void Set(const TracedGlobal<S>& handle);
3904  template <typename S>
3905  V8_INLINE void Set(const Local<S> handle);
3906  // Fast primitive setters
3907  V8_INLINE void Set(bool value);
3908  V8_INLINE void Set(double i);
3909  V8_INLINE void Set(int32_t i);
3910  V8_INLINE void Set(uint32_t i);
3911  // Fast JS primitive setters
3912  V8_INLINE void SetNull();
3913  V8_INLINE void SetUndefined();
3914  V8_INLINE void SetEmptyString();
3915  // Convenience getter for Isolate
3916  V8_INLINE Isolate* GetIsolate() const;
3917 
3918  // Pointer setter: Uncompilable to prevent inadvertent misuse.
3919  template <typename S>
3920  V8_INLINE void Set(S* whatever);
3921 
3922  // Getter. Creates a new Local<> so it comes with a certain performance
3923  // hit. If the ReturnValue was not yet set, this will return the undefined
3924  // value.
3925  V8_INLINE Local<Value> Get() const;
3926 
3927  private:
3928  template<class F> friend class ReturnValue;
3929  template<class F> friend class FunctionCallbackInfo;
3930  template<class F> friend class PropertyCallbackInfo;
3931  template <class F, class G, class H>
3933  V8_INLINE void SetInternal(internal::Address value) { *value_ = value; }
3934  V8_INLINE internal::Address GetDefaultValue();
3935  V8_INLINE explicit ReturnValue(internal::Address* slot);
3936  internal::Address* value_;
3937 };
3938 
3939 
3946 template<typename T>
3947 class FunctionCallbackInfo {
3948  public:
3950  V8_INLINE int Length() const;
3952  V8_INLINE Local<Value> operator[](int i) const;
3954  V8_INLINE Local<Object> This() const;
3965  V8_INLINE Local<Object> Holder() const;
3967  V8_INLINE Local<Value> NewTarget() const;
3969  V8_INLINE bool IsConstructCall() const;
3971  V8_INLINE Local<Value> Data() const;
3973  V8_INLINE Isolate* GetIsolate() const;
3975  V8_INLINE ReturnValue<T> GetReturnValue() const;
3976  // This shouldn't be public, but the arm compiler needs it.
3977  static const int kArgsLength = 6;
3978 
3979  protected:
3983  static const int kHolderIndex = 0;
3984  static const int kIsolateIndex = 1;
3985  static const int kReturnValueDefaultValueIndex = 2;
3986  static const int kReturnValueIndex = 3;
3987  static const int kDataIndex = 4;
3988  static const int kNewTargetIndex = 5;
3989 
3991  internal::Address* values, int length);
3994  int length_;
3995 };
3996 
3997 
4002 template<typename T>
4003 class PropertyCallbackInfo {
4004  public:
4008  V8_INLINE Isolate* GetIsolate() const;
4009 
4015  V8_INLINE Local<Value> Data() const;
4016 
4058  V8_INLINE Local<Object> This() const;
4059 
4069  V8_INLINE Local<Object> Holder() const;
4070 
4080 
4088  V8_INLINE bool ShouldThrowOnError() const;
4089 
4090  // This shouldn't be public, but the arm compiler needs it.
4091  static const int kArgsLength = 7;
4092 
4093  protected:
4094  friend class MacroAssembler;
4095  friend class internal::PropertyCallbackArguments;
4097  static const int kShouldThrowOnErrorIndex = 0;
4098  static const int kHolderIndex = 1;
4099  static const int kIsolateIndex = 2;
4100  static const int kReturnValueDefaultValueIndex = 3;
4101  static const int kReturnValueIndex = 4;
4102  static const int kDataIndex = 5;
4103  static const int kThisIndex = 6;
4104 
4107 };
4108 
4109 
4110 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
4111 
4113 
4117 class V8_EXPORT Function : public Object {
4118  public:
4123  static MaybeLocal<Function> New(
4124  Local<Context> context, FunctionCallback callback,
4125  Local<Value> data = Local<Value>(), int length = 0,
4127  SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
4128 
4130  Local<Context> context, int argc, Local<Value> argv[]) const;
4131 
4133  Local<Context> context) const {
4134  return NewInstance(context, 0, nullptr);
4135  }
4136 
4142  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstanceWithSideEffectType(
4143  Local<Context> context, int argc, Local<Value> argv[],
4144  SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
4145 
4147  Local<Value> recv, int argc,
4148  Local<Value> argv[]);
4149 
4150  void SetName(Local<String> name);
4151  Local<Value> GetName() const;
4152 
4159  Local<Value> GetInferredName() const;
4160 
4165  Local<Value> GetDebugName() const;
4166 
4171  Local<Value> GetDisplayName() const;
4172 
4177  int GetScriptLineNumber() const;
4182  int GetScriptColumnNumber() const;
4183 
4187  int ScriptId() const;
4188 
4193  Local<Value> GetBoundFunction() const;
4194 
4195  ScriptOrigin GetScriptOrigin() const;
4196  V8_INLINE static Function* Cast(Value* obj);
4197  static const int kLineOffsetNotFound;
4198 
4199  private:
4200  Function();
4201  static void CheckCast(Value* obj);
4202 };
4203 
4204 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
4205 // The number of required internal fields can be defined by embedder.
4206 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0
4207 #endif
4208 
4212 class V8_EXPORT Promise : public Object {
4213  public:
4218  enum PromiseState { kPending, kFulfilled, kRejected };
4219 
4220  class V8_EXPORT Resolver : public Object {
4221  public:
4226  Local<Context> context);
4227 
4231  Local<Promise> GetPromise();
4232 
4238  Local<Value> value);
4239 
4241  Local<Value> value);
4242 
4243  V8_INLINE static Resolver* Cast(Value* obj);
4244 
4245  private:
4246  Resolver();
4247  static void CheckCast(Value* obj);
4248  };
4249 
4257  Local<Function> handler);
4258 
4260  Local<Function> handler);
4261 
4263  Local<Function> on_fulfilled,
4264  Local<Function> on_rejected);
4265 
4270  bool HasHandler();
4271 
4276  Local<Value> Result();
4277 
4281  PromiseState State();
4282 
4286  void MarkAsHandled();
4287 
4288  V8_INLINE static Promise* Cast(Value* obj);
4289 
4290  static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
4291 
4292  private:
4293  Promise();
4294  static void CheckCast(Value* obj);
4295 };
4296 
4326  public:
4327  // GenericDescriptor
4329 
4330  // DataDescriptor
4331  explicit PropertyDescriptor(Local<Value> value);
4332 
4333  // DataDescriptor with writable property
4334  PropertyDescriptor(Local<Value> value, bool writable);
4335 
4336  // AccessorDescriptor
4338 
4339  ~PropertyDescriptor();
4340 
4341  Local<Value> value() const;
4342  bool has_value() const;
4343 
4344  Local<Value> get() const;
4345  bool has_get() const;
4346  Local<Value> set() const;
4347  bool has_set() const;
4348 
4349  void set_enumerable(bool enumerable);
4350  bool enumerable() const;
4351  bool has_enumerable() const;
4352 
4353  void set_configurable(bool configurable);
4354  bool configurable() const;
4355  bool has_configurable() const;
4356 
4357  bool writable() const;
4358  bool has_writable() const;
4359 
4360  struct PrivateData;
4361  PrivateData* get_private() const { return private_; }
4362 
4363  PropertyDescriptor(const PropertyDescriptor&) = delete;
4364  void operator=(const PropertyDescriptor&) = delete;
4365 
4366  private:
4367  PrivateData* private_;
4368 };
4369 
4374 class V8_EXPORT Proxy : public Object {
4375  public:
4376  Local<Value> GetTarget();
4377  Local<Value> GetHandler();
4378  bool IsRevoked();
4379  void Revoke();
4380 
4384  static MaybeLocal<Proxy> New(Local<Context> context,
4385  Local<Object> local_target,
4386  Local<Object> local_handler);
4387 
4388  V8_INLINE static Proxy* Cast(Value* obj);
4389 
4390  private:
4391  Proxy();
4392  static void CheckCast(Value* obj);
4393 };
4394 
4405 template <typename T>
4407  public:
4409  constexpr MemorySpan() = default;
4410 
4411  constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
4412 
4414  constexpr T* data() const { return data_; }
4416  constexpr size_t size() const { return size_; }
4417 
4418  private:
4419  T* data_ = nullptr;
4420  size_t size_ = 0;
4421 };
4422 
4426 struct OwnedBuffer {
4427  std::unique_ptr<const uint8_t[]> buffer;
4428  size_t size = 0;
4429  OwnedBuffer(std::unique_ptr<const uint8_t[]> buffer, size_t size)
4430  : buffer(std::move(buffer)), size(size) {}
4431  OwnedBuffer() = default;
4432 };
4433 
4434 // Wrapper around a compiled WebAssembly module, which is potentially shared by
4435 // different WasmModuleObjects.
4437  public:
4442  OwnedBuffer Serialize();
4443 
4447  MemorySpan<const uint8_t> GetWireBytesRef();
4448 
4449  private:
4450  explicit CompiledWasmModule(std::shared_ptr<internal::wasm::NativeModule>);
4451  friend class Utils;
4452 
4453  const std::shared_ptr<internal::wasm::NativeModule> native_module_;
4454 };
4455 
4456 // An instance of WebAssembly.Module.
4458  public:
4465  class TransferrableModule final {
4466  public:
4467  TransferrableModule(TransferrableModule&& src) = default;
4468  TransferrableModule(const TransferrableModule& src) = delete;
4469 
4470  TransferrableModule& operator=(TransferrableModule&& src) = default;
4471  TransferrableModule& operator=(const TransferrableModule& src) = delete;
4472 
4473  private:
4474  typedef std::shared_ptr<internal::wasm::NativeModule> SharedModule;
4475  friend class WasmModuleObject;
4476  explicit TransferrableModule(SharedModule shared_module)
4477  : shared_module_(std::move(shared_module)) {}
4478  TransferrableModule(OwnedBuffer serialized, OwnedBuffer bytes)
4479  : serialized_(std::move(serialized)), wire_bytes_(std::move(bytes)) {}
4480 
4481  SharedModule shared_module_;
4482  OwnedBuffer serialized_ = {nullptr, 0};
4483  OwnedBuffer wire_bytes_ = {nullptr, 0};
4484  };
4485 
4491  TransferrableModule GetTransferrableModule();
4492 
4497  static MaybeLocal<WasmModuleObject> FromTransferrableModule(
4498  Isolate* isolate, const TransferrableModule&);
4499 
4504  CompiledWasmModule GetCompiledModule();
4505 
4510  static MaybeLocal<WasmModuleObject> DeserializeOrCompile(
4511  Isolate* isolate, MemorySpan<const uint8_t> serialized_module,
4512  MemorySpan<const uint8_t> wire_bytes);
4513  V8_INLINE static WasmModuleObject* Cast(Value* obj);
4514 
4515  private:
4516  static MaybeLocal<WasmModuleObject> Deserialize(
4517  Isolate* isolate, MemorySpan<const uint8_t> serialized_module,
4518  MemorySpan<const uint8_t> wire_bytes);
4519  static MaybeLocal<WasmModuleObject> Compile(Isolate* isolate,
4520  const uint8_t* start,
4521  size_t length);
4522  static MemorySpan<const uint8_t> AsReference(const OwnedBuffer& buff) {
4523  return {buff.buffer.get(), buff.size};
4524  }
4525 
4526  WasmModuleObject();
4527  static void CheckCast(Value* obj);
4528 };
4529 
4530 V8_DEPRECATED("Use WasmModuleObject",
4531  typedef WasmModuleObject WasmCompiledModule);
4532 
4540  public:
4541  class WasmStreamingImpl;
4542 
4546  class Client {
4547  public:
4548  virtual ~Client() = default;
4553  virtual void OnModuleCompiled(CompiledWasmModule compiled_module) = 0;
4554  };
4555 
4556  explicit WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl);
4557 
4558  ~WasmStreaming();
4559 
4564  void OnBytesReceived(const uint8_t* bytes, size_t size);
4565 
4571  void Finish();
4572 
4578  void Abort(MaybeLocal<Value> exception);
4579 
4587  bool SetCompiledModuleBytes(const uint8_t* bytes, size_t size);
4588 
4593  void SetClient(std::shared_ptr<Client> client);
4594 
4600  static std::shared_ptr<WasmStreaming> Unpack(Isolate* isolate,
4601  Local<Value> value);
4602 
4603  private:
4604  std::unique_ptr<WasmStreamingImpl> impl_;
4605 };
4606 
4607 // TODO(mtrofin): when streaming compilation is done, we can rename this
4608 // to simply WasmModuleObjectBuilder
4610  public:
4611  explicit WasmModuleObjectBuilderStreaming(Isolate* isolate);
4615  void OnBytesReceived(const uint8_t*, size_t size);
4616  void Finish();
4622  void Abort(MaybeLocal<Value> exception);
4623  Local<Promise> GetPromise();
4624 
4625  ~WasmModuleObjectBuilderStreaming() = default;
4626 
4627  private:
4629  delete;
4631  default;
4633  const WasmModuleObjectBuilderStreaming&) = delete;
4635  WasmModuleObjectBuilderStreaming&&) = default;
4636  Isolate* isolate_ = nullptr;
4637 
4638 #if V8_CC_MSVC
4639 
4647 #else
4648  Persistent<Promise> promise_;
4649 #endif
4650  std::shared_ptr<internal::wasm::StreamingDecoder> streaming_decoder_;
4651 };
4652 
4653 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
4654 // The number of required internal fields can be defined by embedder.
4655 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
4656 #endif
4657 
4658 
4660 
4661 
4665 class V8_EXPORT ArrayBuffer : public Object {
4666  public:
4682  class V8_EXPORT Allocator { // NOLINT
4683  public:
4684  virtual ~Allocator() = default;
4685 
4690  virtual void* Allocate(size_t length) = 0;
4691 
4696  virtual void* AllocateUninitialized(size_t length) = 0;
4697 
4702  virtual void Free(void* data, size_t length) = 0;
4703 
4709  enum class AllocationMode { kNormal, kReservation };
4710 
4717  static Allocator* NewDefaultAllocator();
4718  };
4719 
4729  class V8_EXPORT Contents { // NOLINT
4730  public:
4731  using DeleterCallback = void (*)(void* buffer, size_t length, void* info);
4732 
4734  : data_(nullptr),
4735  byte_length_(0),
4736  allocation_base_(nullptr),
4737  allocation_length_(0),
4738  allocation_mode_(Allocator::AllocationMode::kNormal),
4739  deleter_(nullptr),
4740  deleter_data_(nullptr) {}
4741 
4742  void* AllocationBase() const { return allocation_base_; }
4743  size_t AllocationLength() const { return allocation_length_; }
4745  return allocation_mode_;
4746  }
4747 
4748  void* Data() const { return data_; }
4749  size_t ByteLength() const { return byte_length_; }
4750  DeleterCallback Deleter() const { return deleter_; }
4751  void* DeleterData() const { return deleter_data_; }
4752 
4753  private:
4754  Contents(void* data, size_t byte_length, void* allocation_base,
4755  size_t allocation_length,
4756  Allocator::AllocationMode allocation_mode, DeleterCallback deleter,
4757  void* deleter_data);
4758 
4759  void* data_;
4760  size_t byte_length_;
4761  void* allocation_base_;
4762  size_t allocation_length_;
4763  Allocator::AllocationMode allocation_mode_;
4764  DeleterCallback deleter_;
4765  void* deleter_data_;
4766 
4767  friend class ArrayBuffer;
4768  };
4769 
4770 
4774  size_t ByteLength() const;
4775 
4782  static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
4783 
4793  static Local<ArrayBuffer> New(
4794  Isolate* isolate, void* data, size_t byte_length,
4796 
4801  bool IsExternal() const;
4802 
4806  bool IsDetachable() const;
4807 
4808  // TODO(913887): fix the use of 'neuter' in the API.
4809  V8_DEPRECATE_SOON("Use IsDetachable() instead.",
4810  inline bool IsNeuterable() const) {
4811  return IsDetachable();
4812  }
4813 
4820  void Detach();
4821 
4822  // TODO(913887): fix the use of 'neuter' in the API.
4823  V8_DEPRECATE_SOON("Use Detach() instead.", inline void Neuter()) { Detach(); }
4824 
4835  Contents Externalize();
4836 
4845  Contents GetContents();
4846 
4847  V8_INLINE static ArrayBuffer* Cast(Value* obj);
4848 
4849  static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4850  static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4851 
4852  private:
4853  ArrayBuffer();
4854  static void CheckCast(Value* obj);
4855 };
4856 
4857 
4858 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
4859 // The number of required internal fields can be defined by embedder.
4860 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
4861 #endif
4862 
4863 
4869  public:
4873  Local<ArrayBuffer> Buffer();
4877  size_t ByteOffset();
4881  size_t ByteLength();
4882 
4892  size_t CopyContents(void* dest, size_t byte_length);
4893 
4898  bool HasBuffer() const;
4899 
4900  V8_INLINE static ArrayBufferView* Cast(Value* obj);
4901 
4902  static const int kInternalFieldCount =
4904  static const int kEmbedderFieldCount =
4906 
4907  private:
4908  ArrayBufferView();
4909  static void CheckCast(Value* obj);
4910 };
4911 
4912 
4918  public:
4919  /*
4920  * The largest typed array size that can be constructed using New.
4921  */
4922  static constexpr size_t kMaxLength = internal::kSmiMaxValue;
4923 
4928  size_t Length();
4929 
4930  V8_INLINE static TypedArray* Cast(Value* obj);
4931 
4932  private:
4933  TypedArray();
4934  static void CheckCast(Value* obj);
4935 };
4936 
4937 
4942  public:
4943  static Local<Uint8Array> New(Local<ArrayBuffer> array_buffer,
4944  size_t byte_offset, size_t length);
4945  static Local<Uint8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
4946  size_t byte_offset, size_t length);
4947  V8_INLINE static Uint8Array* Cast(Value* obj);
4948 
4949  private:
4950  Uint8Array();
4951  static void CheckCast(Value* obj);
4952 };
4953 
4954 
4959  public:
4960  static Local<Uint8ClampedArray> New(Local<ArrayBuffer> array_buffer,
4961  size_t byte_offset, size_t length);
4962  static Local<Uint8ClampedArray> New(
4963  Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset,
4964  size_t length);
4965  V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
4966 
4967  private:
4969  static void CheckCast(Value* obj);
4970 };
4971 
4976  public:
4977  static Local<Int8Array> New(Local<ArrayBuffer> array_buffer,
4978  size_t byte_offset, size_t length);
4979  static Local<Int8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
4980  size_t byte_offset, size_t length);
4981  V8_INLINE static Int8Array* Cast(Value* obj);
4982 
4983  private:
4984  Int8Array();
4985  static void CheckCast(Value* obj);
4986 };
4987 
4988 
4993  public:
4994  static Local<Uint16Array> New(Local<ArrayBuffer> array_buffer,
4995  size_t byte_offset, size_t length);
4996  static Local<Uint16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
4997  size_t byte_offset, size_t length);
4998  V8_INLINE static Uint16Array* Cast(Value* obj);
4999 
5000  private:
5001  Uint16Array();
5002  static void CheckCast(Value* obj);
5003 };
5004 
5005 
5010  public:
5011  static Local<Int16Array> New(Local<ArrayBuffer> array_buffer,
5012  size_t byte_offset, size_t length);
5013  static Local<Int16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5014  size_t byte_offset, size_t length);
5015  V8_INLINE static Int16Array* Cast(Value* obj);
5016 
5017  private:
5018  Int16Array();
5019  static void CheckCast(Value* obj);
5020 };
5021 
5022 
5027  public:
5028  static Local<Uint32Array> New(Local<ArrayBuffer> array_buffer,
5029  size_t byte_offset, size_t length);
5030  static Local<Uint32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5031  size_t byte_offset, size_t length);
5032  V8_INLINE static Uint32Array* Cast(Value* obj);
5033 
5034  private:
5035  Uint32Array();
5036  static void CheckCast(Value* obj);
5037 };
5038 
5039 
5044  public:
5045  static Local<Int32Array> New(Local<ArrayBuffer> array_buffer,
5046  size_t byte_offset, size_t length);
5047  static Local<Int32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5048  size_t byte_offset, size_t length);
5049  V8_INLINE static Int32Array* Cast(Value* obj);
5050 
5051  private:
5052  Int32Array();
5053  static void CheckCast(Value* obj);
5054 };
5055 
5056 
5061  public:
5062  static Local<Float32Array> New(Local<ArrayBuffer> array_buffer,
5063  size_t byte_offset, size_t length);
5064  static Local<Float32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5065  size_t byte_offset, size_t length);
5066  V8_INLINE static Float32Array* Cast(Value* obj);
5067 
5068  private:
5069  Float32Array();
5070  static void CheckCast(Value* obj);
5071 };
5072 
5073 
5078  public:
5079  static Local<Float64Array> New(Local<ArrayBuffer> array_buffer,
5080  size_t byte_offset, size_t length);
5081  static Local<Float64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5082  size_t byte_offset, size_t length);
5083  V8_INLINE static Float64Array* Cast(Value* obj);
5084 
5085  private:
5086  Float64Array();
5087  static void CheckCast(Value* obj);
5088 };
5089 
5094  public:
5095  static Local<BigInt64Array> New(Local<ArrayBuffer> array_buffer,
5096  size_t byte_offset, size_t length);
5097  static Local<BigInt64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5098  size_t byte_offset, size_t length);
5099  V8_INLINE static BigInt64Array* Cast(Value* obj);
5100 
5101  private:
5102  BigInt64Array();
5103  static void CheckCast(Value* obj);
5104 };
5105 
5110  public:
5111  static Local<BigUint64Array> New(Local<ArrayBuffer> array_buffer,
5112  size_t byte_offset, size_t length);
5113  static Local<BigUint64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5114  size_t byte_offset, size_t length);
5115  V8_INLINE static BigUint64Array* Cast(Value* obj);
5116 
5117  private:
5118  BigUint64Array();
5119  static void CheckCast(Value* obj);
5120 };
5121 
5126  public:
5127  static Local<DataView> New(Local<ArrayBuffer> array_buffer,
5128  size_t byte_offset, size_t length);
5129  static Local<DataView> New(Local<SharedArrayBuffer> shared_array_buffer,
5130  size_t byte_offset, size_t length);
5131  V8_INLINE static DataView* Cast(Value* obj);
5132 
5133  private:
5134  DataView();
5135  static void CheckCast(Value* obj);
5136 };
5137 
5138 
5144  public:
5156  class V8_EXPORT Contents { // NOLINT
5157  public:
5159  using DeleterCallback = void (*)(void* buffer, size_t length, void* info);
5160 
5162  : data_(nullptr),
5163  byte_length_(0),
5164  allocation_base_(nullptr),
5165  allocation_length_(0),
5166  allocation_mode_(Allocator::AllocationMode::kNormal),
5167  deleter_(nullptr),
5168  deleter_data_(nullptr),
5169  is_growable_(false) {}
5170 
5171  void* AllocationBase() const { return allocation_base_; }
5172  size_t AllocationLength() const { return allocation_length_; }
5174  return allocation_mode_;
5175  }
5176 
5177  void* Data() const { return data_; }
5178  size_t ByteLength() const { return byte_length_; }
5179  DeleterCallback Deleter() const { return deleter_; }
5180  void* DeleterData() const { return deleter_data_; }
5181  bool IsGrowable() const { return is_growable_; }
5182 
5183  private:
5184  Contents(void* data, size_t byte_length, void* allocation_base,
5185  size_t allocation_length,
5186  Allocator::AllocationMode allocation_mode, DeleterCallback deleter,
5187  void* deleter_data, bool is_growable);
5188 
5189  void* data_;
5190  size_t byte_length_;
5191  void* allocation_base_;
5192  size_t allocation_length_;
5193  Allocator::AllocationMode allocation_mode_;
5194  DeleterCallback deleter_;
5195  void* deleter_data_;
5196  bool is_growable_;
5197 
5198  friend class SharedArrayBuffer;
5199  };
5200 
5204  size_t ByteLength() const;
5205 
5212  static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length);
5213 
5220  static Local<SharedArrayBuffer> New(
5221  Isolate* isolate, void* data, size_t byte_length,
5223 
5228  static Local<SharedArrayBuffer> New(
5229  Isolate* isolate, const SharedArrayBuffer::Contents&,
5231 
5236  bool IsExternal() const;
5237 
5250  Contents Externalize();
5251 
5264  Contents GetContents();
5265 
5266  V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
5267 
5268  static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
5269 
5270  private:
5272  static void CheckCast(Value* obj);
5273 };
5274 
5275 
5279 class V8_EXPORT Date : public Object {
5280  public:
5282  double time);
5283 
5288  double ValueOf() const;
5289 
5290  V8_INLINE static Date* Cast(Value* obj);
5291 
5305  enum class TimeZoneDetection { kSkip, kRedetect };
5306 
5320  "Use Isolate::DateTimeConfigurationChangeNotification",
5321  static void DateTimeConfigurationChangeNotification(
5322  Isolate* isolate,
5323  TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip));
5324 
5325  private:
5326  static void CheckCast(Value* obj);
5327 };
5328 
5329 
5334  public:
5335  static Local<Value> New(Isolate* isolate, double value);
5336 
5337  double ValueOf() const;
5338 
5339  V8_INLINE static NumberObject* Cast(Value* obj);
5340 
5341  private:
5342  static void CheckCast(Value* obj);
5343 };
5344 
5349  public:
5350  static Local<Value> New(Isolate* isolate, int64_t value);
5351 
5352  Local<BigInt> ValueOf() const;
5353 
5354  V8_INLINE static BigIntObject* Cast(Value* obj);
5355 
5356  private:
5357  static void CheckCast(Value* obj);
5358 };
5359 
5364  public:
5365  static Local<Value> New(Isolate* isolate, bool value);
5366 
5367  bool ValueOf() const;
5368 
5369  V8_INLINE static BooleanObject* Cast(Value* obj);
5370 
5371  private:
5372  static void CheckCast(Value* obj);
5373 };
5374 
5375 
5380  public:
5381  static Local<Value> New(Isolate* isolate, Local<String> value);
5382 
5383  Local<String> ValueOf() const;
5384 
5385  V8_INLINE static StringObject* Cast(Value* obj);
5386 
5387  private:
5388  static void CheckCast(Value* obj);
5389 };
5390 
5391 
5396  public:
5397  static Local<Value> New(Isolate* isolate, Local<Symbol> value);
5398 
5399  Local<Symbol> ValueOf() const;
5400 
5401  V8_INLINE static SymbolObject* Cast(Value* obj);
5402 
5403  private:
5404  static void CheckCast(Value* obj);
5405 };
5406 
5407 
5411 class V8_EXPORT RegExp : public Object {
5412  public:
5417  enum Flags {
5418  kNone = 0,
5419  kGlobal = 1 << 0,
5420  kIgnoreCase = 1 << 1,
5421  kMultiline = 1 << 2,
5422  kSticky = 1 << 3,
5423  kUnicode = 1 << 4,
5424  kDotAll = 1 << 5,
5425  };
5426 
5438  Local<String> pattern,
5439  Flags flags);
5440 
5445  Local<String> GetSource() const;
5446 
5450  Flags GetFlags() const;
5451 
5452  V8_INLINE static RegExp* Cast(Value* obj);
5453 
5454  private:
5455  static void CheckCast(Value* obj);
5456 };
5457 
5458 
5463 class V8_EXPORT External : public Value {
5464  public:
5465  static Local<External> New(Isolate* isolate, void* value);
5466  V8_INLINE static External* Cast(Value* obj);
5467  void* Value() const;
5468  private:
5469  static void CheckCast(v8::Value* obj);
5470 };
5471 
5472 #define V8_INTRINSICS_LIST(F) \
5473  F(ArrayProto_entries, array_entries_iterator) \
5474  F(ArrayProto_forEach, array_for_each_iterator) \
5475  F(ArrayProto_keys, array_keys_iterator) \
5476  F(ArrayProto_values, array_values_iterator) \
5477  F(ErrorPrototype, initial_error_prototype) \
5478  F(IteratorPrototype, initial_iterator_prototype)
5479 
5481 #define V8_DECL_INTRINSIC(name, iname) k##name,
5483 #undef V8_DECL_INTRINSIC
5484 };
5485 
5486 
5487 // --- Templates ---
5488 
5489 
5493 class V8_EXPORT Template : public Data {
5494  public:
5500  void Set(Local<Name> name, Local<Data> value,
5501  PropertyAttribute attributes = None);
5502  void SetPrivate(Local<Private> name, Local<Data> value,
5503  PropertyAttribute attributes = None);
5504  V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value);
5505 
5506  void SetAccessorProperty(
5507  Local<Name> name,
5510  PropertyAttribute attribute = None,
5511  AccessControl settings = DEFAULT);
5512 
5540  void SetNativeDataProperty(
5542  AccessorSetterCallback setter = nullptr,
5543  // TODO(dcarney): gcc can't handle Local below
5544  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
5546  AccessControl settings = DEFAULT,
5547  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
5548  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
5549  void SetNativeDataProperty(
5551  AccessorNameSetterCallback setter = nullptr,
5552  // TODO(dcarney): gcc can't handle Local below
5553  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
5555  AccessControl settings = DEFAULT,
5556  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
5557  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
5558 
5563  void SetLazyDataProperty(
5565  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
5566  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
5567  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
5568 
5573  void SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
5574  PropertyAttribute attribute = None);
5575 
5576  private:
5577  Template();
5578 
5579  friend class ObjectTemplate;
5580  friend class FunctionTemplate;
5581 };
5582 
5583 // TODO(dcarney): Replace GenericNamedPropertyFooCallback with just
5584 // NamedPropertyFooCallback.
5585 
5623  Local<Name> property, const PropertyCallbackInfo<Value>& info);
5624 
5647  Local<Name> property, Local<Value> value,
5648  const PropertyCallbackInfo<Value>& info);
5649 
5672  Local<Name> property, const PropertyCallbackInfo<Integer>& info);
5673 
5696  Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
5697 
5705  const PropertyCallbackInfo<Array>& info);
5706 
5728  Local<Name> property, const PropertyDescriptor& desc,
5729  const PropertyCallbackInfo<Value>& info);
5730 
5751  Local<Name> property, const PropertyCallbackInfo<Value>& info);
5752 
5757  uint32_t index,
5758  const PropertyCallbackInfo<Value>& info);
5759 
5764  uint32_t index,
5765  Local<Value> value,
5766  const PropertyCallbackInfo<Value>& info);
5767 
5772  uint32_t index,
5773  const PropertyCallbackInfo<Integer>& info);
5774 
5779  uint32_t index,
5780  const PropertyCallbackInfo<Boolean>& info);
5781 
5789  const PropertyCallbackInfo<Array>& info);
5790 
5795  uint32_t index, const PropertyDescriptor& desc,
5796  const PropertyCallbackInfo<Value>& info);
5797 
5802  uint32_t index, const PropertyCallbackInfo<Value>& info);
5803 
5813 };
5814 
5815 
5820 typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
5821  Local<Object> accessed_object,
5822  Local<Value> data);
5823 
5925  public:
5927  static Local<FunctionTemplate> New(
5928  Isolate* isolate, FunctionCallback callback = nullptr,
5929  Local<Value> data = Local<Value>(),
5930  Local<Signature> signature = Local<Signature>(), int length = 0,
5932  SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
5933 
5935  static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate,
5936  size_t index);
5937 
5941  static Local<FunctionTemplate> NewWithCache(
5942  Isolate* isolate, FunctionCallback callback,
5943  Local<Private> cache_property, Local<Value> data = Local<Value>(),
5944  Local<Signature> signature = Local<Signature>(), int length = 0,
5945  SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
5946 
5949  Local<Context> context);
5950 
5958  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewRemoteInstance();
5959 
5965  void SetCallHandler(
5966  FunctionCallback callback, Local<Value> data = Local<Value>(),
5967  SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
5968 
5970  void SetLength(int length);
5971 
5973  Local<ObjectTemplate> InstanceTemplate();
5974 
5980  void Inherit(Local<FunctionTemplate> parent);
5981 
5986  Local<ObjectTemplate> PrototypeTemplate();
5987 
5994  void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
5995 
6001  void SetClassName(Local<String> name);
6002 
6003 
6008  void SetAcceptAnyReceiver(bool value);
6009 
6022  V8_DEPRECATED("This feature is incompatible with ES6+.",
6023  void SetHiddenPrototype(bool value));
6024 
6029  void ReadOnlyPrototype();
6030 
6035  void RemovePrototype();
6036 
6041  bool HasInstance(Local<Value> object);
6042 
6043  V8_INLINE static FunctionTemplate* Cast(Data* data);
6044 
6045  private:
6046  FunctionTemplate();
6047 
6048  static void CheckCast(Data* that);
6049  friend class Context;
6050  friend class ObjectTemplate;
6051 };
6052 
6061  kNone = 0,
6062 
6066  kAllCanRead = 1,
6067 
6072  kNonMasking = 1 << 1,
6073 
6078  kOnlyInterceptStrings = 1 << 2,
6079 
6083  kHasNoSideEffect = 1 << 3,
6084 };
6085 
6097  : getter(getter),
6098  setter(setter),
6099  query(query),
6100  deleter(deleter),
6102  definer(definer),
6104  data(data),
6105  flags(flags) {}
6106 
6116  : getter(getter),
6117  setter(setter),
6118  query(query),
6119  deleter(deleter),
6121  definer(nullptr),
6122  descriptor(nullptr),
6123  data(data),
6124  flags(flags) {}
6125 
6135  : getter(getter),
6136  setter(setter),
6137  query(nullptr),
6138  deleter(deleter),
6140  definer(definer),
6142  data(data),
6143  flags(flags) {}
6144 
6154 };
6155 
6156 
6167  : getter(getter),
6168  setter(setter),
6169  query(query),
6170  deleter(deleter),
6172  definer(definer),
6174  data(data),
6175  flags(flags) {}
6176 
6186  : getter(getter),
6187  setter(setter),
6188  query(query),
6189  deleter(deleter),
6191  definer(nullptr),
6192  descriptor(nullptr),
6193  data(data),
6194  flags(flags) {}
6195 
6205  : getter(getter),
6206  setter(setter),
6207  query(nullptr),
6208  deleter(deleter),
6210  definer(definer),
6212  data(data),
6213  flags(flags) {}
6214 
6224 };
6225 
6226 
6234  public:
6236  static Local<ObjectTemplate> New(
6237  Isolate* isolate,
6239 
6241  static MaybeLocal<ObjectTemplate> FromSnapshot(Isolate* isolate,
6242  size_t index);
6243 
6246 
6276  void SetAccessor(
6278  AccessorSetterCallback setter = nullptr,
6279  Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
6280  PropertyAttribute attribute = None,
6282  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
6283  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
6284  void SetAccessor(
6286  AccessorNameSetterCallback setter = nullptr,
6287  Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
6288  PropertyAttribute attribute = None,
6290  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
6291  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
6292 
6304  void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
6305 
6322  // TODO(dcarney): deprecate
6325  IndexedPropertySetterCallback setter = nullptr,
6326  IndexedPropertyQueryCallback query = nullptr,
6327  IndexedPropertyDeleterCallback deleter = nullptr,
6328  IndexedPropertyEnumeratorCallback enumerator = nullptr,
6329  Local<Value> data = Local<Value>()) {
6330  SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
6331  deleter, enumerator, data));
6332  }
6333 
6344  void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
6345 
6352  void SetCallAsFunctionHandler(FunctionCallback callback,
6353  Local<Value> data = Local<Value>());
6354 
6363  void MarkAsUndetectable();
6364 
6373  void SetAccessCheckCallback(AccessCheckCallback callback,
6374  Local<Value> data = Local<Value>());
6375 
6382  void SetAccessCheckCallbackAndHandler(
6383  AccessCheckCallback callback,
6384  const NamedPropertyHandlerConfiguration& named_handler,
6385  const IndexedPropertyHandlerConfiguration& indexed_handler,
6386  Local<Value> data = Local<Value>());
6387 
6392  int InternalFieldCount();
6393 
6398  void SetInternalFieldCount(int value);
6399 
6403  bool IsImmutableProto();
6404 
6409  void SetImmutableProto();
6410 
6411  V8_INLINE static ObjectTemplate* Cast(Data* data);
6412 
6413  private:
6414  ObjectTemplate();
6415  static Local<ObjectTemplate> New(internal::Isolate* isolate,
6416  Local<FunctionTemplate> constructor);
6417  static void CheckCast(Data* that);
6418  friend class FunctionTemplate;
6419 };
6420 
6429 class V8_EXPORT Signature : public Data {
6430  public:
6431  static Local<Signature> New(
6432  Isolate* isolate,
6434 
6435  V8_INLINE static Signature* Cast(Data* data);
6436 
6437  private:
6438  Signature();
6439 
6440  static void CheckCast(Data* that);
6441 };
6442 
6443 
6449  public:
6450  static Local<AccessorSignature> New(
6451  Isolate* isolate,
6453 
6454  V8_INLINE static AccessorSignature* Cast(Data* data);
6455 
6456  private:
6458 
6459  static void CheckCast(Data* that);
6460 };
6461 
6462 
6463 // --- Extensions ---
6464 
6468 class V8_EXPORT Extension { // NOLINT
6469  public:
6470  // Note that the strings passed into this constructor must live as long
6471  // as the Extension itself.
6472  Extension(const char* name, const char* source = nullptr, int dep_count = 0,
6473  const char** deps = nullptr, int source_length = -1);
6474  virtual ~Extension() { delete source_; }
6476  Isolate* isolate, Local<String> name) {
6477  return Local<FunctionTemplate>();
6478  }
6479 
6480  const char* name() const { return name_; }
6481  size_t source_length() const { return source_length_; }
6483  return source_;
6484  }
6485  int dependency_count() const { return dep_count_; }
6486  const char** dependencies() const { return deps_; }
6487  void set_auto_enable(bool value) { auto_enable_ = value; }
6488  bool auto_enable() { return auto_enable_; }
6489 
6490  // Disallow copying and assigning.
6491  Extension(const Extension&) = delete;
6492  void operator=(const Extension&) = delete;
6493 
6494  private:
6495  const char* name_;
6496  size_t source_length_; // expected to initialize before source_
6498  int dep_count_;
6499  const char** deps_;
6500  bool auto_enable_;
6501 };
6502 
6504  "Use unique_ptr version or stop using extension (http://crbug.com/334679).",
6505  void V8_EXPORT RegisterExtension(Extension* extension));
6506 
6507 void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>);
6508 
6509 // --- Statics ---
6510 
6511 V8_INLINE Local<Primitive> Undefined(Isolate* isolate);
6512 V8_INLINE Local<Primitive> Null(Isolate* isolate);
6513 V8_INLINE Local<Boolean> True(Isolate* isolate);
6514 V8_INLINE Local<Boolean> False(Isolate* isolate);
6515 
6531  public:
6533 
6543  void ConfigureDefaults(uint64_t physical_memory,
6544  uint64_t virtual_memory_limit);
6545 
6546  // Returns the max semi-space size in KB.
6547  size_t max_semi_space_size_in_kb() const {
6548  return max_semi_space_size_in_kb_;
6549  }
6550 
6551  // Sets the max semi-space size in KB.
6552  void set_max_semi_space_size_in_kb(size_t limit_in_kb) {
6553  max_semi_space_size_in_kb_ = limit_in_kb;
6554  }
6555 
6556  size_t max_old_space_size() const { return max_old_space_size_; }
6557  void set_max_old_space_size(size_t limit_in_mb) {
6558  max_old_space_size_ = limit_in_mb;
6559  }
6560  uint32_t* stack_limit() const { return stack_limit_; }
6561  // Sets an address beyond which the VM's stack may not grow.
6562  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
6563  size_t code_range_size() const { return code_range_size_; }
6564  void set_code_range_size(size_t limit_in_mb) {
6565  code_range_size_ = limit_in_mb;
6566  }
6567  V8_DEPRECATE_SOON("Zone does not pool memory any more.",
6568  size_t max_zone_pool_size() const) {
6569  return max_zone_pool_size_;
6570  }
6571  V8_DEPRECATE_SOON("Zone does not pool memory any more.",
6572  void set_max_zone_pool_size(size_t bytes)) {
6573  max_zone_pool_size_ = bytes;
6574  }
6575 
6576  private:
6577  // max_semi_space_size_ is in KB
6578  size_t max_semi_space_size_in_kb_;
6579 
6580  // The remaining limits are in MB
6581  size_t max_old_space_size_;
6582  uint32_t* stack_limit_;
6583  size_t code_range_size_;
6584  size_t max_zone_pool_size_;
6585 };
6586 
6587 
6588 // --- Exceptions ---
6589 
6590 
6591 typedef void (*FatalErrorCallback)(const char* location, const char* message);
6592 
6593 typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom);
6594 
6595 typedef void (*DcheckErrorCallback)(const char* file, int line,
6596  const char* message);
6597 
6598 typedef void (*MessageCallback)(Local<Message> message, Local<Value> data);
6599 
6600 // --- Tracing ---
6601 
6602 typedef void (*LogEventCallback)(const char* name, int event);
6603 
6609  public:
6610  static Local<Value> RangeError(Local<String> message);
6611  static Local<Value> ReferenceError(Local<String> message);
6612  static Local<Value> SyntaxError(Local<String> message);
6613  static Local<Value> TypeError(Local<String> message);
6614  static Local<Value> Error(Local<String> message);
6615 
6621  static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
6622 
6627  static Local<StackTrace> GetStackTrace(Local<Value> exception);
6628 };
6629 
6630 
6631 // --- Counters Callbacks ---
6632 
6633 typedef int* (*CounterLookupCallback)(const char* name);
6634 
6635 typedef void* (*CreateHistogramCallback)(const char* name,
6636  int min,
6637  int max,
6638  size_t buckets);
6639 
6640 typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
6641 
6642 // --- Enter/Leave Script Callback ---
6644 typedef void (*CallCompletedCallback)(Isolate*);
6645 
6667  Local<Context> context, Local<ScriptOrModule> referrer,
6668  Local<String> specifier);
6669 
6681  Local<Module> module,
6682  Local<Object> meta);
6683 
6692  Local<Value> error,
6693  Local<Array> sites);
6694 
6712 
6713 typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
6714  Local<Value> parent);
6715 
6716 // --- Promise Reject Callback ---
6722 };
6723 
6725  public:
6727  Local<Value> value, Local<StackTrace> stack_trace)
6728  : promise_(promise),
6729  event_(event),
6730  value_(value),
6731  stack_trace_(stack_trace) {}
6732 
6733  V8_INLINE Local<Promise> GetPromise() const { return promise_; }
6734  V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
6735  V8_INLINE Local<Value> GetValue() const { return value_; }
6736 
6737  private:
6738  Local<Promise> promise_;
6739  PromiseRejectEvent event_;
6740  Local<Value> value_;
6741  Local<StackTrace> stack_trace_;
6742 };
6743 
6745 
6746 // --- Microtasks Callbacks ---
6749 typedef void (*MicrotaskCallback)(void* data);
6750 
6751 
6760 
6777  public:
6781  static std::unique_ptr<MicrotaskQueue> New();
6782 
6783  virtual ~MicrotaskQueue() = default;
6784 
6788  virtual void EnqueueMicrotask(Isolate* isolate,
6789  Local<Function> microtask) = 0;
6790 
6794  virtual void EnqueueMicrotask(v8::Isolate* isolate,
6795  MicrotaskCallback callback,
6796  void* data = nullptr) = 0;
6797 
6810  virtual void AddMicrotasksCompletedCallback(
6811  MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
6812 
6816  virtual void RemoveMicrotasksCompletedCallback(
6817  MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
6818 
6822  virtual void PerformCheckpoint(Isolate* isolate) = 0;
6823 
6827  virtual bool IsRunningMicrotasks() const = 0;
6828 
6829  private:
6830  friend class internal::MicrotaskQueue;
6831  MicrotaskQueue() = default;
6832  MicrotaskQueue(const MicrotaskQueue&) = delete;
6833  MicrotaskQueue& operator=(const MicrotaskQueue&) = delete;
6834 };
6835 
6846  public:
6847  enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
6848 
6849  MicrotasksScope(Isolate* isolate, Type type);
6850  MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
6851  ~MicrotasksScope();
6852 
6856  static void PerformCheckpoint(Isolate* isolate);
6857 
6861  static int GetCurrentDepth(Isolate* isolate);
6862 
6866  static bool IsRunningMicrotasks(Isolate* isolate);
6867 
6868  // Prevent copying.
6869  MicrotasksScope(const MicrotasksScope&) = delete;
6870  MicrotasksScope& operator=(const MicrotasksScope&) = delete;
6871 
6872  private:
6873  internal::Isolate* const isolate_;
6874  internal::MicrotaskQueue* const microtask_queue_;
6875  bool run_;
6876 };
6877 
6878 
6879 // --- Failed Access Check Callback ---
6881  AccessType type,
6882  Local<Value> data);
6883 
6884 // --- AllowCodeGenerationFromStrings callbacks ---
6885 
6891  Local<String> source);
6892 
6893 // --- WebAssembly compilation callbacks ---
6895 
6897  Local<String> source);
6898 
6899 // --- Callback for APIs defined on v8-supported objects, but implemented
6900 // by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
6902 
6903 // --- Callback for WebAssembly.compileStreaming ---
6905 
6906 // --- Callback for checking if WebAssembly threads are enabled ---
6908 
6909 // --- Garbage Collection Callbacks ---
6910 
6918 enum GCType {
6925 };
6926 
6949 };
6950 
6951 typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
6952 
6953 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
6954 
6962 typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit,
6963  size_t initial_heap_limit);
6964 
6972  public:
6973  HeapStatistics();
6974  size_t total_heap_size() { return total_heap_size_; }
6975  size_t total_heap_size_executable() { return total_heap_size_executable_; }
6976  size_t total_physical_size() { return total_physical_size_; }
6977  size_t total_available_size() { return total_available_size_; }
6978  size_t used_heap_size() { return used_heap_size_; }
6979  size_t heap_size_limit() { return heap_size_limit_; }
6980  size_t malloced_memory() { return malloced_memory_; }
6981  size_t external_memory() { return external_memory_; }
6982  size_t peak_malloced_memory() { return peak_malloced_memory_; }
6983  size_t number_of_native_contexts() { return number_of_native_contexts_; }
6984  size_t number_of_detached_contexts() { return number_of_detached_contexts_; }
6985 
6990  size_t does_zap_garbage() { return does_zap_garbage_; }
6991 
6992  private:
6993  size_t total_heap_size_;
6994  size_t total_heap_size_executable_;
6995  size_t total_physical_size_;
6996  size_t total_available_size_;
6997  size_t used_heap_size_;
6998  size_t heap_size_limit_;
6999  size_t malloced_memory_;
7000  size_t external_memory_;
7001  size_t peak_malloced_memory_;
7002  bool does_zap_garbage_;
7003  size_t number_of_native_contexts_;
7004  size_t number_of_detached_contexts_;
7005 
7006  friend class V8;
7007  friend class Isolate;
7008 };
7009 
7010 
7012  public:
7014  const char* space_name() { return space_name_; }
7015  size_t space_size() { return space_size_; }
7016  size_t space_used_size() { return space_used_size_; }
7017  size_t space_available_size() { return space_available_size_; }
7018  size_t physical_space_size() { return physical_space_size_; }
7019 
7020  private:
7021  const char* space_name_;
7022  size_t space_size_;
7023  size_t space_used_size_;
7024  size_t space_available_size_;
7025  size_t physical_space_size_;
7026 
7027  friend class Isolate;
7028 };
7029 
7030 
7032  public:
7034  const char* object_type() { return object_type_; }
7035  const char* object_sub_type() { return object_sub_type_; }
7036  size_t object_count() { return object_count_; }
7037  size_t object_size() { return object_size_; }
7038 
7039  private:
7040  const char* object_type_;
7041  const char* object_sub_type_;
7042  size_t object_count_;
7043  size_t object_size_;
7044 
7045  friend class Isolate;
7046 };
7047 
7049  public:
7051  size_t code_and_metadata_size() { return code_and_metadata_size_; }
7052  size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; }
7053  size_t external_script_source_size() { return external_script_source_size_; }
7054 
7055  private:
7056  size_t code_and_metadata_size_;
7057  size_t bytecode_and_metadata_size_;
7058  size_t external_script_source_size_;
7059 
7060  friend class Isolate;
7061 };
7062 
7069  enum EventType {
7076  };
7077  // Definition of the code position type. The "POSITION" type means the place
7078  // in the source code which are of interest when making stack traces to
7079  // pin-point the source location of a stack frame as close as possible.
7080  // The "STATEMENT_POSITION" means the place at the beginning of each
7081  // statement, and is used to indicate possible break locations.
7083 
7084  // There are two different kinds of JitCodeEvents, one for JIT code generated
7085  // by the optimizing compiler, and one for byte code generated for the
7086  // interpreter. For JIT_CODE events, the |code_start| member of the event
7087  // points to the beginning of jitted assembly code, while for BYTE_CODE
7088  // events, |code_start| points to the first bytecode of the interpreted
7089  // function.
7091 
7092  // Type of event.
7095  // Start of the instructions.
7096  void* code_start;
7097  // Size of the instructions.
7098  size_t code_len;
7099  // Script info for CODE_ADDED event.
7101  // User-defined data for *_LINE_INFO_* event. It's used to hold the source
7102  // code line information which is returned from the
7103  // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
7104  // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
7105  void* user_data;
7106 
7107  struct name_t {
7108  // Name of the object associated with the code, note that the string is not
7109  // zero-terminated.
7110  const char* str;
7111  // Number of chars in str.
7112  size_t len;
7113  };
7114 
7115  struct line_info_t {
7116  // PC offset
7117  size_t offset;
7118  // Code position
7119  size_t pos;
7120  // The position type.
7122  };
7123 
7124  union {
7125  // Only valid for CODE_ADDED.
7126  struct name_t name;
7127 
7128  // Only valid for CODE_ADD_LINE_POS_INFO
7130 
7131  // New location of instructions. Only valid for CODE_MOVED.
7133  };
7134 
7136 };
7137 
7143 enum RAILMode : unsigned {
7144  // Response performance mode: In this mode very low virtual machine latency
7145  // is provided. V8 will try to avoid JavaScript execution interruptions.
7146  // Throughput may be throttled.
7148  // Animation performance mode: In this mode low virtual machine latency is
7149  // provided. V8 will try to avoid as many JavaScript execution interruptions
7150  // as possible. Throughput may be throttled. This is the default mode.
7152  // Idle performance mode: The embedder is idle. V8 can complete deferred work
7153  // in this mode.
7155  // Load performance mode: In this mode high throughput is provided. V8 may
7156  // turn off latency optimizations.
7158 };
7159 
7165  // Generate callbacks for already existent code.
7167 };
7168 
7169 
7175 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
7176 
7177 
7182  public:
7183  virtual ~ExternalResourceVisitor() = default;
7184  virtual void VisitExternalString(Local<String> string) {}
7185 };
7186 
7187 
7192  public:
7193  virtual ~PersistentHandleVisitor() = default;
7195  uint16_t class_id) {}
7196 };
7197 
7207 
7216  public:
7217  // Indicator for the stack state of the embedder.
7222  };
7223 
7228  public:
7229  virtual ~TracedGlobalHandleVisitor() = default;
7230  virtual void VisitTracedGlobalHandle(const TracedGlobal<Value>& value) = 0;
7231  };
7232 
7233  virtual ~EmbedderHeapTracer() = default;
7234 
7239  void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);
7240 
7247  virtual void RegisterV8References(
7248  const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
7249 
7250  void RegisterEmbedderReference(const TracedGlobal<v8::Value>& ref);
7251 
7255  virtual void TracePrologue() = 0;
7256 
7267  virtual bool AdvanceTracing(double deadline_in_ms) = 0;
7268 
7269  /*
7270  * Returns true if there no more tracing work to be done (see AdvanceTracing)
7271  * and false otherwise.
7272  */
7273  virtual bool IsTracingDone() = 0;
7274 
7280  virtual void TraceEpilogue() = 0;
7281 
7286  virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
7287 
7288  /*
7289  * Called by the embedder to request immediate finalization of the currently
7290  * running tracing phase that has been started with TracePrologue and not
7291  * yet finished with TraceEpilogue.
7292  *
7293  * Will be a noop when currently not in tracing.
7294  *
7295  * This is an experimental feature.
7296  */
7297  void FinalizeTracing();
7298 
7306  const v8::TracedGlobal<v8::Value>& handle) {
7307  return true;
7308  }
7309 
7310  /*
7311  * Called by the embedder to immediately perform a full garbage collection.
7312  *
7313  * Should only be used in testing code.
7314  */
7315  void GarbageCollectionForTesting(EmbedderStackState stack_state);
7316 
7317  /*
7318  * Returns the v8::Isolate this tracer is attached too and |nullptr| if it
7319  * is not attached to any v8::Isolate.
7320  */
7321  v8::Isolate* isolate() const { return isolate_; }
7322 
7323  protected:
7324  v8::Isolate* isolate_ = nullptr;
7325 
7326  friend class internal::LocalEmbedderHeapTracer;
7327 };
7328 
7338  typedef StartupData (*CallbackFunction)(Local<Object> holder, int index,
7339  void* data);
7341  void* data_arg = nullptr)
7342  : callback(function), data(data_arg) {}
7344  void* data;
7345 };
7346 // Note that these fields are called "internal fields" in the API and called
7347 // "embedder fields" within V8.
7349 
7355  typedef void (*CallbackFunction)(Local<Object> holder, int index,
7356  StartupData payload, void* data);
7358  void* data_arg = nullptr)
7359  : callback(function), data(data_arg) {}
7360  void (*callback)(Local<Object> holder, int index, StartupData payload,
7361  void* data);
7362  void* data;
7363 };
7365 
7375  public:
7379  struct CreateParams {
7381  : code_event_handler(nullptr),
7382  snapshot_blob(nullptr),
7383  counter_lookup_callback(nullptr),
7384  create_histogram_callback(nullptr),
7385  add_histogram_sample_callback(nullptr),
7386  array_buffer_allocator(nullptr),
7387  external_references(nullptr),
7388  allow_atomics_wait(true),
7389  only_terminate_in_safe_scope(false) {}
7390 
7396 
7401 
7406 
7407 
7413 
7422 
7428 
7435  const intptr_t* external_references;
7436 
7442 
7447  };
7448 
7449 
7455  public:
7456  explicit Scope(Isolate* isolate) : isolate_(isolate) {
7457  isolate->Enter();
7458  }
7459 
7460  ~Scope() { isolate_->Exit(); }
7461 
7462  // Prevent copying of Scope objects.
7463  Scope(const Scope&) = delete;
7464  Scope& operator=(const Scope&) = delete;
7465 
7466  private:
7467  Isolate* const isolate_;
7468  };
7469 
7470 
7475  public:
7476  enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
7477 
7478  DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
7480 
7481  // Prevent copying of Scope objects.
7483  delete;
7485  const DisallowJavascriptExecutionScope&) = delete;
7486 
7487  private:
7488  OnFailure on_failure_;
7489  void* internal_;
7490  };
7491 
7492 
7497  public:
7498  explicit AllowJavascriptExecutionScope(Isolate* isolate);
7500 
7501  // Prevent copying of Scope objects.
7503  delete;
7504  AllowJavascriptExecutionScope& operator=(
7505  const AllowJavascriptExecutionScope&) = delete;
7506 
7507  private:
7508  void* internal_throws_;
7509  void* internal_assert_;
7510  void* internal_dump_;
7511  };
7512 
7518  public:
7519  explicit SuppressMicrotaskExecutionScope(Isolate* isolate);
7520  explicit SuppressMicrotaskExecutionScope(MicrotaskQueue* microtask_queue);
7522 
7523  // Prevent copying of Scope objects.
7525  delete;
7527  const SuppressMicrotaskExecutionScope&) = delete;
7528 
7529  private:
7530  internal::Isolate* const isolate_;
7531  internal::MicrotaskQueue* const microtask_queue_;
7532  };
7533 
7539  public:
7540  explicit SafeForTerminationScope(v8::Isolate* isolate);
7542 
7543  // Prevent copying of Scope objects.
7545  SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete;
7546 
7547  private:
7548  internal::Isolate* isolate_;
7549  bool prev_value_;
7550  };
7551 
7558  kMinorGarbageCollection
7559  };
7560 
7567  kUseAsm = 0,
7568  kBreakIterator = 1,
7569  kLegacyConst = 2,
7570  kMarkDequeOverflow = 3,
7571  kStoreBufferOverflow = 4,
7572  kSlotsBufferOverflow = 5,
7573  kObjectObserve = 6,
7574  kForcedGC = 7,
7575  kSloppyMode = 8,
7576  kStrictMode = 9,
7577  kStrongMode = 10,
7578  kRegExpPrototypeStickyGetter = 11,
7579  kRegExpPrototypeToString = 12,
7580  kRegExpPrototypeUnicodeGetter = 13,
7581  kIntlV8Parse = 14,
7582  kIntlPattern = 15,
7583  kIntlResolved = 16,
7584  kPromiseChain = 17,
7585  kPromiseAccept = 18,
7586  kPromiseDefer = 19,
7587  kHtmlCommentInExternalScript = 20,
7588  kHtmlComment = 21,
7589  kSloppyModeBlockScopedFunctionRedefinition = 22,
7590  kForInInitializer = 23,
7591  kArrayProtectorDirtied = 24,
7592  kArraySpeciesModified = 25,
7593  kArrayPrototypeConstructorModified = 26,
7594  kArrayInstanceProtoModified = 27,
7595  kArrayInstanceConstructorModified = 28,
7596  kLegacyFunctionDeclaration = 29,
7597  kRegExpPrototypeSourceGetter = 30,
7598  kRegExpPrototypeOldFlagGetter = 31,
7599  kDecimalWithLeadingZeroInStrictMode = 32,
7600  kLegacyDateParser = 33,
7601  kDefineGetterOrSetterWouldThrow = 34,
7602  kFunctionConstructorReturnedUndefined = 35,
7603  kAssigmentExpressionLHSIsCallInSloppy = 36,
7604  kAssigmentExpressionLHSIsCallInStrict = 37,
7605  kPromiseConstructorReturnedUndefined = 38,
7606  kConstructorNonUndefinedPrimitiveReturn = 39,
7607  kLabeledExpressionStatement = 40,
7608  kLineOrParagraphSeparatorAsLineTerminator = 41,
7609  kIndexAccessor = 42,
7610  kErrorCaptureStackTrace = 43,
7611  kErrorPrepareStackTrace = 44,
7612  kErrorStackTraceLimit = 45,
7613  kWebAssemblyInstantiation = 46,
7614  kDeoptimizerDisableSpeculation = 47,
7615  kArrayPrototypeSortJSArrayModifiedPrototype = 48,
7616  kFunctionTokenOffsetTooLongForToString = 49,
7617  kWasmSharedMemory = 50,
7618  kWasmThreadOpcodes = 51,
7619  kAtomicsNotify = 52,
7620  kAtomicsWake = 53,
7621  kCollator = 54,
7622  kNumberFormat = 55,
7623  kDateTimeFormat = 56,
7624  kPluralRules = 57,
7625  kRelativeTimeFormat = 58,
7626  kLocale = 59,
7627  kListFormat = 60,
7628  kSegmenter = 61,
7629  kStringLocaleCompare = 62,
7630  kStringToLocaleUpperCase = 63,
7631  kStringToLocaleLowerCase = 64,
7632  kNumberToLocaleString = 65,
7633  kDateToLocaleString = 66,
7634  kDateToLocaleDateString = 67,
7635  kDateToLocaleTimeString = 68,
7636  kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
7637  kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
7638  kOptimizedFunctionWithOneShotBytecode = 71,
7639  kRegExpMatchIsTrueishOnNonJSRegExp = 72,
7640  kRegExpMatchIsFalseishOnJSRegExp = 73,
7641  kDateGetTimezoneOffset = 74,
7642  kStringNormalize = 75,
7643 
7644  // If you add new values here, you'll also need to update Chromium's:
7645  // web_feature.mojom, UseCounterCallback.cpp, and enums.xml. V8 changes to
7646  // this list need to be landed first, then changes on the Chromium side.
7647  kUseCounterFeatureCount // This enum value must be last.
7648  };
7649 
7651  kMessageLog = (1 << 0),
7652  kMessageDebug = (1 << 1),
7653  kMessageInfo = (1 << 2),
7654  kMessageError = (1 << 3),
7655  kMessageWarning = (1 << 4),
7656  kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
7657  kMessageWarning,
7658  };
7659 
7660  typedef void (*UseCounterCallback)(Isolate* isolate,
7661  UseCounterFeature feature);
7662 
7677  static Isolate* Allocate();
7678 
7682  static void Initialize(Isolate* isolate, const CreateParams& params);
7683 
7693  static Isolate* New(const CreateParams& params);
7694 
7701  static Isolate* GetCurrent();
7702 
7712  typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
7713  void SetAbortOnUncaughtExceptionCallback(
7714  AbortOnUncaughtExceptionCallback callback);
7715 
7720  void SetHostImportModuleDynamicallyCallback(
7722 
7727  void SetHostInitializeImportMetaObjectCallback(
7729 
7734  void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback);
7735 
7742  void MemoryPressureNotification(MemoryPressureLevel level);
7743 
7754  void Enter();
7755 
7763  void Exit();
7764 
7769  void Dispose();
7770 
7775  void DumpAndResetStats();
7776 
7784  void DiscardThreadSpecificMetadata();
7785 
7790  V8_INLINE void SetData(uint32_t slot, void* data);
7791 
7796  V8_INLINE void* GetData(uint32_t slot);
7797 
7802  V8_INLINE static uint32_t GetNumberOfDataSlots();
7803 
7809  template <class T>
7810  V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
7811 
7815  void GetHeapStatistics(HeapStatistics* heap_statistics);
7816 
7820  size_t NumberOfHeapSpaces();
7821 
7831  bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
7832  size_t index);
7833 
7837  size_t NumberOfTrackedHeapObjectTypes();
7838 
7848  bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
7849  size_t type_index);
7850 
7858  bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
7859 
7872  void GetStackSample(const RegisterState& state, void** frames,
7873  size_t frames_limit, SampleInfo* sample_info);
7874 
7888  V8_INLINE int64_t
7889  AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
7890 
7895  size_t NumberOfPhantomHandleResetsSinceLastCall();
7896 
7901  HeapProfiler* GetHeapProfiler();
7902 
7906  void SetIdle(bool is_idle);
7907 
7909  ArrayBuffer::Allocator* GetArrayBufferAllocator();
7910 
7912  bool InContext();
7913 
7918  Local<Context> GetCurrentContext();
7919 
7921  V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
7922  Local<Context> GetEnteredContext());
7923 
7930  Local<Context> GetEnteredOrMicrotaskContext();
7931 
7936  Local<Context> GetIncumbentContext();
7937 
7944  Local<Value> ThrowException(Local<Value> exception);
7945 
7946  typedef void (*GCCallback)(Isolate* isolate, GCType type,
7947  GCCallbackFlags flags);
7948  typedef void (*GCCallbackWithData)(Isolate* isolate, GCType type,
7949  GCCallbackFlags flags, void* data);
7950 
7960  void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
7961  GCType gc_type_filter = kGCTypeAll);
7962  void AddGCPrologueCallback(GCCallback callback,
7963  GCType gc_type_filter = kGCTypeAll);
7964 
7969  void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
7970  void RemoveGCPrologueCallback(GCCallback callback);
7971 
7975  void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
7976 
7977  /*
7978  * Gets the currently active heap tracer for the isolate.
7979  */
7980  EmbedderHeapTracer* GetEmbedderHeapTracer();
7981 
7985  enum class AtomicsWaitEvent {
7987  kStartWait,
7989  kWokenUp,
7991  kTimedOut,
7993  kTerminatedExecution,
7995  kAPIStopped,
7997  kNotEqual
7998  };
7999 
8005  public:
8020  void Wake();
8021  };
8022 
8046  typedef void (*AtomicsWaitCallback)(AtomicsWaitEvent event,
8047  Local<SharedArrayBuffer> array_buffer,
8048  size_t offset_in_bytes, int64_t value,
8049  double timeout_in_ms,
8050  AtomicsWaitWakeHandle* stop_handle,
8051  void* data);
8052 
8059  void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void* data);
8060 
8070  void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
8071  GCType gc_type_filter = kGCTypeAll);
8072  void AddGCEpilogueCallback(GCCallback callback,
8073  GCType gc_type_filter = kGCTypeAll);
8074 
8079  void RemoveGCEpilogueCallback(GCCallbackWithData callback,
8080  void* data = nullptr);
8081  void RemoveGCEpilogueCallback(GCCallback callback);
8082 
8083  typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
8084 
8091  void SetGetExternallyAllocatedMemoryInBytesCallback(
8092  GetExternallyAllocatedMemoryInBytesCallback callback);
8093 
8101  void TerminateExecution();
8102 
8111  bool IsExecutionTerminating();
8112 
8127  void CancelTerminateExecution();
8128 
8137  void RequestInterrupt(InterruptCallback callback, void* data);
8138 
8149  void RequestGarbageCollectionForTesting(GarbageCollectionType type);
8150 
8154  void SetEventLogger(LogEventCallback that);
8155 
8162  void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
8163 
8167  void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
8168 
8176  void AddCallCompletedCallback(CallCompletedCallback callback);
8177 
8181  void RemoveCallCompletedCallback(CallCompletedCallback callback);
8182 
8187  void SetPromiseHook(PromiseHook hook);
8188 
8193  void SetPromiseRejectCallback(PromiseRejectCallback callback);
8194 
8199  void RunMicrotasks();
8200 
8204  void EnqueueMicrotask(Local<Function> microtask);
8205 
8209  void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
8210 
8214  void SetMicrotasksPolicy(MicrotasksPolicy policy);
8215 
8219  MicrotasksPolicy GetMicrotasksPolicy() const;
8220 
8234  void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
8235 
8239  void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
8240 
8244  void SetUseCounterCallback(UseCounterCallback callback);
8245 
8250  void SetCounterFunction(CounterLookupCallback);
8251 
8258  void SetCreateHistogramFunction(CreateHistogramCallback);
8259  void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
8260 
8275  bool IdleNotificationDeadline(double deadline_in_seconds);
8276 
8281  void LowMemoryNotification();
8282 
8292  int ContextDisposedNotification(bool dependant_context = true);
8293 
8298  void IsolateInForegroundNotification();
8299 
8304  void IsolateInBackgroundNotification();
8305 
8311  void EnableMemorySavingsMode();
8312 
8316  void DisableMemorySavingsMode();
8317 
8325  void SetRAILMode(RAILMode rail_mode);
8326 
8331  void IncreaseHeapLimitForDebugging();
8332 
8336  void RestoreOriginalHeapLimit();
8337 
8342  bool IsHeapLimitIncreasedForDebugging();
8343 
8366  void SetJitCodeEventHandler(JitCodeEventOptions options,
8367  JitCodeEventHandler event_handler);
8368 
8378  void SetStackLimit(uintptr_t stack_limit);
8379 
8395  void GetCodeRange(void** start, size_t* length_in_bytes);
8396 
8400  UnwindState GetUnwindState();
8401 
8403  void SetFatalErrorHandler(FatalErrorCallback that);
8404 
8406  void SetOOMErrorHandler(OOMErrorCallback that);
8407 
8413  void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void* data);
8414 
8422  void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
8423  size_t heap_limit);
8424 
8431  void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
8432 
8437  void SetAllowCodeGenerationFromStringsCallback(
8439 
8444  void SetAllowWasmCodeGenerationCallback(
8446 
8451  void SetWasmModuleCallback(ExtensionCallback callback);
8452  void SetWasmInstanceCallback(ExtensionCallback callback);
8453 
8454  void SetWasmStreamingCallback(WasmStreamingCallback callback);
8455 
8456  void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
8457 
8462  bool IsDead();
8463 
8473  bool AddMessageListener(MessageCallback that,
8474  Local<Value> data = Local<Value>());
8475 
8487  bool AddMessageListenerWithErrorLevel(MessageCallback that,
8488  int message_levels,
8489  Local<Value> data = Local<Value>());
8490 
8494  void RemoveMessageListeners(MessageCallback that);
8495 
8497  void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
8498 
8503  void SetCaptureStackTraceForUncaughtExceptions(
8504  bool capture, int frame_limit = 10,
8506 
8512  void VisitExternalResources(ExternalResourceVisitor* visitor);
8513 
8518  void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
8519 
8527  V8_DEPRECATED(
8528  "Use VisitHandlesWithClassIds",
8529  void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor));
8530 
8536  void VisitWeakHandles(PersistentHandleVisitor* visitor);
8537 
8542  bool IsInUse();
8543 
8549  void SetAllowAtomicsWait(bool allow);
8550 
8564  enum class TimeZoneDetection { kSkip, kRedetect };
8565 
8576  void DateTimeConfigurationChangeNotification(
8577  TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
8578 
8588  void LocaleConfigurationChangeNotification();
8589 
8590  Isolate() = delete;
8591  ~Isolate() = delete;
8592  Isolate(const Isolate&) = delete;
8593  Isolate& operator=(const Isolate&) = delete;
8594  // Deleting operator new and delete here is allowed as ctor and dtor is also
8595  // deleted.
8596  void* operator new(size_t size) = delete;
8597  void* operator new[](size_t size) = delete;
8598  void operator delete(void*, size_t) = delete;
8599  void operator delete[](void*, size_t) = delete;
8600 
8601  private:
8602  template <class K, class V, class Traits>
8604 
8605  internal::Address* GetDataFromSnapshotOnce(size_t index);
8606  void ReportExternalAllocationLimitReached();
8607  void CheckMemoryPressure();
8608 };
8609 
8611  public:
8612  const char* data;
8614 };
8615 
8616 
8621 typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
8622 
8636 typedef uintptr_t (*ReturnAddressLocationResolver)(
8637  uintptr_t return_addr_location);
8638 
8639 
8643 class V8_EXPORT V8 {
8644  public:
8660  static void SetNativesDataBlob(StartupData* startup_blob);
8661  static void SetSnapshotDataBlob(StartupData* startup_blob);
8662 
8664  static void SetDcheckErrorHandler(DcheckErrorCallback that);
8665 
8666 
8670  static void SetFlagsFromString(const char* str, int length);
8671 
8675  static void SetFlagsFromCommandLine(int* argc,
8676  char** argv,
8677  bool remove_flags);
8678 
8680  static const char* GetVersion();
8681 
8686  static bool Initialize();
8687 
8692  static void SetEntropySource(EntropySource source);
8693 
8698  static void SetReturnAddressLocationResolver(
8699  ReturnAddressLocationResolver return_address_resolver);
8700 
8710  static bool Dispose();
8711 
8719  static bool InitializeICU(const char* icu_data_file = nullptr);
8720 
8733  static bool InitializeICUDefaultLocation(const char* exec_path,
8734  const char* icu_data_file = nullptr);
8735 
8752  static void InitializeExternalStartupData(const char* directory_path);
8753  static void InitializeExternalStartupData(const char* natives_blob,
8754  const char* snapshot_blob);
8759  static void InitializePlatform(Platform* platform);
8760 
8765  static void ShutdownPlatform();
8766 
8767 #if V8_OS_POSIX
8768 
8787  V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix",
8788  static bool TryHandleSignal(int signal_number, void* info,
8789  void* context));
8790 #endif // V8_OS_POSIX
8791 
8798  static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
8799 
8800  private:
8801  V8();
8802 
8803  static internal::Address* GlobalizeReference(internal::Isolate* isolate,
8804  internal::Address* handle);
8805  static internal::Address* GlobalizeTracedReference(internal::Isolate* isolate,
8806  internal::Address* handle,
8807  internal::Address* slot);
8808  static void MoveGlobalReference(internal::Address** from,
8809  internal::Address** to);
8810  static void MoveTracedGlobalReference(internal::Address** from,
8811  internal::Address** to);
8812  static internal::Address* CopyGlobalReference(internal::Address* from);
8813  static void DisposeGlobal(internal::Address* global_handle);
8814  static void DisposeTracedGlobal(internal::Address* global_handle);
8815  static void MakeWeak(internal::Address* location, void* data,
8816  WeakCallbackInfo<void>::Callback weak_callback,
8817  WeakCallbackType type);
8818  static void MakeWeak(internal::Address** location_addr);
8819  static void* ClearWeak(internal::Address* location);
8820  static void SetFinalizationCallbackTraced(
8821  internal::Address* location, void* parameter,
8823  static void AnnotateStrongRetainer(internal::Address* location,
8824  const char* label);
8825  static Value* Eternalize(Isolate* isolate, Value* handle);
8826 
8827  static void RegisterExternallyReferencedObject(internal::Address* location,
8828  internal::Isolate* isolate);
8829 
8830  template <class K, class V, class T>
8832 
8833  static void FromJustIsNothing();
8834  static void ToLocalEmpty();
8835  static void InternalFieldOutOfBounds(int index);
8836  template <class T>
8837  friend class Global;
8838  template <class T> friend class Local;
8839  template <class T>
8840  friend class MaybeLocal;
8841  template <class T>
8842  friend class Maybe;
8843  template <class T>
8844  friend class TracedGlobal;
8845  template <class T>
8846  friend class WeakCallbackInfo;
8847  template <class T> friend class Eternal;
8848  template <class T> friend class PersistentBase;
8849  template <class T, class M> friend class Persistent;
8850  friend class Context;
8851 };
8852 
8857  public:
8858  enum class FunctionCodeHandling { kClear, kKeep };
8859 
8868  SnapshotCreator(Isolate* isolate,
8869  const intptr_t* external_references = nullptr,
8870  StartupData* existing_blob = nullptr);
8871 
8880  SnapshotCreator(const intptr_t* external_references = nullptr,
8881  StartupData* existing_blob = nullptr);
8882 
8883  ~SnapshotCreator();
8884 
8888  Isolate* GetIsolate();
8889 
8897  void SetDefaultContext(Local<Context> context,
8900 
8909  size_t AddContext(Local<Context> context,
8912 
8917  size_t AddTemplate(Local<Template> template_obj);
8918 
8925  template <class T>
8926  V8_INLINE size_t AddData(Local<Context> context, Local<T> object);
8927 
8934  template <class T>
8935  V8_INLINE size_t AddData(Local<T> object);
8936 
8945  StartupData CreateBlob(FunctionCodeHandling function_code_handling);
8946 
8947  // Disallow copying and assigning.
8948  SnapshotCreator(const SnapshotCreator&) = delete;
8949  void operator=(const SnapshotCreator&) = delete;
8950 
8951  private:
8952  size_t AddData(Local<Context> context, internal::Address object);
8953  size_t AddData(internal::Address object);
8954 
8955  void* data_;
8956 };
8957 
8968 template <class T>
8969 class Maybe {
8970  public:
8971  V8_INLINE bool IsNothing() const { return !has_value_; }
8972  V8_INLINE bool IsJust() const { return has_value_; }
8973 
8977  V8_INLINE T ToChecked() const { return FromJust(); }
8978 
8983  V8_INLINE void Check() const {
8984  if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
8985  }
8986 
8991  V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const {
8992  if (V8_LIKELY(IsJust())) *out = value_;
8993  return IsJust();
8994  }
8995 
9000  V8_INLINE T FromJust() const {
9001  if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
9002  return value_;
9003  }
9004 
9009  V8_INLINE T FromMaybe(const T& default_value) const {
9010  return has_value_ ? value_ : default_value;
9011  }
9012 
9013  V8_INLINE bool operator==(const Maybe& other) const {
9014  return (IsJust() == other.IsJust()) &&
9015  (!IsJust() || FromJust() == other.FromJust());
9016  }
9017 
9018  V8_INLINE bool operator!=(const Maybe& other) const {
9019  return !operator==(other);
9020  }
9021 
9022  private:
9023  Maybe() : has_value_(false) {}
9024  explicit Maybe(const T& t) : has_value_(true), value_(t) {}
9025 
9026  bool has_value_;
9027  T value_;
9028 
9029  template <class U>
9030  friend Maybe<U> Nothing();
9031  template <class U>
9032  friend Maybe<U> Just(const U& u);
9033 };
9034 
9035 template <class T>
9036 inline Maybe<T> Nothing() {
9037  return Maybe<T>();
9038 }
9039 
9040 template <class T>
9041 inline Maybe<T> Just(const T& t) {
9042  return Maybe<T>(t);
9043 }
9044 
9045 // A template specialization of Maybe<T> for the case of T = void.
9046 template <>
9047 class Maybe<void> {
9048  public:
9049  V8_INLINE bool IsNothing() const { return !is_valid_; }
9050  V8_INLINE bool IsJust() const { return is_valid_; }
9051 
9052  V8_INLINE bool operator==(const Maybe& other) const {
9053  return IsJust() == other.IsJust();
9054  }
9055 
9056  V8_INLINE bool operator!=(const Maybe& other) const {
9057  return !operator==(other);
9058  }
9059 
9060  private:
9061  struct JustTag {};
9062 
9063  Maybe() : is_valid_(false) {}
9064  explicit Maybe(JustTag) : is_valid_(true) {}
9065 
9066  bool is_valid_;
9067 
9068  template <class U>
9069  friend Maybe<U> Nothing();
9070  friend Maybe<void> JustVoid();
9071 };
9072 
9074 
9079  public:
9085  explicit TryCatch(Isolate* isolate);
9086 
9090  ~TryCatch();
9091 
9095  bool HasCaught() const;
9096 
9105  bool CanContinue() const;
9106 
9119  bool HasTerminated() const;
9120 
9128  Local<Value> ReThrow();
9129 
9136  Local<Value> Exception() const;
9137 
9143  Local<Context> context) const;
9144 
9152  Local<v8::Message> Message() const;
9153 
9164  void Reset();
9165 
9174  void SetVerbose(bool value);
9175 
9179  bool IsVerbose() const;
9180 
9186  void SetCaptureMessage(bool value);
9187 
9199  static void* JSStackComparableAddress(TryCatch* handler) {
9200  if (handler == nullptr) return nullptr;
9201  return handler->js_stack_comparable_address_;
9202  }
9203 
9204  TryCatch(const TryCatch&) = delete;
9205  void operator=(const TryCatch&) = delete;
9206 
9207  private:
9208  // Declaring operator new and delete as deleted is not spec compliant.
9209  // Therefore declare them private instead to disable dynamic alloc
9210  void* operator new(size_t size);
9211  void* operator new[](size_t size);
9212  void operator delete(void*, size_t);
9213  void operator delete[](void*, size_t);
9214 
9215  void ResetInternal();
9216 
9217  internal::Isolate* isolate_;
9218  TryCatch* next_;
9219  void* exception_;
9220  void* message_obj_;
9221  void* js_stack_comparable_address_;
9222  bool is_verbose_ : 1;
9223  bool can_continue_ : 1;
9224  bool capture_message_ : 1;
9225  bool rethrow_ : 1;
9226  bool has_terminated_ : 1;
9227 
9228  friend class internal::Isolate;
9229 };
9230 
9231 
9232 // --- Context ---
9233 
9234 
9239  public:
9240  ExtensionConfiguration() : name_count_(0), names_(nullptr) {}
9241  ExtensionConfiguration(int name_count, const char* names[])
9242  : name_count_(name_count), names_(names) { }
9243 
9244  const char** begin() const { return &names_[0]; }
9245  const char** end() const { return &names_[name_count_]; }
9246 
9247  private:
9248  const int name_count_;
9249  const char** names_;
9250 };
9251 
9257  public:
9271 
9276  void DetachGlobal();
9277 
9296  static Local<Context> New(
9297  Isolate* isolate, ExtensionConfiguration* extensions = nullptr,
9299  MaybeLocal<Value> global_object = MaybeLocal<Value>(),
9300  DeserializeInternalFieldsCallback internal_fields_deserializer =
9302  MicrotaskQueue* microtask_queue = nullptr);
9303 
9322  static MaybeLocal<Context> FromSnapshot(
9323  Isolate* isolate, size_t context_snapshot_index,
9324  DeserializeInternalFieldsCallback embedder_fields_deserializer =
9326  ExtensionConfiguration* extensions = nullptr,
9327  MaybeLocal<Value> global_object = MaybeLocal<Value>(),
9328  MicrotaskQueue* microtask_queue = nullptr);
9329 
9347  static MaybeLocal<Object> NewRemoteContext(
9348  Isolate* isolate, Local<ObjectTemplate> global_template,
9349  MaybeLocal<Value> global_object = MaybeLocal<Value>());
9350 
9355  void SetSecurityToken(Local<Value> token);
9356 
9358  void UseDefaultSecurityToken();
9359 
9361  Local<Value> GetSecurityToken();
9362 
9369  void Enter();
9370 
9375  void Exit();
9376 
9378  Isolate* GetIsolate();
9379 
9384  enum EmbedderDataFields { kDebugIdIndex = 0 };
9385 
9389  uint32_t GetNumberOfEmbedderDataFields();
9390 
9395  V8_INLINE Local<Value> GetEmbedderData(int index);
9396 
9403  Local<Object> GetExtrasBindingObject();
9404 
9410  void SetEmbedderData(int index, Local<Value> value);
9411 
9418  V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
9419 
9425  void SetAlignedPointerInEmbedderData(int index, void* value);
9426 
9440  void AllowCodeGenerationFromStrings(bool allow);
9441 
9446  bool IsCodeGenerationFromStringsAllowed();
9447 
9453  void SetErrorMessageForCodeGenerationFromStrings(Local<String> message);
9454 
9460  template <class T>
9461  V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
9462 
9467  class Scope {
9468  public:
9469  explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
9470  context_->Enter();
9471  }
9472  V8_INLINE ~Scope() { context_->Exit(); }
9473 
9474  private:
9475  Local<Context> context_;
9476  };
9477 
9484  public:
9489  explicit BackupIncumbentScope(Local<Context> backup_incumbent_context);
9491 
9497  uintptr_t JSStackComparableAddress() const {
9498  return js_stack_comparable_address_;
9499  }
9500 
9501  private:
9502  friend class internal::Isolate;
9503 
9504  Local<Context> backup_incumbent_context_;
9505  uintptr_t js_stack_comparable_address_ = 0;
9506  const BackupIncumbentScope* prev_ = nullptr;
9507  };
9508 
9509  private:
9510  friend class Value;
9511  friend class Script;
9512  friend class Object;
9513  friend class Function;
9514 
9515  internal::Address* GetDataFromSnapshotOnce(size_t index);
9516  Local<Value> SlowGetEmbedderData(int index);
9517  void* SlowGetAlignedPointerFromEmbedderData(int index);
9518 };
9519 
9520 
9598  public:
9602  V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
9603 
9604  ~Unlocker();
9605  private:
9606  void Initialize(Isolate* isolate);
9607 
9608  internal::Isolate* isolate_;
9609 };
9610 
9611 
9613  public:
9617  V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
9618 
9619  ~Locker();
9620 
9625  static bool IsLocked(Isolate* isolate);
9626 
9630  static bool IsActive();
9631 
9632  // Disallow copying and assigning.
9633  Locker(const Locker&) = delete;
9634  void operator=(const Locker&) = delete;
9635 
9636  private:
9637  void Initialize(Isolate* isolate);
9638 
9639  bool has_lock_;
9640  bool top_level_;
9641  internal::Isolate* isolate_;
9642 };
9643 
9650  public:
9679  static bool TryUnwindV8Frames(const UnwindState& unwind_state,
9680  RegisterState* register_state,
9681  const void* stack_base);
9682 
9691  static bool PCIsInV8(const UnwindState& unwind_state, void* pc);
9692 };
9693 
9694 // --- Implementation ---
9695 
9696 template <class T>
9698  return New(isolate, that.val_);
9699 }
9700 
9701 template <class T>
9703  return New(isolate, that.val_);
9704 }
9705 
9706 template <class T>
9708  return New(isolate, that.val_);
9709 }
9710 
9711 template <class T>
9712 Local<T> Local<T>::New(Isolate* isolate, T* that) {
9713  if (that == nullptr) return Local<T>();
9714  T* that_ptr = that;
9715  internal::Address* p = reinterpret_cast<internal::Address*>(that_ptr);
9716  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
9717  reinterpret_cast<internal::Isolate*>(isolate), *p)));
9718 }
9719 
9720 
9721 template<class T>
9722 template<class S>
9723 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
9724  TYPE_CHECK(T, S);
9725  val_ = reinterpret_cast<T*>(
9726  V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle)));
9727 }
9728 
9729 template <class T>
9731  // The eternal handle will never go away, so as with the roots, we don't even
9732  // need to open a handle.
9733  return Local<T>(val_);
9734 }
9735 
9736 
9737 template <class T>
9739  if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
9740  return Local<T>(val_);
9741 }
9742 
9743 
9744 template <class T>
9746 #ifdef V8_ENABLE_CHECKS
9747  if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
9748  V8::InternalFieldOutOfBounds(index);
9749  }
9750 #endif
9751  return embedder_fields_[index];
9752 }
9753 
9754 
9755 template <class T>
9756 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
9757  if (that == nullptr) return nullptr;
9758  internal::Address* p = reinterpret_cast<internal::Address*>(that);
9759  return reinterpret_cast<T*>(
9760  V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
9761  p));
9762 }
9763 
9764 
9765 template <class T, class M>
9766 template <class S, class M2>
9768  TYPE_CHECK(T, S);
9769  this->Reset();
9770  if (that.IsEmpty()) return;
9771  internal::Address* p = reinterpret_cast<internal::Address*>(that.val_);
9772  this->val_ = reinterpret_cast<T*>(V8::CopyGlobalReference(p));
9773  M::Copy(that, this);
9774 }
9775 
9776 template <class T>
9777 bool PersistentBase<T>::IsIndependent() const {
9778  typedef internal::Internals I;
9779  if (this->IsEmpty()) return false;
9780  return I::GetNodeFlag(reinterpret_cast<internal::Address*>(this->val_),
9781  I::kNodeIsIndependentShift);
9782 }
9783 
9784 template <class T>
9785 bool PersistentBase<T>::IsNearDeath() const {
9786  typedef internal::Internals I;
9787  if (this->IsEmpty()) return false;
9788  uint8_t node_state =
9789  I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_));
9790  return node_state == I::kNodeStateIsNearDeathValue ||
9791  node_state == I::kNodeStateIsPendingValue;
9792 }
9793 
9794 
9795 template <class T>
9797  typedef internal::Internals I;
9798  if (this->IsEmpty()) return false;
9799  return I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)) ==
9800  I::kNodeStateIsWeakValue;
9801 }
9802 
9803 
9804 template <class T>
9806  if (this->IsEmpty()) return;
9807  V8::DisposeGlobal(reinterpret_cast<internal::Address*>(this->val_));
9808  val_ = nullptr;
9809 }
9810 
9811 
9812 template <class T>
9813 template <class S>
9814 void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) {
9815  TYPE_CHECK(T, S);
9816  Reset();
9817  if (other.IsEmpty()) return;
9818  this->val_ = New(isolate, other.val_);
9819 }
9820 
9821 
9822 template <class T>
9823 template <class S>
9825  const PersistentBase<S>& other) {
9826  TYPE_CHECK(T, S);
9827  Reset();
9828  if (other.IsEmpty()) return;
9829  this->val_ = New(isolate, other.val_);
9830 }
9831 
9832 
9833 template <class T>
9834 template <typename P>
9836  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
9837  WeakCallbackType type) {
9838  typedef typename WeakCallbackInfo<void>::Callback Callback;
9839  V8::MakeWeak(reinterpret_cast<internal::Address*>(this->val_), parameter,
9840  reinterpret_cast<Callback>(callback), type);
9841 }
9842 
9843 template <class T>
9845  V8::MakeWeak(reinterpret_cast<internal::Address**>(&this->val_));
9846 }
9847 
9848 template <class T>
9849 template <typename P>
9851  return reinterpret_cast<P*>(
9852  V8::ClearWeak(reinterpret_cast<internal::Address*>(this->val_)));
9853 }
9854 
9855 template <class T>
9857  V8::AnnotateStrongRetainer(reinterpret_cast<internal::Address*>(this->val_),
9858  label);
9859 }
9860 
9861 template <class T>
9863  if (IsEmpty()) return;
9864  V8::RegisterExternallyReferencedObject(
9865  reinterpret_cast<internal::Address*>(this->val_),
9866  reinterpret_cast<internal::Isolate*>(isolate));
9867 }
9868 
9869 template <class T>
9870 void PersistentBase<T>::MarkIndependent() {
9871  typedef internal::Internals I;
9872  if (this->IsEmpty()) return;
9873  I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
9874  I::kNodeIsIndependentShift);
9875 }
9876 
9877 template <class T>
9878 void PersistentBase<T>::MarkActive() {
9879  typedef internal::Internals I;
9880  if (this->IsEmpty()) return;
9881  I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
9882  I::kNodeIsActiveShift);
9883 }
9884 
9885 
9886 template <class T>
9887 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
9888  typedef internal::Internals I;
9889  if (this->IsEmpty()) return;
9890  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
9891  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9892  *reinterpret_cast<uint16_t*>(addr) = class_id;
9893 }
9894 
9895 
9896 template <class T>
9898  typedef internal::Internals I;
9899  if (this->IsEmpty()) return 0;
9900  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
9901  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9902  return *reinterpret_cast<uint16_t*>(addr);
9903 }
9904 
9905 template <class T>
9906 Global<T>::Global(Global&& other) : PersistentBase<T>(other.val_) {
9907  if (other.val_ != nullptr) {
9908  V8::MoveGlobalReference(reinterpret_cast<internal::Address**>(&other.val_),
9909  reinterpret_cast<internal::Address**>(&this->val_));
9910  other.val_ = nullptr;
9911  }
9912 }
9913 
9914 template <class T>
9915 template <class S>
9917  TYPE_CHECK(T, S);
9918  if (this != &rhs) {
9919  this->Reset();
9920  if (rhs.val_ != nullptr) {
9921  this->val_ = rhs.val_;
9922  V8::MoveGlobalReference(
9923  reinterpret_cast<internal::Address**>(&rhs.val_),
9924  reinterpret_cast<internal::Address**>(&this->val_));
9925  rhs.val_ = nullptr;
9926  }
9927  }
9928  return *this;
9929 }
9930 
9931 template <class T>
9932 T* TracedGlobal<T>::New(Isolate* isolate, T* that, T** slot) {
9933  if (that == nullptr) return nullptr;
9934  internal::Address* p = reinterpret_cast<internal::Address*>(that);
9935  return reinterpret_cast<T*>(V8::GlobalizeTracedReference(
9936  reinterpret_cast<internal::Isolate*>(isolate), p,
9937  reinterpret_cast<internal::Address*>(slot)));
9938 }
9939 
9940 template <class T>
9942  if (IsEmpty()) return;
9943  V8::DisposeTracedGlobal(reinterpret_cast<internal::Address*>(val_));
9944  val_ = nullptr;
9945 }
9946 
9947 template <class T>
9948 template <class S>
9949 void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
9950  TYPE_CHECK(T, S);
9951  Reset();
9952  if (other.IsEmpty()) return;
9953  this->val_ = New(isolate, other.val_, &val_);
9954 }
9955 
9956 template <class T>
9957 TracedGlobal<T>::TracedGlobal(TracedGlobal&& other) : val_(other.val_) {
9958  if (other.val_ != nullptr) {
9959  V8::MoveTracedGlobalReference(
9960  reinterpret_cast<internal::Address**>(&other.val_),
9961  reinterpret_cast<internal::Address**>(&this->val_));
9962  other.val_ = nullptr;
9963  }
9964 }
9965 
9966 template <class T>
9967 template <class S>
9969  TYPE_CHECK(T, S);
9970  if (this != &rhs) {
9971  this->Reset();
9972  if (rhs.val_ != nullptr) {
9973  this->val_ = rhs.val_;
9974  V8::MoveTracedGlobalReference(
9975  reinterpret_cast<internal::Address**>(&rhs.val_),
9976  reinterpret_cast<internal::Address**>(&this->val_));
9977  rhs.val_ = nullptr;
9978  }
9979  }
9980  return *this;
9981 }
9982 
9983 template <class T>
9984 void TracedGlobal<T>::SetWrapperClassId(uint16_t class_id) {
9985  typedef internal::Internals I;
9986  if (IsEmpty()) return;
9987  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
9988  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9989  *reinterpret_cast<uint16_t*>(addr) = class_id;
9990 }
9991 
9992 template <class T>
9994  typedef internal::Internals I;
9995  if (IsEmpty()) return 0;
9996  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
9997  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9998  return *reinterpret_cast<uint16_t*>(addr);
9999 }
10000 
10001 template <class T>
10003  void* parameter, typename WeakCallbackInfo<void>::Callback callback) {
10004  V8::SetFinalizationCallbackTraced(
10005  reinterpret_cast<internal::Address*>(this->val_), parameter, callback);
10006 }
10007 
10008 template <typename T>
10009 ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
10010 
10011 template<typename T>
10012 template<typename S>
10013 void ReturnValue<T>::Set(const Persistent<S>& handle) {
10014  TYPE_CHECK(T, S);
10015  if (V8_UNLIKELY(handle.IsEmpty())) {
10016  *value_ = GetDefaultValue();
10017  } else {
10018  *value_ = *reinterpret_cast<internal::Address*>(*handle);
10019  }
10020 }
10021 
10022 template <typename T>
10023 template <typename S>
10024 void ReturnValue<T>::Set(const Global<S>& handle) {
10025  TYPE_CHECK(T, S);
10026  if (V8_UNLIKELY(handle.IsEmpty())) {
10027  *value_ = GetDefaultValue();
10028  } else {
10029  *value_ = *reinterpret_cast<internal::Address*>(*handle);
10030  }
10031 }
10032 
10033 template <typename T>
10034 template <typename S>
10036  TYPE_CHECK(T, S);
10037  if (V8_UNLIKELY(handle.IsEmpty())) {
10038  *value_ = GetDefaultValue();
10039  } else {
10040  *value_ = *reinterpret_cast<internal::Address*>(*handle);
10041  }
10042 }
10043 
10044 template <typename T>
10045 template <typename S>
10046 void ReturnValue<T>::Set(const Local<S> handle) {
10047  TYPE_CHECK(T, S);
10048  if (V8_UNLIKELY(handle.IsEmpty())) {
10049  *value_ = GetDefaultValue();
10050  } else {
10051  *value_ = *reinterpret_cast<internal::Address*>(*handle);
10052  }
10053 }
10054 
10055 template<typename T>
10056 void ReturnValue<T>::Set(double i) {
10057  TYPE_CHECK(T, Number);
10058  Set(Number::New(GetIsolate(), i));
10059 }
10060 
10061 template<typename T>
10062 void ReturnValue<T>::Set(int32_t i) {
10063  TYPE_CHECK(T, Integer);
10064  typedef internal::Internals I;
10065  if (V8_LIKELY(I::IsValidSmi(i))) {
10066  *value_ = I::IntToSmi(i);
10067  return;
10068  }
10069  Set(Integer::New(GetIsolate(), i));
10070 }
10071 
10072 template<typename T>
10073 void ReturnValue<T>::Set(uint32_t i) {
10074  TYPE_CHECK(T, Integer);
10075  // Can't simply use INT32_MAX here for whatever reason.
10076  bool fits_into_int32_t = (i & (1U << 31)) == 0;
10077  if (V8_LIKELY(fits_into_int32_t)) {
10078  Set(static_cast<int32_t>(i));
10079  return;
10080  }
10081  Set(Integer::NewFromUnsigned(GetIsolate(), i));
10082 }
10083 
10084 template<typename T>
10085 void ReturnValue<T>::Set(bool value) {
10086  TYPE_CHECK(T, Boolean);
10087  typedef internal::Internals I;
10088  int root_index;
10089  if (value) {
10090  root_index = I::kTrueValueRootIndex;
10091  } else {
10092  root_index = I::kFalseValueRootIndex;
10093  }
10094  *value_ = *I::GetRoot(GetIsolate(), root_index);
10095 }
10096 
10097 template<typename T>
10099  TYPE_CHECK(T, Primitive);
10100  typedef internal::Internals I;
10101  *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
10102 }
10103 
10104 template<typename T>
10106  TYPE_CHECK(T, Primitive);
10107  typedef internal::Internals I;
10108  *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
10109 }
10110 
10111 template<typename T>
10113  TYPE_CHECK(T, String);
10114  typedef internal::Internals I;
10115  *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
10116 }
10117 
10118 template <typename T>
10120  // Isolate is always the pointer below the default value on the stack.
10121  return *reinterpret_cast<Isolate**>(&value_[-2]);
10122 }
10123 
10124 template <typename T>
10126  typedef internal::Internals I;
10127  if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
10128  return Local<Value>(*Undefined(GetIsolate()));
10129  return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
10130 }
10131 
10132 template <typename T>
10133 template <typename S>
10134 void ReturnValue<T>::Set(S* whatever) {
10135  // Uncompilable to prevent inadvertent misuse.
10136  TYPE_CHECK(S*, Primitive);
10137 }
10138 
10139 template <typename T>
10141  // Default value is always the pointer below value_ on the stack.
10142  return value_[-1];
10143 }
10144 
10145 template <typename T>
10147  internal::Address* values,
10148  int length)
10149  : implicit_args_(implicit_args), values_(values), length_(length) {}
10150 
10151 template<typename T>
10153  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
10154  return Local<Value>(reinterpret_cast<Value*>(values_ - i));
10155 }
10156 
10157 
10158 template<typename T>
10160  return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
10161 }
10162 
10163 
10164 template<typename T>
10166  return Local<Object>(reinterpret_cast<Object*>(
10167  &implicit_args_[kHolderIndex]));
10168 }
10169 
10170 template <typename T>
10172  return Local<Value>(
10173  reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
10174 }
10175 
10176 template <typename T>
10178  return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
10179 }
10180 
10181 
10182 template<typename T>
10184  return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
10185 }
10186 
10187 
10188 template<typename T>
10190  return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
10191 }
10192 
10193 
10194 template<typename T>
10196  return !NewTarget()->IsUndefined();
10197 }
10198 
10199 
10200 template<typename T>
10202  return length_;
10203 }
10204 
10206  Local<Integer> resource_line_offset,
10207  Local<Integer> resource_column_offset,
10208  Local<Boolean> resource_is_shared_cross_origin,
10209  Local<Integer> script_id,
10210  Local<Value> source_map_url,
10211  Local<Boolean> resource_is_opaque,
10212  Local<Boolean> is_wasm, Local<Boolean> is_module,
10213  Local<PrimitiveArray> host_defined_options)
10214  : resource_name_(resource_name),
10215  resource_line_offset_(resource_line_offset),
10216  resource_column_offset_(resource_column_offset),
10217  options_(!resource_is_shared_cross_origin.IsEmpty() &&
10218  resource_is_shared_cross_origin->IsTrue(),
10219  !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
10220  !is_wasm.IsEmpty() && is_wasm->IsTrue(),
10221  !is_module.IsEmpty() && is_module->IsTrue()),
10222  script_id_(script_id),
10223  source_map_url_(source_map_url),
10224  host_defined_options_(host_defined_options) {}
10225 
10226 Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
10227 
10229  return host_defined_options_;
10230 }
10231 
10233  return resource_line_offset_;
10234 }
10235 
10236 
10238  return resource_column_offset_;
10239 }
10240 
10241 
10242 Local<Integer> ScriptOrigin::ScriptID() const { return script_id_; }
10243 
10244 
10245 Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
10246 
10248  CachedData* data)
10249  : source_string(string),
10250  resource_name(origin.ResourceName()),
10251  resource_line_offset(origin.ResourceLineOffset()),
10252  resource_column_offset(origin.ResourceColumnOffset()),
10253  resource_options(origin.Options()),
10254  source_map_url(origin.SourceMapUrl()),
10255  host_defined_options(origin.HostDefinedOptions()),
10256  cached_data(data) {}
10257 
10259  CachedData* data)
10260  : source_string(string), cached_data(data) {}
10261 
10262 
10264  delete cached_data;
10265 }
10266 
10267 
10269  const {
10270  return cached_data;
10271 }
10272 
10274  return resource_options;
10275 }
10276 
10277 Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
10278  return value ? True(isolate) : False(isolate);
10279 }
10280 
10281 void Template::Set(Isolate* isolate, const char* name, Local<Data> value) {
10283  .ToLocalChecked(),
10284  value);
10285 }
10286 
10288 #ifdef V8_ENABLE_CHECKS
10289  CheckCast(data);
10290 #endif
10291  return reinterpret_cast<FunctionTemplate*>(data);
10292 }
10293 
10295 #ifdef V8_ENABLE_CHECKS
10296  CheckCast(data);
10297 #endif
10298  return reinterpret_cast<ObjectTemplate*>(data);
10299 }
10300 
10302 #ifdef V8_ENABLE_CHECKS
10303  CheckCast(data);
10304 #endif
10305  return reinterpret_cast<Signature*>(data);
10306 }
10307 
10309 #ifdef V8_ENABLE_CHECKS
10310  CheckCast(data);
10311 #endif
10312  return reinterpret_cast<AccessorSignature*>(data);
10313 }
10314 
10316 #if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
10317  typedef internal::Address A;
10318  typedef internal::Internals I;
10319  A obj = *reinterpret_cast<A*>(this);
10320  // Fast path: If the object is a plain JSObject, which is the common case, we
10321  // know where to find the internal fields and can return the value directly.
10322  auto instance_type = I::GetInstanceType(obj);
10323  if (instance_type == I::kJSObjectType ||
10324  instance_type == I::kJSApiObjectType ||
10325  instance_type == I::kJSSpecialApiObjectType) {
10326  int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
10327  A value = I::ReadTaggedAnyField(obj, offset);
10328  internal::Isolate* isolate =
10330  A* result = HandleScope::CreateHandle(isolate, value);
10331  return Local<Value>(reinterpret_cast<Value*>(result));
10332  }
10333 #endif
10334  return SlowGetInternalField(index);
10335 }
10336 
10337 
10339 #if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
10340  typedef internal::Address A;
10341  typedef internal::Internals I;
10342  A obj = *reinterpret_cast<A*>(this);
10343  // Fast path: If the object is a plain JSObject, which is the common case, we
10344  // know where to find the internal fields and can return the value directly.
10345  auto instance_type = I::GetInstanceType(obj);
10346  if (V8_LIKELY(instance_type == I::kJSObjectType ||
10347  instance_type == I::kJSApiObjectType ||
10348  instance_type == I::kJSSpecialApiObjectType)) {
10349  int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
10350  return I::ReadRawField<void*>(obj, offset);
10351  }
10352 #endif
10353  return SlowGetAlignedPointerFromInternalField(index);
10354 }
10355 
10357 #ifdef V8_ENABLE_CHECKS
10358  CheckCast(value);
10359 #endif
10360  return static_cast<String*>(value);
10361 }
10362 
10363 
10365  typedef internal::Address S;
10366  typedef internal::Internals I;
10367  I::CheckInitialized(isolate);
10368  S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
10369  return Local<String>(reinterpret_cast<String*>(slot));
10370 }
10371 
10372 
10374  typedef internal::Address A;
10375  typedef internal::Internals I;
10376  A obj = *reinterpret_cast<const A*>(this);
10377 
10378  ExternalStringResource* result;
10379  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
10380  void* value = I::ReadRawField<void*>(obj, I::kStringResourceOffset);
10381  result = reinterpret_cast<String::ExternalStringResource*>(value);
10382  } else {
10383  result = GetExternalStringResourceSlow();
10384  }
10385 #ifdef V8_ENABLE_CHECKS
10386  VerifyExternalStringResource(result);
10387 #endif
10388  return result;
10389 }
10390 
10391 
10393  String::Encoding* encoding_out) const {
10394  typedef internal::Address A;
10395  typedef internal::Internals I;
10396  A obj = *reinterpret_cast<const A*>(this);
10397  int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
10398  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
10399  ExternalStringResourceBase* resource;
10400  if (type == I::kExternalOneByteRepresentationTag ||
10401  type == I::kExternalTwoByteRepresentationTag) {
10402  void* value = I::ReadRawField<void*>(obj, I::kStringResourceOffset);
10403  resource = static_cast<ExternalStringResourceBase*>(value);
10404  } else {
10405  resource = GetExternalStringResourceBaseSlow(encoding_out);
10406  }
10407 #ifdef V8_ENABLE_CHECKS
10408  VerifyExternalStringResourceBase(resource, *encoding_out);
10409 #endif
10410  return resource;
10411 }
10412 
10413 
10414 bool Value::IsUndefined() const {
10415 #ifdef V8_ENABLE_CHECKS
10416  return FullIsUndefined();
10417 #else
10418  return QuickIsUndefined();
10419 #endif
10420 }
10421 
10422 bool Value::QuickIsUndefined() const {
10423  typedef internal::Address A;
10424  typedef internal::Internals I;
10425  A obj = *reinterpret_cast<const A*>(this);
10426  if (!I::HasHeapObjectTag(obj)) return false;
10427  if (I::GetInstanceType(obj) != I::kOddballType) return false;
10428  return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
10429 }
10430 
10431 
10432 bool Value::IsNull() const {
10433 #ifdef V8_ENABLE_CHECKS
10434  return FullIsNull();
10435 #else
10436  return QuickIsNull();
10437 #endif
10438 }
10439 
10440 bool Value::QuickIsNull() const {
10441  typedef internal::Address A;
10442  typedef internal::Internals I;
10443  A obj = *reinterpret_cast<const A*>(this);
10444  if (!I::HasHeapObjectTag(obj)) return false;
10445  if (I::GetInstanceType(obj) != I::kOddballType) return false;
10446  return (I::GetOddballKind(obj) == I::kNullOddballKind);
10447 }
10448 
10450 #ifdef V8_ENABLE_CHECKS
10451  return FullIsNull() || FullIsUndefined();
10452 #else
10453  return QuickIsNullOrUndefined();
10454 #endif
10455 }
10456 
10457 bool Value::QuickIsNullOrUndefined() const {
10458  typedef internal::Address A;
10459  typedef internal::Internals I;
10460  A obj = *reinterpret_cast<const A*>(this);
10461  if (!I::HasHeapObjectTag(obj)) return false;
10462  if (I::GetInstanceType(obj) != I::kOddballType) return false;
10463  int kind = I::GetOddballKind(obj);
10464  return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind;
10465 }
10466 
10467 bool Value::IsString() const {
10468 #ifdef V8_ENABLE_CHECKS
10469  return FullIsString();
10470 #else
10471  return QuickIsString();
10472 #endif
10473 }
10474 
10475 bool Value::QuickIsString() const {
10476  typedef internal::Address A;
10477  typedef internal::Internals I;
10478  A obj = *reinterpret_cast<const A*>(this);
10479  if (!I::HasHeapObjectTag(obj)) return false;
10480  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
10481 }
10482 
10483 
10484 template <class T> Value* Value::Cast(T* value) {
10485  return static_cast<Value*>(value);
10486 }
10487 
10488 
10490 #ifdef V8_ENABLE_CHECKS
10491  CheckCast(value);
10492 #endif
10493  return static_cast<Boolean*>(value);
10494 }
10495 
10496 
10498 #ifdef V8_ENABLE_CHECKS
10499  CheckCast(value);
10500 #endif
10501  return static_cast<Name*>(value);
10502 }
10503 
10504 
10506 #ifdef V8_ENABLE_CHECKS
10507  CheckCast(value);
10508 #endif
10509  return static_cast<Symbol*>(value);
10510 }
10511 
10512 
10514 #ifdef V8_ENABLE_CHECKS
10515  CheckCast(data);
10516 #endif
10517  return reinterpret_cast<Private*>(data);
10518 }
10519 
10520 
10522 #ifdef V8_ENABLE_CHECKS
10523  CheckCast(value);
10524 #endif
10525  return static_cast<Number*>(value);
10526 }
10527 
10528 
10530 #ifdef V8_ENABLE_CHECKS
10531  CheckCast(value);
10532 #endif
10533  return static_cast<Integer*>(value);
10534 }
10535 
10536 
10538 #ifdef V8_ENABLE_CHECKS
10539  CheckCast(value);
10540 #endif
10541  return static_cast<Int32*>(value);
10542 }
10543 
10544 
10546 #ifdef V8_ENABLE_CHECKS
10547  CheckCast(value);
10548 #endif
10549  return static_cast<Uint32*>(value);
10550 }
10551 
10553 #ifdef V8_ENABLE_CHECKS
10554  CheckCast(value);
10555 #endif
10556  return static_cast<BigInt*>(value);
10557 }
10558 
10560 #ifdef V8_ENABLE_CHECKS
10561  CheckCast(value);
10562 #endif
10563  return static_cast<Date*>(value);
10564 }
10565 
10566 
10568 #ifdef V8_ENABLE_CHECKS
10569  CheckCast(value);
10570 #endif
10571  return static_cast<StringObject*>(value);
10572 }
10573 
10574 
10576 #ifdef V8_ENABLE_CHECKS
10577  CheckCast(value);
10578 #endif
10579  return static_cast<SymbolObject*>(value);
10580 }
10581 
10582 
10584 #ifdef V8_ENABLE_CHECKS
10585  CheckCast(value);
10586 #endif
10587  return static_cast<NumberObject*>(value);
10588 }
10589 
10591 #ifdef V8_ENABLE_CHECKS
10592  CheckCast(value);
10593 #endif
10594  return static_cast<BigIntObject*>(value);
10595 }
10596 
10598 #ifdef V8_ENABLE_CHECKS
10599  CheckCast(value);
10600 #endif
10601  return static_cast<BooleanObject*>(value);
10602 }
10603 
10604 
10606 #ifdef V8_ENABLE_CHECKS
10607  CheckCast(value);
10608 #endif
10609  return static_cast<RegExp*>(value);
10610 }
10611 
10612 
10614 #ifdef V8_ENABLE_CHECKS
10615  CheckCast(value);
10616 #endif
10617  return static_cast<Object*>(value);
10618 }
10619 
10620 
10622 #ifdef V8_ENABLE_CHECKS
10623  CheckCast(value);
10624 #endif
10625  return static_cast<Array*>(value);
10626 }
10627 
10628 
10630 #ifdef V8_ENABLE_CHECKS
10631  CheckCast(value);
10632 #endif
10633  return static_cast<Map*>(value);
10634 }
10635 
10636 
10638 #ifdef V8_ENABLE_CHECKS
10639  CheckCast(value);
10640 #endif
10641  return static_cast<Set*>(value);
10642 }
10643 
10644 
10646 #ifdef V8_ENABLE_CHECKS
10647  CheckCast(value);
10648 #endif
10649  return static_cast<Promise*>(value);
10650 }
10651 
10652 
10654 #ifdef V8_ENABLE_CHECKS
10655  CheckCast(value);
10656 #endif
10657  return static_cast<Proxy*>(value);
10658 }
10659 
10661 #ifdef V8_ENABLE_CHECKS
10662  CheckCast(value);
10663 #endif
10664  return static_cast<WasmModuleObject*>(value);
10665 }
10666 
10668 #ifdef V8_ENABLE_CHECKS
10669  CheckCast(value);
10670 #endif
10671  return static_cast<Promise::Resolver*>(value);
10672 }
10673 
10674 
10676 #ifdef V8_ENABLE_CHECKS
10677  CheckCast(value);
10678 #endif
10679  return static_cast<ArrayBuffer*>(value);
10680 }
10681 
10682 
10684 #ifdef V8_ENABLE_CHECKS
10685  CheckCast(value);
10686 #endif
10687  return static_cast<ArrayBufferView*>(value);
10688 }
10689 
10690 
10692 #ifdef V8_ENABLE_CHECKS
10693  CheckCast(value);
10694 #endif
10695  return static_cast<TypedArray*>(value);
10696 }
10697 
10698 
10700 #ifdef V8_ENABLE_CHECKS
10701  CheckCast(value);
10702 #endif
10703  return static_cast<Uint8Array*>(value);
10704 }
10705 
10706 
10708 #ifdef V8_ENABLE_CHECKS
10709  CheckCast(value);
10710 #endif
10711  return static_cast<Int8Array*>(value);
10712 }
10713 
10714 
10716 #ifdef V8_ENABLE_CHECKS
10717  CheckCast(value);
10718 #endif
10719  return static_cast<Uint16Array*>(value);
10720 }
10721 
10722 
10724 #ifdef V8_ENABLE_CHECKS
10725  CheckCast(value);
10726 #endif
10727  return static_cast<Int16Array*>(value);
10728 }
10729 
10730 
10732 #ifdef V8_ENABLE_CHECKS
10733  CheckCast(value);
10734 #endif
10735  return static_cast<Uint32Array*>(value);
10736 }
10737 
10738 
10740 #ifdef V8_ENABLE_CHECKS
10741  CheckCast(value);
10742 #endif
10743  return static_cast<Int32Array*>(value);
10744 }
10745 
10746 
10748 #ifdef V8_ENABLE_CHECKS
10749  CheckCast(value);
10750 #endif
10751  return static_cast<Float32Array*>(value);
10752 }
10753 
10754 
10756 #ifdef V8_ENABLE_CHECKS
10757  CheckCast(value);
10758 #endif
10759  return static_cast<Float64Array*>(value);
10760 }
10761 
10763 #ifdef V8_ENABLE_CHECKS
10764  CheckCast(value);
10765 #endif
10766  return static_cast<BigInt64Array*>(value);
10767 }
10768 
10770 #ifdef V8_ENABLE_CHECKS
10771  CheckCast(value);
10772 #endif
10773  return static_cast<BigUint64Array*>(value);
10774 }
10775 
10777 #ifdef V8_ENABLE_CHECKS
10778  CheckCast(value);
10779 #endif
10780  return static_cast<Uint8ClampedArray*>(value);
10781 }
10782 
10783 
10785 #ifdef V8_ENABLE_CHECKS
10786  CheckCast(value);
10787 #endif
10788  return static_cast<DataView*>(value);
10789 }
10790 
10791 
10793 #ifdef V8_ENABLE_CHECKS
10794  CheckCast(value);
10795 #endif
10796  return static_cast<SharedArrayBuffer*>(value);
10797 }
10798 
10799 
10801 #ifdef V8_ENABLE_CHECKS
10802  CheckCast(value);
10803 #endif
10804  return static_cast<Function*>(value);
10805 }
10806 
10807 
10809 #ifdef V8_ENABLE_CHECKS
10810  CheckCast(value);
10811 #endif
10812  return static_cast<External*>(value);
10813 }
10814 
10815 
10816 template<typename T>
10818  return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
10819 }
10820 
10821 
10822 template<typename T>
10824  return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
10825 }
10826 
10827 
10828 template<typename T>
10830  return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
10831 }
10832 
10833 
10834 template<typename T>
10836  return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
10837 }
10838 
10839 
10840 template<typename T>
10842  return ReturnValue<T>(&args_[kReturnValueIndex]);
10843 }
10844 
10845 template <typename T>
10847  typedef internal::Internals I;
10848  if (args_[kShouldThrowOnErrorIndex] !=
10849  I::IntToSmi(I::kInferShouldThrowMode)) {
10850  return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
10851  }
10853  reinterpret_cast<v8::internal::Isolate*>(GetIsolate()));
10854 }
10855 
10857  typedef internal::Address S;
10858  typedef internal::Internals I;
10859  I::CheckInitialized(isolate);
10860  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
10861  return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
10862 }
10863 
10864 
10866  typedef internal::Address S;
10867  typedef internal::Internals I;
10868  I::CheckInitialized(isolate);
10869  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
10870  return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
10871 }
10872 
10873 
10875  typedef internal::Address S;
10876  typedef internal::Internals I;
10877  I::CheckInitialized(isolate);
10878  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
10879  return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
10880 }
10881 
10882 
10884  typedef internal::Address S;
10885  typedef internal::Internals I;
10886  I::CheckInitialized(isolate);
10887  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
10888  return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
10889 }
10890 
10891 
10892 void Isolate::SetData(uint32_t slot, void* data) {
10893  typedef internal::Internals I;
10894  I::SetEmbedderData(this, slot, data);
10895 }
10896 
10897 
10898 void* Isolate::GetData(uint32_t slot) {
10899  typedef internal::Internals I;
10900  return I::GetEmbedderData(this, slot);
10901 }
10902 
10903 
10905  typedef internal::Internals I;
10906  return I::kNumIsolateDataSlots;
10907 }
10908 
10909 template <class T>
10911  T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
10912  if (data) internal::PerformCastCheck(data);
10913  return Local<T>(data);
10914 }
10915 
10917  int64_t change_in_bytes) {
10918  typedef internal::Internals I;
10919  constexpr int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
10920  int64_t* external_memory = reinterpret_cast<int64_t*>(
10921  reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
10922  int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
10923  reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
10924  int64_t* external_memory_at_last_mc =
10925  reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
10926  I::kExternalMemoryAtLastMarkCompactOffset);
10927 
10928  const int64_t amount = *external_memory + change_in_bytes;
10929  *external_memory = amount;
10930 
10931  int64_t allocation_diff_since_last_mc =
10932  *external_memory - *external_memory_at_last_mc;
10933  // Only check memory pressure and potentially trigger GC if the amount of
10934  // external memory increased.
10935  if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
10936  CheckMemoryPressure();
10937  }
10938 
10939  if (change_in_bytes < 0) {
10940  const int64_t lower_limit = *external_memory_limit + change_in_bytes;
10941  if (lower_limit > I::kExternalAllocationSoftLimit)
10942  *external_memory_limit = lower_limit;
10943  } else if (change_in_bytes > 0 && amount > *external_memory_limit) {
10944  ReportExternalAllocationLimitReached();
10945  }
10946  return *external_memory;
10947 }
10948 
10950 #if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
10951  typedef internal::Address A;
10952  typedef internal::Internals I;
10953  internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
10954  *reinterpret_cast<A*>(this));
10955  A* result =
10956  HandleScope::CreateHandle(isolate, I::ReadEmbedderData<A>(this, index));
10957  return Local<Value>(reinterpret_cast<Value*>(result));
10958 #else
10959  return SlowGetEmbedderData(index);
10960 #endif
10961 }
10962 
10963 
10965 #if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
10966  typedef internal::Internals I;
10967  return I::ReadEmbedderData<void*>(this, index);
10968 #else
10969  return SlowGetAlignedPointerFromEmbedderData(index);
10970 #endif
10971 }
10972 
10973 template <class T>
10975  T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
10976  if (data) internal::PerformCastCheck(data);
10977  return Local<T>(data);
10978 }
10979 
10980 template <class T>
10982  T* object_ptr = *object;
10983  internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
10984  return AddData(context, *p);
10985 }
10986 
10987 template <class T>
10989  T* object_ptr = *object;
10990  internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
10991  return AddData(*p);
10992 }
10993 
11006 } // namespace v8
11007 
11008 
11009 #undef TYPE_CHECK
11010 
11011 
11012 #endif // INCLUDE_V8_H_
GenericNamedPropertyDefinerCallback definer
Definition: v8.h:6150
V8_DEPRECATED("Weak objects are always considered independent. " "Use TracedGlobal when trying to use EmbedderHeapTracer. " "Use a strong handle when trying to keep an object alive.", V8_INLINE void MarkIndependent())
int GetLineNumber()
Definition: v8.h:1263
static V8_INLINE StringObject * Cast(Value *obj)
Definition: v8.h:10567
TracedGlobal(Isolate *isolate, Local< S > that)
Definition: v8.h:855
Location(int line_number, int column_number)
Definition: v8.h:1266
Definition: v8.h:1971
void(* GCCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:6951
V8_INLINE Local< Boolean > True(Isolate *isolate)
Definition: v8.h:10874
size_t space_available_size()
Definition: v8.h:7017
V8_INLINE Local< Value > GetEmbedderData(int index)
Definition: v8.h:10949
Local< T > Get(Isolate *isolate) const
Definition: v8.h:899
V8_INLINE Local< Value > GetValue() const
Definition: v8.h:6735
friend Maybe< U > Just(const U &u)
GarbageCollectionType
Definition: v8.h:7556
static V8_INLINE BigInt64Array * Cast(Value *obj)
Definition: v8.h:10762
V8_INLINE void Set(const Global< S > &handle)
static V8_INLINE Object * Cast(Value *obj)
Definition: v8.h:10613
Definition: v8.h:95
Definition: v8.h:3824
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:6591
OwnedBuffer(std::unique_ptr< const uint8_t[]> buffer, size_t size)
Definition: v8.h:4429
static V8_INLINE Uint8ClampedArray * Cast(Value *obj)
Definition: v8.h:10776
void(* BeforeCallEnteredCallback)(Isolate *)
Definition: v8.h:6643
void V8_EXPORT RegisterExtension(std::unique_ptr< Extension >)
AtomicsWaitEvent
Definition: v8.h:7985
Persistent< T, CopyablePersistentTraits< T > > CopyablePersistent
Definition: v8.h:650
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:9887
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:9897
KeyConversionMode
Definition: v8.h:3344
static V8_INLINE void Uncompilable()
Definition: v8.h:638
virtual bool IsRootForNonTracingGC(const v8::TracedGlobal< v8::Value > &handle)
Definition: v8.h:7305
size_t number_of_native_contexts()
Definition: v8.h:6983
SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback
Definition: v8.h:7348
void(* WasmStreamingCallback)(const FunctionCallbackInfo< Value > &)
Definition: v8.h:6904
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:217
const char * data
Definition: v8.h:8612
const char * space_name()
Definition: v8.h:7014
friend Maybe< U > Nothing()
Definition: v8.h:9036
IntegrityLevel
Definition: v8.h:3349
void(* ApiImplementationCallback)(const FunctionCallbackInfo< Value > &)
Definition: v8.h:6901
static V8_INLINE Int8Array * Cast(Value *obj)
Definition: v8.h:10707
const int kSmiMaxValue
Definition: v8-internal.h:106
Definition: v8.h:1984
StateTag vm_state
Definition: v8.h:1961
#define V8_EXPORT
Definition: v8config.h:377
V8_INLINE Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8.h:712
PromiseRejectEvent
Definition: v8.h:6717
static V8_INLINE ArrayBufferView * Cast(Value *obj)
Definition: v8.h:10683
friend Local< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:10856
size_t code_and_metadata_size()
Definition: v8.h:7051
V8_INLINE Eternal(Isolate *isolate, Local< S > handle)
Definition: v8.h:386
MaybeLocal< Promise >(* HostImportModuleDynamicallyCallback)(Local< Context > context, Local< ScriptOrModule > referrer, Local< String > specifier)
Definition: v8.h:6666
friend class ReturnValue
Definition: v8.h:3928
static V8_INLINE SharedArrayBuffer * Cast(Value *obj)
Definition: v8.h:10792
PropertyHandlerFlags flags
Definition: v8.h:6153
uintptr_t Address
Definition: v8-internal.h:23
V8_INLINE void SetUndefined()
Definition: v8.h:10105
PropertyHandlerFlags
Definition: v8.h:6057
static V8_INLINE Float32Array * Cast(Value *obj)
Definition: v8.h:10747
static V8_INLINE Map * Cast(Value *obj)
Definition: v8.h:10629
Maybe< T > Just(const T &t)
Definition: v8.h:9041
V8_INLINE bool IsNothing() const
Definition: v8.h:8971
v8::Isolate * isolate() const
Definition: v8.h:7321
Definition: v8.h:8643
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
Definition: v8.h:4655
V8_INLINE PropertyCallbackInfo(internal::Address *args)
Definition: v8.h:4105
Definition: v8.h:2238
void * user_data
Definition: v8.h:7105
IndexedPropertyDefinerCallback definer
Definition: v8.h:6220
static V8_INLINE Proxy * Cast(Value *obj)
Definition: v8.h:10653
size_t peak_malloced_memory()
Definition: v8.h:6982
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:10338
V8_INLINE Local< T > Get(Isolate *isolate) const
Definition: v8.h:480
V8_INLINE bool IsJust() const
Definition: v8.h:8972
V8_INLINE bool operator!=(const Persistent< S > &that) const
Definition: v8.h:245
static V8_INLINE Uint32Array * Cast(Value *obj)
Definition: v8.h:10731
const char * object_type()
Definition: v8.h:7034
void set_code_range_size(size_t limit_in_mb)
Definition: v8.h:6564
size_t frames_count
Definition: v8.h:1960
static V8_INLINE AccessorSignature * Cast(Data *data)
Definition: v8.h:10308
virtual void Lock() const
Definition: v8.h:2787
void(* InterruptCallback)(Isolate *isolate, void *data)
Definition: v8.h:6953
CreateHistogramCallback create_histogram_callback
Definition: v8.h:7420
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:508
bool IsEmpty() const
Definition: v8.h:881
Definition: v8.h:3860
StateTag
Definition: v8.h:1938
V8_INLINE T FromJust() const
Definition: v8.h:9000
bool IsWasm() const
Definition: v8.h:1170
V8_INLINE T * GetParameter() const
Definition: v8.h:417
size_t space_used_size()
Definition: v8.h:7016
StackTraceOptions
Definition: v8.h:1833
size_t does_zap_garbage()
Definition: v8.h:6990
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:6640
Definition: v8.h:1944
V8_INLINE Local< Value > SourceMapUrl() const
Definition: v8.h:10245
size_t code_range_size() const
Definition: v8.h:6563
bool IsModule() const
Definition: v8.h:1171
int dependency_count() const
Definition: v8.h:6485
V8_INLINE const CachedData * GetCachedData() const
Definition: v8.h:10268
static const int kArgsLength
Definition: v8.h:3977
friend class PersistentBase
Definition: v8.h:607
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:917
bool auto_enable()
Definition: v8.h:6488
IndexedPropertyDeleterCallback deleter
Definition: v8.h:6218
friend Local< Primitive > Null(Isolate *isolate)
Definition: v8.h:10865
static V8_INLINE Uint32 * Cast(v8::Value *obj)
Definition: v8.h:10545
Definition: v8.h:2616
friend class Utils
Definition: v8.h:744
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:10189
size_t length_in_bytes
Definition: v8.h:1968
static V8_INLINE Array * Cast(Value *obj)
Definition: v8.h:10621
size_t AllocationLength() const
Definition: v8.h:4743
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5788
static const int kHolderIndex
Definition: v8.h:3983
V8_INLINE Persistent & operator=(const Persistent &that)
Definition: v8.h:707
size_t size
Definition: v8.h:4428
void * new_code_start
Definition: v8.h:7132
void(* MicrotasksCompletedCallback)(Isolate *)
Definition: v8.h:6747
V8_INLINE void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:10964
EmbedderDataFields
Definition: v8.h:9384
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5778
V8_INLINE bool IsString() const
Definition: v8.h:10467
size_t used_heap_size()
Definition: v8.h:6978
friend class internal::FunctionCallbackArguments
Definition: v8.h:3980
V8_INLINE bool IsNothing() const
Definition: v8.h:9049
void * fp
Definition: v8.h:1955
static V8_INLINE Float64Array * Cast(Value *obj)
Definition: v8.h:10755
static const bool kResetInDestructor
Definition: v8.h:631
const char * name() const
Definition: v8.h:6480
Definition: v8.h:1109
V8_INLINE MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
Status
Definition: v8.h:1286
WriteOptions
Definition: v8.h:2718
Encoding
Definition: v8.h:2662
V8_INLINE Eternal()
Definition: v8.h:384
static V8_INLINE uint32_t GetNumberOfDataSlots()
Definition: v8.h:10904
bool(* ExtensionCallback)(const FunctionCallbackInfo< Value > &)
Definition: v8.h:6894
constexpr MemorySpan(T *data, size_t size)
Definition: v8.h:4411
V8_INLINE Local< S > As() const
Definition: v8.h:270
void(* CallCompletedCallback)(Isolate *)
Definition: v8.h:6644
V8_INLINE Local< Value > ResourceName() const
Definition: v8.h:10226
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:1050
V8_INLINE bool IsEmpty() const
Definition: v8.h:347
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5756
static const int kNewTargetIndex
Definition: v8.h:3988
GenericNamedPropertyEnumeratorCallback enumerator
Definition: v8.h:6149
AddHistogramSampleCallback add_histogram_sample_callback
Definition: v8.h:7421
void(* LogEventCallback)(const char *name, int event)
Definition: v8.h:6602
size_t external_memory()
Definition: v8.h:6981
static const int kLineOffsetNotFound
Definition: v8.h:4197
TimeZoneDetection
Definition: v8.h:5305
V8_INLINE ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:10373
V8_INLINE Persistent(const Persistent< S, M2 > &that)
Definition: v8.h:704
static V8_INLINE ObjectTemplate * Cast(Data *data)
Definition: v8.h:10294
static V8_INLINE Resolver * Cast(Value *obj)
Definition: v8.h:10667
DeleterCallback Deleter() const
Definition: v8.h:5179
V8_DEPRECATED("Use WasmModuleObject", typedef WasmModuleObject WasmCompiledModule)
V8_INLINE T FromMaybe(const T &default_value) const
Definition: v8.h:9009
static V8_INLINE Boolean * Cast(v8::Value *obj)
Definition: v8.h:10489
PromiseHookType
Definition: v8.h:6711
Persistent< T, NonCopyablePersistentTraits< T > > NonCopyablePersistent
Definition: v8.h:630
V8_DEPRECATE_SOON("Zone does not pool memory any more.", void set_max_zone_pool_size(size_t bytes))
Definition: v8.h:6571
V8_INLINE ScriptOrigin(Local< Value > resource_name, Local< Integer > resource_line_offset=Local< Integer >(), Local< Integer > resource_column_offset=Local< Integer >(), Local< Boolean > resource_is_shared_cross_origin=Local< Boolean >(), Local< Integer > script_id=Local< Integer >(), Local< Value > source_map_url=Local< Value >(), Local< Boolean > resource_is_opaque=Local< Boolean >(), Local< Boolean > is_wasm=Local< Boolean >(), Local< Boolean > is_module=Local< Boolean >(), Local< PrimitiveArray > host_defined_options=Local< PrimitiveArray >())
Definition: v8.h:10205
V8_INLINE bool operator==(const TracedGlobal< S > &that) const
Definition: v8.h:908
const char * object_sub_type()
Definition: v8.h:7035
V8_INLINE ~Persistent()
Definition: v8.h:721
static const bool kResetInDestructor
Definition: v8.h:651
BufferPolicy buffer_policy
Definition: v8.h:1430
const void * start
Definition: v8.h:1967
friend class Utils
Definition: v8.h:602
static V8_INLINE BigUint64Array * Cast(Value *obj)
Definition: v8.h:10769
V8_INLINE bool IsUndefined() const
Definition: v8.h:10414
MaybeLocal< Value >(* PrepareStackTraceCallback)(Local< Context > context, Local< Value > error, Local< Array > sites)
Definition: v8.h:6691
V8_INLINE Local< T > Get(Isolate *isolate) const
Definition: v8.h:9730
size_t heap_size_limit()
Definition: v8.h:6979
Maybe< T > Nothing()
Definition: v8.h:9036
MemoryPressureLevel
Definition: v8.h:7206
V8_INLINE Local< Value > GetInternalField(int index)
Definition: v8.h:10315
DeleterCallback Deleter() const
Definition: v8.h:4750
void(* GenericNamedPropertyQueryCallback)(Local< Name > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5671
V8_INLINE bool IsNullOrUndefined() const
Definition: v8.h:10449
V8_INLINE Local< Value > Data() const
Definition: v8.h:10823
void(* GenericNamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5704
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:225
void(* PromiseRejectCallback)(PromiseRejectMessage message)
Definition: v8.h:6744
internal::ScriptStreamingData * impl() const
Definition: v8.h:1541
GenericNamedPropertyDescriptorCallback descriptor
Definition: v8.h:6151
void(* GenericNamedPropertyDeleterCallback)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5695
V8_INLINE Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:786
void(* Callback)(const WeakCallbackInfo< T > &data)
Definition: v8.h:405
void(* IndexedPropertyDescriptorCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5801
void * DeleterData() const
Definition: v8.h:4751
V8_INLINE ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:10392
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:10119
V8_INLINE Global()
Definition: v8.h:767
void SetIndexedPropertyHandler(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=nullptr, IndexedPropertyQueryCallback query=nullptr, IndexedPropertyDeleterCallback deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >())
Definition: v8.h:6323
MemoryRange code
Definition: v8.h:1972
static V8_INLINE void Copy(const Persistent< S, M > &source, CopyablePersistent *dest)
Definition: v8.h:653
UseCounterFeature
Definition: v8.h:7566
void * AllocationBase() const
Definition: v8.h:4742
V8_INLINE TracedGlobal< S > & As() const
Definition: v8.h:902
V8_INLINE void Set(Isolate *isolate, Local< S > handle)
static V8_INLINE Function * Cast(Value *obj)
Definition: v8.h:10800
V8_INLINE Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:690
V8_INLINE V8_DEPRECATED("Use Global<> instead", void Set(const Persistent< S > &handle))
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:9984
V8_INLINE int Length() const
Definition: v8.h:10201
size_t physical_space_size()
Definition: v8.h:7018
static const int kArgsLength
Definition: v8.h:4091
static V8_INLINE Date * Cast(Value *obj)
Definition: v8.h:10559
V8_INLINE Local< Object > This() const
Definition: v8.h:10159
int length() const
Definition: v8.h:2997
V8_INLINE P * ClearWeak()
static V8_INLINE Number * Cast(v8::Value *obj)
Definition: v8.h:10521
static V8_INLINE WasmModuleObject * Cast(Value *obj)
Definition: v8.h:10660
MessageErrorLevel
Definition: v8.h:7650
IndexedPropertySetterCallback setter
Definition: v8.h:6216
IndexedPropertyGetterCallback getter
Definition: v8.h:6215
void(* MessageCallback)(Local< Message > message, Local< Value > data)
Definition: v8.h:6598
size_t max_old_space_size() const
Definition: v8.h:6556
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8.h:9241
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, IndexedPropertyDescriptorCallback descriptor, IndexedPropertyDeleterCallback deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6196
bool IsSharedCrossOrigin() const
Definition: v8.h:1166
friend Local< Boolean > True(Isolate *isolate)
Definition: v8.h:10874
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, GenericNamedPropertyQueryCallback query, GenericNamedPropertyDeleterCallback deleter, GenericNamedPropertyEnumeratorCallback enumerator, GenericNamedPropertyDefinerCallback definer, GenericNamedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6087
V8_INLINE Local< PrimitiveArray > HostDefinedOptions() const
Definition: v8.h:10228
V8_DEPRECATE_SOON("Use Detach() instead.", inline void Neuter())
Definition: v8.h:4823
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:8636
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:10817
size_t total_physical_size()
Definition: v8.h:6976
size_t malloced_memory()
Definition: v8.h:6980
ResourceConstraints constraints
Definition: v8.h:7400
void MoveOnlyTypeForCPP03
Definition: v8.h:812
size_t ByteLength() const
Definition: v8.h:4749
V8_INLINE bool IsEmpty() const
Definition: v8.h:477
V8_INLINE void AnnotateStrongRetainer(const char *label)
Definition: v8.h:9856
static V8_INLINE Int32Array * Cast(Value *obj)
Definition: v8.h:10739
size_t external_script_source_size()
Definition: v8.h:7053
static const int kDataIndex
Definition: v8.h:3987
int GetColumnNumber()
Definition: v8.h:1264
#define V8_DEPRECATE_SOON(message, declarator)
Definition: v8config.h:329
static V8_INLINE Set * Cast(Value *obj)
Definition: v8.h:10637
V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate *isolate)
V8_INLINE ~Source()
Definition: v8.h:10263
V8_INLINE Local< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:10856
IndexFilter
Definition: v8.h:3338
static V8_INLINE Int32 * Cast(v8::Value *obj)
Definition: v8.h:10537
internal::Address * implicit_args_
Definition: v8.h:3992
bool(* WasmThreadsEnabledCallback)(Local< Context > context)
Definition: v8.h:6907
V8_INLINE bool ShouldThrowOnError() const
Definition: v8.h:10846
V8_INLINE bool operator!=(const TracedGlobal< S > &that) const
Definition: v8.h:926
V8_INLINE Local< Integer > ResourceColumnOffset() const
Definition: v8.h:10237
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:10841
KeyCollectionMode
Definition: v8.h:3332
static V8_INLINE Local< Context > CreationContext(const PersistentBase< Object > &object)
Definition: v8.h:3721
virtual void VisitExternalString(Local< String > string)
Definition: v8.h:7184
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3263
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context, Local< String > source)
Definition: v8.h:6890
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:3612
~TracedGlobal()
Definition: v8.h:846
V8_INLINE Persistent()
Definition: v8.h:673
V8_INLINE PromiseRejectEvent GetEvent() const
Definition: v8.h:6734
V8_INLINE ReturnValue(const ReturnValue< S > &that)
Definition: v8.h:3892
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:931
V8_INLINE void SetNull()
Definition: v8.h:10098
void operator=(const PersistentBase &)=delete
PrivateData * get_private() const
Definition: v8.h:4361
static const int kReturnValueDefaultValueIndex
Definition: v8.h:3985
bool(* AccessCheckCallback)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data)
Definition: v8.h:5820
V8_INLINE Local< Integer > ScriptID() const
Definition: v8.h:10242
StartupData * snapshot_blob
Definition: v8.h:7405
V8_INLINE MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
V8_INLINE ~Scope()
Definition: v8.h:9472
V8_INLINE Local< Primitive > Null(Isolate *isolate)
Definition: v8.h:10865
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:485
static const int kReturnValueIndex
Definition: v8.h:4101
V8_INLINE bool operator!=(const Maybe &other) const
Definition: v8.h:9018
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, v8::NewStringType type, int length=-1)
Definition: libplatform.h:13
MemoryRange embedded_code_range
Definition: v8.h:1977
size_t number_of_detached_contexts()
Definition: v8.h:6984
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5771
void * Data() const
Definition: v8.h:4748
void(* GenericNamedPropertyGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5622
EventType type
Definition: v8.h:7093
#define V8_PROMISE_INTERNAL_FIELD_COUNT
Definition: v8.h:4206
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local< S > *out) const
Definition: v8.h:354
static V8_INLINE SymbolObject * Cast(Value *obj)
Definition: v8.h:10575
V8_INLINE bool operator!=(const Maybe &other) const
Definition: v8.h:9056
V8_INLINE Local< Object > This() const
Definition: v8.h:10829
void(*)(void *buffer, size_t length, void *info) DeleterCallback
Definition: v8.h:5159
void(* callback)(Local< Object > holder, int index, StartupData payload, void *data)
Definition: v8.h:7360
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T *out) const
Definition: v8.h:8991
V8_INLINE bool operator==(const Maybe &other) const
Definition: v8.h:9013
#define V8_DECL_INTRINSIC(name, iname)
Definition: v8.h:5481
V8_INLINE Local()
Definition: v8.h:184
static V8_INLINE NumberObject * Cast(Value *obj)
Definition: v8.h:10583
V8_INLINE void PerformCastCheck(T *data)
Definition: v8-internal.h:366
CallbackFunction callback
Definition: v8.h:7343
void * sp
Definition: v8.h:1954
V8_DEPRECATE_SOON("Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", V8_INLINE void RegisterExternalReference(Isolate *isolate) const)
V8_INLINE bool IsJust() const
Definition: v8.h:9050
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:416
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:8621
V8_INLINE ~Global()
Definition: v8.h:796
V8_INLINE void SetData(uint32_t slot, void *data)
Definition: v8.h:10892
DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback
Definition: v8.h:7364
Maybe< void > JustVoid()
Definition: v8.h:9073
static V8_INLINE Symbol * Cast(Value *obj)
Definition: v8.h:10505
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
V8_INLINE bool IsNull() const
Definition: v8.h:10432
int raw_size
Definition: v8.h:8613
V8_INLINE MaybeLocal< T > EscapeMaybe(MaybeLocal< T > value)
Definition: v8.h:1057
const char ** begin() const
Definition: v8.h:9244
size_t AllocationLength() const
Definition: v8.h:5172
V8_INLINE Unlocker(Isolate *isolate)
Definition: v8.h:9602
void(* AccessorNameSetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:3275
virtual void Unlock() const
Definition: v8.h:2792
void(* MicrotasksCompletedCallbackWithData)(Isolate *, void *)
Definition: v8.h:6748
struct name_t name
Definition: v8.h:7126
bool IsOpaque() const
Definition: v8.h:1169
static Local< Number > New(Isolate *isolate, double value)
V8_INLINE Local< Object > Holder() const
Definition: v8.h:10835
void Enter()
static const int kReturnValueDefaultValueIndex
Definition: v8.h:4100
GCType
Definition: v8.h:6918
#define V8_UNLIKELY(condition)
Definition: v8config.h:338
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:494
RAILMode
Definition: v8.h:7143
void set_stack_limit(uint32_t *value)
Definition: v8.h:6562
int length() const
Definition: v8.h:3020
V8_INLINE void Empty()
Definition: v8.h:478
const intptr_t * external_references
Definition: v8.h:7435
V8_INLINE Local< T > ToLocalChecked()
Definition: v8.h:9738
AccessType
Definition: v8.h:5807
void Set(Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:7175
static V8_INLINE String * Cast(v8::Value *obj)
Definition: v8.h:10356
V8_INLINE TracedGlobal & operator=(TracedGlobal< S > &&rhs)
void(* GenericNamedPropertyDescriptorCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5750
V8_INLINE FunctionCallbackInfo(internal::Address *implicit_args, internal::Address *values, int length)
Definition: v8.h:10146
static V8_INLINE External * Cast(Value *obj)
Definition: v8.h:10808
Global Pass()
Definition: v8.h:807
V8_INLINE bool IsWeak() const
Definition: v8.h:9796
void(* PromiseHook)(PromiseHookType type, Local< Promise > promise, Local< Value > parent)
Definition: v8.h:6713
virtual Local< FunctionTemplate > GetNativeFunctionTemplate(Isolate *isolate, Local< String > name)
Definition: v8.h:6475
V8_INLINE size_t AddData(Local< Context > context, Local< T > object)
static V8_INLINE Integer * Cast(v8::Value *obj)
Definition: v8.h:10529
Intrinsic
Definition: v8.h:5480
V8_DEPRECATE_SOON("Use IsDetachable() instead.", inline bool IsNeuterable() const)
Definition: v8.h:4809
MicrotasksPolicy
Definition: v8.h:6759
OwnedBuffer()=default
static V8_INLINE ArrayBuffer * Cast(Value *obj)
Definition: v8.h:10675
bool IsGrowable() const
Definition: v8.h:5181
static V8_INLINE Local< T > Cast(Local< S > that)
Definition: v8.h:255
V8_INLINE bool operator==(const Maybe &other) const
Definition: v8.h:9052
struct line_info_t line_info
Definition: v8.h:7129
static const int kShouldThrowOnErrorIndex
Definition: v8.h:4097
size_t ByteLength() const
Definition: v8.h:5178
JitCodeEventHandler code_event_handler
Definition: v8.h:7395
ConstructorBehavior
Definition: v8.h:4112
V8_INLINE Local(Local< S > that)
Definition: v8.h:186
V8_INLINE bool IsEmpty() const
Definition: v8.h:199
V8_INLINE void SetFinalizationCallback(void *parameter, WeakCallbackInfo< void >::Callback callback)
Definition: v8.h:10002
Definition: v8.h:1939
Definition: v8.h:3798
static V8_INLINE BooleanObject * Cast(Value *obj)
Definition: v8.h:10597
void(* FunctionCallback)(const FunctionCallbackInfo< Value > &info)
Definition: v8.h:4110
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter=nullptr, IndexedPropertySetterCallback setter=nullptr, IndexedPropertyQueryCallback query=nullptr, IndexedPropertyDeleterCallback deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6177
IndexedPropertyQueryCallback query
Definition: v8.h:6217
ArrayBuffer::Allocator * array_buffer_allocator
Definition: v8.h:7427
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter=nullptr, GenericNamedPropertySetterCallback setter=nullptr, GenericNamedPropertyQueryCallback query=nullptr, GenericNamedPropertyDeleterCallback deleter=nullptr, GenericNamedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6107
Definition: v8.h:1940
static V8_INLINE BigIntObject * Cast(Value *obj)
Definition: v8.h:10590
const String::ExternalOneByteStringResource * source() const
Definition: v8.h:6482
static V8_INLINE Name * Cast(Value *obj)
Definition: v8.h:10497
Definition: v8.h:3249
V8_INLINE MaybeLocal()
Definition: v8.h:340
V8_INLINE Local< Object > Holder() const
Definition: v8.h:10165
static V8_INLINE void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8.h:633
TracedGlobal()=default
SideEffectType
Definition: v8.h:3319
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:10183
void * AllocationBase() const
Definition: v8.h:5171
V8_DEPRECATE_SOON("Zone does not pool memory any more.", size_t max_zone_pool_size() const)
Definition: v8.h:6567
static const int kIsolateIndex
Definition: v8.h:3984
internal::Address * args_
Definition: v8.h:4106
MemoryRange code_range
Definition: v8.h:1976
V8_INLINE void Reset()
Definition: v8.h:9941
V8_EXPORT internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
NewStringType
Definition: v8.h:2882
V8_INLINE Local< Boolean > False(Isolate *isolate)
Definition: v8.h:10883
PromiseState
Definition: v8.h:4218
int Flags() const
Definition: v8.h:1173
virtual ~Extension()
Definition: v8.h:6474
V8_INLINE ScriptOriginOptions(int flags)
Definition: v8.h:1162
Definition: v8.h:56
Definition: v8.h:4374
size_t source_length() const
Definition: v8.h:6481
friend class debug::ConsoleCallArguments
Definition: v8.h:3982
V8_INLINE void ClearWeak()
Definition: v8.h:537
V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin=false, bool is_opaque=false, bool is_wasm=false, bool is_module=false)
Definition: v8.h:1156
V8_INLINE T ToChecked() const
Definition: v8.h:8977
static Local< Integer > New(Isolate *isolate, int32_t value)
V8_INLINE bool IsEmpty() const
Definition: v8.h:391
JSEntryStub js_entry_stub
Definition: v8.h:1978
static internal::Address * CreateHandle(internal::Isolate *isolate, internal::Address value)
IndexedPropertyEnumeratorCallback enumerator
Definition: v8.h:6219
V8_INLINE ScriptOriginOptions Options() const
Definition: v8.h:1208
SerializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition: v8.h:7340
void SetSecondPassCallback(Callback callback) const
Definition: v8.h:426
void set_max_old_space_size(size_t limit_in_mb)
Definition: v8.h:6557
static V8_INLINE DataView * Cast(Value *obj)
Definition: v8.h:10784
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:999
V8_INLINE void Check() const
Definition: v8.h:8983
static V8_INLINE Promise * Cast(Value *obj)
Definition: v8.h:10645
V8_INLINE Global & operator=(Global< S > &&rhs)
size_t space_size()
Definition: v8.h:7015
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:241
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
Definition: v8.h:4860
size_t(* NearHeapLimitCallback)(void *data, size_t current_heap_limit, size_t initial_heap_limit)
Definition: v8.h:6962
V8_INLINE void * GetInternalField(int index) const
Definition: v8.h:9745
static const int kIsolateIndex
Definition: v8.h:4099
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:349
#define V8_INTRINSICS_LIST(F)
Definition: v8.h:5472
V8_INLINE void Reset()
Definition: v8.h:9805
size_t bytecode_and_metadata_size()
Definition: v8.h:7052
GenericNamedPropertyDeleterCallback deleter
Definition: v8.h:6148
IndexedPropertyDescriptorCallback descriptor
Definition: v8.h:6221
V8_INLINE Local< Value > Get() const
Definition: v8.h:10125
constexpr size_t size() const
Definition: v8.h:4416
V8_INLINE void * GetData(uint32_t slot)
Definition: v8.h:10898
void *(* CreateHistogramCallback)(const char *name, int min, int max, size_t buckets)
Definition: v8.h:6635
uintptr_t JSStackComparableAddress() const
Definition: v8.h:9497
void(*)(void *buffer, size_t length, void *info) DeleterCallback
Definition: v8.h:4731
static V8_INLINE void * GetAlignedPointerFromInternalField(const TracedGlobal< Object > &object, int index)
Definition: v8.h:3618
const uint8_t * data
Definition: v8.h:1427
Definition: v8.h:1946
const char ** dependencies() const
Definition: v8.h:6486
void(* GenericNamedPropertyDefinerCallback)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5727
static V8_INLINE Signature * Cast(Data *data)
Definition: v8.h:10301
void set_max_semi_space_size_in_kb(size_t limit_in_kb)
Definition: v8.h:6552
Definition: v8.h:5279
static void * JSStackComparableAddress(TryCatch *handler)
Definition: v8.h:9199
friend Local< Boolean > False(Isolate *isolate)
Definition: v8.h:10883
GenericNamedPropertySetterCallback setter
Definition: v8.h:6146
void set_auto_enable(bool value)
Definition: v8.h:6487
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
Definition: v8.h:7194
static const int kThisIndex
Definition: v8.h:4103
size_t total_available_size()
Definition: v8.h:6977
Allocator::AllocationMode AllocationMode() const
Definition: v8.h:5173
friend class Utils
Definition: v8.h:285
static V8_INLINE Private * Cast(Data *data)
Definition: v8.h:10513
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:9697
bool(* AllowWasmCodeGenerationCallback)(Local< Context > context, Local< String > source)
Definition: v8.h:6896
DeserializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition: v8.h:7357
const int kApiTaggedSize
Definition: v8-internal.h:32
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:9993
void * pc
Definition: v8.h:1953
StartupData(* CallbackFunction)(Local< Object > holder, int index, void *data)
Definition: v8.h:7338
V8_INLINE Persistent(Isolate *isolate, Local< S > that)
Definition: v8.h:680
WeakCallbackInfo(Isolate *isolate, T *parameter, void *embedder_fields[kEmbedderFieldsInWeakCallback], Callback *callback)
Definition: v8.h:407
static V8_INLINE FunctionTemplate * Cast(Data *data)
Definition: v8.h:10287
ArrayBufferCreationMode
Definition: v8.h:4659
void(* IndexedPropertyDefinerCallback)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5794
V8_INLINE bool IsConstructCall() const
Definition: v8.h:10195
#define TYPE_CHECK(T, S)
Definition: v8.h:145
int *(* CounterLookupCallback)(const char *name)
Definition: v8.h:6633
void(* AccessorNameGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3266
Definition: v8.h:3165
V8_INLINE void SetEmptyString()
Definition: v8.h:10112
static const int kHolderIndex
Definition: v8.h:4098
GCCallbackFlags
Definition: v8.h:6941
static V8_INLINE RegExp * Cast(Value *obj)
Definition: v8.h:10605
static V8_INLINE Uint16Array * Cast(Value *obj)
Definition: v8.h:10715
std::unique_ptr< const uint8_t[]> buffer
Definition: v8.h:4427
size_t object_count()
Definition: v8.h:7036
V8_INLINE int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Definition: v8.h:10916
friend class MacroAssembler
Definition: v8.h:4094
Local< UnboundScript > script
Definition: v8.h:7100
Definition: v8.h:89
V8_INLINE void Clear()
Definition: v8.h:204
PropertyHandlerFlags flags
Definition: v8.h:6223
GenericNamedPropertyQueryCallback query
Definition: v8.h:6147
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5763
V8_INLINE Persistent(const Persistent &that)
Definition: v8.h:700
V8_INLINE Persistent< S > & As() const
Definition: v8.h:738
V8_INLINE Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=nullptr)
Definition: v8.h:10247
constexpr T * data() const
Definition: v8.h:4414
const char ** end() const
Definition: v8.h:9245
friend class Isolate
Definition: v8.h:601
Allocator::AllocationMode AllocationMode() const
Definition: v8.h:4744
V8_INLINE void SetWeak()
Definition: v8.h:9844
NewStringType
Definition: v8.h:2639
static V8_INLINE Uint8Array * Cast(Value *obj)
Definition: v8.h:10699
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, GenericNamedPropertyDescriptorCallback descriptor, GenericNamedPropertyDeleterCallback deleter, GenericNamedPropertyEnumeratorCallback enumerator, GenericNamedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6126
CounterLookupCallback counter_lookup_callback
Definition: v8.h:7412
TimeZoneDetection
Definition: v8.h:8564
Scope(Isolate *isolate)
Definition: v8.h:7456
internal::Address * values_
Definition: v8.h:3993
size_t total_heap_size()
Definition: v8.h:6974
static V8_INLINE TypedArray * Cast(Value *obj)
Definition: v8.h:10691
static V8_INLINE Value * Cast(T *value)
void(* DcheckErrorCallback)(const char *file, int line, const char *message)
Definition: v8.h:6595
uint32_t * stack_limit() const
Definition: v8.h:6560
size_t max_semi_space_size_in_kb() const
Definition: v8.h:6547
V8_INLINE bool operator!=(const PersistentBase< S > &that) const
Definition: v8.h:503
void(* CallbackFunction)(Local< Object > holder, int index, StartupData payload, void *data)
Definition: v8.h:7355
V8_INLINE Local< S > FromMaybe(Local< S > default_value) const
Definition: v8.h:370
size_t object_size()
Definition: v8.h:7037
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:6880
CodeType code_type
Definition: v8.h:7094
void * DeleterData() const
Definition: v8.h:5180
static V8_INLINE int InternalFieldCount(const TracedGlobal< Object > &object)
Definition: v8.h:3594
static V8_INLINE int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8.h:3588
static const int kReturnValueIndex
Definition: v8.h:3986
void * code_start
Definition: v8.h:7096
V8_INLINE T * operator *() const
Definition: v8.h:208
PromiseRejectMessage(Local< Promise > promise, PromiseRejectEvent event, Local< Value > value, Local< StackTrace > stack_trace)
Definition: v8.h:6726
void * external_callback_entry
Definition: v8.h:1962
const char * str
Definition: v8.h:7110
void * Data() const
Definition: v8.h:5177
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context) const
Definition: v8.h:4132
bool only_terminate_in_safe_scope
Definition: v8.h:7446
V8_INLINE Locker(Isolate *isolate)
Definition: v8.h:9617
Definition: v8.h:86
#define V8_INLINE
Definition: v8config.h:287
static V8_INLINE Local< String > Empty(Isolate *isolate)
Definition: v8.h:10364
void(* MicrotaskCallback)(void *data)
Definition: v8.h:6749
WeakCallbackType
Definition: v8.h:441
V8_INLINE Scope(Local< Context > context)
Definition: v8.h:9469
void(* GenericNamedPropertySetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5646
static V8_INLINE Int16Array * Cast(Value *obj)
Definition: v8.h:10723
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query, IndexedPropertyDeleterCallback deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallback definer, IndexedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6158
void(* OOMErrorCallback)(const char *location, bool is_heap_oom)
Definition: v8.h:6593
AccessControl
Definition: v8.h:3290
V8_INLINE Local< Value > NewTarget() const
Definition: v8.h:10171
PropertyAttribute
Definition: v8.h:3247
#define V8_LIKELY(condition)
Definition: v8config.h:339
static const int kDataIndex
Definition: v8.h:4102
size_t code_len
Definition: v8.h:7098
V8_INLINE Global(Isolate *isolate, Local< S > that)
Definition: v8.h:775
size_t total_heap_size_executable()
Definition: v8.h:6975
V8_INLINE Local< Promise > GetPromise() const
Definition: v8.h:6733
V8_INLINE T * operator->() const
Definition: v8.h:206
GenericNamedPropertyGetterCallback getter
Definition: v8.h:6145
V8_INLINE MaybeLocal(Local< S > that)
Definition: v8.h:342
void(* AccessorSetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:3271
V8_INLINE Local< Value > Data() const
Definition: v8.h:10177
static V8_INLINE Local< Boolean > New(Isolate *isolate, bool value)
Definition: v8.h:10277
static V8_INLINE BigInt * Cast(v8::Value *obj)
Definition: v8.h:10552
Isolate * isolate
Definition: v8.h:7135
JitCodeEventOptions
Definition: v8.h:7163
static V8_INLINE Persistent< T > & Cast(const Persistent< S > &that)
Definition: v8.h:727
V8_INLINE Local< Integer > ResourceLineOffset() const
Definition: v8.h:10232
void(* HostInitializeImportMetaObjectCallback)(Local< Context > context, Local< Module > module, Local< Object > meta)
Definition: v8.h:6680
virtual bool IsCacheable() const
Definition: v8.h:2763
PropertyFilter
Definition: v8.h:3300
V8_INLINE const ScriptOriginOptions & GetResourceOptions() const
Definition: v8.h:10273
PositionType position_type
Definition: v8.h:7121
V8_INLINE Local< Value > operator[](int i) const
Definition: v8.h:10152