v8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 V8_H_
16 #define V8_H_
17 
18 #include <stddef.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 
22 #include "v8-version.h"
23 #include "v8config.h"
24 
25 // We reserve the V8_* prefix for macros defined in V8 public API and
26 // assume there are no name conflicts with the embedder's code.
27 
28 #ifdef V8_OS_WIN
29 
30 // Setup for Windows DLL export/import. When building the V8 DLL the
31 // BUILDING_V8_SHARED needs to be defined. When building a program which uses
32 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
33 // static library or building a program which uses the V8 static library neither
34 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
35 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
36 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
37  build configuration to ensure that at most one of these is set
38 #endif
39 
40 #ifdef BUILDING_V8_SHARED
41 # define V8_EXPORT __declspec(dllexport)
42 #elif USING_V8_SHARED
43 # define V8_EXPORT __declspec(dllimport)
44 #else
45 # define V8_EXPORT
46 #endif // BUILDING_V8_SHARED
47 
48 #else // V8_OS_WIN
49 
50 // Setup for Linux shared library export.
51 #if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED)
52 # ifdef BUILDING_V8_SHARED
53 # define V8_EXPORT __attribute__ ((visibility("default")))
54 # else
55 # define V8_EXPORT
56 # endif
57 #else
58 # define V8_EXPORT
59 #endif
60 
61 #endif // V8_OS_WIN
62 
66 namespace v8 {
67 
68 class AccessorSignature;
69 class Array;
70 class Boolean;
71 class BooleanObject;
72 class Context;
73 class CpuProfiler;
74 class Data;
75 class Date;
76 class External;
77 class Function;
78 class FunctionTemplate;
79 class HeapProfiler;
80 class ImplementationUtilities;
81 class Int32;
82 class Integer;
83 class Isolate;
84 template <class T>
85 class Maybe;
86 class Name;
87 class Number;
88 class NumberObject;
89 class Object;
90 class ObjectOperationDescriptor;
91 class ObjectTemplate;
92 class Platform;
93 class Primitive;
94 class Promise;
95 class RawOperationDescriptor;
96 class Script;
97 class SharedArrayBuffer;
98 class Signature;
99 class StartupData;
100 class StackFrame;
101 class StackTrace;
102 class String;
103 class StringObject;
104 class Symbol;
105 class SymbolObject;
106 class Uint32;
107 class Utils;
108 class Value;
109 template <class T> class Local;
110 template <class T>
112 template <class T> class Eternal;
113 template<class T> class NonCopyablePersistentTraits;
114 template<class T> class PersistentBase;
115 template<class T,
117 template <class T>
118 class Global;
119 template<class K, class V, class T> class PersistentValueMap;
120 template <class K, class V, class T>
122 template <class K, class V, class T>
124 template<class V, class T> class PersistentValueVector;
125 template<class T, class P> class WeakCallbackObject;
126 class FunctionTemplate;
127 class ObjectTemplate;
128 class Data;
129 template<typename T> class FunctionCallbackInfo;
130 template<typename T> class PropertyCallbackInfo;
131 class StackTrace;
132 class StackFrame;
133 class Isolate;
134 class CallHandlerHelper;
136 template<typename T> class ReturnValue;
137 
138 namespace internal {
139 class Arguments;
140 class Heap;
141 class HeapObject;
142 class Isolate;
143 class Object;
144 struct StreamedSource;
145 template<typename T> class CustomArguments;
146 class PropertyCallbackArguments;
147 class FunctionCallbackArguments;
148 class GlobalHandles;
149 }
150 
151 
155 class UniqueId {
156  public:
157  explicit UniqueId(intptr_t data)
158  : data_(data) {}
159 
160  bool operator==(const UniqueId& other) const {
161  return data_ == other.data_;
162  }
163 
164  bool operator!=(const UniqueId& other) const {
165  return data_ != other.data_;
166  }
167 
168  bool operator<(const UniqueId& other) const {
169  return data_ < other.data_;
170  }
171 
172  private:
173  intptr_t data_;
174 };
175 
176 // --- Handles ---
177 
178 #define TYPE_CHECK(T, S) \
179  while (false) { \
180  *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
181  }
182 
183 
209 template <class T>
210 class Local {
211  public:
212  V8_INLINE Local() : val_(0) {}
213  template <class S>
214  V8_INLINE Local(Local<S> that)
215  : val_(reinterpret_cast<T*>(*that)) {
221  TYPE_CHECK(T, S);
222  }
223 
227  V8_INLINE bool IsEmpty() const { return val_ == 0; }
228 
232  V8_INLINE void Clear() { val_ = 0; }
233 
234  V8_INLINE T* operator->() const { return val_; }
235 
236  V8_INLINE T* operator*() const { return val_; }
237 
244  template <class S>
245  V8_INLINE bool operator==(const Local<S>& that) const {
246  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
247  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
248  if (a == 0) return b == 0;
249  if (b == 0) return false;
250  return *a == *b;
251  }
252 
253  template <class S> V8_INLINE bool operator==(
254  const PersistentBase<S>& that) const {
255  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
256  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
257  if (a == 0) return b == 0;
258  if (b == 0) return false;
259  return *a == *b;
260  }
261 
268  template <class S>
269  V8_INLINE bool operator!=(const Local<S>& that) const {
270  return !operator==(that);
271  }
272 
273  template <class S> V8_INLINE bool operator!=(
274  const Persistent<S>& that) const {
275  return !operator==(that);
276  }
277 
278  template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
279 #ifdef V8_ENABLE_CHECKS
280  // If we're going to perform the type check then we have to check
281  // that the handle isn't empty before doing the checked cast.
282  if (that.IsEmpty()) return Local<T>();
283 #endif
284  return Local<T>(T::Cast(*that));
285  }
286 
287 
288  template <class S> V8_INLINE Local<S> As() {
289  return Local<S>::Cast(*this);
290  }
291 
297  V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that);
298  V8_INLINE static Local<T> New(Isolate* isolate,
299  const PersistentBase<T>& that);
300 
301  private:
302  friend class Utils;
303  template<class F> friend class Eternal;
304  template<class F> friend class PersistentBase;
305  template<class F, class M> friend class Persistent;
306  template<class F> friend class Local;
307  template <class F>
308  friend class MaybeLocal;
309  template<class F> friend class FunctionCallbackInfo;
310  template<class F> friend class PropertyCallbackInfo;
311  friend class String;
312  friend class Object;
313  friend class Context;
314  template<class F> friend class internal::CustomArguments;
315  friend Local<Primitive> Undefined(Isolate* isolate);
316  friend Local<Primitive> Null(Isolate* isolate);
317  friend Local<Boolean> True(Isolate* isolate);
318  friend Local<Boolean> False(Isolate* isolate);
319  friend class HandleScope;
320  friend class EscapableHandleScope;
321  template <class F1, class F2, class F3>
323  template<class F1, class F2> friend class PersistentValueVector;
324 
325  template <class S>
326  V8_INLINE Local(S* that)
327  : val_(that) {}
328  V8_INLINE static Local<T> New(Isolate* isolate, T* that);
329  T* val_;
330 };
331 
332 
333 // Handle is an alias for Local for historical reasons.
334 template <class T>
335 using Handle = Local<T>;
336 
337 
348 template <class T>
349 class MaybeLocal {
350  public:
351  V8_INLINE MaybeLocal() : val_(nullptr) {}
352  template <class S>
353  V8_INLINE MaybeLocal(Local<S> that)
354  : val_(reinterpret_cast<T*>(*that)) {
355  TYPE_CHECK(T, S);
356  }
357 
358  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
359 
360  template <class S>
361  V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
362  out->val_ = IsEmpty() ? nullptr : this->val_;
363  return !IsEmpty();
364  }
365 
366  // Will crash if the MaybeLocal<> is empty.
367  V8_INLINE Local<T> ToLocalChecked();
368 
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 
378 
379 // Eternal handles are set-once handles that live for the life of the isolate.
380 template <class T> class Eternal {
381  public:
382  V8_INLINE Eternal() : index_(kInitialValue) { }
383  template<class S>
384  V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) {
385  Set(isolate, handle);
386  }
387  // Can only be safely called if already set.
388  V8_INLINE Local<T> Get(Isolate* isolate);
389  V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
390  template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
391 
392  private:
393  static const int kInitialValue = -1;
394  int index_;
395 };
396 
397 
398 static const int kInternalFieldsInWeakCallback = 2;
399 
400 
401 template <typename T>
403  public:
404  typedef void (*Callback)(const WeakCallbackInfo<T>& data);
405 
406  WeakCallbackInfo(Isolate* isolate, T* parameter,
407  void* internal_fields[kInternalFieldsInWeakCallback],
408  Callback* callback)
409  : isolate_(isolate), parameter_(parameter), callback_(callback) {
410  for (int i = 0; i < kInternalFieldsInWeakCallback; ++i) {
411  internal_fields_[i] = internal_fields[i];
412  }
413  }
414 
415  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
416  V8_INLINE T* GetParameter() const { return parameter_; }
417  V8_INLINE void* GetInternalField(int index) const;
418 
419  V8_INLINE V8_DEPRECATE_SOON("use indexed version",
420  void* GetInternalField1() const) {
421  return internal_fields_[0];
422  }
423  V8_INLINE V8_DEPRECATE_SOON("use indexed version",
424  void* GetInternalField2() const) {
425  return internal_fields_[1];
426  }
427 
428  bool IsFirstPass() const { return callback_ != nullptr; }
429 
430  // When first called, the embedder MUST Reset() the Global which triggered the
431  // callback. The Global itself is unusable for anything else. No v8 other api
432  // calls may be called in the first callback. Should additional work be
433  // required, the embedder must set a second pass callback, which will be
434  // called after all the initial callbacks are processed.
435  // Calling SetSecondPassCallback on the second pass will immediately crash.
436  void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
437 
438  private:
439  Isolate* isolate_;
440  T* parameter_;
441  Callback* callback_;
442  void* internal_fields_[kInternalFieldsInWeakCallback];
443 };
444 
445 
446 template <class T, class P>
448  public:
449  typedef void (*Callback)(const WeakCallbackData<T, P>& data);
450 
451  WeakCallbackData(Isolate* isolate, P* parameter, Local<T> handle)
452  : isolate_(isolate), parameter_(parameter), handle_(handle) {}
453 
454  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
455  V8_INLINE P* GetParameter() const { return parameter_; }
456  V8_INLINE Local<T> GetValue() const { return handle_; }
457 
458  private:
459  Isolate* isolate_;
460  P* parameter_;
461  Local<T> handle_;
462 };
463 
464 
465 // TODO(dcarney): delete this with WeakCallbackData
466 template <class T>
468 
469 
471 
472 
486 template <class T> class PersistentBase {
487  public:
492  V8_INLINE void Reset();
497  template <class S>
498  V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
499 
504  template <class S>
505  V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
506 
507  V8_INLINE bool IsEmpty() const { return val_ == NULL; }
508  V8_INLINE void Empty() { val_ = 0; }
509 
510  template <class S>
511  V8_INLINE bool operator==(const PersistentBase<S>& that) const {
512  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
513  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
514  if (a == NULL) return b == NULL;
515  if (b == NULL) return false;
516  return *a == *b;
517  }
518 
519  template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
520  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
521  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
522  if (a == NULL) return b == NULL;
523  if (b == NULL) return false;
524  return *a == *b;
525  }
526 
527  template <class S>
528  V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
529  return !operator==(that);
530  }
531 
532  template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
533  return !operator==(that);
534  }
535 
543  template <typename P>
544  V8_INLINE V8_DEPRECATE_SOON(
545  "use WeakCallbackInfo version",
546  void SetWeak(P* parameter,
547  typename WeakCallbackData<T, P>::Callback callback));
548 
549  template <typename S, typename P>
550  V8_INLINE V8_DEPRECATE_SOON(
551  "use WeakCallbackInfo version",
552  void SetWeak(P* parameter,
553  typename WeakCallbackData<S, P>::Callback callback));
554 
555  // Phantom persistents work like weak persistents, except that the pointer to
556  // the object being collected is not available in the finalization callback.
557  // This enables the garbage collector to collect the object and any objects
558  // it references transitively in one GC cycle. At the moment you can either
559  // specify a parameter for the callback or the location of two internal
560  // fields in the dying object.
561  template <typename P>
562  V8_INLINE V8_DEPRECATE_SOON(
563  "use SetWeak",
564  void SetPhantom(P* parameter,
565  typename WeakCallbackInfo<P>::Callback callback,
566  int internal_field_index1 = -1,
567  int internal_field_index2 = -1));
568 
569  template <typename P>
570  V8_INLINE void SetWeak(P* parameter,
571  typename WeakCallbackInfo<P>::Callback callback,
572  WeakCallbackType type);
573 
574  template<typename P>
575  V8_INLINE P* ClearWeak();
576 
577  // TODO(dcarney): remove this.
578  V8_INLINE void ClearWeak() { ClearWeak<void>(); }
579 
586  V8_INLINE void MarkIndependent();
587 
596  V8_INLINE void MarkPartiallyDependent();
597 
598  V8_INLINE bool IsIndependent() const;
599 
601  V8_INLINE bool IsNearDeath() const;
602 
604  V8_INLINE bool IsWeak() const;
605 
610  V8_INLINE void SetWrapperClassId(uint16_t class_id);
611 
616  V8_INLINE uint16_t WrapperClassId() const;
617 
618  private:
619  friend class Isolate;
620  friend class Utils;
621  template<class F> friend class Local;
622  template<class F1, class F2> friend class Persistent;
623  template <class F>
624  friend class Global;
625  template<class F> friend class PersistentBase;
626  template<class F> friend class ReturnValue;
627  template <class F1, class F2, class F3>
629  template<class F1, class F2> friend class PersistentValueVector;
630  friend class Object;
631 
632  explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
633  PersistentBase(PersistentBase& other) = delete; // NOLINT
634  void operator=(PersistentBase&) = delete;
635  V8_INLINE static T* New(Isolate* isolate, T* that);
636 
637  T* val_;
638 };
639 
640 
647 template<class T>
648 class NonCopyablePersistentTraits {
649  public:
651  static const bool kResetInDestructor = false;
652  template<class S, class M>
653  V8_INLINE static void Copy(const Persistent<S, M>& source,
654  NonCopyablePersistent* dest) {
655  Uncompilable<Object>();
656  }
657  // TODO(dcarney): come up with a good compile error here.
658  template<class O> V8_INLINE static void Uncompilable() {
659  TYPE_CHECK(O, Primitive);
660  }
661 };
662 
663 
668 template<class T>
671  static const bool kResetInDestructor = true;
672  template<class S, class M>
673  static V8_INLINE void Copy(const Persistent<S, M>& source,
674  CopyablePersistent* dest) {
675  // do nothing, just allow copy
676  }
677 };
678 
679 
688 template <class T, class M> class Persistent : public PersistentBase<T> {
689  public:
693  V8_INLINE Persistent() : PersistentBase<T>(0) { }
699  template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that)
700  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
701  TYPE_CHECK(T, S);
702  }
708  template <class S, class M2>
709  V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
710  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
711  TYPE_CHECK(T, S);
712  }
719  V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(0) {
720  Copy(that);
721  }
722  template <class S, class M2>
723  V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) {
724  Copy(that);
725  }
726  V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
727  Copy(that);
728  return *this;
729  }
730  template <class S, class M2>
731  V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT
732  Copy(that);
733  return *this;
734  }
740  V8_INLINE ~Persistent() {
741  if (M::kResetInDestructor) this->Reset();
742  }
743 
744  // TODO(dcarney): this is pretty useless, fix or remove
745  template <class S>
746  V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
747 #ifdef V8_ENABLE_CHECKS
748  // If we're going to perform the type check then we have to check
749  // that the handle isn't empty before doing the checked cast.
750  if (!that.IsEmpty()) T::Cast(*that);
751 #endif
752  return reinterpret_cast<Persistent<T>&>(that);
753  }
754 
755  // TODO(dcarney): this is pretty useless, fix or remove
756  template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
757  return Persistent<S>::Cast(*this);
758  }
759 
760  private:
761  friend class Isolate;
762  friend class Utils;
763  template<class F> friend class Local;
764  template<class F1, class F2> friend class Persistent;
765  template<class F> friend class ReturnValue;
766 
767  template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
768  V8_INLINE T* operator*() const { return this->val_; }
769  template<class S, class M2>
770  V8_INLINE void Copy(const Persistent<S, M2>& that);
771 };
772 
773 
779 template <class T>
780 class Global : public PersistentBase<T> {
781  public:
785  V8_INLINE Global() : PersistentBase<T>(nullptr) {}
791  template <class S>
792  V8_INLINE Global(Isolate* isolate, Handle<S> that)
793  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
794  TYPE_CHECK(T, S);
795  }
801  template <class S>
802  V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
803  : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
804  TYPE_CHECK(T, S);
805  }
809  V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {
810  other.val_ = nullptr;
811  }
812  V8_INLINE ~Global() { this->Reset(); }
816  template <class S>
817  V8_INLINE Global& operator=(Global<S>&& rhs) {
818  TYPE_CHECK(T, S);
819  if (this != &rhs) {
820  this->Reset();
821  this->val_ = rhs.val_;
822  rhs.val_ = nullptr;
823  }
824  return *this;
825  }
829  Global Pass() { return static_cast<Global&&>(*this); }
830 
831  /*
832  * For compatibility with Chromium's base::Bind (base::Passed).
833  */
834  typedef void MoveOnlyTypeForCPP03;
835 
836  private:
837  template <class F>
838  friend class ReturnValue;
839  Global(Global&) = delete;
840  void operator=(Global&) = delete;
841  V8_INLINE T* operator*() const { return this->val_; }
842 };
843 
844 
845 // UniquePersistent is an alias for Global for historical reason.
846 template <class T>
848 
849 
865  public:
866  HandleScope(Isolate* isolate);
867 
868  ~HandleScope();
869 
873  static int NumberOfHandles(Isolate* isolate);
874 
875  V8_INLINE Isolate* GetIsolate() const {
876  return reinterpret_cast<Isolate*>(isolate_);
877  }
878 
879  protected:
880  V8_INLINE HandleScope() {}
881 
882  void Initialize(Isolate* isolate);
883 
884  static internal::Object** CreateHandle(internal::Isolate* isolate,
885  internal::Object* value);
886 
887  private:
888  // Uses heap_object to obtain the current Isolate.
889  static internal::Object** CreateHandle(internal::HeapObject* heap_object,
890  internal::Object* value);
891 
892  // Make it hard to create heap-allocated or illegal handle scopes by
893  // disallowing certain operations.
894  HandleScope(const HandleScope&);
895  void operator=(const HandleScope&);
896  void* operator new(size_t size);
897  void operator delete(void*, size_t);
898 
899  internal::Isolate* isolate_;
900  internal::Object** prev_next_;
901  internal::Object** prev_limit_;
902 
903  // Local::New uses CreateHandle with an Isolate* parameter.
904  template<class F> friend class Local;
905 
906  // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
907  // a HeapObject* in their shortcuts.
908  friend class Object;
909  friend class Context;
910 };
911 
912 
918  public:
919  EscapableHandleScope(Isolate* isolate);
920  V8_INLINE ~EscapableHandleScope() {}
921 
926  template <class T>
927  V8_INLINE Local<T> Escape(Local<T> value) {
928  internal::Object** slot =
929  Escape(reinterpret_cast<internal::Object**>(*value));
930  return Local<T>(reinterpret_cast<T*>(slot));
931  }
932 
933  private:
934  internal::Object** Escape(internal::Object** escape_value);
935 
936  // Make it hard to create heap-allocated or illegal handle scopes by
937  // disallowing certain operations.
939  void operator=(const EscapableHandleScope&);
940  void* operator new(size_t size);
941  void operator delete(void*, size_t);
942 
943  internal::Object** escape_slot_;
944 };
945 
947  public:
948  SealHandleScope(Isolate* isolate);
949  ~SealHandleScope();
950 
951  private:
952  // Make it hard to create heap-allocated or illegal handle scopes by
953  // disallowing certain operations.
955  void operator=(const SealHandleScope&);
956  void* operator new(size_t size);
957  void operator delete(void*, size_t);
958 
959  internal::Isolate* isolate_;
960  int prev_level_;
961  internal::Object** prev_limit_;
962 };
963 
964 
965 // --- Special objects ---
966 
967 
972  private:
973  Data();
974 };
975 
976 
981  public:
982  V8_INLINE ScriptOriginOptions(bool is_embedder_debug_script = false,
983  bool is_shared_cross_origin = false,
984  bool is_opaque = false)
985  : flags_((is_embedder_debug_script ? kIsEmbedderDebugScript : 0) |
986  (is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
987  (is_opaque ? kIsOpaque : 0)) {}
988  V8_INLINE ScriptOriginOptions(int flags)
989  : flags_(flags &
990  (kIsEmbedderDebugScript | kIsSharedCrossOrigin | kIsOpaque)) {}
991  bool IsEmbedderDebugScript() const {
992  return (flags_ & kIsEmbedderDebugScript) != 0;
993  }
994  bool IsSharedCrossOrigin() const {
995  return (flags_ & kIsSharedCrossOrigin) != 0;
996  }
997  bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
998  int Flags() const { return flags_; }
999 
1000  private:
1001  enum {
1002  kIsEmbedderDebugScript = 1,
1003  kIsSharedCrossOrigin = 1 << 1,
1004  kIsOpaque = 1 << 2
1005  };
1006  const int flags_;
1007 };
1008 
1013  public:
1014  V8_INLINE ScriptOrigin(
1015  Handle<Value> resource_name,
1016  Handle<Integer> resource_line_offset = Handle<Integer>(),
1017  Handle<Integer> resource_column_offset = Handle<Integer>(),
1018  Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
1019  Handle<Integer> script_id = Handle<Integer>(),
1020  Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(),
1021  Handle<Value> source_map_url = Handle<Value>(),
1022  Handle<Boolean> resource_is_opaque = Handle<Boolean>());
1023  V8_INLINE Handle<Value> ResourceName() const;
1024  V8_INLINE Handle<Integer> ResourceLineOffset() const;
1025  V8_INLINE Handle<Integer> ResourceColumnOffset() const;
1029  V8_INLINE Handle<Integer> ScriptID() const;
1030  V8_INLINE Handle<Value> SourceMapUrl() const;
1031  V8_INLINE ScriptOriginOptions Options() const { return options_; }
1032 
1033  private:
1034  Handle<Value> resource_name_;
1035  Handle<Integer> resource_line_offset_;
1036  Handle<Integer> resource_column_offset_;
1037  ScriptOriginOptions options_;
1038  Handle<Integer> script_id_;
1039  Handle<Value> source_map_url_;
1040 };
1041 
1042 
1047  public:
1051  Local<Script> BindToCurrentContext();
1052 
1053  int GetId();
1054  Handle<Value> GetScriptName();
1055 
1059  Handle<Value> GetSourceURL();
1063  Handle<Value> GetSourceMappingURL();
1064 
1069  int GetLineNumber(int code_pos);
1070 
1071  static const int kNoScriptId = 0;
1072 };
1073 
1074 
1080  public:
1084  static V8_DEPRECATE_SOON(
1085  "Use maybe version",
1086  Local<Script> Compile(Handle<String> source,
1087  ScriptOrigin* origin = nullptr));
1088  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
1089  Local<Context> context, Handle<String> source,
1090  ScriptOrigin* origin = nullptr);
1091 
1092  static Local<Script> V8_DEPRECATE_SOON("Use maybe version",
1093  Compile(Handle<String> source,
1094  Handle<String> file_name));
1095 
1101  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run());
1102  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Run(Local<Context> context);
1103 
1107  Local<UnboundScript> GetUnboundScript();
1108 
1109  V8_DEPRECATED("Use GetUnboundScript()->GetId()",
1110  int GetId()) {
1111  return GetUnboundScript()->GetId();
1112  }
1113 };
1114 
1115 
1120  public:
1131  BufferOwned
1132  };
1133 
1135  : data(NULL),
1136  length(0),
1137  rejected(false),
1138  buffer_policy(BufferNotOwned) {}
1139 
1140  // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
1141  // data and guarantees that it stays alive until the CachedData object is
1142  // destroyed. If the policy is BufferOwned, the given data will be deleted
1143  // (with delete[]) when the CachedData object is destroyed.
1144  CachedData(const uint8_t* data, int length,
1145  BufferPolicy buffer_policy = BufferNotOwned);
1146  ~CachedData();
1147  // TODO(marja): Async compilation; add constructors which take a callback
1148  // which will be called when V8 no longer needs the data.
1149  const uint8_t* data;
1150  int length;
1151  bool rejected;
1153 
1154  private:
1155  // Prevent copying. Not implemented.
1156  CachedData(const CachedData&);
1157  CachedData& operator=(const CachedData&);
1158  };
1159 
1163  class Source {
1164  public:
1165  // Source takes ownership of CachedData.
1166  V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1167  CachedData* cached_data = NULL);
1168  V8_INLINE Source(Local<String> source_string,
1169  CachedData* cached_data = NULL);
1170  V8_INLINE ~Source();
1171 
1172  // Ownership of the CachedData or its buffers is *not* transferred to the
1173  // caller. The CachedData object is alive as long as the Source object is
1174  // alive.
1175  V8_INLINE const CachedData* GetCachedData() const;
1176 
1177  private:
1178  friend class ScriptCompiler;
1179  // Prevent copying. Not implemented.
1180  Source(const Source&);
1181  Source& operator=(const Source&);
1182 
1183  Local<String> source_string;
1184 
1185  // Origin information
1186  Handle<Value> resource_name;
1187  Handle<Integer> resource_line_offset;
1188  Handle<Integer> resource_column_offset;
1189  ScriptOriginOptions resource_options;
1190  Handle<Value> source_map_url;
1191 
1192  // Cached data from previous compilation (if a kConsume*Cache flag is
1193  // set), or hold newly generated cache data (kProduce*Cache flags) are
1194  // set when calling a compile method.
1195  CachedData* cached_data;
1196  };
1197 
1203  public:
1205 
1223  virtual size_t GetMoreData(const uint8_t** src) = 0;
1224 
1235  virtual bool SetBookmark();
1236 
1240  virtual void ResetToBookmark();
1241  };
1242 
1243 
1251  public:
1252  enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1253 
1254  StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
1255  ~StreamedSource();
1256 
1257  // Ownership of the CachedData or its buffers is *not* transferred to the
1258  // caller. The CachedData object is alive as long as the StreamedSource
1259  // object is alive.
1260  const CachedData* GetCachedData() const;
1261 
1262  internal::StreamedSource* impl() const { return impl_; }
1263 
1264  private:
1265  // Prevent copying. Not implemented.
1267  StreamedSource& operator=(const StreamedSource&);
1268 
1269  internal::StreamedSource* impl_;
1270  };
1271 
1277  public:
1279  virtual void Run() = 0;
1280  };
1281 
1283  kNoCompileOptions = 0,
1288 
1289  // Support the previous API for a transition period.
1290  kProduceDataToCache
1291  };
1292 
1306  static V8_DEPRECATE_SOON("Use maybe version",
1307  Local<UnboundScript> CompileUnbound(
1308  Isolate* isolate, Source* source,
1309  CompileOptions options = kNoCompileOptions));
1310  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript(
1311  Isolate* isolate, Source* source,
1312  CompileOptions options = kNoCompileOptions);
1313 
1325  static V8_DEPRECATE_SOON(
1326  "Use maybe version",
1327  Local<Script> Compile(Isolate* isolate, Source* source,
1328  CompileOptions options = kNoCompileOptions));
1329  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
1330  Local<Context> context, Source* source,
1331  CompileOptions options = kNoCompileOptions);
1332 
1344  static ScriptStreamingTask* StartStreamingScript(
1345  Isolate* isolate, StreamedSource* source,
1346  CompileOptions options = kNoCompileOptions);
1347 
1355  static V8_DEPRECATE_SOON(
1356  "Use maybe version",
1357  Local<Script> Compile(Isolate* isolate, StreamedSource* source,
1358  Handle<String> full_source_string,
1359  const ScriptOrigin& origin));
1360  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
1361  Local<Context> context, StreamedSource* source,
1362  Handle<String> full_source_string, const ScriptOrigin& origin);
1363 
1382  static uint32_t CachedDataVersionTag();
1383 
1392  static V8_DEPRECATE_SOON(
1393  "Use maybe version",
1394  Local<Script> CompileModule(Isolate* isolate, Source* source,
1395  CompileOptions options = kNoCompileOptions));
1396  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> CompileModule(
1397  Local<Context> context, Source* source,
1398  CompileOptions options = kNoCompileOptions);
1399 
1410  static V8_DEPRECATE_SOON("Use maybe version",
1411  Local<Function> CompileFunctionInContext(
1412  Isolate* isolate, Source* source,
1413  Local<Context> context, size_t arguments_count,
1414  Local<String> arguments[],
1415  size_t context_extension_count,
1416  Local<Object> context_extensions[]));
1417  static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
1418  Local<Context> context, Source* source, size_t arguments_count,
1419  Local<String> arguments[], size_t context_extension_count,
1420  Local<Object> context_extensions[]);
1421 
1422  private:
1423  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
1424  Isolate* isolate, Source* source, CompileOptions options, bool is_module);
1425 };
1426 
1427 
1432  public:
1433  Local<String> Get() const;
1434 
1435  V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine() const);
1436  V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
1437  Local<Context> context) const;
1438 
1443  ScriptOrigin GetScriptOrigin() const;
1444 
1449  Handle<Value> GetScriptResourceName() const;
1450 
1456  Handle<StackTrace> GetStackTrace() const;
1457 
1461  V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber() const);
1462  V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
1463 
1468  int GetStartPosition() const;
1469 
1474  int GetEndPosition() const;
1475 
1480  V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn() const);
1481  V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const;
1482 
1487  V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn() const);
1488  V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
1489 
1494  bool IsSharedCrossOrigin() const;
1495  bool IsOpaque() const;
1496 
1497  // TODO(1245381): Print to a string instead of on a FILE.
1498  static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1499 
1500  static const int kNoLineNumberInfo = 0;
1501  static const int kNoColumnInfo = 0;
1502  static const int kNoScriptIdInfo = 0;
1503 };
1504 
1505 
1512  public:
1518  kLineNumber = 1,
1519  kColumnOffset = 1 << 1 | kLineNumber,
1520  kScriptName = 1 << 2,
1521  kFunctionName = 1 << 3,
1522  kIsEval = 1 << 4,
1523  kIsConstructor = 1 << 5,
1524  kScriptNameOrSourceURL = 1 << 6,
1525  kScriptId = 1 << 7,
1526  kExposeFramesAcrossSecurityOrigins = 1 << 8,
1527  kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
1528  kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
1529  };
1530 
1534  Local<StackFrame> GetFrame(uint32_t index) const;
1535 
1539  int GetFrameCount() const;
1540 
1544  Local<Array> AsArray();
1545 
1553  static Local<StackTrace> CurrentStackTrace(
1554  Isolate* isolate,
1555  int frame_limit,
1556  StackTraceOptions options = kOverview);
1557 };
1558 
1559 
1564  public:
1571  int GetLineNumber() const;
1572 
1580  int GetColumn() const;
1581 
1588  int GetScriptId() const;
1589 
1594  Local<String> GetScriptName() const;
1595 
1602  Local<String> GetScriptNameOrSourceURL() const;
1603 
1607  Local<String> GetFunctionName() const;
1608 
1613  bool IsEval() const;
1614 
1619  bool IsConstructor() const;
1620 };
1621 
1622 
1623 // A StateTag represents a possible state of the VM.
1625 
1626 
1627 // A RegisterState represents the current state of registers used
1628 // by the sampling profiler API.
1630  RegisterState() : pc(NULL), sp(NULL), fp(NULL) {}
1631  void* pc; // Instruction pointer.
1632  void* sp; // Stack pointer.
1633  void* fp; // Frame pointer.
1634 };
1635 
1636 
1637 // The output structure filled up by GetStackSample API function.
1638 struct SampleInfo {
1641 };
1642 
1643 
1648  public:
1656  static V8_DEPRECATE_SOON("Use maybe version",
1657  Local<Value> Parse(Local<String> json_string));
1658  static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
1659  Isolate* isolate, Local<String> json_string);
1660 };
1661 
1662 
1668 class V8_EXPORT NativeWeakMap : public Data {
1669  public:
1670  static Local<NativeWeakMap> New(Isolate* isolate);
1671  void Set(Handle<Value> key, Handle<Value> value);
1672  Local<Value> Get(Handle<Value> key);
1673  bool Has(Handle<Value> key);
1674  bool Delete(Handle<Value> key);
1675 };
1676 
1677 
1678 // --- Value ---
1679 
1680 
1684 class V8_EXPORT Value : public Data {
1685  public:
1690  V8_INLINE bool IsUndefined() const;
1691 
1696  V8_INLINE bool IsNull() const;
1697 
1701  bool IsTrue() const;
1702 
1706  bool IsFalse() const;
1707 
1712  bool IsName() const;
1713 
1718  V8_INLINE bool IsString() const;
1719 
1724  bool IsSymbol() const;
1725 
1729  bool IsFunction() const;
1730 
1734  bool IsArray() const;
1735 
1739  bool IsObject() const;
1740 
1744  bool IsBoolean() const;
1745 
1749  bool IsNumber() const;
1750 
1754  bool IsExternal() const;
1755 
1759  bool IsInt32() const;
1760 
1764  bool IsUint32() const;
1765 
1769  bool IsDate() const;
1770 
1774  bool IsArgumentsObject() const;
1775 
1779  bool IsBooleanObject() const;
1780 
1784  bool IsNumberObject() const;
1785 
1789  bool IsStringObject() const;
1790 
1795  bool IsSymbolObject() const;
1796 
1800  bool IsNativeError() const;
1801 
1805  bool IsRegExp() const;
1806 
1811  bool IsGeneratorFunction() const;
1812 
1817  bool IsGeneratorObject() const;
1818 
1823  bool IsPromise() const;
1824 
1828  bool IsMap() const;
1829 
1833  bool IsSet() const;
1834 
1838  bool IsMapIterator() const;
1839 
1843  bool IsSetIterator() const;
1844 
1848  bool IsWeakMap() const;
1849 
1853  bool IsWeakSet() const;
1854 
1859  bool IsArrayBuffer() const;
1860 
1865  bool IsArrayBufferView() const;
1866 
1871  bool IsTypedArray() const;
1872 
1877  bool IsUint8Array() const;
1878 
1883  bool IsUint8ClampedArray() const;
1884 
1889  bool IsInt8Array() const;
1890 
1895  bool IsUint16Array() const;
1896 
1901  bool IsInt16Array() const;
1902 
1907  bool IsUint32Array() const;
1908 
1913  bool IsInt32Array() const;
1914 
1919  bool IsFloat32Array() const;
1920 
1925  bool IsFloat64Array() const;
1926 
1931  bool IsFloat32x4() const;
1932 
1937  bool IsDataView() const;
1938 
1943  bool IsSharedArrayBuffer() const;
1944 
1945 
1946  V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
1947  Local<Context> context) const;
1948  V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
1949  Local<Context> context) const;
1950  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
1951  Local<Context> context) const;
1952  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
1953  Local<Context> context) const;
1954  V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
1955  Local<Context> context) const;
1956  V8_WARN_UNUSED_RESULT MaybeLocal<Integer> ToInteger(
1957  Local<Context> context) const;
1958  V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToUint32(
1959  Local<Context> context) const;
1960  V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
1961 
1962  V8_DEPRECATE_SOON("Use maybe version",
1963  Local<Boolean> ToBoolean(Isolate* isolate) const);
1964  V8_DEPRECATE_SOON("Use maybe version",
1965  Local<Number> ToNumber(Isolate* isolate) const);
1966  V8_DEPRECATE_SOON("Use maybe version",
1967  Local<String> ToString(Isolate* isolate) const);
1968  V8_DEPRECATE_SOON("Use maybe version",
1969  Local<String> ToDetailString(Isolate* isolate) const);
1970  V8_DEPRECATE_SOON("Use maybe version",
1971  Local<Object> ToObject(Isolate* isolate) const);
1972  V8_DEPRECATE_SOON("Use maybe version",
1973  Local<Integer> ToInteger(Isolate* isolate) const);
1974  V8_DEPRECATE_SOON("Use maybe version",
1975  Local<Uint32> ToUint32(Isolate* isolate) const);
1976  V8_DEPRECATE_SOON("Use maybe version",
1977  Local<Int32> ToInt32(Isolate* isolate) const);
1978 
1979  inline V8_DEPRECATE_SOON("Use maybe version",
1980  Local<Boolean> ToBoolean() const);
1981  inline V8_DEPRECATE_SOON("Use maybe version", Local<Number> ToNumber() const);
1982  inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString() const);
1983  inline V8_DEPRECATE_SOON("Use maybe version",
1984  Local<String> ToDetailString() const);
1985  inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject() const);
1986  inline V8_DEPRECATE_SOON("Use maybe version",
1987  Local<Integer> ToInteger() const);
1988  inline V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToUint32() const);
1989  inline V8_DEPRECATE_SOON("Use maybe version", Local<Int32> ToInt32() const);
1990 
1995  V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToArrayIndex() const);
1996  V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex(
1997  Local<Context> context) const;
1998 
1999  V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(Local<Context> context) const;
2000  V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
2001  V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
2002  Local<Context> context) const;
2003  V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
2004  Local<Context> context) const;
2005  V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
2006 
2007  V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue() const);
2008  V8_DEPRECATE_SOON("Use maybe version", double NumberValue() const);
2009  V8_DEPRECATE_SOON("Use maybe version", int64_t IntegerValue() const);
2010  V8_DEPRECATE_SOON("Use maybe version", uint32_t Uint32Value() const);
2011  V8_DEPRECATE_SOON("Use maybe version", int32_t Int32Value() const);
2012 
2014  V8_DEPRECATE_SOON("Use maybe version", bool Equals(Handle<Value> that) const);
2015  V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context,
2016  Handle<Value> that) const;
2017  bool StrictEquals(Handle<Value> that) const;
2018  bool SameValue(Handle<Value> that) const;
2019 
2020  template <class T> V8_INLINE static Value* Cast(T* value);
2021 
2022  private:
2023  V8_INLINE bool QuickIsUndefined() const;
2024  V8_INLINE bool QuickIsNull() const;
2025  V8_INLINE bool QuickIsString() const;
2026  bool FullIsUndefined() const;
2027  bool FullIsNull() const;
2028  bool FullIsString() const;
2029 };
2030 
2031 
2035 class V8_EXPORT Primitive : public Value { };
2036 
2037 
2042 class V8_EXPORT Boolean : public Primitive {
2043  public:
2044  bool Value() const;
2045  V8_INLINE static Boolean* Cast(v8::Value* obj);
2046  V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
2047  private:
2048  static void CheckCast(v8::Value* obj);
2049 };
2050 
2051 
2055 class V8_EXPORT Name : public Primitive {
2056  public:
2064  int GetIdentityHash();
2065 
2066  V8_INLINE static Name* Cast(v8::Value* obj);
2067  private:
2068  static void CheckCast(v8::Value* obj);
2069 };
2070 
2071 
2073 
2074 
2078 class V8_EXPORT String : public Name {
2079  public:
2080  static const int kMaxLength = (1 << 28) - 16;
2081 
2082  enum Encoding {
2083  UNKNOWN_ENCODING = 0x1,
2084  TWO_BYTE_ENCODING = 0x0,
2085  ONE_BYTE_ENCODING = 0x4
2086  };
2090  int Length() const;
2091 
2096  int Utf8Length() const;
2097 
2103  bool IsOneByte() const;
2104 
2109  bool ContainsOnlyOneByte() const;
2110 
2137  NO_OPTIONS = 0,
2138  HINT_MANY_WRITES_EXPECTED = 1,
2139  NO_NULL_TERMINATION = 2,
2140  PRESERVE_ONE_BYTE_NULL = 4,
2141  // Used by WriteUtf8 to replace orphan surrogate code units with the
2142  // unicode replacement character. Needs to be set to guarantee valid UTF-8
2143  // output.
2144  REPLACE_INVALID_UTF8 = 8
2145  };
2146 
2147  // 16-bit character codes.
2148  int Write(uint16_t* buffer,
2149  int start = 0,
2150  int length = -1,
2151  int options = NO_OPTIONS) const;
2152  // One byte characters.
2153  int WriteOneByte(uint8_t* buffer,
2154  int start = 0,
2155  int length = -1,
2156  int options = NO_OPTIONS) const;
2157  // UTF-8 encoded characters.
2158  int WriteUtf8(char* buffer,
2159  int length = -1,
2160  int* nchars_ref = NULL,
2161  int options = NO_OPTIONS) const;
2162 
2166  V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
2167 
2171  bool IsExternal() const;
2172 
2176  bool IsExternalOneByte() const;
2177 
2179  public:
2181 
2182  protected:
2184 
2191  virtual void Dispose() { delete this; }
2192 
2193  private:
2194  // Disallow copying and assigning.
2196  void operator=(const ExternalStringResourceBase&);
2197 
2198  friend class v8::internal::Heap;
2199  };
2200 
2208  : public ExternalStringResourceBase {
2209  public:
2215 
2219  virtual const uint16_t* data() const = 0;
2220 
2224  virtual size_t length() const = 0;
2225 
2226  protected:
2228  };
2229 
2241  : public ExternalStringResourceBase {
2242  public:
2249  virtual const char* data() const = 0;
2251  virtual size_t length() const = 0;
2252  protected:
2254  };
2255 
2261  V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
2262  Encoding* encoding_out) const;
2263 
2268  V8_INLINE ExternalStringResource* GetExternalStringResource() const;
2269 
2274  const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
2275 
2276  V8_INLINE static String* Cast(v8::Value* obj);
2277 
2278  // TODO(dcarney): remove with deprecation of New functions.
2280  kNormalString = static_cast<int>(v8::NewStringType::kNormal),
2281  kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
2282  };
2283 
2285  static V8_DEPRECATE_SOON(
2286  "Use maybe version",
2287  Local<String> NewFromUtf8(Isolate* isolate, const char* data,
2288  NewStringType type = kNormalString,
2289  int length = -1));
2290 
2293  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
2294  Isolate* isolate, const char* data, v8::NewStringType type,
2295  int length = -1);
2296 
2298  static V8_DEPRECATE_SOON(
2299  "Use maybe version",
2300  Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data,
2301  NewStringType type = kNormalString,
2302  int length = -1));
2303 
2306  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
2307  Isolate* isolate, const uint8_t* data, v8::NewStringType type,
2308  int length = -1);
2309 
2311  static V8_DEPRECATE_SOON(
2312  "Use maybe version",
2313  Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
2314  NewStringType type = kNormalString,
2315  int length = -1));
2316 
2319  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
2320  Isolate* isolate, const uint16_t* data, v8::NewStringType type,
2321  int length = -1);
2322 
2327  static Local<String> Concat(Handle<String> left, Handle<String> right);
2328 
2337  static V8_DEPRECATE_SOON(
2338  "Use maybe version",
2339  Local<String> NewExternal(Isolate* isolate,
2340  ExternalStringResource* resource));
2341  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
2342  Isolate* isolate, ExternalStringResource* resource);
2343 
2353  bool MakeExternal(ExternalStringResource* resource);
2354 
2363  static V8_DEPRECATE_SOON(
2364  "Use maybe version",
2365  Local<String> NewExternal(Isolate* isolate,
2366  ExternalOneByteStringResource* resource));
2367  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
2368  Isolate* isolate, ExternalOneByteStringResource* resource);
2369 
2379  bool MakeExternal(ExternalOneByteStringResource* resource);
2380 
2384  bool CanMakeExternal();
2385 
2394  public:
2395  explicit Utf8Value(Handle<v8::Value> obj);
2396  ~Utf8Value();
2397  char* operator*() { return str_; }
2398  const char* operator*() const { return str_; }
2399  int length() const { return length_; }
2400  private:
2401  char* str_;
2402  int length_;
2403 
2404  // Disallow copying and assigning.
2405  Utf8Value(const Utf8Value&);
2406  void operator=(const Utf8Value&);
2407  };
2408 
2416  public:
2417  explicit Value(Handle<v8::Value> obj);
2418  ~Value();
2419  uint16_t* operator*() { return str_; }
2420  const uint16_t* operator*() const { return str_; }
2421  int length() const { return length_; }
2422  private:
2423  uint16_t* str_;
2424  int length_;
2425 
2426  // Disallow copying and assigning.
2427  Value(const Value&);
2428  void operator=(const Value&);
2429  };
2430 
2431  private:
2432  void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
2433  Encoding encoding) const;
2434  void VerifyExternalStringResource(ExternalStringResource* val) const;
2435  static void CheckCast(v8::Value* obj);
2436 };
2437 
2438 
2444 class V8_EXPORT Symbol : public Name {
2445  public:
2446  // Returns the print name string of the symbol, or undefined if none.
2447  Local<Value> Name() const;
2448 
2449  // Create a symbol. If name is not empty, it will be used as the description.
2450  static Local<Symbol> New(
2451  Isolate *isolate, Local<String> name = Local<String>());
2452 
2453  // Access global symbol registry.
2454  // Note that symbols created this way are never collected, so
2455  // they should only be used for statically fixed properties.
2456  // Also, there is only one global name space for the names used as keys.
2457  // To minimize the potential for clashes, use qualified names as keys.
2458  static Local<Symbol> For(Isolate *isolate, Local<String> name);
2459 
2460  // Retrieve a global symbol. Similar to |For|, but using a separate
2461  // registry that is not accessible by (and cannot clash with) JavaScript code.
2462  static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
2463 
2464  // Well-known symbols
2465  static Local<Symbol> GetIterator(Isolate* isolate);
2466  static Local<Symbol> GetUnscopables(Isolate* isolate);
2467  static Local<Symbol> GetToStringTag(Isolate* isolate);
2468 
2469  V8_INLINE static Symbol* Cast(v8::Value* obj);
2470 
2471  private:
2472  Symbol();
2473  static void CheckCast(v8::Value* obj);
2474 };
2475 
2476 
2480 class V8_EXPORT Number : public Primitive {
2481  public:
2482  double Value() const;
2483  static Local<Number> New(Isolate* isolate, double value);
2484  V8_INLINE static Number* Cast(v8::Value* obj);
2485  private:
2486  Number();
2487  static void CheckCast(v8::Value* obj);
2488 };
2489 
2490 
2494 class V8_EXPORT Integer : public Number {
2495  public:
2496  static Local<Integer> New(Isolate* isolate, int32_t value);
2497  static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
2498  int64_t Value() const;
2499  V8_INLINE static Integer* Cast(v8::Value* obj);
2500  private:
2501  Integer();
2502  static void CheckCast(v8::Value* obj);
2503 };
2504 
2505 
2509 class V8_EXPORT Int32 : public Integer {
2510  public:
2511  int32_t Value() const;
2512  V8_INLINE static Int32* Cast(v8::Value* obj);
2513 
2514  private:
2515  Int32();
2516  static void CheckCast(v8::Value* obj);
2517 };
2518 
2519 
2523 class V8_EXPORT Uint32 : public Integer {
2524  public:
2525  uint32_t Value() const;
2526  V8_INLINE static Uint32* Cast(v8::Value* obj);
2527 
2528  private:
2529  Uint32();
2530  static void CheckCast(v8::Value* obj);
2531 };
2532 
2533 
2535  None = 0,
2536  ReadOnly = 1 << 0,
2537  DontEnum = 1 << 1,
2538  DontDelete = 1 << 2
2539 };
2540 
2546 typedef void (*AccessorGetterCallback)(
2547  Local<String> property,
2548  const PropertyCallbackInfo<Value>& info);
2550  Local<Name> property,
2551  const PropertyCallbackInfo<Value>& info);
2552 
2553 
2554 typedef void (*AccessorSetterCallback)(
2555  Local<String> property,
2556  Local<Value> value,
2557  const PropertyCallbackInfo<void>& info);
2559  Local<Name> property,
2560  Local<Value> value,
2561  const PropertyCallbackInfo<void>& info);
2562 
2563 
2574  DEFAULT = 0,
2576  ALL_CAN_WRITE = 1 << 1,
2578 };
2579 
2580 
2584 class V8_EXPORT Object : public Value {
2585  public:
2586  V8_DEPRECATE_SOON("Use maybe version",
2587  bool Set(Handle<Value> key, Handle<Value> value));
2588  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
2589  Local<Value> key, Local<Value> value);
2590 
2591  V8_DEPRECATE_SOON("Use maybe version",
2592  bool Set(uint32_t index, Handle<Value> value));
2593  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
2594  Local<Value> value);
2595 
2596  // Implements CreateDataProperty (ECMA-262, 7.3.4).
2597  //
2598  // Defines a configurable, writable, enumerable property with the given value
2599  // on the object unless the property already exists and is not configurable
2600  // or the object is not extensible.
2601  //
2602  // Returns true on success.
2603  V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
2604  Local<Name> key,
2605  Local<Value> value);
2606  V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
2607  uint32_t index,
2608  Local<Value> value);
2609 
2610  // Implements DefineOwnProperty.
2611  //
2612  // In general, CreateDataProperty will be faster, however, does not allow
2613  // for specifying attributes.
2614  //
2615  // Returns true on success.
2616  V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
2617  Local<Context> context, Local<Name> key, Local<Value> value,
2618  PropertyAttribute attributes = None);
2619 
2620  // Sets an own property on this object bypassing interceptors and
2621  // overriding accessors or read-only properties.
2622  //
2623  // Note that if the object has an interceptor the property will be set
2624  // locally, but since the interceptor takes precedence the local property
2625  // will only be returned if the interceptor doesn't return a value.
2626  //
2627  // Note also that this only works for named properties.
2628  V8_DEPRECATE_SOON("Use CreateDataProperty",
2629  bool ForceSet(Handle<Value> key, Handle<Value> value,
2630  PropertyAttribute attribs = None));
2631  V8_DEPRECATE_SOON("Use CreateDataProperty",
2632  Maybe<bool> ForceSet(Local<Context> context,
2633  Local<Value> key, Local<Value> value,
2634  PropertyAttribute attribs = None));
2635 
2636  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Handle<Value> key));
2637  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
2638  Local<Value> key);
2639 
2640  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
2641  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
2642  uint32_t index);
2643 
2649  V8_DEPRECATE_SOON("Use maybe version",
2650  PropertyAttribute GetPropertyAttributes(Handle<Value> key));
2651  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetPropertyAttributes(
2652  Local<Context> context, Local<Value> key);
2653 
2657  V8_DEPRECATE_SOON("Use maybe version",
2658  Local<Value> GetOwnPropertyDescriptor(Local<String> key));
2659  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
2660  Local<Context> context, Local<String> key);
2661 
2662  V8_DEPRECATE_SOON("Use maybe version", bool Has(Handle<Value> key));
2663  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
2664  Local<Value> key);
2665 
2666  V8_DEPRECATE_SOON("Use maybe version", bool Delete(Handle<Value> key));
2667  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2668  Maybe<bool> Delete(Local<Context> context, Local<Value> key);
2669 
2670  V8_DEPRECATE_SOON("Use maybe version", bool Has(uint32_t index));
2671  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
2672 
2673  V8_DEPRECATE_SOON("Use maybe version", bool Delete(uint32_t index));
2674  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2675  Maybe<bool> Delete(Local<Context> context, uint32_t index);
2676 
2677  V8_DEPRECATE_SOON("Use maybe version",
2678  bool SetAccessor(Handle<String> name,
2679  AccessorGetterCallback getter,
2680  AccessorSetterCallback setter = 0,
2681  Handle<Value> data = Handle<Value>(),
2682  AccessControl settings = DEFAULT,
2683  PropertyAttribute attribute = None));
2684  V8_DEPRECATE_SOON("Use maybe version",
2685  bool SetAccessor(Handle<Name> name,
2687  AccessorNameSetterCallback setter = 0,
2688  Handle<Value> data = Handle<Value>(),
2689  AccessControl settings = DEFAULT,
2690  PropertyAttribute attribute = None));
2691  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2692  Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
2694  AccessorNameSetterCallback setter = 0,
2696  AccessControl settings = DEFAULT,
2697  PropertyAttribute attribute = None);
2698 
2699  void SetAccessorProperty(Local<Name> name,
2700  Local<Function> getter,
2702  PropertyAttribute attribute = None,
2703  AccessControl settings = DEFAULT);
2704 
2711  V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames());
2712  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
2713  Local<Context> context);
2714 
2720  V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetOwnPropertyNames());
2721  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
2722  Local<Context> context);
2723 
2729  Local<Value> GetPrototype();
2730 
2736  V8_DEPRECATE_SOON("Use maybe version",
2737  bool SetPrototype(Handle<Value> prototype));
2738  V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
2739  Local<Value> prototype);
2740 
2745  Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl);
2746 
2752  V8_DEPRECATE_SOON("Use maybe version", Local<String> ObjectProtoToString());
2753  V8_WARN_UNUSED_RESULT MaybeLocal<String> ObjectProtoToString(
2754  Local<Context> context);
2755 
2759  Local<String> GetConstructorName();
2760 
2762  int InternalFieldCount();
2763 
2765  V8_INLINE static int InternalFieldCount(
2766  const PersistentBase<Object>& object) {
2767  return object.val_->InternalFieldCount();
2768  }
2769 
2771  V8_INLINE Local<Value> GetInternalField(int index);
2772 
2774  void SetInternalField(int index, Handle<Value> value);
2775 
2781  V8_INLINE void* GetAlignedPointerFromInternalField(int index);
2782 
2784  V8_INLINE static void* GetAlignedPointerFromInternalField(
2785  const PersistentBase<Object>& object, int index) {
2786  return object.val_->GetAlignedPointerFromInternalField(index);
2787  }
2788 
2794  void SetAlignedPointerInInternalField(int index, void* value);
2795 
2796  // Testers for local properties.
2797  V8_DEPRECATE_SOON("Use maybe version",
2798  bool HasOwnProperty(Handle<String> key));
2799  V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
2800  Local<Name> key);
2801  V8_DEPRECATE_SOON("Use maybe version",
2802  bool HasRealNamedProperty(Handle<String> key));
2803  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
2804  Local<Name> key);
2805  V8_DEPRECATE_SOON("Use maybe version",
2806  bool HasRealIndexedProperty(uint32_t index));
2807  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty(
2808  Local<Context> context, uint32_t index);
2809  V8_DEPRECATE_SOON("Use maybe version",
2810  bool HasRealNamedCallbackProperty(Handle<String> key));
2811  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty(
2812  Local<Context> context, Local<Name> key);
2813 
2818  V8_DEPRECATE_SOON(
2819  "Use maybe version",
2820  Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key));
2821  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(
2822  Local<Context> context, Local<Name> key);
2823 
2829  V8_DEPRECATE_SOON(
2830  "Use maybe version",
2831  Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
2832  Handle<String> key));
2833  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute>
2834  GetRealNamedPropertyAttributesInPrototypeChain(Local<Context> context,
2835  Local<Name> key);
2836 
2842  V8_DEPRECATE_SOON("Use maybe version",
2843  Local<Value> GetRealNamedProperty(Handle<String> key));
2844  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty(
2845  Local<Context> context, Local<Name> key);
2846 
2852  V8_DEPRECATE_SOON("Use maybe version",
2853  Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
2854  Handle<String> key));
2855  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
2856  Local<Context> context, Local<Name> key);
2857 
2859  bool HasNamedLookupInterceptor();
2860 
2862  bool HasIndexedLookupInterceptor();
2863 
2869  V8_DEPRECATE_SOON("No alternative", void TurnOnAccessCheck());
2870 
2878  int GetIdentityHash();
2879 
2886  // TODO(dcarney): convert these to take a isolate and optionally bailout?
2887  bool SetHiddenValue(Handle<String> key, Handle<Value> value);
2888  Local<Value> GetHiddenValue(Handle<String> key);
2889  bool DeleteHiddenValue(Handle<String> key);
2890 
2895  // TODO(dcarney): take an isolate and optionally bail out?
2896  Local<Object> Clone();
2897 
2901  Local<Context> CreationContext();
2902 
2908  bool IsCallable();
2909 
2914  V8_DEPRECATE_SOON("Use maybe version",
2915  Local<Value> CallAsFunction(Handle<Value> recv, int argc,
2916  Handle<Value> argv[]));
2917  V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsFunction(Local<Context> context,
2918  Handle<Value> recv,
2919  int argc,
2920  Handle<Value> argv[]);
2921 
2927  V8_DEPRECATE_SOON("Use maybe version",
2928  Local<Value> CallAsConstructor(int argc,
2929  Handle<Value> argv[]));
2930  V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsConstructor(
2931  Local<Context> context, int argc, Local<Value> argv[]);
2932 
2936  V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate());
2937 
2938  static Local<Object> New(Isolate* isolate);
2939 
2940  V8_INLINE static Object* Cast(Value* obj);
2941 
2942  private:
2943  Object();
2944  static void CheckCast(Value* obj);
2945  Local<Value> SlowGetInternalField(int index);
2946  void* SlowGetAlignedPointerFromInternalField(int index);
2947 };
2948 
2949 
2953 class V8_EXPORT Array : public Object {
2954  public:
2955  uint32_t Length() const;
2956 
2961  V8_DEPRECATE_SOON("Use maybe version",
2962  Local<Object> CloneElementAt(uint32_t index));
2963  V8_WARN_UNUSED_RESULT MaybeLocal<Object> CloneElementAt(
2964  Local<Context> context, uint32_t index);
2965 
2970  static Local<Array> New(Isolate* isolate, int length = 0);
2971 
2972  V8_INLINE static Array* Cast(Value* obj);
2973  private:
2974  Array();
2975  static void CheckCast(Value* obj);
2976 };
2977 
2978 
2982 class V8_EXPORT Map : public Object {
2983  public:
2984  size_t Size() const;
2985 
2990  Local<Array> AsArray() const;
2991 
2995  static Local<Map> New(Isolate* isolate);
2996 
3002  static V8_WARN_UNUSED_RESULT MaybeLocal<Map> FromArray(Local<Context> context,
3003  Local<Array> array);
3004 
3005  V8_INLINE static Map* Cast(Value* obj);
3006 
3007  private:
3008  Map();
3009  static void CheckCast(Value* obj);
3010 };
3011 
3012 
3016 class V8_EXPORT Set : public Object {
3017  public:
3018  size_t Size() const;
3019 
3023  Local<Array> AsArray() const;
3024 
3028  static Local<Set> New(Isolate* isolate);
3029 
3034  static V8_WARN_UNUSED_RESULT MaybeLocal<Set> FromArray(Local<Context> context,
3035  Local<Array> array);
3036 
3037  V8_INLINE static Set* Cast(Value* obj);
3038 
3039  private:
3040  Set();
3041  static void CheckCast(Value* obj);
3042 };
3043 
3044 
3045 template<typename T>
3046 class ReturnValue {
3047  public:
3048  template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
3049  : value_(that.value_) {
3050  TYPE_CHECK(T, S);
3051  }
3052  // Handle setters
3053  template <typename S>
3054  V8_INLINE V8_DEPRECATE_SOON("Use Global<> instead",
3055  void Set(const Persistent<S>& handle));
3056  template <typename S>
3057  V8_INLINE void Set(const Global<S>& handle);
3058  template <typename S>
3059  V8_INLINE void Set(const Local<S> handle);
3060  // Fast primitive setters
3061  V8_INLINE void Set(bool value);
3062  V8_INLINE void Set(double i);
3063  V8_INLINE void Set(int32_t i);
3064  V8_INLINE void Set(uint32_t i);
3065  // Fast JS primitive setters
3066  V8_INLINE void SetNull();
3067  V8_INLINE void SetUndefined();
3068  V8_INLINE void SetEmptyString();
3069  // Convenience getter for Isolate
3070  V8_INLINE Isolate* GetIsolate();
3071 
3072  // Pointer setter: Uncompilable to prevent inadvertent misuse.
3073  template <typename S>
3074  V8_INLINE void Set(S* whatever);
3075 
3076  private:
3077  template<class F> friend class ReturnValue;
3078  template<class F> friend class FunctionCallbackInfo;
3079  template<class F> friend class PropertyCallbackInfo;
3080  template <class F, class G, class H>
3082  V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; }
3083  V8_INLINE internal::Object* GetDefaultValue();
3084  V8_INLINE explicit ReturnValue(internal::Object** slot);
3085  internal::Object** value_;
3086 };
3087 
3088 
3095 template<typename T>
3096 class FunctionCallbackInfo {
3097  public:
3098  V8_INLINE int Length() const;
3099  V8_INLINE Local<Value> operator[](int i) const;
3100  V8_INLINE Local<Function> Callee() const;
3101  V8_INLINE Local<Object> This() const;
3102  V8_INLINE Local<Object> Holder() const;
3103  V8_INLINE bool IsConstructCall() const;
3104  V8_INLINE Local<Value> Data() const;
3105  V8_INLINE Isolate* GetIsolate() const;
3106  V8_INLINE ReturnValue<T> GetReturnValue() const;
3107  // This shouldn't be public, but the arm compiler needs it.
3108  static const int kArgsLength = 7;
3109 
3110  protected:
3113  static const int kHolderIndex = 0;
3114  static const int kIsolateIndex = 1;
3115  static const int kReturnValueDefaultValueIndex = 2;
3116  static const int kReturnValueIndex = 3;
3117  static const int kDataIndex = 4;
3118  static const int kCalleeIndex = 5;
3119  static const int kContextSaveIndex = 6;
3120 
3121  V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
3122  internal::Object** values,
3123  int length,
3124  bool is_construct_call);
3125  internal::Object** implicit_args_;
3126  internal::Object** values_;
3127  int length_;
3129 };
3130 
3131 
3136 template<typename T>
3137 class PropertyCallbackInfo {
3138  public:
3139  V8_INLINE Isolate* GetIsolate() const;
3140  V8_INLINE Local<Value> Data() const;
3141  V8_INLINE Local<Object> This() const;
3142  V8_INLINE Local<Object> Holder() const;
3143  V8_INLINE ReturnValue<T> GetReturnValue() const;
3144  // This shouldn't be public, but the arm compiler needs it.
3145  static const int kArgsLength = 6;
3146 
3147  protected:
3148  friend class MacroAssembler;
3149  friend class internal::PropertyCallbackArguments;
3151  static const int kHolderIndex = 0;
3152  static const int kIsolateIndex = 1;
3153  static const int kReturnValueDefaultValueIndex = 2;
3154  static const int kReturnValueIndex = 3;
3155  static const int kDataIndex = 4;
3156  static const int kThisIndex = 5;
3157 
3158  V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
3159  internal::Object** args_;
3160 };
3161 
3162 
3163 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
3164 
3165 
3169 class V8_EXPORT Function : public Object {
3170  public:
3175  static MaybeLocal<Function> New(Local<Context> context,
3176  FunctionCallback callback,
3177  Local<Value> data = Local<Value>(),
3178  int length = 0);
3179  static V8_DEPRECATE_SOON(
3180  "Use maybe version",
3181  Local<Function> New(Isolate* isolate, FunctionCallback callback,
3182  Local<Value> data = Local<Value>(), int length = 0));
3183 
3184  V8_DEPRECATE_SOON("Use maybe version",
3185  Local<Object> NewInstance(int argc, Handle<Value> argv[])
3186  const);
3187  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
3188  Local<Context> context, int argc, Handle<Value> argv[]) const;
3189 
3190  V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance() const);
3191  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
3192  Local<Context> context) const {
3193  return NewInstance(context, 0, nullptr);
3194  }
3195 
3196  V8_DEPRECATE_SOON("Use maybe version",
3197  Local<Value> Call(Handle<Value> recv, int argc,
3198  Handle<Value> argv[]));
3199  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
3200  Handle<Value> recv, int argc,
3201  Handle<Value> argv[]);
3202 
3203  void SetName(Handle<String> name);
3204  Handle<Value> GetName() const;
3205 
3212  Handle<Value> GetInferredName() const;
3213 
3218  Handle<Value> GetDisplayName() const;
3219 
3224  int GetScriptLineNumber() const;
3229  int GetScriptColumnNumber() const;
3230 
3234  bool IsBuiltin() const;
3235 
3239  int ScriptId() const;
3240 
3245  Local<Value> GetBoundFunction() const;
3246 
3247  ScriptOrigin GetScriptOrigin() const;
3248  V8_INLINE static Function* Cast(Value* obj);
3249  static const int kLineOffsetNotFound;
3250 
3251  private:
3252  Function();
3253  static void CheckCast(Value* obj);
3254 };
3255 
3256 
3261 class V8_EXPORT Promise : public Object {
3262  public:
3263  class V8_EXPORT Resolver : public Object {
3264  public:
3268  static V8_DEPRECATE_SOON("Use maybe version",
3269  Local<Resolver> New(Isolate* isolate));
3270  static V8_WARN_UNUSED_RESULT MaybeLocal<Resolver> New(
3271  Local<Context> context);
3272 
3276  Local<Promise> GetPromise();
3277 
3282  V8_DEPRECATE_SOON("Use maybe version", void Resolve(Handle<Value> value));
3283  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
3284  Maybe<bool> Resolve(Local<Context> context, Handle<Value> value);
3285 
3286  V8_DEPRECATE_SOON("Use maybe version", void Reject(Handle<Value> value));
3287  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
3288  Maybe<bool> Reject(Local<Context> context, Handle<Value> value);
3289 
3290  V8_INLINE static Resolver* Cast(Value* obj);
3291 
3292  private:
3293  Resolver();
3294  static void CheckCast(Value* obj);
3295  };
3296 
3303  V8_DEPRECATE_SOON("Use maybe version",
3304  Local<Promise> Chain(Handle<Function> handler));
3305  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(Local<Context> context,
3306  Handle<Function> handler);
3307 
3308  V8_DEPRECATE_SOON("Use maybe version",
3309  Local<Promise> Catch(Handle<Function> handler));
3310  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context,
3311  Handle<Function> handler);
3312 
3313  V8_DEPRECATE_SOON("Use maybe version",
3314  Local<Promise> Then(Handle<Function> handler));
3315  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
3316  Handle<Function> handler);
3317 
3322  bool HasHandler();
3323 
3324  V8_INLINE static Promise* Cast(Value* obj);
3325 
3326  private:
3327  Promise();
3328  static void CheckCast(Value* obj);
3329 };
3330 
3331 
3332 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
3333 // The number of required internal fields can be defined by embedder.
3334 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
3335 #endif
3336 
3337 
3339 
3340 
3345 class V8_EXPORT ArrayBuffer : public Object {
3346  public:
3354  class V8_EXPORT Allocator { // NOLINT
3355  public:
3356  virtual ~Allocator() {}
3357 
3362  virtual void* Allocate(size_t length) = 0;
3363 
3368  virtual void* AllocateUninitialized(size_t length) = 0;
3373  virtual void Free(void* data, size_t length) = 0;
3374  };
3375 
3386  class V8_EXPORT Contents { // NOLINT
3387  public:
3388  Contents() : data_(NULL), byte_length_(0) {}
3389 
3390  void* Data() const { return data_; }
3391  size_t ByteLength() const { return byte_length_; }
3392 
3393  private:
3394  void* data_;
3395  size_t byte_length_;
3396 
3397  friend class ArrayBuffer;
3398  };
3399 
3400 
3404  size_t ByteLength() const;
3405 
3412  static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
3413 
3420  static Local<ArrayBuffer> New(
3421  Isolate* isolate, void* data, size_t byte_length,
3423 
3428  bool IsExternal() const;
3429 
3433  bool IsNeuterable() const;
3434 
3441  void Neuter();
3442 
3452  Contents Externalize();
3453 
3464  Contents GetContents();
3465 
3466  V8_INLINE static ArrayBuffer* Cast(Value* obj);
3467 
3468  static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
3469 
3470  private:
3471  ArrayBuffer();
3472  static void CheckCast(Value* obj);
3473 };
3474 
3475 
3476 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
3477 // The number of required internal fields can be defined by embedder.
3478 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
3479 #endif
3480 
3481 
3489  public:
3493  Local<ArrayBuffer> Buffer();
3497  size_t ByteOffset();
3501  size_t ByteLength();
3502 
3512  size_t CopyContents(void* dest, size_t byte_length);
3513 
3518  bool HasBuffer() const;
3519 
3520  V8_INLINE static ArrayBufferView* Cast(Value* obj);
3521 
3522  static const int kInternalFieldCount =
3524 
3525  private:
3526  ArrayBufferView();
3527  static void CheckCast(Value* obj);
3528 };
3529 
3530 
3537  public:
3542  size_t Length();
3543 
3544  V8_INLINE static TypedArray* Cast(Value* obj);
3545 
3546  private:
3547  TypedArray();
3548  static void CheckCast(Value* obj);
3549 };
3550 
3551 
3557  public:
3558  static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
3559  size_t byte_offset, size_t length);
3560  static Local<Uint8Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3561  size_t byte_offset, size_t length);
3562  V8_INLINE static Uint8Array* Cast(Value* obj);
3563 
3564  private:
3565  Uint8Array();
3566  static void CheckCast(Value* obj);
3567 };
3568 
3569 
3575  public:
3576  static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
3577  size_t byte_offset, size_t length);
3578  static Local<Uint8ClampedArray> New(
3579  Handle<SharedArrayBuffer> shared_array_buffer, size_t byte_offset,
3580  size_t length);
3581  V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
3582 
3583  private:
3585  static void CheckCast(Value* obj);
3586 };
3587 
3593  public:
3594  static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
3595  size_t byte_offset, size_t length);
3596  static Local<Int8Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3597  size_t byte_offset, size_t length);
3598  V8_INLINE static Int8Array* Cast(Value* obj);
3599 
3600  private:
3601  Int8Array();
3602  static void CheckCast(Value* obj);
3603 };
3604 
3605 
3611  public:
3612  static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
3613  size_t byte_offset, size_t length);
3614  static Local<Uint16Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3615  size_t byte_offset, size_t length);
3616  V8_INLINE static Uint16Array* Cast(Value* obj);
3617 
3618  private:
3619  Uint16Array();
3620  static void CheckCast(Value* obj);
3621 };
3622 
3623 
3629  public:
3630  static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
3631  size_t byte_offset, size_t length);
3632  static Local<Int16Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3633  size_t byte_offset, size_t length);
3634  V8_INLINE static Int16Array* Cast(Value* obj);
3635 
3636  private:
3637  Int16Array();
3638  static void CheckCast(Value* obj);
3639 };
3640 
3641 
3647  public:
3648  static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
3649  size_t byte_offset, size_t length);
3650  static Local<Uint32Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3651  size_t byte_offset, size_t length);
3652  V8_INLINE static Uint32Array* Cast(Value* obj);
3653 
3654  private:
3655  Uint32Array();
3656  static void CheckCast(Value* obj);
3657 };
3658 
3659 
3665  public:
3666  static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
3667  size_t byte_offset, size_t length);
3668  static Local<Int32Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3669  size_t byte_offset, size_t length);
3670  V8_INLINE static Int32Array* Cast(Value* obj);
3671 
3672  private:
3673  Int32Array();
3674  static void CheckCast(Value* obj);
3675 };
3676 
3677 
3683  public:
3684  static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
3685  size_t byte_offset, size_t length);
3686  static Local<Float32Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3687  size_t byte_offset, size_t length);
3688  V8_INLINE static Float32Array* Cast(Value* obj);
3689 
3690  private:
3691  Float32Array();
3692  static void CheckCast(Value* obj);
3693 };
3694 
3695 
3701  public:
3702  static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
3703  size_t byte_offset, size_t length);
3704  static Local<Float64Array> New(Handle<SharedArrayBuffer> shared_array_buffer,
3705  size_t byte_offset, size_t length);
3706  V8_INLINE static Float64Array* Cast(Value* obj);
3707 
3708  private:
3709  Float64Array();
3710  static void CheckCast(Value* obj);
3711 };
3712 
3713 
3719  public:
3720  static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
3721  size_t byte_offset, size_t length);
3722  static Local<DataView> New(Handle<SharedArrayBuffer> shared_array_buffer,
3723  size_t byte_offset, size_t length);
3724  V8_INLINE static DataView* Cast(Value* obj);
3725 
3726  private:
3727  DataView();
3728  static void CheckCast(Value* obj);
3729 };
3730 
3731 
3737  public:
3749  class V8_EXPORT Contents { // NOLINT
3750  public:
3751  Contents() : data_(NULL), byte_length_(0) {}
3752 
3753  void* Data() const { return data_; }
3754  size_t ByteLength() const { return byte_length_; }
3755 
3756  private:
3757  void* data_;
3758  size_t byte_length_;
3759 
3760  friend class SharedArrayBuffer;
3761  };
3762 
3763 
3767  size_t ByteLength() const;
3768 
3775  static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length);
3776 
3783  static Local<SharedArrayBuffer> New(
3784  Isolate* isolate, void* data, size_t byte_length,
3786 
3791  bool IsExternal() const;
3792 
3805  Contents Externalize();
3806 
3819  Contents GetContents();
3820 
3821  V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
3822 
3823  static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
3824 
3825  private:
3827  static void CheckCast(Value* obj);
3828 };
3829 
3830 
3834 class V8_EXPORT Date : public Object {
3835  public:
3836  static V8_DEPRECATE_SOON("Use maybe version.",
3837  Local<Value> New(Isolate* isolate, double time));
3838  static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
3839  double time);
3840 
3845  double ValueOf() const;
3846 
3847  V8_INLINE static Date* Cast(v8::Value* obj);
3848 
3861  static void DateTimeConfigurationChangeNotification(Isolate* isolate);
3862 
3863  private:
3864  static void CheckCast(v8::Value* obj);
3865 };
3866 
3867 
3872  public:
3873  static Local<Value> New(Isolate* isolate, double value);
3874 
3875  double ValueOf() const;
3876 
3877  V8_INLINE static NumberObject* Cast(v8::Value* obj);
3878 
3879  private:
3880  static void CheckCast(v8::Value* obj);
3881 };
3882 
3883 
3888  public:
3889  static Local<Value> New(bool value);
3890 
3891  bool ValueOf() const;
3892 
3893  V8_INLINE static BooleanObject* Cast(v8::Value* obj);
3894 
3895  private:
3896  static void CheckCast(v8::Value* obj);
3897 };
3898 
3899 
3904  public:
3905  static Local<Value> New(Handle<String> value);
3906 
3907  Local<String> ValueOf() const;
3908 
3909  V8_INLINE static StringObject* Cast(v8::Value* obj);
3910 
3911  private:
3912  static void CheckCast(v8::Value* obj);
3913 };
3914 
3915 
3922  public:
3923  static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
3924 
3925  Local<Symbol> ValueOf() const;
3926 
3927  V8_INLINE static SymbolObject* Cast(v8::Value* obj);
3928 
3929  private:
3930  static void CheckCast(v8::Value* obj);
3931 };
3932 
3933 
3937 class V8_EXPORT RegExp : public Object {
3938  public:
3943  enum Flags {
3944  kNone = 0,
3945  kGlobal = 1,
3946  kIgnoreCase = 2,
3947  kMultiline = 4
3948  };
3949 
3960  static V8_DEPRECATE_SOON("Use maybe version",
3961  Local<RegExp> New(Handle<String> pattern,
3962  Flags flags));
3963  static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> New(Local<Context> context,
3964  Handle<String> pattern,
3965  Flags flags);
3966 
3971  Local<String> GetSource() const;
3972 
3976  Flags GetFlags() const;
3977 
3978  V8_INLINE static RegExp* Cast(v8::Value* obj);
3979 
3980  private:
3981  static void CheckCast(v8::Value* obj);
3982 };
3983 
3984 
3989 class V8_EXPORT External : public Value {
3990  public:
3991  static Local<External> New(Isolate* isolate, void* value);
3992  V8_INLINE static External* Cast(Value* obj);
3993  void* Value() const;
3994  private:
3995  static void CheckCast(v8::Value* obj);
3996 };
3997 
3998 
3999 // --- Templates ---
4000 
4001 
4005 class V8_EXPORT Template : public Data {
4006  public:
4008  void Set(Handle<Name> name, Handle<Data> value,
4009  PropertyAttribute attributes = None);
4010  V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
4011 
4012  void SetAccessorProperty(
4013  Local<Name> name,
4016  PropertyAttribute attribute = None,
4017  AccessControl settings = DEFAULT);
4018 
4046  void SetNativeDataProperty(Local<String> name,
4047  AccessorGetterCallback getter,
4048  AccessorSetterCallback setter = 0,
4049  // TODO(dcarney): gcc can't handle Local below
4050  Handle<Value> data = Handle<Value>(),
4051  PropertyAttribute attribute = None,
4052  Local<AccessorSignature> signature =
4054  AccessControl settings = DEFAULT);
4055  void SetNativeDataProperty(Local<Name> name,
4057  AccessorNameSetterCallback setter = 0,
4058  // TODO(dcarney): gcc can't handle Local below
4059  Handle<Value> data = Handle<Value>(),
4060  PropertyAttribute attribute = None,
4061  Local<AccessorSignature> signature =
4063  AccessControl settings = DEFAULT);
4064 
4065  private:
4066  Template();
4067 
4068  friend class ObjectTemplate;
4069  friend class FunctionTemplate;
4070 };
4071 
4072 
4078  Local<String> property,
4079  const PropertyCallbackInfo<Value>& info);
4080 
4081 
4087  Local<String> property,
4088  Local<Value> value,
4089  const PropertyCallbackInfo<Value>& info);
4090 
4091 
4098  Local<String> property,
4099  const PropertyCallbackInfo<Integer>& info);
4100 
4101 
4108  Local<String> property,
4109  const PropertyCallbackInfo<Boolean>& info);
4110 
4111 
4117  const PropertyCallbackInfo<Array>& info);
4118 
4119 
4120 // TODO(dcarney): Deprecate and remove previous typedefs, and replace
4121 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
4127  Local<Name> property, const PropertyCallbackInfo<Value>& info);
4128 
4129 
4135  Local<Name> property, Local<Value> value,
4136  const PropertyCallbackInfo<Value>& info);
4137 
4138 
4145  Local<Name> property, const PropertyCallbackInfo<Integer>& info);
4146 
4147 
4154  Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
4155 
4156 
4162  const PropertyCallbackInfo<Array>& info);
4163 
4164 
4170  uint32_t index,
4171  const PropertyCallbackInfo<Value>& info);
4172 
4173 
4179  uint32_t index,
4180  Local<Value> value,
4181  const PropertyCallbackInfo<Value>& info);
4182 
4183 
4189  uint32_t index,
4190  const PropertyCallbackInfo<Integer>& info);
4191 
4192 
4199  uint32_t index,
4200  const PropertyCallbackInfo<Boolean>& info);
4201 
4202 
4208  const PropertyCallbackInfo<Array>& info);
4209 
4210 
4220 };
4221 
4222 
4228  Local<Value> key,
4229  AccessType type,
4230  Local<Value> data);
4231 
4232 
4238  uint32_t index,
4239  AccessType type,
4240  Local<Value> data);
4241 
4242 
4339  public:
4341  static Local<FunctionTemplate> New(
4342  Isolate* isolate,
4343  FunctionCallback callback = 0,
4344  Handle<Value> data = Handle<Value>(),
4345  Handle<Signature> signature = Handle<Signature>(),
4346  int length = 0);
4347 
4349  V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction());
4350  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
4351  Local<Context> context);
4352 
4358  void SetCallHandler(FunctionCallback callback,
4359  Handle<Value> data = Handle<Value>());
4360 
4362  void SetLength(int length);
4363 
4365  Local<ObjectTemplate> InstanceTemplate();
4366 
4368  void Inherit(Handle<FunctionTemplate> parent);
4369 
4374  Local<ObjectTemplate> PrototypeTemplate();
4375 
4381  void SetClassName(Handle<String> name);
4382 
4383 
4388  void SetAcceptAnyReceiver(bool value);
4389 
4402  void SetHiddenPrototype(bool value);
4403 
4408  void ReadOnlyPrototype();
4409 
4414  void RemovePrototype();
4415 
4420  bool HasInstance(Handle<Value> object);
4421 
4422  private:
4423  FunctionTemplate();
4424  friend class Context;
4425  friend class ObjectTemplate;
4426 };
4427 
4428 
4430  kNone = 0,
4431  // See ALL_CAN_READ above.
4432  kAllCanRead = 1,
4433  // Will not call into interceptor for properties on the receiver or prototype
4434  // chain. Currently only valid for named interceptors.
4435  kNonMasking = 1 << 1,
4436  // Will not call into interceptor for symbol lookup. Only meaningful for
4437  // named interceptors.
4438  kOnlyInterceptStrings = 1 << 2,
4439 };
4440 
4441 
4452  : getter(getter),
4453  setter(setter),
4454  query(query),
4455  deleter(deleter),
4457  data(data),
4458  flags(flags) {}
4459 
4467 };
4468 
4469 
4473  IndexedPropertyGetterCallback getter = 0,
4480  : getter(getter),
4481  setter(setter),
4482  query(query),
4483  deleter(deleter),
4485  data(data),
4486  flags(flags) {}
4487 
4495 };
4496 
4497 
4505  public:
4507  static Local<ObjectTemplate> New(
4508  Isolate* isolate,
4510  static V8_DEPRECATE_SOON("Use isolate version", Local<ObjectTemplate> New());
4511 
4513  V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
4514  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
4515 
4545  void SetAccessor(Handle<String> name,
4546  AccessorGetterCallback getter,
4547  AccessorSetterCallback setter = 0,
4548  Handle<Value> data = Handle<Value>(),
4549  AccessControl settings = DEFAULT,
4550  PropertyAttribute attribute = None,
4551  Handle<AccessorSignature> signature =
4553  void SetAccessor(Handle<Name> name,
4555  AccessorNameSetterCallback setter = 0,
4556  Handle<Value> data = Handle<Value>(),
4557  AccessControl settings = DEFAULT,
4558  PropertyAttribute attribute = None,
4559  Handle<AccessorSignature> signature =
4561 
4582  // TODO(dcarney): deprecate
4583  void SetNamedPropertyHandler(
4585  NamedPropertySetterCallback setter = 0,
4586  NamedPropertyQueryCallback query = 0,
4587  NamedPropertyDeleterCallback deleter = 0,
4588  NamedPropertyEnumeratorCallback enumerator = 0,
4589  Handle<Value> data = Handle<Value>());
4590  void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
4591 
4608  void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
4609  // TODO(dcarney): deprecate
4612  IndexedPropertySetterCallback setter = 0,
4613  IndexedPropertyQueryCallback query = 0,
4614  IndexedPropertyDeleterCallback deleter = 0,
4615  IndexedPropertyEnumeratorCallback enumerator = 0,
4616  Handle<Value> data = Handle<Value>()) {
4617  SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
4618  deleter, enumerator, data));
4619  }
4626  void SetCallAsFunctionHandler(FunctionCallback callback,
4627  Handle<Value> data = Handle<Value>());
4628 
4637  void MarkAsUndetectable();
4638 
4650  void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
4651  IndexedSecurityCallback indexed_handler,
4652  Handle<Value> data = Handle<Value>(),
4653  bool turned_on_by_default = true);
4654 
4659  int InternalFieldCount();
4660 
4665  void SetInternalFieldCount(int value);
4666 
4667  private:
4668  ObjectTemplate();
4669  static Local<ObjectTemplate> New(internal::Isolate* isolate,
4670  Handle<FunctionTemplate> constructor);
4671  friend class FunctionTemplate;
4672 };
4673 
4674 
4678 class V8_EXPORT Signature : public Data {
4679  public:
4680  static Local<Signature> New(
4681  Isolate* isolate,
4683 
4684  private:
4685  Signature();
4686 };
4687 
4688 
4694  public:
4695  static Local<AccessorSignature> New(Isolate* isolate,
4696  Handle<FunctionTemplate> receiver =
4698 
4699  private:
4701 };
4702 
4703 
4708 class V8_EXPORT TypeSwitch : public Data {
4709  public:
4711  static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
4712  int match(Handle<Value> value);
4713  private:
4714  TypeSwitch();
4715 };
4716 
4717 
4718 // --- Extensions ---
4719 
4722  public:
4723  ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
4724  ExternalOneByteStringResourceImpl(const char* data, size_t length)
4725  : data_(data), length_(length) {}
4726  const char* data() const { return data_; }
4727  size_t length() const { return length_; }
4728 
4729  private:
4730  const char* data_;
4731  size_t length_;
4732 };
4733 
4737 class V8_EXPORT Extension { // NOLINT
4738  public:
4739  // Note that the strings passed into this constructor must live as long
4740  // as the Extension itself.
4741  Extension(const char* name,
4742  const char* source = 0,
4743  int dep_count = 0,
4744  const char** deps = 0,
4745  int source_length = -1);
4746  virtual ~Extension() { }
4748  v8::Isolate* isolate, v8::Handle<v8::String> name) {
4750  }
4751 
4752  const char* name() const { return name_; }
4753  size_t source_length() const { return source_length_; }
4755  return &source_; }
4756  int dependency_count() { return dep_count_; }
4757  const char** dependencies() { return deps_; }
4758  void set_auto_enable(bool value) { auto_enable_ = value; }
4759  bool auto_enable() { return auto_enable_; }
4760 
4761  private:
4762  const char* name_;
4763  size_t source_length_; // expected to initialize before source_
4765  int dep_count_;
4766  const char** deps_;
4767  bool auto_enable_;
4768 
4769  // Disallow copying and assigning.
4770  Extension(const Extension&);
4771  void operator=(const Extension&);
4772 };
4773 
4774 
4775 void V8_EXPORT RegisterExtension(Extension* extension);
4776 
4777 
4778 // --- Statics ---
4779 
4780 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
4781 V8_INLINE Handle<Primitive> Null(Isolate* isolate);
4782 V8_INLINE Handle<Boolean> True(Isolate* isolate);
4783 V8_INLINE Handle<Boolean> False(Isolate* isolate);
4784 
4785 
4796  public:
4798 
4808  void ConfigureDefaults(uint64_t physical_memory,
4809  uint64_t virtual_memory_limit);
4810 
4811  // Deprecated, will be removed soon.
4812  V8_DEPRECATED("Use two-args version instead",
4813  void ConfigureDefaults(uint64_t physical_memory,
4814  uint64_t virtual_memory_limit,
4815  uint32_t number_of_processors));
4816 
4817  int max_semi_space_size() const { return max_semi_space_size_; }
4818  void set_max_semi_space_size(int value) { max_semi_space_size_ = value; }
4819  int max_old_space_size() const { return max_old_space_size_; }
4820  void set_max_old_space_size(int value) { max_old_space_size_ = value; }
4821  int max_executable_size() const { return max_executable_size_; }
4822  void set_max_executable_size(int value) { max_executable_size_ = value; }
4823  uint32_t* stack_limit() const { return stack_limit_; }
4824  // Sets an address beyond which the VM's stack may not grow.
4825  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
4826  V8_DEPRECATED("Unused, will be removed", int max_available_threads() const) {
4827  return max_available_threads_;
4828  }
4829  // Set the number of threads available to V8, assuming at least 1.
4830  V8_DEPRECATED("Unused, will be removed",
4831  void set_max_available_threads(int value)) {
4832  max_available_threads_ = value;
4833  }
4834  size_t code_range_size() const { return code_range_size_; }
4835  void set_code_range_size(size_t value) {
4836  code_range_size_ = value;
4837  }
4838 
4839  private:
4840  int max_semi_space_size_;
4841  int max_old_space_size_;
4842  int max_executable_size_;
4843  uint32_t* stack_limit_;
4844  int max_available_threads_;
4845  size_t code_range_size_;
4846 };
4847 
4848 
4849 // --- Exceptions ---
4850 
4851 
4852 typedef void (*FatalErrorCallback)(const char* location, const char* message);
4853 
4854 
4855 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
4856 
4857 // --- Tracing ---
4858 
4859 typedef void (*LogEventCallback)(const char* name, int event);
4860 
4866  public:
4867  static Local<Value> RangeError(Handle<String> message);
4868  static Local<Value> ReferenceError(Handle<String> message);
4869  static Local<Value> SyntaxError(Handle<String> message);
4870  static Local<Value> TypeError(Handle<String> message);
4871  static Local<Value> Error(Handle<String> message);
4872 
4878  static Local<Message> CreateMessage(Handle<Value> exception);
4879 
4884  static Local<StackTrace> GetStackTrace(Handle<Value> exception);
4885 };
4886 
4887 
4888 // --- Counters Callbacks ---
4889 
4890 typedef int* (*CounterLookupCallback)(const char* name);
4891 
4892 typedef void* (*CreateHistogramCallback)(const char* name,
4893  int min,
4894  int max,
4895  size_t buckets);
4896 
4897 typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
4898 
4899 // --- Memory Allocation Callback ---
4909 };
4910 
4915  };
4916 
4918  AllocationAction action,
4919  int size);
4920 
4921 // --- Leave Script Callback ---
4922 typedef void (*CallCompletedCallback)();
4923 
4924 // --- Promise Reject Callback ---
4928 };
4929 
4931  public:
4933  Handle<Value> value, Handle<StackTrace> stack_trace)
4934  : promise_(promise),
4935  event_(event),
4936  value_(value),
4937  stack_trace_(stack_trace) {}
4938 
4939  V8_INLINE Handle<Promise> GetPromise() const { return promise_; }
4940  V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
4941  V8_INLINE Handle<Value> GetValue() const { return value_; }
4942 
4943  // DEPRECATED. Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()
4944  V8_INLINE Handle<StackTrace> GetStackTrace() const { return stack_trace_; }
4945 
4946  private:
4947  Handle<Promise> promise_;
4948  PromiseRejectEvent event_;
4949  Handle<Value> value_;
4950  Handle<StackTrace> stack_trace_;
4951 };
4952 
4954 
4955 // --- Microtask Callback ---
4956 typedef void (*MicrotaskCallback)(void* data);
4957 
4958 // --- Failed Access Check Callback ---
4960  AccessType type,
4961  Local<Value> data);
4962 
4963 // --- AllowCodeGenerationFromStrings callbacks ---
4964 
4970 
4971 // --- Garbage Collection Callbacks ---
4972 
4980 enum GCType {
4984 };
4985 
4991 };
4992 
4993 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
4994 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
4995 
4996 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
4997 
4998 
5006  public:
5007  HeapStatistics();
5008  size_t total_heap_size() { return total_heap_size_; }
5009  size_t total_heap_size_executable() { return total_heap_size_executable_; }
5010  size_t total_physical_size() { return total_physical_size_; }
5011  size_t total_available_size() { return total_available_size_; }
5012  size_t used_heap_size() { return used_heap_size_; }
5013  size_t heap_size_limit() { return heap_size_limit_; }
5014 
5015  private:
5016  size_t total_heap_size_;
5017  size_t total_heap_size_executable_;
5018  size_t total_physical_size_;
5019  size_t total_available_size_;
5020  size_t used_heap_size_;
5021  size_t heap_size_limit_;
5022 
5023  friend class V8;
5024  friend class Isolate;
5025 };
5026 
5027 
5029  public:
5031  const char* space_name() { return space_name_; }
5032  size_t space_size() { return space_size_; }
5033  size_t space_used_size() { return space_used_size_; }
5034  size_t space_available_size() { return space_available_size_; }
5035  size_t physical_space_size() { return physical_space_size_; }
5036 
5037  private:
5038  const char* space_name_;
5039  size_t space_size_;
5040  size_t space_used_size_;
5041  size_t space_available_size_;
5042  size_t physical_space_size_;
5043 
5044  friend class Isolate;
5045 };
5046 
5047 
5049  public:
5051  const char* object_type() { return object_type_; }
5052  const char* object_sub_type() { return object_sub_type_; }
5053  size_t object_count() { return object_count_; }
5054  size_t object_size() { return object_size_; }
5055 
5056  private:
5057  const char* object_type_;
5058  const char* object_sub_type_;
5059  size_t object_count_;
5060  size_t object_size_;
5061 
5062  friend class Isolate;
5063 };
5064 
5065 
5066 class RetainedObjectInfo;
5067 
5068 
5080 typedef void (*FunctionEntryHook)(uintptr_t function,
5081  uintptr_t return_addr_location);
5082 
5089  enum EventType {
5096  };
5097  // Definition of the code position type. The "POSITION" type means the place
5098  // in the source code which are of interest when making stack traces to
5099  // pin-point the source location of a stack frame as close as possible.
5100  // The "STATEMENT_POSITION" means the place at the beginning of each
5101  // statement, and is used to indicate possible break locations.
5103 
5104  // Type of event.
5106  // Start of the instructions.
5107  void* code_start;
5108  // Size of the instructions.
5109  size_t code_len;
5110  // Script info for CODE_ADDED event.
5112  // User-defined data for *_LINE_INFO_* event. It's used to hold the source
5113  // code line information which is returned from the
5114  // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
5115  // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
5116  void* user_data;
5117 
5118  struct name_t {
5119  // Name of the object associated with the code, note that the string is not
5120  // zero-terminated.
5121  const char* str;
5122  // Number of chars in str.
5123  size_t len;
5124  };
5125 
5126  struct line_info_t {
5127  // PC offset
5128  size_t offset;
5129  // Code postion
5130  size_t pos;
5131  // The position type.
5133  };
5134 
5135  union {
5136  // Only valid for CODE_ADDED.
5137  struct name_t name;
5138 
5139  // Only valid for CODE_ADD_LINE_POS_INFO
5141 
5142  // New location of instructions. Only valid for CODE_MOVED.
5144  };
5145 };
5146 
5152  // Generate callbacks for already existent code.
5154 };
5155 
5156 
5162 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
5163 
5164 
5169  public:
5171  virtual void VisitExternalString(Handle<String> string) {}
5172 };
5173 
5174 
5179  public:
5182  uint16_t class_id) {}
5183 };
5184 
5185 
5195  public:
5199  struct CreateParams {
5201  : entry_hook(NULL),
5202  code_event_handler(NULL),
5203  snapshot_blob(NULL),
5204  counter_lookup_callback(NULL),
5205  create_histogram_callback(NULL),
5206  add_histogram_sample_callback(NULL),
5207  array_buffer_allocator(NULL) {}
5208 
5217 
5223 
5228 
5233 
5234 
5240 
5249 
5255  };
5256 
5257 
5263  public:
5264  explicit Scope(Isolate* isolate) : isolate_(isolate) {
5265  isolate->Enter();
5266  }
5267 
5268  ~Scope() { isolate_->Exit(); }
5269 
5270  private:
5271  Isolate* const isolate_;
5272 
5273  // Prevent copying of Scope objects.
5274  Scope(const Scope&);
5275  Scope& operator=(const Scope&);
5276  };
5277 
5278 
5283  public:
5284  enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
5285 
5286  DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
5288 
5289  private:
5290  bool on_failure_;
5291  void* internal_;
5292 
5293  // Prevent copying of Scope objects.
5297  };
5298 
5299 
5304  public:
5305  explicit AllowJavascriptExecutionScope(Isolate* isolate);
5307 
5308  private:
5309  void* internal_throws_;
5310  void* internal_assert_;
5311 
5312  // Prevent copying of Scope objects.
5314  AllowJavascriptExecutionScope& operator=(
5316  };
5317 
5323  public:
5324  explicit SuppressMicrotaskExecutionScope(Isolate* isolate);
5326 
5327  private:
5328  internal::Isolate* isolate_;
5329 
5330  // Prevent copying of Scope objects.
5334  };
5335 
5342  kMinorGarbageCollection
5343  };
5344 
5351  kUseAsm = 0,
5352  kBreakIterator = 1,
5353  kLegacyConst = 2,
5354  kMarkDequeOverflow = 3,
5355  kStoreBufferOverflow = 4,
5356  kSlotsBufferOverflow = 5,
5357  kObjectObserve = 6,
5358  kForcedGC = 7,
5359  kUseCounterFeatureCount // This enum value must be last.
5360  };
5361 
5362  typedef void (*UseCounterCallback)(Isolate* isolate,
5363  UseCounterFeature feature);
5364 
5365 
5375  static Isolate* New(const CreateParams& params);
5376 
5377  static V8_DEPRECATED("Always pass CreateParams", Isolate* New());
5378 
5385  static Isolate* GetCurrent();
5386 
5397  void Enter();
5398 
5406  void Exit();
5407 
5412  void Dispose();
5413 
5418  V8_INLINE void SetData(uint32_t slot, void* data);
5419 
5424  V8_INLINE void* GetData(uint32_t slot);
5425 
5430  V8_INLINE static uint32_t GetNumberOfDataSlots();
5431 
5435  void GetHeapStatistics(HeapStatistics* heap_statistics);
5436 
5440  size_t NumberOfHeapSpaces();
5441 
5451  bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
5452  size_t index);
5453 
5457  size_t NumberOfTrackedHeapObjectTypes();
5458 
5468  bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
5469  size_t type_index);
5470 
5483  void GetStackSample(const RegisterState& state, void** frames,
5484  size_t frames_limit, SampleInfo* sample_info);
5485 
5499  V8_INLINE int64_t
5500  AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
5501 
5506  HeapProfiler* GetHeapProfiler();
5507 
5513  CpuProfiler* GetCpuProfiler();
5514 
5516  bool InContext();
5517 
5519  Local<Context> GetCurrentContext();
5520 
5526  Local<Context> GetCallingContext();
5527 
5529  Local<Context> GetEnteredContext();
5530 
5537  Local<Value> ThrowException(Local<Value> exception);
5538 
5550  template<typename T> void SetObjectGroupId(const Persistent<T>& object,
5551  UniqueId id);
5552 
5560  template<typename T> void SetReferenceFromGroup(UniqueId id,
5561  const Persistent<T>& child);
5562 
5569  template<typename T, typename S>
5570  void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
5571 
5572  typedef void (*GCPrologueCallback)(Isolate* isolate,
5573  GCType type,
5574  GCCallbackFlags flags);
5575  typedef void (*GCEpilogueCallback)(Isolate* isolate,
5576  GCType type,
5577  GCCallbackFlags flags);
5578 
5588  void AddGCPrologueCallback(
5589  GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
5590 
5595  void RemoveGCPrologueCallback(GCPrologueCallback callback);
5596 
5606  void AddGCEpilogueCallback(
5607  GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
5608 
5613  void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
5614 
5615 
5623  void TerminateExecution();
5624 
5633  bool IsExecutionTerminating();
5634 
5649  void CancelTerminateExecution();
5650 
5659  void RequestInterrupt(InterruptCallback callback, void* data);
5660 
5671  void RequestGarbageCollectionForTesting(GarbageCollectionType type);
5672 
5676  void SetEventLogger(LogEventCallback that);
5677 
5685  void AddCallCompletedCallback(CallCompletedCallback callback);
5686 
5690  void RemoveCallCompletedCallback(CallCompletedCallback callback);
5691 
5692 
5697  void SetPromiseRejectCallback(PromiseRejectCallback callback);
5698 
5703  void RunMicrotasks();
5704 
5708  void EnqueueMicrotask(Handle<Function> microtask);
5709 
5713  void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
5714 
5719  void SetAutorunMicrotasks(bool autorun);
5720 
5725  bool WillAutorunMicrotasks() const;
5726 
5730  void SetUseCounterCallback(UseCounterCallback callback);
5731 
5736  void SetCounterFunction(CounterLookupCallback);
5737 
5744  void SetCreateHistogramFunction(CreateHistogramCallback);
5745  void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
5746 
5761  bool IdleNotificationDeadline(double deadline_in_seconds);
5762 
5763  V8_DEPRECATE_SOON("use IdleNotificationDeadline()",
5764  bool IdleNotification(int idle_time_in_ms));
5765 
5770  void LowMemoryNotification();
5771 
5781  int ContextDisposedNotification(bool dependant_context = true);
5782 
5805  void SetJitCodeEventHandler(JitCodeEventOptions options,
5806  JitCodeEventHandler event_handler);
5807 
5817  void SetStackLimit(uintptr_t stack_limit);
5818 
5832  void GetCodeRange(void** start, size_t* length_in_bytes);
5833 
5835  void SetFatalErrorHandler(FatalErrorCallback that);
5836 
5841  void SetAllowCodeGenerationFromStringsCallback(
5843 
5848  bool IsDead();
5849 
5859  bool AddMessageListener(MessageCallback that,
5860  Handle<Value> data = Handle<Value>());
5861 
5865  void RemoveMessageListeners(MessageCallback that);
5866 
5868  void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
5869 
5874  void SetCaptureStackTraceForUncaughtExceptions(
5875  bool capture, int frame_limit = 10,
5877 
5882  void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
5883  ObjectSpace space, AllocationAction action);
5884 
5888  void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
5889 
5895  void VisitExternalResources(ExternalResourceVisitor* visitor);
5896 
5901  void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
5902 
5910  void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
5911 
5912  private:
5913  template <class K, class V, class Traits>
5915 
5916  Isolate();
5917  Isolate(const Isolate&);
5918  ~Isolate();
5919  Isolate& operator=(const Isolate&);
5920  void* operator new(size_t size);
5921  void operator delete(void*, size_t);
5922 
5923  void SetObjectGroupId(internal::Object** object, UniqueId id);
5924  void SetReferenceFromGroup(UniqueId id, internal::Object** object);
5925  void SetReference(internal::Object** parent, internal::Object** child);
5926  void CollectAllGarbage(const char* gc_reason);
5927 };
5928 
5930  public:
5931  const char* data;
5933 };
5934 
5935 
5940 typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
5941 
5942 
5956 typedef uintptr_t (*ReturnAddressLocationResolver)(
5957  uintptr_t return_addr_location);
5958 
5959 
5963 class V8_EXPORT V8 {
5964  public:
5966  V8_INLINE static V8_DEPRECATE_SOON(
5967  "Use isolate version",
5968  void SetFatalErrorHandler(FatalErrorCallback that));
5969 
5974  V8_INLINE static V8_DEPRECATE_SOON(
5975  "Use isolate version", void SetAllowCodeGenerationFromStringsCallback(
5977 
5984  static V8_DEPRECATE_SOON(
5985  "Use isolate version",
5986  void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator));
5987 
5992  V8_INLINE static V8_DEPRECATE_SOON("no alternative", bool IsDead());
5993 
6009  static void SetNativesDataBlob(StartupData* startup_blob);
6010  static void SetSnapshotDataBlob(StartupData* startup_blob);
6011 
6017  static StartupData CreateSnapshotDataBlob(const char* custom_source = NULL);
6018 
6028  V8_INLINE static V8_DEPRECATE_SOON(
6029  "Use isolate version",
6030  bool AddMessageListener(MessageCallback that,
6031  Handle<Value> data = Handle<Value>()));
6032 
6036  V8_INLINE static V8_DEPRECATE_SOON(
6037  "Use isolate version", void RemoveMessageListeners(MessageCallback that));
6038 
6043  V8_INLINE static V8_DEPRECATE_SOON(
6044  "Use isolate version",
6045  void SetCaptureStackTraceForUncaughtExceptions(
6046  bool capture, int frame_limit = 10,
6048 
6052  static void SetFlagsFromString(const char* str, int length);
6053 
6057  static void SetFlagsFromCommandLine(int* argc,
6058  char** argv,
6059  bool remove_flags);
6060 
6062  static const char* GetVersion();
6063 
6065  V8_INLINE static V8_DEPRECATE_SOON(
6066  "Use isolate version",
6067  void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback));
6068 
6079  static V8_DEPRECATE_SOON(
6080  "Use isolate version",
6081  void AddGCPrologueCallback(GCPrologueCallback callback,
6082  GCType gc_type_filter = kGCTypeAll));
6083 
6088  V8_INLINE static V8_DEPRECATE_SOON(
6089  "Use isolate version",
6090  void RemoveGCPrologueCallback(GCPrologueCallback callback));
6091 
6102  static V8_DEPRECATE_SOON(
6103  "Use isolate version",
6104  void AddGCEpilogueCallback(GCEpilogueCallback callback,
6105  GCType gc_type_filter = kGCTypeAll));
6106 
6111  V8_INLINE static V8_DEPRECATE_SOON(
6112  "Use isolate version",
6113  void RemoveGCEpilogueCallback(GCEpilogueCallback callback));
6114 
6119  V8_INLINE static V8_DEPRECATE_SOON(
6120  "Use isolate version",
6121  void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
6122  ObjectSpace space,
6123  AllocationAction action));
6124 
6128  V8_INLINE static V8_DEPRECATE_SOON(
6129  "Use isolate version",
6130  void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback));
6131 
6136  static bool Initialize();
6137 
6142  static void SetEntropySource(EntropySource source);
6143 
6148  static void SetReturnAddressLocationResolver(
6149  ReturnAddressLocationResolver return_address_resolver);
6150 
6160  V8_INLINE static V8_DEPRECATE_SOON("Use isolate version",
6161  void TerminateExecution(Isolate* isolate));
6162 
6173  V8_INLINE static V8_DEPRECATE_SOON(
6174  "Use isolate version",
6175  bool IsExecutionTerminating(Isolate* isolate = NULL));
6176 
6193  V8_INLINE static V8_DEPRECATE_SOON(
6194  "Use isolate version", void CancelTerminateExecution(Isolate* isolate));
6195 
6205  static bool Dispose();
6206 
6212  V8_INLINE static V8_DEPRECATE_SOON(
6213  "Use isoalte version",
6214  void VisitExternalResources(ExternalResourceVisitor* visitor));
6215 
6220  V8_INLINE static V8_DEPRECATE_SOON(
6221  "Use isolate version",
6222  void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor));
6223 
6228  V8_INLINE static V8_DEPRECATE_SOON(
6229  "Use isolate version",
6230  void VisitHandlesWithClassIds(Isolate* isolate,
6231  PersistentHandleVisitor* visitor));
6232 
6240  V8_INLINE static V8_DEPRECATE_SOON(
6241  "Use isolate version",
6242  void VisitHandlesForPartialDependence(Isolate* isolate,
6243  PersistentHandleVisitor* visitor));
6244 
6252  static bool InitializeICU(const char* icu_data_file = NULL);
6253 
6258  static void InitializePlatform(Platform* platform);
6259 
6264  static void ShutdownPlatform();
6265 
6266  private:
6267  V8();
6268 
6269  static internal::Object** GlobalizeReference(internal::Isolate* isolate,
6270  internal::Object** handle);
6271  static internal::Object** CopyPersistent(internal::Object** handle);
6272  static void DisposeGlobal(internal::Object** global_handle);
6273  typedef WeakCallbackData<Value, void>::Callback WeakCallback;
6274  static void MakeWeak(internal::Object** global_handle, void* data,
6275  WeakCallback weak_callback);
6276  static void MakeWeak(internal::Object** global_handle, void* data,
6277  WeakCallbackInfo<void>::Callback weak_callback,
6278  WeakCallbackType type);
6279  static void MakeWeak(internal::Object** global_handle, void* data,
6280  // Must be 0 or -1.
6281  int internal_field_index1,
6282  // Must be 1 or -1.
6283  int internal_field_index2,
6284  WeakCallbackInfo<void>::Callback weak_callback);
6285  static void* ClearWeak(internal::Object** global_handle);
6286  static void Eternalize(Isolate* isolate,
6287  Value* handle,
6288  int* index);
6289  static Local<Value> GetEternal(Isolate* isolate, int index);
6290 
6291  static void FromJustIsNothing();
6292  static void ToLocalEmpty();
6293  static void InternalFieldOutOfBounds(int index);
6294  template <class T> friend class Local;
6295  template <class T>
6296  friend class MaybeLocal;
6297  template <class T>
6298  friend class Maybe;
6299  template <class T>
6300  friend class WeakCallbackInfo;
6301  template <class T> friend class Eternal;
6302  template <class T> friend class PersistentBase;
6303  template <class T, class M> friend class Persistent;
6304  friend class Context;
6305 };
6306 
6307 
6318 template <class T>
6319 class Maybe {
6320  public:
6321  V8_INLINE bool IsNothing() const { return !has_value; }
6322  V8_INLINE bool IsJust() const { return has_value; }
6323 
6324  // Will crash if the Maybe<> is nothing.
6325  V8_INLINE T FromJust() const {
6326  if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
6327  return value;
6328  }
6329 
6330  V8_INLINE T FromMaybe(const T& default_value) const {
6331  return has_value ? value : default_value;
6332  }
6333 
6334  V8_INLINE bool operator==(const Maybe& other) const {
6335  return (IsJust() == other.IsJust()) &&
6336  (!IsJust() || FromJust() == other.FromJust());
6337  }
6338 
6339  V8_INLINE bool operator!=(const Maybe& other) const {
6340  return !operator==(other);
6341  }
6342 
6343  private:
6344  Maybe() : has_value(false) {}
6345  explicit Maybe(const T& t) : has_value(true), value(t) {}
6346 
6347  bool has_value;
6348  T value;
6349 
6350  template <class U>
6351  friend Maybe<U> Nothing();
6352  template <class U>
6353  friend Maybe<U> Just(const U& u);
6354 };
6355 
6356 
6357 template <class T>
6358 inline Maybe<T> Nothing() {
6359  return Maybe<T>();
6360 }
6361 
6362 
6363 template <class T>
6364 inline Maybe<T> Just(const T& t) {
6365  return Maybe<T>(t);
6366 }
6367 
6368 
6373  public:
6379  V8_DEPRECATE_SOON("Use isolate version", TryCatch());
6380 
6386  TryCatch(Isolate* isolate);
6387 
6391  ~TryCatch();
6392 
6396  bool HasCaught() const;
6397 
6406  bool CanContinue() const;
6407 
6420  bool HasTerminated() const;
6421 
6429  Handle<Value> ReThrow();
6430 
6437  Local<Value> Exception() const;
6438 
6443  V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace() const);
6444  V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
6445  Local<Context> context) const;
6446 
6454  Local<v8::Message> Message() const;
6455 
6466  void Reset();
6467 
6476  void SetVerbose(bool value);
6477 
6483  void SetCaptureMessage(bool value);
6484 
6496  static void* JSStackComparableAddress(v8::TryCatch* handler) {
6497  if (handler == NULL) return NULL;
6498  return handler->js_stack_comparable_address_;
6499  }
6500 
6501  private:
6502  void ResetInternal();
6503 
6504  // Make it hard to create heap-allocated TryCatch blocks.
6505  TryCatch(const TryCatch&);
6506  void operator=(const TryCatch&);
6507  void* operator new(size_t size);
6508  void operator delete(void*, size_t);
6509 
6510  v8::internal::Isolate* isolate_;
6511  v8::TryCatch* next_;
6512  void* exception_;
6513  void* message_obj_;
6514  void* js_stack_comparable_address_;
6515  bool is_verbose_ : 1;
6516  bool can_continue_ : 1;
6517  bool capture_message_ : 1;
6518  bool rethrow_ : 1;
6519  bool has_terminated_ : 1;
6520 
6521  friend class v8::internal::Isolate;
6522 };
6523 
6524 
6525 // --- Context ---
6526 
6527 
6532  public:
6533  ExtensionConfiguration() : name_count_(0), names_(NULL) { }
6534  ExtensionConfiguration(int name_count, const char* names[])
6535  : name_count_(name_count), names_(names) { }
6536 
6537  const char** begin() const { return &names_[0]; }
6538  const char** end() const { return &names_[name_count_]; }
6539 
6540  private:
6541  const int name_count_;
6542  const char** names_;
6543 };
6544 
6545 
6551  public:
6565 
6570  void DetachGlobal();
6571 
6590  static Local<Context> New(
6591  Isolate* isolate,
6592  ExtensionConfiguration* extensions = NULL,
6593  Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
6594  Handle<Value> global_object = Handle<Value>());
6595 
6600  void SetSecurityToken(Handle<Value> token);
6601 
6603  void UseDefaultSecurityToken();
6604 
6606  Handle<Value> GetSecurityToken();
6607 
6614  void Enter();
6615 
6620  void Exit();
6621 
6623  v8::Isolate* GetIsolate();
6624 
6630  enum EmbedderDataFields { kDebugIdIndex = 0 };
6631 
6637  V8_INLINE Local<Value> GetEmbedderData(int index);
6638 
6643  Local<Object> GetExtrasExportsObject();
6644 
6650  void SetEmbedderData(int index, Handle<Value> value);
6651 
6658  V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
6659 
6665  void SetAlignedPointerInEmbedderData(int index, void* value);
6666 
6680  void AllowCodeGenerationFromStrings(bool allow);
6681 
6686  bool IsCodeGenerationFromStringsAllowed();
6687 
6693  void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
6694 
6699  class Scope {
6700  public:
6701  explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
6702  context_->Enter();
6703  }
6704  V8_INLINE ~Scope() { context_->Exit(); }
6705 
6706  private:
6707  Handle<Context> context_;
6708  };
6709 
6710  private:
6711  friend class Value;
6712  friend class Script;
6713  friend class Object;
6714  friend class Function;
6715 
6716  Local<Value> SlowGetEmbedderData(int index);
6717  void* SlowGetAlignedPointerFromEmbedderData(int index);
6718 };
6719 
6720 
6798  public:
6802  V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
6803 
6804  ~Unlocker();
6805  private:
6806  void Initialize(Isolate* isolate);
6807 
6808  internal::Isolate* isolate_;
6809 };
6810 
6811 
6813  public:
6817  V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
6818 
6819  ~Locker();
6820 
6825  static bool IsLocked(Isolate* isolate);
6826 
6830  static bool IsActive();
6831 
6832  private:
6833  void Initialize(Isolate* isolate);
6834 
6835  bool has_lock_;
6836  bool top_level_;
6837  internal::Isolate* isolate_;
6838 
6839  // Disallow copying and assigning.
6840  Locker(const Locker&);
6841  void operator=(const Locker&);
6842 };
6843 
6844 
6845 // --- Implementation ---
6846 
6847 
6848 namespace internal {
6849 
6850 const int kApiPointerSize = sizeof(void*); // NOLINT
6851 const int kApiIntSize = sizeof(int); // NOLINT
6852 const int kApiInt64Size = sizeof(int64_t); // NOLINT
6853 
6854 // Tag information for HeapObject.
6855 const int kHeapObjectTag = 1;
6856 const int kHeapObjectTagSize = 2;
6857 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
6858 
6859 // Tag information for Smi.
6860 const int kSmiTag = 0;
6861 const int kSmiTagSize = 1;
6862 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
6863 
6864 template <size_t ptr_size> struct SmiTagging;
6865 
6866 template<int kSmiShiftSize>
6867 V8_INLINE internal::Object* IntToSmi(int value) {
6868  int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
6869  uintptr_t tagged_value =
6870  (static_cast<uintptr_t>(value) << smi_shift_bits) | kSmiTag;
6871  return reinterpret_cast<internal::Object*>(tagged_value);
6872 }
6873 
6874 // Smi constants for 32-bit systems.
6875 template <> struct SmiTagging<4> {
6876  enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
6877  static int SmiShiftSize() { return kSmiShiftSize; }
6878  static int SmiValueSize() { return kSmiValueSize; }
6879  V8_INLINE static int SmiToInt(const internal::Object* value) {
6880  int shift_bits = kSmiTagSize + kSmiShiftSize;
6881  // Throw away top 32 bits and shift down (requires >> to be sign extending).
6882  return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
6883  }
6884  V8_INLINE static internal::Object* IntToSmi(int value) {
6885  return internal::IntToSmi<kSmiShiftSize>(value);
6886  }
6887  V8_INLINE static bool IsValidSmi(intptr_t value) {
6888  // To be representable as an tagged small integer, the two
6889  // most-significant bits of 'value' must be either 00 or 11 due to
6890  // sign-extension. To check this we add 01 to the two
6891  // most-significant bits, and check if the most-significant bit is 0
6892  //
6893  // CAUTION: The original code below:
6894  // bool result = ((value + 0x40000000) & 0x80000000) == 0;
6895  // may lead to incorrect results according to the C language spec, and
6896  // in fact doesn't work correctly with gcc4.1.1 in some cases: The
6897  // compiler may produce undefined results in case of signed integer
6898  // overflow. The computation must be done w/ unsigned ints.
6899  return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
6900  }
6901 };
6902 
6903 // Smi constants for 64-bit systems.
6904 template <> struct SmiTagging<8> {
6905  enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
6906  static int SmiShiftSize() { return kSmiShiftSize; }
6907  static int SmiValueSize() { return kSmiValueSize; }
6908  V8_INLINE static int SmiToInt(const internal::Object* value) {
6909  int shift_bits = kSmiTagSize + kSmiShiftSize;
6910  // Shift down and throw away top 32 bits.
6911  return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
6912  }
6913  V8_INLINE static internal::Object* IntToSmi(int value) {
6914  return internal::IntToSmi<kSmiShiftSize>(value);
6915  }
6916  V8_INLINE static bool IsValidSmi(intptr_t value) {
6917  // To be representable as a long smi, the value must be a 32-bit integer.
6918  return (value == static_cast<int32_t>(value));
6919  }
6920 };
6921 
6925 V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
6926 V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
6927 
6933 class Internals {
6934  public:
6935  // These values match non-compiler-dependent values defined within
6936  // the implementation of v8.
6937  static const int kHeapObjectMapOffset = 0;
6939  1 * kApiPointerSize + kApiIntSize;
6940  static const int kStringResourceOffset = 3 * kApiPointerSize;
6941 
6942  static const int kOddballKindOffset = 3 * kApiPointerSize;
6944  static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
6945  static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
6946  static const int kContextHeaderSize = 2 * kApiPointerSize;
6947  static const int kContextEmbedderDataIndex = 80;
6948  static const int kFullStringRepresentationMask = 0x07;
6949  static const int kStringEncodingMask = 0x4;
6950  static const int kExternalTwoByteRepresentationTag = 0x02;
6951  static const int kExternalOneByteRepresentationTag = 0x06;
6952 
6955  4 * kApiPointerSize;
6957  kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size;
6958  static const int kIsolateRootsOffset =
6959  kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset + kApiInt64Size +
6961  static const int kUndefinedValueRootIndex = 5;
6962  static const int kNullValueRootIndex = 7;
6963  static const int kTrueValueRootIndex = 8;
6964  static const int kFalseValueRootIndex = 9;
6965  static const int kEmptyStringRootIndex = 10;
6966 
6967  // The external allocation limit should be below 256 MB on all architectures
6968  // to avoid that resource-constrained embedders run low on memory.
6969  static const int kExternalAllocationLimit = 192 * 1024 * 1024;
6970 
6971  static const int kNodeClassIdOffset = 1 * kApiPointerSize;
6972  static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
6973  static const int kNodeStateMask = 0x7;
6974  static const int kNodeStateIsWeakValue = 2;
6975  static const int kNodeStateIsPendingValue = 3;
6976  static const int kNodeStateIsNearDeathValue = 4;
6977  static const int kNodeIsIndependentShift = 3;
6978  static const int kNodeIsPartiallyDependentShift = 4;
6979 
6980  static const int kJSObjectType = 0xbe;
6981  static const int kFirstNonstringType = 0x80;
6982  static const int kOddballType = 0x83;
6983  static const int kForeignType = 0x87;
6984 
6985  static const int kUndefinedOddballKind = 5;
6986  static const int kNullOddballKind = 3;
6987 
6988  static const uint32_t kNumIsolateDataSlots = 4;
6989 
6990  V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
6991  V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
6992 #ifdef V8_ENABLE_CHECKS
6993  CheckInitializedImpl(isolate);
6994 #endif
6995  }
6996 
6997  V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
6998  return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
6999  kHeapObjectTag);
7000  }
7001 
7002  V8_INLINE static int SmiValue(const internal::Object* value) {
7003  return PlatformSmiTagging::SmiToInt(value);
7004  }
7005 
7006  V8_INLINE static internal::Object* IntToSmi(int value) {
7007  return PlatformSmiTagging::IntToSmi(value);
7008  }
7009 
7010  V8_INLINE static bool IsValidSmi(intptr_t value) {
7011  return PlatformSmiTagging::IsValidSmi(value);
7012  }
7013 
7014  V8_INLINE static int GetInstanceType(const internal::Object* obj) {
7015  typedef internal::Object O;
7016  O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
7017  // Map::InstanceType is defined so that it will always be loaded into
7018  // the LS 8 bits of one 16-bit word, regardless of endianess.
7019  return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
7020  }
7021 
7022  V8_INLINE static int GetOddballKind(const internal::Object* obj) {
7023  typedef internal::Object O;
7024  return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
7025  }
7026 
7027  V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
7028  int representation = (instance_type & kFullStringRepresentationMask);
7029  return representation == kExternalTwoByteRepresentationTag;
7030  }
7031 
7032  V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
7033  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
7034  return *addr & static_cast<uint8_t>(1U << shift);
7035  }
7036 
7037  V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
7038  bool value, int shift) {
7039  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
7040  uint8_t mask = static_cast<uint8_t>(1U << shift);
7041  *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
7042  }
7043 
7044  V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
7045  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
7046  return *addr & kNodeStateMask;
7047  }
7048 
7049  V8_INLINE static void UpdateNodeState(internal::Object** obj,
7050  uint8_t value) {
7051  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
7052  *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
7053  }
7054 
7055  V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
7056  uint32_t slot,
7057  void* data) {
7058  uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
7059  kIsolateEmbedderDataOffset + slot * kApiPointerSize;
7060  *reinterpret_cast<void**>(addr) = data;
7061  }
7062 
7063  V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
7064  uint32_t slot) {
7065  const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
7066  kIsolateEmbedderDataOffset + slot * kApiPointerSize;
7067  return *reinterpret_cast<void* const*>(addr);
7068  }
7069 
7070  V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
7071  int index) {
7072  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
7073  return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
7074  }
7075 
7076  template <typename T>
7077  V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
7078  const uint8_t* addr =
7079  reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
7080  return *reinterpret_cast<const T*>(addr);
7081  }
7082 
7083  template <typename T>
7084  V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
7085  typedef internal::Object O;
7086  typedef internal::Internals I;
7087  O* ctx = *reinterpret_cast<O* const*>(context);
7088  int embedder_data_offset = I::kContextHeaderSize +
7089  (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
7090  O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
7091  int value_offset =
7092  I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
7093  return I::ReadField<T>(embedder_data, value_offset);
7094  }
7095 };
7096 
7097 } // namespace internal
7098 
7099 
7100 template <class T>
7102  return New(isolate, that.val_);
7103 }
7104 
7105 template <class T>
7107  return New(isolate, that.val_);
7108 }
7109 
7110 
7111 template <class T>
7112 Local<T> Local<T>::New(Isolate* isolate, T* that) {
7113  if (that == NULL) return Local<T>();
7114  T* that_ptr = that;
7115  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
7116  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
7117  reinterpret_cast<internal::Isolate*>(isolate), *p)));
7118 }
7119 
7120 
7121 template<class T>
7122 template<class S>
7123 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
7124  TYPE_CHECK(T, S);
7125  V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
7126 }
7127 
7128 
7129 template<class T>
7131  return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
7132 }
7133 
7134 
7135 template <class T>
7137  if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
7138  return Local<T>(val_);
7139 }
7140 
7141 
7142 template <class T>
7144 #ifdef V8_ENABLE_CHECKS
7145  if (index < 0 || index >= kInternalFieldsInWeakCallback) {
7146  V8::InternalFieldOutOfBounds(index);
7147  }
7148 #endif
7149  return internal_fields_[index];
7150 }
7151 
7152 
7153 template <class T>
7154 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
7155  if (that == NULL) return NULL;
7156  internal::Object** p = reinterpret_cast<internal::Object**>(that);
7157  return reinterpret_cast<T*>(
7158  V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
7159  p));
7160 }
7161 
7162 
7163 template <class T, class M>
7164 template <class S, class M2>
7166  TYPE_CHECK(T, S);
7167  this->Reset();
7168  if (that.IsEmpty()) return;
7169  internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
7170  this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
7171  M::Copy(that, this);
7172 }
7173 
7174 
7175 template <class T>
7177  typedef internal::Internals I;
7178  if (this->IsEmpty()) return false;
7179  return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
7180  I::kNodeIsIndependentShift);
7181 }
7182 
7183 
7184 template <class T>
7186  typedef internal::Internals I;
7187  if (this->IsEmpty()) return false;
7188  uint8_t node_state =
7189  I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
7190  return node_state == I::kNodeStateIsNearDeathValue ||
7191  node_state == I::kNodeStateIsPendingValue;
7192 }
7193 
7194 
7195 template <class T>
7197  typedef internal::Internals I;
7198  if (this->IsEmpty()) return false;
7199  return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
7200  I::kNodeStateIsWeakValue;
7201 }
7202 
7203 
7204 template <class T>
7206  if (this->IsEmpty()) return;
7207  V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
7208  val_ = 0;
7209 }
7210 
7211 
7212 template <class T>
7213 template <class S>
7214 void PersistentBase<T>::Reset(Isolate* isolate, const Handle<S>& other) {
7215  TYPE_CHECK(T, S);
7216  Reset();
7217  if (other.IsEmpty()) return;
7218  this->val_ = New(isolate, other.val_);
7219 }
7220 
7221 
7222 template <class T>
7223 template <class S>
7225  const PersistentBase<S>& other) {
7226  TYPE_CHECK(T, S);
7227  Reset();
7228  if (other.IsEmpty()) return;
7229  this->val_ = New(isolate, other.val_);
7230 }
7231 
7232 
7233 template <class T>
7234 template <typename S, typename P>
7236  P* parameter,
7237  typename WeakCallbackData<S, P>::Callback callback) {
7238  TYPE_CHECK(S, T);
7239  typedef typename WeakCallbackData<Value, void>::Callback Callback;
7240  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
7241  reinterpret_cast<Callback>(callback));
7242 }
7243 
7244 
7245 template <class T>
7246 template <typename P>
7248  P* parameter,
7249  typename WeakCallbackData<T, P>::Callback callback) {
7250  SetWeak<T, P>(parameter, callback);
7251 }
7252 
7253 
7254 template <class T>
7255 template <typename P>
7257  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
7258  int internal_field_index1, int internal_field_index2) {
7259  typedef typename WeakCallbackInfo<void>::Callback Callback;
7260  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
7261  internal_field_index1, internal_field_index2,
7262  reinterpret_cast<Callback>(callback));
7263 }
7264 
7265 
7266 template <class T>
7267 template <typename P>
7268 V8_INLINE void PersistentBase<T>::SetWeak(
7269  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
7270  WeakCallbackType type) {
7271  typedef typename WeakCallbackInfo<void>::Callback Callback;
7272  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
7273  reinterpret_cast<Callback>(callback), type);
7274 }
7275 
7276 
7277 template <class T>
7278 template <typename P>
7280  return reinterpret_cast<P*>(
7281  V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
7282 }
7283 
7284 
7285 template <class T>
7287  typedef internal::Internals I;
7288  if (this->IsEmpty()) return;
7289  I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
7290  true,
7291  I::kNodeIsIndependentShift);
7292 }
7293 
7294 
7295 template <class T>
7297  typedef internal::Internals I;
7298  if (this->IsEmpty()) return;
7299  I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
7300  true,
7301  I::kNodeIsPartiallyDependentShift);
7302 }
7303 
7304 
7305 template <class T>
7306 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
7307  typedef internal::Internals I;
7308  if (this->IsEmpty()) return;
7309  internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
7310  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
7311  *reinterpret_cast<uint16_t*>(addr) = class_id;
7312 }
7313 
7314 
7315 template <class T>
7317  typedef internal::Internals I;
7318  if (this->IsEmpty()) return 0;
7319  internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
7320  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
7321  return *reinterpret_cast<uint16_t*>(addr);
7322 }
7323 
7324 
7325 template<typename T>
7326 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
7327 
7328 template<typename T>
7329 template<typename S>
7330 void ReturnValue<T>::Set(const Persistent<S>& handle) {
7331  TYPE_CHECK(T, S);
7332  if (V8_UNLIKELY(handle.IsEmpty())) {
7333  *value_ = GetDefaultValue();
7334  } else {
7335  *value_ = *reinterpret_cast<internal::Object**>(*handle);
7336  }
7337 }
7338 
7339 template <typename T>
7340 template <typename S>
7341 void ReturnValue<T>::Set(const Global<S>& handle) {
7342  TYPE_CHECK(T, S);
7343  if (V8_UNLIKELY(handle.IsEmpty())) {
7344  *value_ = GetDefaultValue();
7345  } else {
7346  *value_ = *reinterpret_cast<internal::Object**>(*handle);
7347  }
7348 }
7349 
7350 template <typename T>
7351 template <typename S>
7352 void ReturnValue<T>::Set(const Local<S> handle) {
7353  TYPE_CHECK(T, S);
7354  if (V8_UNLIKELY(handle.IsEmpty())) {
7355  *value_ = GetDefaultValue();
7356  } else {
7357  *value_ = *reinterpret_cast<internal::Object**>(*handle);
7358  }
7359 }
7360 
7361 template<typename T>
7362 void ReturnValue<T>::Set(double i) {
7363  TYPE_CHECK(T, Number);
7364  Set(Number::New(GetIsolate(), i));
7365 }
7366 
7367 template<typename T>
7368 void ReturnValue<T>::Set(int32_t i) {
7369  TYPE_CHECK(T, Integer);
7370  typedef internal::Internals I;
7371  if (V8_LIKELY(I::IsValidSmi(i))) {
7372  *value_ = I::IntToSmi(i);
7373  return;
7374  }
7375  Set(Integer::New(GetIsolate(), i));
7376 }
7377 
7378 template<typename T>
7379 void ReturnValue<T>::Set(uint32_t i) {
7380  TYPE_CHECK(T, Integer);
7381  // Can't simply use INT32_MAX here for whatever reason.
7382  bool fits_into_int32_t = (i & (1U << 31)) == 0;
7383  if (V8_LIKELY(fits_into_int32_t)) {
7384  Set(static_cast<int32_t>(i));
7385  return;
7386  }
7387  Set(Integer::NewFromUnsigned(GetIsolate(), i));
7388 }
7389 
7390 template<typename T>
7391 void ReturnValue<T>::Set(bool value) {
7392  TYPE_CHECK(T, Boolean);
7393  typedef internal::Internals I;
7394  int root_index;
7395  if (value) {
7396  root_index = I::kTrueValueRootIndex;
7397  } else {
7398  root_index = I::kFalseValueRootIndex;
7399  }
7400  *value_ = *I::GetRoot(GetIsolate(), root_index);
7401 }
7402 
7403 template<typename T>
7405  TYPE_CHECK(T, Primitive);
7406  typedef internal::Internals I;
7407  *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
7408 }
7409 
7410 template<typename T>
7412  TYPE_CHECK(T, Primitive);
7413  typedef internal::Internals I;
7414  *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
7415 }
7416 
7417 template<typename T>
7419  TYPE_CHECK(T, String);
7420  typedef internal::Internals I;
7421  *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
7422 }
7423 
7424 template<typename T>
7426  // Isolate is always the pointer below the default value on the stack.
7427  return *reinterpret_cast<Isolate**>(&value_[-2]);
7428 }
7429 
7430 template<typename T>
7431 template<typename S>
7432 void ReturnValue<T>::Set(S* whatever) {
7433  // Uncompilable to prevent inadvertent misuse.
7434  TYPE_CHECK(S*, Primitive);
7435 }
7436 
7437 template<typename T>
7438 internal::Object* ReturnValue<T>::GetDefaultValue() {
7439  // Default value is always the pointer below value_ on the stack.
7440  return value_[-1];
7441 }
7442 
7443 
7444 template<typename T>
7445 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
7446  internal::Object** values,
7447  int length,
7448  bool is_construct_call)
7449  : implicit_args_(implicit_args),
7450  values_(values),
7451  length_(length),
7452  is_construct_call_(is_construct_call) { }
7453 
7454 
7455 template<typename T>
7457  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
7458  return Local<Value>(reinterpret_cast<Value*>(values_ - i));
7459 }
7460 
7461 
7462 template<typename T>
7464  return Local<Function>(reinterpret_cast<Function*>(
7465  &implicit_args_[kCalleeIndex]));
7466 }
7467 
7468 
7469 template<typename T>
7471  return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
7472 }
7473 
7474 
7475 template<typename T>
7477  return Local<Object>(reinterpret_cast<Object*>(
7478  &implicit_args_[kHolderIndex]));
7479 }
7480 
7481 
7482 template<typename T>
7484  return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
7485 }
7486 
7487 
7488 template<typename T>
7490  return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
7491 }
7492 
7493 
7494 template<typename T>
7496  return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
7497 }
7498 
7499 
7500 template<typename T>
7502  return is_construct_call_ & 0x1;
7503 }
7504 
7505 
7506 template<typename T>
7508  return length_;
7509 }
7510 
7512  Handle<Integer> resource_line_offset,
7513  Handle<Integer> resource_column_offset,
7514  Handle<Boolean> resource_is_shared_cross_origin,
7515  Handle<Integer> script_id,
7516  Handle<Boolean> resource_is_embedder_debug_script,
7517  Handle<Value> source_map_url,
7518  Handle<Boolean> resource_is_opaque)
7519  : resource_name_(resource_name),
7520  resource_line_offset_(resource_line_offset),
7521  resource_column_offset_(resource_column_offset),
7522  options_(!resource_is_embedder_debug_script.IsEmpty() &&
7523  resource_is_embedder_debug_script->IsTrue(),
7524  !resource_is_shared_cross_origin.IsEmpty() &&
7525  resource_is_shared_cross_origin->IsTrue(),
7526  !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue()),
7527  script_id_(script_id),
7528  source_map_url_(source_map_url) {}
7529 
7531  return resource_name_;
7532 }
7533 
7534 
7536  return resource_line_offset_;
7537 }
7538 
7539 
7541  return resource_column_offset_;
7542 }
7543 
7544 
7546  return script_id_;
7547 }
7548 
7549 
7550 Handle<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
7551 
7552 
7554  CachedData* data)
7555  : source_string(string),
7556  resource_name(origin.ResourceName()),
7557  resource_line_offset(origin.ResourceLineOffset()),
7558  resource_column_offset(origin.ResourceColumnOffset()),
7559  resource_options(origin.Options()),
7560  source_map_url(origin.SourceMapUrl()),
7561  cached_data(data) {}
7562 
7563 
7565  CachedData* data)
7566  : source_string(string), cached_data(data) {}
7567 
7568 
7570  delete cached_data;
7571 }
7572 
7573 
7575  const {
7576  return cached_data;
7577 }
7578 
7579 
7580 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) {
7581  return value ? True(isolate) : False(isolate);
7582 }
7583 
7584 
7585 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) {
7587  .ToLocalChecked(),
7588  value);
7589 }
7590 
7591 
7593 #ifndef V8_ENABLE_CHECKS
7594  typedef internal::Object O;
7595  typedef internal::HeapObject HO;
7596  typedef internal::Internals I;
7597  O* obj = *reinterpret_cast<O**>(this);
7598  // Fast path: If the object is a plain JSObject, which is the common case, we
7599  // know where to find the internal fields and can return the value directly.
7600  if (I::GetInstanceType(obj) == I::kJSObjectType) {
7601  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
7602  O* value = I::ReadField<O*>(obj, offset);
7603  O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
7604  return Local<Value>(reinterpret_cast<Value*>(result));
7605  }
7606 #endif
7607  return SlowGetInternalField(index);
7608 }
7609 
7610 
7612 #ifndef V8_ENABLE_CHECKS
7613  typedef internal::Object O;
7614  typedef internal::Internals I;
7615  O* obj = *reinterpret_cast<O**>(this);
7616  // Fast path: If the object is a plain JSObject, which is the common case, we
7617  // know where to find the internal fields and can return the value directly.
7618  if (V8_LIKELY(I::GetInstanceType(obj) == I::kJSObjectType)) {
7619  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
7620  return I::ReadField<void*>(obj, offset);
7621  }
7622 #endif
7623  return SlowGetAlignedPointerFromInternalField(index);
7624 }
7625 
7626 
7628 #ifdef V8_ENABLE_CHECKS
7629  CheckCast(value);
7630 #endif
7631  return static_cast<String*>(value);
7632 }
7633 
7634 
7636  typedef internal::Object* S;
7637  typedef internal::Internals I;
7638  I::CheckInitialized(isolate);
7639  S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
7640  return Local<String>(reinterpret_cast<String*>(slot));
7641 }
7642 
7643 
7645  typedef internal::Object O;
7646  typedef internal::Internals I;
7647  O* obj = *reinterpret_cast<O* const*>(this);
7649  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
7650  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
7651  result = reinterpret_cast<String::ExternalStringResource*>(value);
7652  } else {
7653  result = NULL;
7654  }
7655 #ifdef V8_ENABLE_CHECKS
7656  VerifyExternalStringResource(result);
7657 #endif
7658  return result;
7659 }
7660 
7661 
7663  String::Encoding* encoding_out) const {
7664  typedef internal::Object O;
7665  typedef internal::Internals I;
7666  O* obj = *reinterpret_cast<O* const*>(this);
7667  int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
7668  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
7669  ExternalStringResourceBase* resource = NULL;
7670  if (type == I::kExternalOneByteRepresentationTag ||
7671  type == I::kExternalTwoByteRepresentationTag) {
7672  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
7673  resource = static_cast<ExternalStringResourceBase*>(value);
7674  }
7675 #ifdef V8_ENABLE_CHECKS
7676  VerifyExternalStringResourceBase(resource, *encoding_out);
7677 #endif
7678  return resource;
7679 }
7680 
7681 
7682 bool Value::IsUndefined() const {
7683 #ifdef V8_ENABLE_CHECKS
7684  return FullIsUndefined();
7685 #else
7686  return QuickIsUndefined();
7687 #endif
7688 }
7689 
7690 bool Value::QuickIsUndefined() const {
7691  typedef internal::Object O;
7692  typedef internal::Internals I;
7693  O* obj = *reinterpret_cast<O* const*>(this);
7694  if (!I::HasHeapObjectTag(obj)) return false;
7695  if (I::GetInstanceType(obj) != I::kOddballType) return false;
7696  return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
7697 }
7698 
7699 
7700 bool Value::IsNull() const {
7701 #ifdef V8_ENABLE_CHECKS
7702  return FullIsNull();
7703 #else
7704  return QuickIsNull();
7705 #endif
7706 }
7707 
7708 bool Value::QuickIsNull() const {
7709  typedef internal::Object O;
7710  typedef internal::Internals I;
7711  O* obj = *reinterpret_cast<O* const*>(this);
7712  if (!I::HasHeapObjectTag(obj)) return false;
7713  if (I::GetInstanceType(obj) != I::kOddballType) return false;
7714  return (I::GetOddballKind(obj) == I::kNullOddballKind);
7715 }
7716 
7717 
7718 bool Value::IsString() const {
7719 #ifdef V8_ENABLE_CHECKS
7720  return FullIsString();
7721 #else
7722  return QuickIsString();
7723 #endif
7724 }
7725 
7726 bool Value::QuickIsString() const {
7727  typedef internal::Object O;
7728  typedef internal::Internals I;
7729  O* obj = *reinterpret_cast<O* const*>(this);
7730  if (!I::HasHeapObjectTag(obj)) return false;
7731  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
7732 }
7733 
7734 
7735 template <class T> Value* Value::Cast(T* value) {
7736  return static_cast<Value*>(value);
7737 }
7738 
7739 
7741  return ToBoolean(Isolate::GetCurrent()->GetCurrentContext())
7742  .FromMaybe(Local<Boolean>());
7743 }
7744 
7745 
7747  return ToNumber(Isolate::GetCurrent()->GetCurrentContext())
7748  .FromMaybe(Local<Number>());
7749 }
7750 
7751 
7753  return ToString(Isolate::GetCurrent()->GetCurrentContext())
7754  .FromMaybe(Local<String>());
7755 }
7756 
7757 
7759  return ToDetailString(Isolate::GetCurrent()->GetCurrentContext())
7760  .FromMaybe(Local<String>());
7761 }
7762 
7763 
7765  return ToObject(Isolate::GetCurrent()->GetCurrentContext())
7766  .FromMaybe(Local<Object>());
7767 }
7768 
7769 
7771  return ToInteger(Isolate::GetCurrent()->GetCurrentContext())
7772  .FromMaybe(Local<Integer>());
7773 }
7774 
7775 
7777  return ToUint32(Isolate::GetCurrent()->GetCurrentContext())
7778  .FromMaybe(Local<Uint32>());
7779 }
7780 
7781 
7783  return ToInt32(Isolate::GetCurrent()->GetCurrentContext())
7784  .FromMaybe(Local<Int32>());
7785 }
7786 
7787 
7789 #ifdef V8_ENABLE_CHECKS
7790  CheckCast(value);
7791 #endif
7792  return static_cast<Boolean*>(value);
7793 }
7794 
7795 
7797 #ifdef V8_ENABLE_CHECKS
7798  CheckCast(value);
7799 #endif
7800  return static_cast<Name*>(value);
7801 }
7802 
7803 
7805 #ifdef V8_ENABLE_CHECKS
7806  CheckCast(value);
7807 #endif
7808  return static_cast<Symbol*>(value);
7809 }
7810 
7811 
7813 #ifdef V8_ENABLE_CHECKS
7814  CheckCast(value);
7815 #endif
7816  return static_cast<Number*>(value);
7817 }
7818 
7819 
7821 #ifdef V8_ENABLE_CHECKS
7822  CheckCast(value);
7823 #endif
7824  return static_cast<Integer*>(value);
7825 }
7826 
7827 
7829 #ifdef V8_ENABLE_CHECKS
7830  CheckCast(value);
7831 #endif
7832  return static_cast<Int32*>(value);
7833 }
7834 
7835 
7837 #ifdef V8_ENABLE_CHECKS
7838  CheckCast(value);
7839 #endif
7840  return static_cast<Uint32*>(value);
7841 }
7842 
7843 
7845 #ifdef V8_ENABLE_CHECKS
7846  CheckCast(value);
7847 #endif
7848  return static_cast<Date*>(value);
7849 }
7850 
7851 
7853 #ifdef V8_ENABLE_CHECKS
7854  CheckCast(value);
7855 #endif
7856  return static_cast<StringObject*>(value);
7857 }
7858 
7859 
7861 #ifdef V8_ENABLE_CHECKS
7862  CheckCast(value);
7863 #endif
7864  return static_cast<SymbolObject*>(value);
7865 }
7866 
7867 
7869 #ifdef V8_ENABLE_CHECKS
7870  CheckCast(value);
7871 #endif
7872  return static_cast<NumberObject*>(value);
7873 }
7874 
7875 
7877 #ifdef V8_ENABLE_CHECKS
7878  CheckCast(value);
7879 #endif
7880  return static_cast<BooleanObject*>(value);
7881 }
7882 
7883 
7885 #ifdef V8_ENABLE_CHECKS
7886  CheckCast(value);
7887 #endif
7888  return static_cast<RegExp*>(value);
7889 }
7890 
7891 
7893 #ifdef V8_ENABLE_CHECKS
7894  CheckCast(value);
7895 #endif
7896  return static_cast<Object*>(value);
7897 }
7898 
7899 
7901 #ifdef V8_ENABLE_CHECKS
7902  CheckCast(value);
7903 #endif
7904  return static_cast<Array*>(value);
7905 }
7906 
7907 
7909 #ifdef V8_ENABLE_CHECKS
7910  CheckCast(value);
7911 #endif
7912  return static_cast<Map*>(value);
7913 }
7914 
7915 
7916 Set* Set::Cast(v8::Value* value) {
7917 #ifdef V8_ENABLE_CHECKS
7918  CheckCast(value);
7919 #endif
7920  return static_cast<Set*>(value);
7921 }
7922 
7923 
7925 #ifdef V8_ENABLE_CHECKS
7926  CheckCast(value);
7927 #endif
7928  return static_cast<Promise*>(value);
7929 }
7930 
7931 
7933 #ifdef V8_ENABLE_CHECKS
7934  CheckCast(value);
7935 #endif
7936  return static_cast<Promise::Resolver*>(value);
7937 }
7938 
7939 
7941 #ifdef V8_ENABLE_CHECKS
7942  CheckCast(value);
7943 #endif
7944  return static_cast<ArrayBuffer*>(value);
7945 }
7946 
7947 
7949 #ifdef V8_ENABLE_CHECKS
7950  CheckCast(value);
7951 #endif
7952  return static_cast<ArrayBufferView*>(value);
7953 }
7954 
7955 
7957 #ifdef V8_ENABLE_CHECKS
7958  CheckCast(value);
7959 #endif
7960  return static_cast<TypedArray*>(value);
7961 }
7962 
7963 
7965 #ifdef V8_ENABLE_CHECKS
7966  CheckCast(value);
7967 #endif
7968  return static_cast<Uint8Array*>(value);
7969 }
7970 
7971 
7973 #ifdef V8_ENABLE_CHECKS
7974  CheckCast(value);
7975 #endif
7976  return static_cast<Int8Array*>(value);
7977 }
7978 
7979 
7981 #ifdef V8_ENABLE_CHECKS
7982  CheckCast(value);
7983 #endif
7984  return static_cast<Uint16Array*>(value);
7985 }
7986 
7987 
7989 #ifdef V8_ENABLE_CHECKS
7990  CheckCast(value);
7991 #endif
7992  return static_cast<Int16Array*>(value);
7993 }
7994 
7995 
7997 #ifdef V8_ENABLE_CHECKS
7998  CheckCast(value);
7999 #endif
8000  return static_cast<Uint32Array*>(value);
8001 }
8002 
8003 
8005 #ifdef V8_ENABLE_CHECKS
8006  CheckCast(value);
8007 #endif
8008  return static_cast<Int32Array*>(value);
8009 }
8010 
8011 
8013 #ifdef V8_ENABLE_CHECKS
8014  CheckCast(value);
8015 #endif
8016  return static_cast<Float32Array*>(value);
8017 }
8018 
8019 
8021 #ifdef V8_ENABLE_CHECKS
8022  CheckCast(value);
8023 #endif
8024  return static_cast<Float64Array*>(value);
8025 }
8026 
8027 
8029 #ifdef V8_ENABLE_CHECKS
8030  CheckCast(value);
8031 #endif
8032  return static_cast<Uint8ClampedArray*>(value);
8033 }
8034 
8035 
8037 #ifdef V8_ENABLE_CHECKS
8038  CheckCast(value);
8039 #endif
8040  return static_cast<DataView*>(value);
8041 }
8042 
8043 
8045 #ifdef V8_ENABLE_CHECKS
8046  CheckCast(value);
8047 #endif
8048  return static_cast<SharedArrayBuffer*>(value);
8049 }
8050 
8051 
8053 #ifdef V8_ENABLE_CHECKS
8054  CheckCast(value);
8055 #endif
8056  return static_cast<Function*>(value);
8057 }
8058 
8059 
8061 #ifdef V8_ENABLE_CHECKS
8062  CheckCast(value);
8063 #endif
8064  return static_cast<External*>(value);
8065 }
8066 
8067 
8068 template<typename T>
8070  return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
8071 }
8072 
8073 
8074 template<typename T>
8076  return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
8077 }
8078 
8079 
8080 template<typename T>
8082  return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
8083 }
8084 
8085 
8086 template<typename T>
8088  return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
8089 }
8090 
8091 
8092 template<typename T>
8094  return ReturnValue<T>(&args_[kReturnValueIndex]);
8095 }
8096 
8097 
8099  typedef internal::Object* S;
8100  typedef internal::Internals I;
8101  I::CheckInitialized(isolate);
8102  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
8103  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
8104 }
8105 
8106 
8108  typedef internal::Object* S;
8109  typedef internal::Internals I;
8110  I::CheckInitialized(isolate);
8111  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
8112  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
8113 }
8114 
8115 
8117  typedef internal::Object* S;
8118  typedef internal::Internals I;
8119  I::CheckInitialized(isolate);
8120  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
8121  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
8122 }
8123 
8124 
8126  typedef internal::Object* S;
8127  typedef internal::Internals I;
8128  I::CheckInitialized(isolate);
8129  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
8130  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
8131 }
8132 
8133 
8134 void Isolate::SetData(uint32_t slot, void* data) {
8135  typedef internal::Internals I;
8136  I::SetEmbedderData(this, slot, data);
8137 }
8138 
8139 
8140 void* Isolate::GetData(uint32_t slot) {
8141  typedef internal::Internals I;
8142  return I::GetEmbedderData(this, slot);
8143 }
8144 
8145 
8147  typedef internal::Internals I;
8148  return I::kNumIsolateDataSlots;
8149 }
8150 
8151 
8153  int64_t change_in_bytes) {
8154  typedef internal::Internals I;
8155  int64_t* amount_of_external_allocated_memory =
8156  reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
8157  I::kAmountOfExternalAllocatedMemoryOffset);
8158  int64_t* amount_of_external_allocated_memory_at_last_global_gc =
8159  reinterpret_cast<int64_t*>(
8160  reinterpret_cast<uint8_t*>(this) +
8161  I::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset);
8162  int64_t amount = *amount_of_external_allocated_memory + change_in_bytes;
8163  if (change_in_bytes > 0 &&
8164  amount - *amount_of_external_allocated_memory_at_last_global_gc >
8165  I::kExternalAllocationLimit) {
8166  CollectAllGarbage("external memory allocation limit reached.");
8167  }
8168  *amount_of_external_allocated_memory = amount;
8169  return *amount_of_external_allocated_memory;
8170 }
8171 
8172 
8173 template<typename T>
8175  UniqueId id) {
8176  TYPE_CHECK(Value, T);
8177  SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id);
8178 }
8179 
8180 
8181 template<typename T>
8183  const Persistent<T>& object) {
8184  TYPE_CHECK(Value, T);
8185  SetReferenceFromGroup(id,
8186  reinterpret_cast<v8::internal::Object**>(object.val_));
8187 }
8188 
8189 
8190 template<typename T, typename S>
8192  const Persistent<S>& child) {
8193  TYPE_CHECK(Object, T);
8194  TYPE_CHECK(Value, S);
8195  SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_),
8196  reinterpret_cast<v8::internal::Object**>(child.val_));
8197 }
8198 
8199 
8201 #ifndef V8_ENABLE_CHECKS
8202  typedef internal::Object O;
8203  typedef internal::HeapObject HO;
8204  typedef internal::Internals I;
8205  HO* context = *reinterpret_cast<HO**>(this);
8206  O** result =
8207  HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
8208  return Local<Value>(reinterpret_cast<Value*>(result));
8209 #else
8210  return SlowGetEmbedderData(index);
8211 #endif
8212 }
8213 
8214 
8216 #ifndef V8_ENABLE_CHECKS
8217  typedef internal::Internals I;
8218  return I::ReadEmbedderData<void*>(this, index);
8219 #else
8220  return SlowGetAlignedPointerFromEmbedderData(index);
8221 #endif
8222 }
8223 
8224 
8225 void V8::SetAllowCodeGenerationFromStringsCallback(
8227  Isolate* isolate = Isolate::GetCurrent();
8228  isolate->SetAllowCodeGenerationFromStringsCallback(callback);
8229 }
8230 
8231 
8232 bool V8::IsDead() {
8233  Isolate* isolate = Isolate::GetCurrent();
8234  return isolate->IsDead();
8235 }
8236 
8237 
8238 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
8239  Isolate* isolate = Isolate::GetCurrent();
8240  return isolate->AddMessageListener(that, data);
8241 }
8242 
8243 
8244 void V8::RemoveMessageListeners(MessageCallback that) {
8245  Isolate* isolate = Isolate::GetCurrent();
8246  isolate->RemoveMessageListeners(that);
8247 }
8248 
8249 
8250 void V8::SetFailedAccessCheckCallbackFunction(
8251  FailedAccessCheckCallback callback) {
8252  Isolate* isolate = Isolate::GetCurrent();
8253  isolate->SetFailedAccessCheckCallbackFunction(callback);
8254 }
8255 
8256 
8257 void V8::SetCaptureStackTraceForUncaughtExceptions(
8258  bool capture, int frame_limit, StackTrace::StackTraceOptions options) {
8259  Isolate* isolate = Isolate::GetCurrent();
8260  isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit,
8261  options);
8262 }
8263 
8264 
8265 void V8::SetFatalErrorHandler(FatalErrorCallback callback) {
8266  Isolate* isolate = Isolate::GetCurrent();
8267  isolate->SetFatalErrorHandler(callback);
8268 }
8269 
8270 
8271 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) {
8272  Isolate* isolate = Isolate::GetCurrent();
8273  isolate->RemoveGCPrologueCallback(
8274  reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
8275 }
8276 
8277 
8278 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) {
8279  Isolate* isolate = Isolate::GetCurrent();
8280  isolate->RemoveGCEpilogueCallback(
8281  reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
8282 }
8283 
8284 
8285 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
8286  ObjectSpace space,
8287  AllocationAction action) {
8288  Isolate* isolate = Isolate::GetCurrent();
8289  isolate->AddMemoryAllocationCallback(callback, space, action);
8290 }
8291 
8292 
8293 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
8294  Isolate* isolate = Isolate::GetCurrent();
8295  isolate->RemoveMemoryAllocationCallback(callback);
8296 }
8297 
8298 
8299 void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }
8300 
8301 
8302 bool V8::IsExecutionTerminating(Isolate* isolate) {
8303  if (isolate == NULL) {
8304  isolate = Isolate::GetCurrent();
8305  }
8306  return isolate->IsExecutionTerminating();
8307 }
8308 
8309 
8310 void V8::CancelTerminateExecution(Isolate* isolate) {
8311  isolate->CancelTerminateExecution();
8312 }
8313 
8314 
8315 void V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
8316  Isolate* isolate = Isolate::GetCurrent();
8317  isolate->VisitExternalResources(visitor);
8318 }
8319 
8320 
8321 void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
8322  Isolate* isolate = Isolate::GetCurrent();
8323  isolate->VisitHandlesWithClassIds(visitor);
8324 }
8325 
8326 
8327 void V8::VisitHandlesWithClassIds(Isolate* isolate,
8328  PersistentHandleVisitor* visitor) {
8329  isolate->VisitHandlesWithClassIds(visitor);
8330 }
8331 
8332 
8333 void V8::VisitHandlesForPartialDependence(Isolate* isolate,
8334  PersistentHandleVisitor* visitor) {
8335  isolate->VisitHandlesForPartialDependence(visitor);
8336 }
8337 
8350 } // namespace v8
8351 
8352 
8353 #undef TYPE_CHECK
8354 
8355 
8356 #endif // V8_H_
static const int kNodeStateIsWeakValue
Definition: v8.h:6974
size_t total_heap_size()
Definition: v8.h:5008
friend Maybe< U > Nothing()
Definition: v8.h:6358
size_t object_count()
Definition: v8.h:5053
V8_INLINE Handle< Value > ResourceName() const
Definition: v8.h:7530
void(* NamedPropertySetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:4086
static V8_EXPORT void CheckInitializedImpl(v8::Isolate *isolate)
V8_INLINE Eternal()
Definition: v8.h:382
CreateParams()
Definition: v8.h:5200
Definition: v8.h:4901
Definition: v8.h:2415
static V8_INLINE int SmiValue(const internal::Object *value)
Definition: v8.h:7002
static V8_INLINE void UpdateNodeFlag(internal::Object **obj, bool value, int shift)
Definition: v8.h:7037
AddHistogramSampleCallback add_histogram_sample_callback
Definition: v8.h:5248
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8.h:6534
static V8_INLINE Value * Cast(T *value)
Definition: v8.h:6797
friend Local< Boolean > False(Isolate *isolate)
Definition: v8.h:8125
void(* GCEpilogueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:4994
Definition: v8.h:5153
V8_INLINE bool operator==(const Handle< S > &that) const
Definition: v8.h:519
Definition: v8.h:2982
Definition: v8.h:4219
Definition: v8.h:112
Definition: v8.h:3736
void(* GenericNamedPropertyDeleterCallback)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:4153
size_t length() const
Definition: v8.h:4727
V8_INLINE T * operator->() const
Definition: v8.h:234
V8_INLINE bool IsString() const
Definition: v8.h:7718
const char * operator*() const
Definition: v8.h:2398
V8_DEPRECATED("Unused, will be removed", int max_available_threads() const)
Definition: v8.h:4826
JitCodeEventHandler code_event_handler
Definition: v8.h:5222
WeakCallbackData(Isolate *isolate, P *parameter, Local< T > handle)
Definition: v8.h:451
static V8_INLINE DataView * Cast(Value *obj)
Definition: v8.h:8036
V8_INLINE Unlocker(Isolate *isolate)
Definition: v8.h:6802
void *(* CreateHistogramCallback)(const char *name, int min, int max, size_t buckets)
Definition: v8.h:4892
GCCallbackFlags
Definition: v8.h:4986
ArrayBufferCreationMode
Definition: v8.h:3338
static V8_INLINE Symbol * Cast(v8::Value *obj)
Definition: v8.h:7804
static const int kUndefinedValueRootIndex
Definition: v8.h:6961
V8_INLINE void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:8215
static V8_INLINE NumberObject * Cast(v8::Value *obj)
Definition: v8.h:7868
void(* NamedPropertyDeleterCallback)(Local< String > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:4107
Definition: v8.h:1624
static V8_INLINE Function * Cast(Value *obj)
Definition: v8.h:8052
static V8_INLINE int SmiToInt(const internal::Object *value)
Definition: v8.h:6908
static const int kHolderIndex
Definition: v8.h:3151
Definition: v8.h:1647
static const int kOddballType
Definition: v8.h:6982
static const int kIsolateEmbedderDataOffset
Definition: v8.h:6953
V8_INLINE ScriptOriginOptions(bool is_embedder_debug_script=false, bool is_shared_cross_origin=false, bool is_opaque=false)
Definition: v8.h:982
void MoveOnlyTypeForCPP03
Definition: v8.h:834
AllocationAction
Definition: v8.h:4911
Definition: v8.h:5929
V8_INLINE Local< S > FromMaybe(Local< S > default_value) const
Definition: v8.h:370
static int SmiValueSize()
Definition: v8.h:6907
Encoding
Definition: v8.h:2082
V8_INLINE void MarkIndependent()
Definition: v8.h:7286
Definition: v8.h:6550
size_t pos
Definition: v8.h:5130
Definition: v8.h:5168
V8_INLINE void * GetData(uint32_t slot)
Definition: v8.h:8140
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2546
V8_INLINE ReturnValue(const ReturnValue< S > &that)
Definition: v8.h:3048
Definition: v8.h:864
Definition: v8.h:1163
PromiseRejectMessage(Handle< Promise > promise, PromiseRejectEvent event, Handle< Value > value, Handle< StackTrace > stack_trace)
Definition: v8.h:4932
V8_INLINE bool operator!=(const Handle< S > &that) const
Definition: v8.h:532
bool IsSharedCrossOrigin() const
Definition: v8.h:994
V8_INLINE Local< Value > GetInternalField(int index)
Definition: v8.h:7592
GenericNamedPropertySetterCallback setter
Definition: v8.h:4461
Contents()
Definition: v8.h:3388
Maybe< T > Just(const T &t)
Definition: v8.h:6364
V8_DEPRECATED("Unused, will be removed", void set_max_available_threads(int value))
Definition: v8.h:4830
static const int kStringEncodingMask
Definition: v8.h:6949
void * new_code_start
Definition: v8.h:5143
WeakCallbackType
Definition: v8.h:470
Definition: v8.h:5963
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
Definition: v8.h:3334
Definition: v8.h:6864
void * sp
Definition: v8.h:1632
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context) const
Definition: v8.h:3191
NewStringType
Definition: v8.h:2072
Definition: v8.h:1684
static int SmiShiftSize()
Definition: v8.h:6906
bool operator==(const UniqueId &other) const
Definition: v8.h:160
GenericNamedPropertyDeleterCallback deleter
Definition: v8.h:4463
int length_
Definition: v8.h:3127
Definition: v8.h:2538
void Set(Handle< Name > name, Handle< Data > value, PropertyAttribute attributes=None)
NewStringType
Definition: v8.h:2279
V8_INLINE void * GetInternalField(int index) const
Definition: v8.h:7143
V8_INLINE bool IsEmpty()
Definition: v8.h:389
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:4178
Definition: v8.h:5090
size_t space_available_size()
Definition: v8.h:5034
Definition: v8.h:3016
static V8_INLINE internal::Object ** GetRoot(v8::Isolate *isolate, int index)
Definition: v8.h:7070
V8_INLINE bool IsConstructCall() const
Definition: v8.h:7501
Definition: v8.h:3261
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:4188
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:245
Definition: v8.h:1511
V8_INLINE ~Global()
Definition: v8.h:812
static const int kThisIndex
Definition: v8.h:3156
V8_INLINE MaybeLocal()
Definition: v8.h:351
const int kApiIntSize
Definition: v8.h:6851
V8_INLINE Eternal(Isolate *isolate, Local< S > handle)
Definition: v8.h:384
Definition: v8.h:2055
Definition: v8.h:1012
V8_WARN_UNUSED_RESULT MaybeLocal< String > ToDetailString(Local< Context > context) const
Definition: v8.h:7758
PropertyAttribute
Definition: v8.h:2534
static const int kForeignAddressOffset
Definition: v8.h:6943
Definition: v8.h:109
Definition: v8.h:6699
ExternalStringResource()
Definition: v8.h:2227
static V8_INLINE Resolver * Cast(Value *obj)
Definition: v8.h:7932
static const int kCalleeIndex
Definition: v8.h:3118
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:7316
V8_WARN_UNUSED_RESULT MaybeLocal< Boolean > ToBoolean(Local< Context > context) const
Definition: v8.h:7740
void(* MessageCallback)(Handle< Message > message, Handle< Value > error)
Definition: v8.h:4855
Definition: v8.h:4865
IndexedPropertyQueryCallback query
Definition: v8.h:4490
Definition: v8.h:5126
bool auto_enable()
Definition: v8.h:4759
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
Definition: v8.h:5181
const char * data() const
Definition: v8.h:4726
PositionType position_type
Definition: v8.h:5132
const uint16_t * operator*() const
Definition: v8.h:2420
Definition: v8.h:2494
Definition: v8.h:2584
Definition: v8.h:971
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Definition: v8.h:4969
Definition: v8.h:85
V8_INLINE bool IsJust() const
Definition: v8.h:6322
IndexedPropertyEnumeratorCallback enumerator
Definition: v8.h:4492
Definition: v8.h:114
const int kApiPointerSize
Definition: v8.h:6850
static const int kDataIndex
Definition: v8.h:3117
V8_INLINE Persistent(const Persistent< S, M2 > &that)
Definition: v8.h:723
Definition: v8.h:121
static V8_INLINE Map * Cast(Value *obj)
Definition: v8.h:7908
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:7306
Definition: v8.h:3887
void(* NamedPropertyGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:4077
Definition: v8.h:4504
Definition: v8.h:5092
V8_INLINE Local< T > Get(Isolate *isolate)
Definition: v8.h:7130
V8_INLINE V8_DEPRECATE_SOON("Use Global<> instead", void Set(const Persistent< S > &handle))
ObjectSpace
Definition: v8.h:4900
static V8_INLINE TypedArray * Cast(Value *obj)
Definition: v8.h:7956
Definition: v8.h:4737
Definition: v8.h:1431
Definition: v8.h:5151
CounterLookupCallback counter_lookup_callback
Definition: v8.h:5239
static const int kHeapObjectMapOffset
Definition: v8.h:6937
Definition: v8.h:2536
void(* NamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:4116
Definition: v8.h:5005
Definition: v8.h:5028
Definition: v8.h:4904
WriteOptions
Definition: v8.h:2136
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, v8::NewStringType type, int length=-1)
static Local< Number > New(Isolate *isolate, double value)
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:4198
Definition: v8.h:5048
Definition: v8.h:1624
V8_INLINE Local< Function > Callee() const
Definition: v8.h:7463
virtual ~Allocator()
Definition: v8.h:3356
PositionType
Definition: v8.h:5102
Definition: v8.h:3700
Definition: v8.h:4990
size_t heap_size_limit()
Definition: v8.h:5013
Definition: v8.h:1128
internal::Object ** values_
Definition: v8.h:3126
Flags
Definition: v8.h:3943
IndexedPropertyGetterCallback getter
Definition: v8.h:4488
void SetSecondPassCallback(Callback callback) const
Definition: v8.h:436
Definition: v8.h:5102
Definition: v8.h:3682
V8_INLINE Local< S > As()
Definition: v8.h:288
static const int kFullStringRepresentationMask
Definition: v8.h:6948
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:4852
V8_INLINE void Reset()
Definition: v8.h:7205
static V8_INLINE int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8.h:2765
static V8_INLINE uint8_t GetNodeState(internal::Object **obj)
Definition: v8.h:7044
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:269
static int SmiValueSize()
Definition: v8.h:6878
static V8_INLINE T ReadEmbedderData(const v8::Context *context, int index)
Definition: v8.h:7084
V8_INLINE Persistent & operator=(const Persistent &that)
Definition: v8.h:726
V8_INLINE Persistent< S > & As()
Definition: v8.h:756
char * operator*()
Definition: v8.h:2397
bool(* IndexedSecurityCallback)(Local< Object > host, uint32_t index, AccessType type, Local< Value > data)
Definition: v8.h:4237
V8_INLINE Isolate * GetIsolate()
Definition: v8.h:7425
V8_INLINE Handle< Boolean > True(Isolate *isolate)
Definition: v8.h:8116
internal::Object ** args_
Definition: v8.h:3159
static const int kNullOddballKind
Definition: v8.h:6986
void * Data() const
Definition: v8.h:3390
Maybe< T > Nothing()
Definition: v8.h:6358
V8_INLINE Local< Object > Holder() const
Definition: v8.h:7476
static const int kLineOffsetNotFound
Definition: v8.h:3249
static V8_INLINE void UpdateNodeState(internal::Object **obj, uint8_t value)
Definition: v8.h:7049
int length
Definition: v8.h:1150
size_t space_used_size()
Definition: v8.h:5033
V8_INLINE MaybeLocal(Local< S > that)
Definition: v8.h:353
V8_INLINE void SetData(uint32_t slot, void *data)
Definition: v8.h:8134
static Isolate * GetCurrent()
static V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:6913
virtual v8::Handle< v8::FunctionTemplate > GetNativeFunctionTemplate(v8::Isolate *isolate, v8::Handle< v8::String > name)
Definition: v8.h:4747
Definition: v8.h:4982
void(* GenericNamedPropertyGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:4126
CompileOptions
Definition: v8.h:1282
static V8_INLINE Handle< Boolean > New(Isolate *isolate, bool value)
Definition: v8.h:7580
Definition: v8.h:4906
const int kSmiTag
Definition: v8.h:6860
friend class ReturnValue
Definition: v8.h:3077
V8_INLINE V8_DEPRECATE_SOON("use WeakCallbackInfo version", void SetWeak(P *parameter, typename WeakCallbackData< T, P >::Callback callback))
V8_INLINE PromiseRejectEvent GetEvent() const
Definition: v8.h:4940
bool operator<(const UniqueId &other) const
Definition: v8.h:168
Definition: v8.h:116
V8_WARN_UNUSED_RESULT MaybeLocal< Int32 > ToInt32(Local< Context > context) const
Definition: v8.h:7782
bool IsFirstPass() const
Definition: v8.h:428
StateTag vm_state
Definition: v8.h:1640
void * fp
Definition: v8.h:1633
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:7495
V8_INLINE Handle< Value > SourceMapUrl() const
Definition: v8.h:7550
V8_INLINE ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:7644
Definition: v8.h:136
V8_INLINE Local< T > GetValue() const
Definition: v8.h:456
V8_INLINE int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Definition: v8.h:8152
const int kSmiTagSize
Definition: v8.h:6861
static V8_INLINE void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8.h:7055
static V8_INLINE int GetInstanceType(const internal::Object *obj)
Definition: v8.h:7014
const String::ExternalOneByteStringResource * source() const
Definition: v8.h:4754
V8_WARN_UNUSED_RESULT MaybeLocal< String > ToString(Local< Context > context) const
Definition: v8.h:7752
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:5956
~Scope()
Definition: v8.h:5268
Definition: v8.h:3749
PropertyHandlerFlags
Definition: v8.h:4429
static const int kReturnValueIndex
Definition: v8.h:3116
V8_INLINE bool IsNearDeath() const
Definition: v8.h:7185
V8_INLINE T FromJust() const
Definition: v8.h:6325
Definition: v8.h:2575
Definition: v8.h:2042
const char * data
Definition: v8.h:5931
JitCodeEventOptions
Definition: v8.h:5150
static const int kFixedArrayHeaderSize
Definition: v8.h:6945
void(* GCPrologueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:4993
static const int kDataIndex
Definition: v8.h:3155
size_t used_heap_size()
Definition: v8.h:5012
V8_INLINE ScriptOrigin(Handle< Value > resource_name, Handle< Integer > resource_line_offset=Handle< Integer >(), Handle< Integer > resource_column_offset=Handle< Integer >(), Handle< Boolean > resource_is_shared_cross_origin=Handle< Boolean >(), Handle< Integer > script_id=Handle< Integer >(), Handle< Boolean > resource_is_embedder_debug_script=Handle< Boolean >(), Handle< Value > source_map_url=Handle< Value >(), Handle< Boolean > resource_is_opaque=Handle< Boolean >())
Definition: v8.h:7511
static V8_INLINE ArrayBufferView * Cast(Value *obj)
Definition: v8.h:7948
V8_INLINE HandleScope()
Definition: v8.h:880
Definition: v8.h:2393
const intptr_t kSmiTagMask
Definition: v8.h:6862
CachedData()
Definition: v8.h:1134
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:454
void Enter()
void(* InterruptCallback)(Isolate *isolate, void *data)
Definition: v8.h:4996
StartupData * snapshot_blob
Definition: v8.h:5232
Definition: v8.h:4988
V8_INLINE void Empty()
Definition: v8.h:508
static V8_INLINE uint8_t GetNodeFlag(internal::Object **obj, int shift)
Definition: v8.h:7032
static V8_INLINE Promise * Cast(Value *obj)
Definition: v8.h:7924
Definition: v8.h:4217
BufferPolicy buffer_policy
Definition: v8.h:1152
const int kSmiValueSize
Definition: v8.h:6924
void(* GenericNamedPropertyQueryCallback)(Local< Name > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:4144
IndexedPropertySetterCallback setter
Definition: v8.h:4489
size_t code_len
Definition: v8.h:5109
size_t len
Definition: v8.h:5123
bool operator!=(const UniqueId &other) const
Definition: v8.h:164
V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:6867
struct line_info_t line_info
Definition: v8.h:5140
UniqueId(intptr_t data)
Definition: v8.h:157
Definition: v8.h:4930
V8_INLINE ~EscapableHandleScope()
Definition: v8.h:920
V8_INLINE void ClearWeak()
Definition: v8.h:578
Definition: v8.h:3937
V8_INLINE Local()
Definition: v8.h:212
V8_INLINE ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:7662
virtual void VisitExternalString(Handle< String > string)
Definition: v8.h:5171
V8_INLINE Handle< Boolean > False(Isolate *isolate)
Definition: v8.h:8125
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:7101
V8_INLINE Handle< Integer > ScriptID() const
Definition: v8.h:7545
virtual ~ExternalStringResource()
Definition: v8.h:2214
V8_INLINE void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
Definition: v8.h:7235
static const int kArgsLength
Definition: v8.h:3108
PropertyHandlerFlags flags
Definition: v8.h:4466
static const int kArgsLength
Definition: v8.h:3145
Definition: v8.h:4903
Definition: v8.h:3263
EventType type
Definition: v8.h:5105
static const int kContextHeaderSize
Definition: v8.h:6946
static const bool kResetInDestructor
Definition: v8.h:651
V8_WARN_UNUSED_RESULT MaybeLocal< Number > ToNumber(Local< Context > context) const
Definition: v8.h:7746
int is_construct_call_
Definition: v8.h:3128
virtual void Dispose()
Definition: v8.h:2191
WeakCallbackInfo(Isolate *isolate, T *parameter, void *internal_fields[kInternalFieldsInWeakCallback], Callback *callback)
Definition: v8.h:406
Definition: v8.h:3345
static V8_INLINE Float64Array * Cast(Value *obj)
Definition: v8.h:8020
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:415
V8_INLINE T * operator*() const
Definition: v8.h:236
size_t total_physical_size()
Definition: v8.h:5010
V8_INLINE Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:709
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
int raw_size
Definition: v8.h:5932
bool IsOpaque() const
Definition: v8.h:997
static V8_INLINE String * Cast(v8::Value *obj)
Definition: v8.h:7627
Global Pass()
Definition: v8.h:829
void * pc
Definition: v8.h:1631
int length() const
Definition: v8.h:2399
size_t ByteLength() const
Definition: v8.h:3754
V8_INLINE ~Scope()
Definition: v8.h:6704
friend class PersistentBase
Definition: v8.h:625
static internal::Object ** CreateHandle(internal::Isolate *isolate, internal::Object *value)
Definition: v8.h:66
static void * JSStackComparableAddress(v8::TryCatch *handler)
Definition: v8.h:6496
Definition: v8.h:5118
V8_INLINE Local< Object > Holder() const
Definition: v8.h:8087
Definition: v8.h:124
V8_INLINE Handle< Primitive > Null(Isolate *isolate)
Definition: v8.h:8107
const int kHeapObjectTag
Definition: v8.h:6855
Definition: v8.h:4215
void(* AccessorNameGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2549
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:875
static const int kNodeStateMask
Definition: v8.h:6973
static const int kReturnValueDefaultValueIndex
Definition: v8.h:3115
void(* MemoryAllocationCallback)(ObjectSpace space, AllocationAction action, int size)
Definition: v8.h:4917
Definition: v8.h:4981
Definition: v8.h:1624
Definition: v8.h:3169
StateTag
Definition: v8.h:1624
Definition: v8.h:5178
static V8_INLINE StringObject * Cast(v8::Value *obj)
Definition: v8.h:7852
V8_INLINE void Clear()
Definition: v8.h:232
static V8_INLINE Set * Cast(Value *obj)
Definition: v8.h:7916
Definition: v8.h:946
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
Definition: v8.h:8191
const char * object_sub_type()
Definition: v8.h:5052
Definition: v8.h:2078
AccessType
Definition: v8.h:4214
int max_semi_space_size() const
Definition: v8.h:4817
static const int kNullValueRootIndex
Definition: v8.h:6962
GenericNamedPropertyEnumeratorCallback enumerator
Definition: v8.h:4464
void(* LogEventCallback)(const char *name, int event)
Definition: v8.h:4859
static V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:7006
const intptr_t kHeapObjectTagMask
Definition: v8.h:6857
GenericNamedPropertyQueryCallback query
Definition: v8.h:4462
Definition: v8.h:4693
static V8_INLINE Persistent< T > & Cast(Persistent< S > &that)
Definition: v8.h:746
Definition: v8.h:1629
int max_old_space_size() const
Definition: v8.h:4819
static V8_INLINE Uint8Array * Cast(Value *obj)
Definition: v8.h:7964
static const int kNodeStateIsPendingValue
Definition: v8.h:6975
const char * name() const
Definition: v8.h:4752
size_t total_heap_size_executable()
Definition: v8.h:5009
static const int kContextSaveIndex
Definition: v8.h:3119
Definition: v8.h:3718
Definition: v8.h:4902
static V8_INLINE Float32Array * Cast(Value *obj)
Definition: v8.h:8012
static const uint32_t kNumIsolateDataSlots
Definition: v8.h:6988
size_t physical_space_size()
Definition: v8.h:5035
V8_INLINE Locker(Isolate *isolate)
Definition: v8.h:6817
Definition: v8.h:2523
virtual ~ExternalResourceVisitor()
Definition: v8.h:5170
void set_code_range_size(size_t value)
Definition: v8.h:4835
Definition: v8.h:6933
void(* FunctionCallback)(const FunctionCallbackInfo< Value > &info)
Definition: v8.h:3163
static V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:6884
Definition: v8.h:3646
static const int kJSObjectType
Definition: v8.h:6980
Definition: v8.h:5088
V8_INLINE Global & operator=(Global< S > &&rhs)
Definition: v8.h:817
Definition: v8.h:4912
void SetAllowCodeGenerationFromStringsCallback(AllowCodeGenerationFromStringsCallback callback)
void(* Callback)(const WeakCallbackInfo< T > &data)
Definition: v8.h:404
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:4897
Definition: v8.h:4338
Definition: v8.h:2480
V8_INLINE Handle< Integer > ResourceLineOffset() const
Definition: v8.h:7535
Definition: v8.h:1624
static V8_INLINE Name * Cast(v8::Value *obj)
Definition: v8.h:7796
static V8_INLINE void Copy(const Persistent< S, M > &source, CopyablePersistent *dest)
Definition: v8.h:673
void SetObjectGroupId(const Persistent< T > &object, UniqueId id)
Definition: v8.h:8174
V8_INLINE bool operator!=(const Maybe &other) const
Definition: v8.h:6339
Definition: v8.h:1119
StackTraceOptions
Definition: v8.h:1517
static const int kNodeIsIndependentShift
Definition: v8.h:6977
EmbedderDataFields
Definition: v8.h:6630
Definition: v8.h:2535
static const int kUndefinedOddballKind
Definition: v8.h:6985
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter=0, GenericNamedPropertySetterCallback setter=0, GenericNamedPropertyQueryCallback query=0, GenericNamedPropertyDeleterCallback deleter=0, GenericNamedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:4443
void set_max_executable_size(int value)
Definition: v8.h:4822
void * code_start
Definition: v8.h:5107
const int kHeapObjectTagSize
Definition: v8.h:6856
SmiTagging< kApiPointerSize > PlatformSmiTagging
Definition: v8.h:6922
friend Maybe< U > Just(const U &u)
const char * str
Definition: v8.h:5121
V8_INLINE Local< Value > Data() const
Definition: v8.h:8075
Definition: v8.h:4708
ArrayBuffer::Allocator * array_buffer_allocator
Definition: v8.h:5254
Definition: v8.h:4795
Definition: v8.h:111
size_t source_length() const
Definition: v8.h:4753
Definition: v8.h:3871
size_t frames_count
Definition: v8.h:1639
RegisterState()
Definition: v8.h:1630
V8_INLINE void Set(const Global< S > &handle)
Definition: v8.h:1079
Definition: v8.h:2444
Definition: v8.h:2537
ExternalStringResourceBase()
Definition: v8.h:2183
size_t offset
Definition: v8.h:5128
void set_max_old_space_size(int value)
Definition: v8.h:4820
Definition: v8.h:1638
V8_INLINE bool operator!=(const PersistentBase< S > &that) const
Definition: v8.h:528
void(* CallCompletedCallback)()
Definition: v8.h:4922
static V8_INLINE void Uncompilable()
Definition: v8.h:658
Definition: v8.h:4216
Persistent< T, CopyablePersistentTraits< T > > CopyablePersistent
Definition: v8.h:670
Definition: v8.h:2953
void(* PromiseRejectCallback)(PromiseRejectMessage message)
Definition: v8.h:4953
friend class Utils
Definition: v8.h:620
bool IsEmbedderDebugScript() const
Definition: v8.h:991
Definition: v8.h:119
int dependency_count()
Definition: v8.h:4756
V8_INLINE void Set(Isolate *isolate, Local< S > handle)
V8_INLINE bool IsIndependent() const
Definition: v8.h:7176
V8_INLINE Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8.h:731
V8_INLINE Global(Global &&other)
Definition: v8.h:809
static V8_INLINE v8::Local< v8::String > Empty(Isolate *isolate)
Definition: v8.h:7635
static V8_INLINE uint32_t GetNumberOfDataSlots()
Definition: v8.h:8146
void(* Callback)(const WeakCallbackData< T, P > &data)
Definition: v8.h:449
static V8_INLINE Number * Cast(v8::Value *obj)
Definition: v8.h:7812
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:7611
static const int kReturnValueIndex
Definition: v8.h:3154
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:511
Definition: v8.h:3488
V8_INLINE Local< Value > Data() const
Definition: v8.h:7483
FunctionEntryHook entry_hook
Definition: v8.h:5216
V8_INLINE void MarkPartiallyDependent()
Definition: v8.h:7296
static V8_INLINE void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8.h:653
Definition: v8.h:3556
PropertyHandlerFlags flags
Definition: v8.h:4494
ExternalOneByteStringResource()
Definition: v8.h:2253
Definition: v8.h:145
V8_INLINE bool operator!=(const Persistent< S > &that) const
Definition: v8.h:273
virtual ~Extension()
Definition: v8.h:4746
EventType
Definition: v8.h:5089
void(* AccessorSetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:2554
V8_INLINE Local< Object > This() const
Definition: v8.h:7470
Definition: v8.h:4913
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:7489
Definition: v8.h:1563
V8_INLINE Handle< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:8098
friend Local< Primitive > Null(Isolate *isolate)
Definition: v8.h:8107
const char ** begin() const
Definition: v8.h:6537
Definition: v8.h:5091
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:4169
Definition: v8.h:125
V8_INLINE P * ClearWeak()
static V8_INLINE RegExp * Cast(v8::Value *obj)
Definition: v8.h:7884
V8_INLINE bool IsEmpty() const
Definition: v8.h:507
static const int kIsolateRootsOffset
Definition: v8.h:6958
Definition: v8.h:2577
V8_INLINE Local< T > ToLocalChecked()
Definition: v8.h:7136
ExternalOneByteStringResourceImpl(const char *data, size_t length)
Definition: v8.h:4724
Definition: v8.h:118
static const int kNodeIsPartiallyDependentShift
Definition: v8.h:6978
static int SmiShiftSize()
Definition: v8.h:6877
void(* AccessorNameSetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:2558
Definition: v8.h:4983
Definition: v8.h:1668
V8_INLINE Persistent()
Definition: v8.h:693
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local< S > *out) const
Definition: v8.h:361
void set_max_semi_space_size(int value)
Definition: v8.h:4818
V8_INLINE bool IsWeak() const
Definition: v8.h:7196
static const int kExternalTwoByteRepresentationTag
Definition: v8.h:6950
V8_INLINE ScriptOriginOptions Options() const
Definition: v8.h:1031
static V8_INLINE void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8.h:7063
static V8_INLINE Local< T > Cast(Local< S > that)
Definition: v8.h:278
Definition: v8.h:2574
void set_auto_enable(bool value)
Definition: v8.h:4758
PromiseRejectEvent
Definition: v8.h:4925
static const int kFirstNonstringType
Definition: v8.h:6981
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: v8.h:3536
Definition: v8.h:4005
virtual ~ExternalSourceStream()
Definition: v8.h:1204
static const int kIsolateIndex
Definition: v8.h:3114
bool(* NamedSecurityCallback)(Local< Object > host, Local< Value > key, AccessType type, Local< Value > data)
Definition: v8.h:4227
int length() const
Definition: v8.h:2421
internal::StreamedSource * impl() const
Definition: v8.h:1262
void * user_data
Definition: v8.h:5116
V8_INLINE ScriptOriginOptions(int flags)
Definition: v8.h:988
static const int kHolderIndex
Definition: v8.h:3113
static V8_INLINE void CheckInitialized(v8::Isolate *isolate)
Definition: v8.h:6991
V8_INLINE bool IsNothing() const
Definition: v8.h:6321
static const int kExternalAllocationLimit
Definition: v8.h:6969
static V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8.h:7010
static const int kForeignType
Definition: v8.h:6983
GarbageCollectionType
Definition: v8.h:5340
Definition: v8.h:123
Definition: v8.h:3386
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
Definition: v8.h:3478
IndexedPropertyDeleterCallback deleter
Definition: v8.h:4491
Definition: v8.h:4905
Definition: v8.h:3574
V8_INLINE int Length() const
Definition: v8.h:7507
V8_INLINE Global()
Definition: v8.h:785
void(* GenericNamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:4161
Definition: v8.h:2576
V8_INLINE Persistent(Isolate *isolate, Handle< S > that)
Definition: v8.h:699
V8_INLINE Global(Isolate *isolate, Handle< S > that)
Definition: v8.h:792
Handle< Value > data
Definition: v8.h:4465
void(* MicrotaskCallback)(void *data)
Definition: v8.h:4956
V8_WARN_UNUSED_RESULT MaybeLocal< Uint32 > ToUint32(Local< Context > context) const
Definition: v8.h:7776
V8_INLINE T * GetParameter() const
Definition: v8.h:416
static V8_INLINE bool IsExternalTwoByteString(int instance_type)
Definition: v8.h:7027
V8_INLINE void SetUndefined()
Definition: v8.h:7411
void SetReferenceFromGroup(UniqueId id, const Persistent< T > &child)
Definition: v8.h:8182
static V8_INLINE BooleanObject * Cast(v8::Value *obj)
Definition: v8.h:7876
const char ** end() const
Definition: v8.h:6538
static const int kAmountOfExternalAllocatedMemoryOffset
Definition: v8.h:6954
Definition: v8.h:6372
Definition: v8.h:2035
Definition: v8.h:1527
friend class Isolate
Definition: v8.h:619
virtual ~ExternalOneByteStringResource()
Definition: v8.h:2247
static V8_INLINE SharedArrayBuffer * Cast(Value *obj)
Definition: v8.h:8044
static const int kReturnValueDefaultValueIndex
Definition: v8.h:3153
static const int kStringResourceOffset
Definition: v8.h:6940
Definition: v8.h:1624
V8_INLINE Handle< Value > GetValue() const
Definition: v8.h:4941
Definition: v8.h:3834
V8_INLINE Handle< Integer > ResourceColumnOffset() const
Definition: v8.h:7540
Definition: v8.h:155
V8_INLINE P * GetParameter() const
Definition: v8.h:455
static const int kMapInstanceTypeAndBitFieldOffset
Definition: v8.h:6938
V8_INLINE Persistent(const Persistent &that)
Definition: v8.h:719
static const int kNodeClassIdOffset
Definition: v8.h:6971
V8_INLINE V8_DEPRECATE_SOON("use indexed version", void *GetInternalField2() const)
Definition: v8.h:423
uint32_t * stack_limit() const
Definition: v8.h:4823
static V8_INLINE bool HasHeapObjectTag(const internal::Object *value)
Definition: v8.h:6997
Definition: v8.h:3354
Definition: v8.h:3664
Definition: v8.h:447
friend class internal::FunctionCallbackArguments
Definition: v8.h:3111
Definition: v8.h:5194
Definition: v8.h:3921
Definition: v8.h:4926
static const int kJSObjectHeaderSize
Definition: v8.h:6944
friend class MacroAssembler
Definition: v8.h:3148
Definition: v8.h:3989
Scope(Isolate *isolate)
Definition: v8.h:5264
V8_INLINE void SetEmptyString()
Definition: v8.h:7418
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:2784
internal::Object ** implicit_args_
Definition: v8.h:3125
BufferPolicy
Definition: v8.h:1129
int max_executable_size() const
Definition: v8.h:4821
GCType
Definition: v8.h:4980
static V8_INLINE External * Cast(Value *obj)
Definition: v8.h:8060
#define TYPE_CHECK(T, S)
Definition: v8.h:178
Definition: v8.h:2509
Definition: v8.h:5262
bool rejected
Definition: v8.h:1151
friend Local< Boolean > True(Isolate *isolate)
Definition: v8.h:8116
V8_INLINE void SetNull()
Definition: v8.h:7404
static V8_INLINE Int32Array * Cast(Value *obj)
Definition: v8.h:8004
Definition: v8.h:3592
Definition: v8.h:917
static V8_INLINE SymbolObject * Cast(v8::Value *obj)
Definition: v8.h:7860
static V8_INLINE Integer * Cast(v8::Value *obj)
Definition: v8.h:7820
Definition: v8.h:3628
V8_INLINE FunctionCallbackInfo(internal::Object **implicit_args, internal::Object **values, int length, bool is_construct_call)
Definition: v8.h:7445
uint16_t * operator*()
Definition: v8.h:2419
virtual ~ExternalStringResourceBase()
Definition: v8.h:2180
Definition: v8.h:3610
Definition: v8.h:3903
Definition: v8.h:980
Definition: v8.h:1624
Definition: v8.h:129
Definition: v8.h:6531
static V8_INLINE Date * Cast(v8::Value *obj)
Definition: v8.h:7844
friend class Utils
Definition: v8.h:762
void * Data() const
Definition: v8.h:3753
V8_INLINE Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:802
V8_INLINE Local< Value > operator[](int i) const
Definition: v8.h:7456
V8_INLINE Local(Local< S > that)
Definition: v8.h:214
static V8_INLINE int GetOddballKind(const internal::Object *obj)
Definition: v8.h:7022
CreateHistogramCallback create_histogram_callback
Definition: v8.h:5247
static V8_INLINE int SmiToInt(const internal::Object *value)
Definition: v8.h:6879
static V8_INLINE Array * Cast(Value *obj)
Definition: v8.h:7900
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:927
const int kApiInt64Size
Definition: v8.h:6852
static const int kTrueValueRootIndex
Definition: v8.h:6963
static const int kEmptyStringRootIndex
Definition: v8.h:6965
Handle< Value > data
Definition: v8.h:4493
V8_INLINE Handle< Promise > GetPromise() const
Definition: v8.h:4939
V8_INLINE Local< Object > This() const
Definition: v8.h:8081
V8_INLINE bool IsNull() const
Definition: v8.h:7700
V8_INLINE ~Persistent()
Definition: v8.h:740
void(* GenericNamedPropertySetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:4134
V8_WARN_UNUSED_RESULT MaybeLocal< Integer > ToInteger(Local< Context > context) const
Definition: v8.h:7770
V8_INLINE T FromMaybe(const T &default_value) const
Definition: v8.h:6330
V8_INLINE Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=NULL)
Definition: v8.h:7553
V8_INLINE PropertyCallbackInfo(internal::Object **args)
Definition: v8.h:3158
size_t code_range_size() const
Definition: v8.h:4834
static V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8.h:6916
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
Definition: v8.h:5080
static V8_INLINE Boolean * Cast(v8::Value *obj)
Definition: v8.h:7788
Definition: v8.h:6812
GenericNamedPropertyGetterCallback getter
Definition: v8.h:4460
static V8_INLINE Object * Cast(Value *obj)
Definition: v8.h:7892
static V8_INLINE Uint8ClampedArray * Cast(Value *obj)
Definition: v8.h:8028
static V8_INLINE T ReadField(const internal::Object *ptr, int offset)
Definition: v8.h:7077
Definition: v8.h:669
static const int kContextEmbedderDataIndex
Definition: v8.h:6947
static const int kNodeStateIsNearDeathValue
Definition: v8.h:6976
static V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8.h:6887
Definition: v8.h:4218
static const int kExternalOneByteRepresentationTag
Definition: v8.h:6951
const uint8_t * data
Definition: v8.h:1149
static V8_INLINE ArrayBuffer * Cast(Value *obj)
Definition: v8.h:7940
Contents()
Definition: v8.h:3751
int Flags() const
Definition: v8.h:998
Definition: v8.h:5199
#define V8_EXPORT
Definition: v8.h:58
static const int kNodeFlagsOffset
Definition: v8.h:6972
static V8_INLINE Uint32Array * Cast(Value *obj)
Definition: v8.h:7996
Definition: v8.h:402
void V8_EXPORT RegisterExtension(Extension *extension)
friend class Utils
Definition: v8.h:302
UseCounterFeature
Definition: v8.h:5350
virtual ~ScriptStreamingTask()
Definition: v8.h:1278
AccessControl
Definition: v8.h:2573
static const bool kResetInDestructor
Definition: v8.h:671
Definition: v8.h:1046
static V8_INLINE Int8Array * Cast(Value *obj)
Definition: v8.h:7972
virtual ~PersistentHandleVisitor()
Definition: v8.h:5180
Definition: v8.h:4914
int *(* CounterLookupCallback)(const char *name)
Definition: v8.h:4890
V8_INLINE bool IsUndefined() const
Definition: v8.h:7682
ResourceConstraints constraints
Definition: v8.h:5227
void SetIndexedPropertyHandler(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=0, IndexedPropertyQueryCallback query=0, IndexedPropertyDeleterCallback deleter=0, IndexedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >())
Definition: v8.h:4610
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:4207
static V8_INLINE Int32 * Cast(v8::Value *obj)
Definition: v8.h:7828
size_t total_available_size()
Definition: v8.h:5011
static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset
Definition: v8.h:6956
size_t ByteLength() const
Definition: v8.h:3391
static const int kFalseValueRootIndex
Definition: v8.h:6964
void set_stack_limit(uint32_t *value)
Definition: v8.h:4825
V8_DEPRECATED("Use GetUnboundScript()->GetId()", int GetId())
Definition: v8.h:1109
V8_WARN_UNUSED_RESULT MaybeLocal< Object > ToObject(Local< Context > context) const
Definition: v8.h:7764
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:8069
V8_INLINE V8_DEPRECATE_SOON("use indexed version", void *GetInternalField1() const)
Definition: v8.h:419
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:5162
const int kSmiShiftSize
Definition: v8.h:6923
V8_INLINE Local< Value > GetEmbedderData(int index)
Definition: v8.h:8200
V8_INLINE bool operator==(const Maybe &other) const
Definition: v8.h:6334
static const int kIsolateIndex
Definition: v8.h:3152
V8_INLINE bool IsEmpty() const
Definition: v8.h:227
Definition: v8.h:4678
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:8093
Definition: v8.h:130
static const int kOddballKindOffset
Definition: v8.h:6942
Definition: v8.h:4987
const char ** dependencies()
Definition: v8.h:4757
const char * space_name()
Definition: v8.h:5031
size_t object_size()
Definition: v8.h:5054
static V8_INLINE Int16Array * Cast(Value *obj)
Definition: v8.h:7988
V8_INLINE ~Source()
Definition: v8.h:7569
static V8_INLINE Uint32 * Cast(v8::Value *obj)
Definition: v8.h:7836
Persistent< T, NonCopyablePersistentTraits< T > > NonCopyablePersistent
Definition: v8.h:650
V8_INLINE Handle< StackTrace > GetStackTrace() const
Definition: v8.h:4944
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:5940
ExternalOneByteStringResourceImpl()
Definition: v8.h:4723
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:4959
void(* NamedPropertyQueryCallback)(Local< String > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:4097
V8_INLINE const CachedData * GetCachedData() const
Definition: v8.h:7574
const char * object_type()
Definition: v8.h:5051
friend Local< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:8098
ExtensionConfiguration()
Definition: v8.h:6533
Handle< UnboundScript > script
Definition: v8.h:5111
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:253
V8_INLINE bool IsEmpty() const
Definition: v8.h:358
V8_INLINE Scope(Handle< Context > context)
Definition: v8.h:6701
static V8_INLINE Uint16Array * Cast(Value *obj)
Definition: v8.h:7980
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter=0, IndexedPropertySetterCallback setter=0, IndexedPropertyQueryCallback query=0, IndexedPropertyDeleterCallback deleter=0, IndexedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:4471
size_t space_size()
Definition: v8.h:5032