v8
v8.h
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 Signature;
98 class StartupData;
99 class StackFrame;
100 class StackTrace;
101 class String;
102 class StringObject;
103 class Symbol;
104 class SymbolObject;
105 class Private;
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>
123 class GlobalValueMap;
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  friend class Private;
315  template<class F> friend class internal::CustomArguments;
316  friend Local<Primitive> Undefined(Isolate* isolate);
317  friend Local<Primitive> Null(Isolate* isolate);
318  friend Local<Boolean> True(Isolate* isolate);
319  friend Local<Boolean> False(Isolate* isolate);
320  friend class HandleScope;
321  friend class EscapableHandleScope;
322  template <class F1, class F2, class F3>
323  friend class PersistentValueMapBase;
324  template<class F1, class F2> friend class PersistentValueVector;
325 
326  template <class S>
327  V8_INLINE Local(S* that)
328  : val_(that) {}
329  V8_INLINE static Local<T> New(Isolate* isolate, T* that);
330  T* val_;
331 };
332 
333 
334 // Handle is an alias for Local for historical reasons.
335 template <class T>
336 using Handle = Local<T>;
337 
338 
349 template <class T>
350 class MaybeLocal {
351  public:
352  V8_INLINE MaybeLocal() : val_(nullptr) {}
353  template <class S>
354  V8_INLINE MaybeLocal(Local<S> that)
355  : val_(reinterpret_cast<T*>(*that)) {
356  TYPE_CHECK(T, S);
357  }
358 
359  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
360 
361  template <class S>
362  V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
363  out->val_ = IsEmpty() ? nullptr : this->val_;
364  return !IsEmpty();
365  }
366 
367  // Will crash if the MaybeLocal<> is empty.
368  V8_INLINE Local<T> ToLocalChecked();
369 
370  template <class S>
371  V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
372  return IsEmpty() ? default_value : Local<S>(val_);
373  }
374 
375  private:
376  T* val_;
377 };
378 
379 
380 // Eternal handles are set-once handles that live for the life of the isolate.
381 template <class T> class Eternal {
382  public:
383  V8_INLINE Eternal() : index_(kInitialValue) { }
384  template<class S>
385  V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) {
386  Set(isolate, handle);
387  }
388  // Can only be safely called if already set.
389  V8_INLINE Local<T> Get(Isolate* isolate);
390  V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
391  template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
392 
393  private:
394  static const int kInitialValue = -1;
395  int index_;
396 };
397 
398 
399 static const int kInternalFieldsInWeakCallback = 2;
400 
401 
402 template <typename T>
404  public:
405  typedef void (*Callback)(const WeakCallbackInfo<T>& data);
406 
407  WeakCallbackInfo(Isolate* isolate, T* parameter,
408  void* internal_fields[kInternalFieldsInWeakCallback],
409  Callback* callback)
410  : isolate_(isolate), parameter_(parameter), callback_(callback) {
411  for (int i = 0; i < kInternalFieldsInWeakCallback; ++i) {
412  internal_fields_[i] = internal_fields[i];
413  }
414  }
415 
416  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
417  V8_INLINE T* GetParameter() const { return parameter_; }
418  V8_INLINE void* GetInternalField(int index) const;
419 
420  V8_INLINE V8_DEPRECATE_SOON("use indexed version",
421  void* GetInternalField1()) const {
422  return internal_fields_[0];
423  }
424  V8_INLINE V8_DEPRECATE_SOON("use indexed version",
425  void* GetInternalField2()) const {
426  return internal_fields_[1];
427  }
428 
429  bool IsFirstPass() const { return callback_ != nullptr; }
430 
431  // When first called, the embedder MUST Reset() the Global which triggered the
432  // callback. The Global itself is unusable for anything else. No v8 other api
433  // calls may be called in the first callback. Should additional work be
434  // required, the embedder must set a second pass callback, which will be
435  // called after all the initial callbacks are processed.
436  // Calling SetSecondPassCallback on the second pass will immediately crash.
437  void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
438 
439  private:
440  Isolate* isolate_;
441  T* parameter_;
442  Callback* callback_;
443  void* internal_fields_[kInternalFieldsInWeakCallback];
444 };
445 
446 
447 template <class T, class P>
449  public:
450  typedef void (*Callback)(const WeakCallbackData<T, P>& data);
451 
452  WeakCallbackData(Isolate* isolate, P* parameter, Local<T> handle)
453  : isolate_(isolate), parameter_(parameter), handle_(handle) {}
454 
455  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
456  V8_INLINE P* GetParameter() const { return parameter_; }
457  V8_INLINE Local<T> GetValue() const { return handle_; }
458 
459  private:
460  Isolate* isolate_;
461  P* parameter_;
462  Local<T> handle_;
463 };
464 
465 
466 // TODO(dcarney): delete this with WeakCallbackData
467 template <class T>
469 
470 
471 enum class WeakCallbackType { kParameter, kInternalFields };
472 
473 
487 template <class T> class PersistentBase {
488  public:
493  V8_INLINE void Reset();
498  template <class S>
499  V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
500 
505  template <class S>
506  V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
507 
508  V8_INLINE bool IsEmpty() const { return val_ == NULL; }
509  V8_INLINE void Empty() { val_ = 0; }
510 
511  template <class S>
512  V8_INLINE bool operator==(const PersistentBase<S>& that) const {
513  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
514  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
515  if (a == NULL) return b == NULL;
516  if (b == NULL) return false;
517  return *a == *b;
518  }
519 
520  template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
521  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
522  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
523  if (a == NULL) return b == NULL;
524  if (b == NULL) return false;
525  return *a == *b;
526  }
527 
528  template <class S>
529  V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
530  return !operator==(that);
531  }
532 
533  template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
534  return !operator==(that);
535  }
536 
544  template <typename P>
545  V8_INLINE V8_DEPRECATE_SOON(
546  "use WeakCallbackInfo version",
547  void SetWeak(P* parameter,
548  typename WeakCallbackData<T, P>::Callback callback));
549 
550  template <typename S, typename P>
551  V8_INLINE V8_DEPRECATE_SOON(
552  "use WeakCallbackInfo version",
553  void SetWeak(P* parameter,
554  typename WeakCallbackData<S, P>::Callback callback));
555 
556  // Phantom persistents work like weak persistents, except that the pointer to
557  // the object being collected is not available in the finalization callback.
558  // This enables the garbage collector to collect the object and any objects
559  // it references transitively in one GC cycle. At the moment you can either
560  // specify a parameter for the callback or the location of two internal
561  // fields in the dying object.
562  template <typename P>
563  V8_INLINE V8_DEPRECATE_SOON(
564  "use SetWeak",
565  void SetPhantom(P* parameter,
566  typename WeakCallbackInfo<P>::Callback callback,
567  int internal_field_index1 = -1,
568  int internal_field_index2 = -1));
569 
570  template <typename P>
571  V8_INLINE void SetWeak(P* parameter,
572  typename WeakCallbackInfo<P>::Callback callback,
573  WeakCallbackType type);
574 
575  template<typename P>
576  V8_INLINE P* ClearWeak();
577 
578  // TODO(dcarney): remove this.
579  V8_INLINE void ClearWeak() { ClearWeak<void>(); }
580 
587  V8_INLINE void MarkIndependent();
588 
597  V8_INLINE void MarkPartiallyDependent();
598 
599  V8_INLINE bool IsIndependent() const;
600 
602  V8_INLINE bool IsNearDeath() const;
603 
605  V8_INLINE bool IsWeak() const;
606 
611  V8_INLINE void SetWrapperClassId(uint16_t class_id);
612 
617  V8_INLINE uint16_t WrapperClassId() const;
618 
619  private:
620  friend class Isolate;
621  friend class Utils;
622  template<class F> friend class Local;
623  template<class F1, class F2> friend class Persistent;
624  template <class F>
625  friend class Global;
626  template<class F> friend class PersistentBase;
627  template<class F> friend class ReturnValue;
628  template <class F1, class F2, class F3>
629  friend class PersistentValueMapBase;
630  template<class F1, class F2> friend class PersistentValueVector;
631  friend class Object;
632 
633  explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
634  PersistentBase(PersistentBase& other) = delete; // NOLINT
635  void operator=(PersistentBase&) = delete;
636  V8_INLINE static T* New(Isolate* isolate, T* that);
637 
638  T* val_;
639 };
640 
641 
648 template<class T>
649 class NonCopyablePersistentTraits {
650  public:
651  typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
652  static const bool kResetInDestructor = false;
653  template<class S, class M>
654  V8_INLINE static void Copy(const Persistent<S, M>& source,
655  NonCopyablePersistent* dest) {
656  Uncompilable<Object>();
657  }
658  // TODO(dcarney): come up with a good compile error here.
659  template<class O> V8_INLINE static void Uncompilable() {
660  TYPE_CHECK(O, Primitive);
661  }
662 };
663 
664 
669 template<class T>
672  static const bool kResetInDestructor = true;
673  template<class S, class M>
674  static V8_INLINE void Copy(const Persistent<S, M>& source,
675  CopyablePersistent* dest) {
676  // do nothing, just allow copy
677  }
678 };
679 
680 
689 template <class T, class M> class Persistent : public PersistentBase<T> {
690  public:
694  V8_INLINE Persistent() : PersistentBase<T>(0) { }
700  template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that)
701  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
702  TYPE_CHECK(T, S);
703  }
709  template <class S, class M2>
710  V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
711  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
712  TYPE_CHECK(T, S);
713  }
720  V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(0) {
721  Copy(that);
722  }
723  template <class S, class M2>
724  V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) {
725  Copy(that);
726  }
727  V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
728  Copy(that);
729  return *this;
730  }
731  template <class S, class M2>
732  V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT
733  Copy(that);
734  return *this;
735  }
741  V8_INLINE ~Persistent() {
742  if (M::kResetInDestructor) this->Reset();
743  }
744 
745  // TODO(dcarney): this is pretty useless, fix or remove
746  template <class S>
747  V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
748 #ifdef V8_ENABLE_CHECKS
749  // If we're going to perform the type check then we have to check
750  // that the handle isn't empty before doing the checked cast.
751  if (!that.IsEmpty()) T::Cast(*that);
752 #endif
753  return reinterpret_cast<Persistent<T>&>(that);
754  }
755 
756  // TODO(dcarney): this is pretty useless, fix or remove
757  template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
758  return Persistent<S>::Cast(*this);
759  }
760 
761  private:
762  friend class Isolate;
763  friend class Utils;
764  template<class F> friend class Local;
765  template<class F1, class F2> friend class Persistent;
766  template<class F> friend class ReturnValue;
767 
768  template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
769  V8_INLINE T* operator*() const { return this->val_; }
770  template<class S, class M2>
771  V8_INLINE void Copy(const Persistent<S, M2>& that);
772 };
773 
774 
780 template <class T>
781 class Global : public PersistentBase<T> {
782  public:
786  V8_INLINE Global() : PersistentBase<T>(nullptr) {}
792  template <class S>
793  V8_INLINE Global(Isolate* isolate, Handle<S> that)
794  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
795  TYPE_CHECK(T, S);
796  }
802  template <class S>
803  V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
804  : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
805  TYPE_CHECK(T, S);
806  }
810  V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {
811  other.val_ = nullptr;
812  }
813  V8_INLINE ~Global() { this->Reset(); }
817  template <class S>
818  V8_INLINE Global& operator=(Global<S>&& rhs) {
819  TYPE_CHECK(T, S);
820  if (this != &rhs) {
821  this->Reset();
822  this->val_ = rhs.val_;
823  rhs.val_ = nullptr;
824  }
825  return *this;
826  }
830  Global Pass() { return static_cast<Global&&>(*this); }
831 
832  /*
833  * For compatibility with Chromium's base::Bind (base::Passed).
834  */
835  typedef void MoveOnlyTypeForCPP03;
836 
837  private:
838  Global(Global&) = delete;
839  void operator=(Global&) = delete;
840 };
841 
842 
843 // UniquePersistent is an alias for Global for historical reason.
844 template <class T>
845 using UniquePersistent = Global<T>;
846 
847 
862 class V8_EXPORT HandleScope {
863  public:
864  HandleScope(Isolate* isolate);
865 
866  ~HandleScope();
867 
871  static int NumberOfHandles(Isolate* isolate);
872 
873  V8_INLINE Isolate* GetIsolate() const {
874  return reinterpret_cast<Isolate*>(isolate_);
875  }
876 
877  protected:
878  V8_INLINE HandleScope() {}
879 
880  void Initialize(Isolate* isolate);
881 
882  static internal::Object** CreateHandle(internal::Isolate* isolate,
883  internal::Object* value);
884 
885  private:
886  // Uses heap_object to obtain the current Isolate.
887  static internal::Object** CreateHandle(internal::HeapObject* heap_object,
888  internal::Object* value);
889 
890  // Make it hard to create heap-allocated or illegal handle scopes by
891  // disallowing certain operations.
892  HandleScope(const HandleScope&);
893  void operator=(const HandleScope&);
894  void* operator new(size_t size);
895  void operator delete(void*, size_t);
896 
897  internal::Isolate* isolate_;
898  internal::Object** prev_next_;
899  internal::Object** prev_limit_;
900 
901  // Local::New uses CreateHandle with an Isolate* parameter.
902  template<class F> friend class Local;
903 
904  // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
905  // a HeapObject* in their shortcuts.
906  friend class Object;
907  friend class Context;
908 };
909 
910 
915 class V8_EXPORT EscapableHandleScope : public HandleScope {
916  public:
917  EscapableHandleScope(Isolate* isolate);
918  V8_INLINE ~EscapableHandleScope() {}
919 
924  template <class T>
925  V8_INLINE Local<T> Escape(Local<T> value) {
926  internal::Object** slot =
927  Escape(reinterpret_cast<internal::Object**>(*value));
928  return Local<T>(reinterpret_cast<T*>(slot));
929  }
930 
931  private:
932  internal::Object** Escape(internal::Object** escape_value);
933 
934  // Make it hard to create heap-allocated or illegal handle scopes by
935  // disallowing certain operations.
937  void operator=(const EscapableHandleScope&);
938  void* operator new(size_t size);
939  void operator delete(void*, size_t);
940 
941  internal::Object** escape_slot_;
942 };
943 
944 class V8_EXPORT SealHandleScope {
945  public:
946  SealHandleScope(Isolate* isolate);
947  ~SealHandleScope();
948 
949  private:
950  // Make it hard to create heap-allocated or illegal handle scopes by
951  // disallowing certain operations.
953  void operator=(const SealHandleScope&);
954  void* operator new(size_t size);
955  void operator delete(void*, size_t);
956 
957  internal::Isolate* isolate_;
958  int prev_level_;
959  internal::Object** prev_limit_;
960 };
961 
962 
963 // --- Special objects ---
964 
965 
969 class V8_EXPORT Data {
970  private:
971  Data();
972 };
973 
974 
979  public:
980  V8_INLINE ScriptOrigin(
981  Handle<Value> resource_name,
982  Handle<Integer> resource_line_offset = Handle<Integer>(),
983  Handle<Integer> resource_column_offset = Handle<Integer>(),
984  Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
985  Handle<Integer> script_id = Handle<Integer>(),
986  Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(),
987  Handle<Value> source_map_url = Handle<Value>())
988  : resource_name_(resource_name),
989  resource_line_offset_(resource_line_offset),
990  resource_column_offset_(resource_column_offset),
991  resource_is_embedder_debug_script_(resource_is_embedder_debug_script),
992  resource_is_shared_cross_origin_(resource_is_shared_cross_origin),
993  script_id_(script_id),
994  source_map_url_(source_map_url) {}
995  V8_INLINE Handle<Value> ResourceName() const;
996  V8_INLINE Handle<Integer> ResourceLineOffset() const;
997  V8_INLINE Handle<Integer> ResourceColumnOffset() const;
1002  V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const;
1003  V8_INLINE Handle<Integer> ScriptID() const;
1004  V8_INLINE Handle<Value> SourceMapUrl() const;
1005 
1006  private:
1007  Handle<Value> resource_name_;
1008  Handle<Integer> resource_line_offset_;
1009  Handle<Integer> resource_column_offset_;
1010  Handle<Boolean> resource_is_embedder_debug_script_;
1011  Handle<Boolean> resource_is_shared_cross_origin_;
1012  Handle<Integer> script_id_;
1013  Handle<Value> source_map_url_;
1014 };
1015 
1016 
1020 class V8_EXPORT UnboundScript {
1021  public:
1025  Local<Script> BindToCurrentContext();
1026 
1027  int GetId();
1028  Handle<Value> GetScriptName();
1029 
1033  Handle<Value> GetSourceURL();
1037  Handle<Value> GetSourceMappingURL();
1038 
1043  int GetLineNumber(int code_pos);
1044 
1045  static const int kNoScriptId = 0;
1046 };
1047 
1048 
1053 class V8_EXPORT Script {
1054  public:
1058  static V8_DEPRECATE_SOON(
1059  "Use maybe version",
1060  Local<Script> Compile(Handle<String> source,
1061  ScriptOrigin* origin = nullptr));
1062  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
1063  Local<Context> context, Handle<String> source,
1064  ScriptOrigin* origin = nullptr);
1065 
1066  static Local<Script> V8_DEPRECATE_SOON("Use maybe version",
1067  Compile(Handle<String> source,
1068  Handle<String> file_name));
1069 
1075  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run());
1076  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Run(Local<Context> context);
1077 
1081  Local<UnboundScript> GetUnboundScript();
1082 
1083  V8_DEPRECATED("Use GetUnboundScript()->GetId()",
1084  int GetId()) {
1085  return GetUnboundScript()->GetId();
1086  }
1087 };
1088 
1089 
1093 class V8_EXPORT ScriptCompiler {
1094  public:
1102  struct V8_EXPORT CachedData {
1103  enum BufferPolicy {
1104  BufferNotOwned,
1105  BufferOwned
1106  };
1107 
1108  CachedData()
1109  : data(NULL),
1110  length(0),
1111  rejected(false),
1112  buffer_policy(BufferNotOwned) {}
1113 
1114  // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
1115  // data and guarantees that it stays alive until the CachedData object is
1116  // destroyed. If the policy is BufferOwned, the given data will be deleted
1117  // (with delete[]) when the CachedData object is destroyed.
1118  CachedData(const uint8_t* data, int length,
1119  BufferPolicy buffer_policy = BufferNotOwned);
1120  ~CachedData();
1121  // TODO(marja): Async compilation; add constructors which take a callback
1122  // which will be called when V8 no longer needs the data.
1123  const uint8_t* data;
1124  int length;
1125  bool rejected;
1126  BufferPolicy buffer_policy;
1127 
1128  private:
1129  // Prevent copying. Not implemented.
1130  CachedData(const CachedData&);
1131  CachedData& operator=(const CachedData&);
1132  };
1133 
1137  class Source {
1138  public:
1139  // Source takes ownership of CachedData.
1140  V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1141  CachedData* cached_data = NULL);
1142  V8_INLINE Source(Local<String> source_string,
1143  CachedData* cached_data = NULL);
1144  V8_INLINE ~Source();
1145 
1146  // Ownership of the CachedData or its buffers is *not* transferred to the
1147  // caller. The CachedData object is alive as long as the Source object is
1148  // alive.
1149  V8_INLINE const CachedData* GetCachedData() const;
1150 
1151  private:
1152  friend class ScriptCompiler;
1153  // Prevent copying. Not implemented.
1154  Source(const Source&);
1155  Source& operator=(const Source&);
1156 
1157  Local<String> source_string;
1158 
1159  // Origin information
1160  Handle<Value> resource_name;
1161  Handle<Integer> resource_line_offset;
1162  Handle<Integer> resource_column_offset;
1163  Handle<Boolean> resource_is_embedder_debug_script;
1164  Handle<Boolean> resource_is_shared_cross_origin;
1165  Handle<Value> source_map_url;
1166 
1167  // Cached data from previous compilation (if a kConsume*Cache flag is
1168  // set), or hold newly generated cache data (kProduce*Cache flags) are
1169  // set when calling a compile method.
1170  CachedData* cached_data;
1171  };
1172 
1178  public:
1179  virtual ~ExternalSourceStream() {}
1180 
1198  virtual size_t GetMoreData(const uint8_t** src) = 0;
1199  };
1200 
1201 
1208  class V8_EXPORT StreamedSource {
1209  public:
1210  enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1211 
1212  StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
1213  ~StreamedSource();
1214 
1215  // Ownership of the CachedData or its buffers is *not* transferred to the
1216  // caller. The CachedData object is alive as long as the StreamedSource
1217  // object is alive.
1218  const CachedData* GetCachedData() const;
1219 
1220  internal::StreamedSource* impl() const { return impl_; }
1221 
1222  private:
1223  // Prevent copying. Not implemented.
1225  StreamedSource& operator=(const StreamedSource&);
1226 
1227  internal::StreamedSource* impl_;
1228  };
1229 
1235  public:
1236  virtual ~ScriptStreamingTask() {}
1237  virtual void Run() = 0;
1238  };
1239 
1240  enum CompileOptions {
1241  kNoCompileOptions = 0,
1242  kProduceParserCache,
1243  kConsumeParserCache,
1244  kProduceCodeCache,
1245  kConsumeCodeCache,
1246 
1247  // Support the previous API for a transition period.
1248  kProduceDataToCache
1249  };
1250 
1264  static V8_DEPRECATE_SOON("Use maybe version",
1265  Local<UnboundScript> CompileUnbound(
1266  Isolate* isolate, Source* source,
1267  CompileOptions options = kNoCompileOptions));
1268  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript(
1269  Isolate* isolate, Source* source,
1270  CompileOptions options = kNoCompileOptions);
1271 
1283  static V8_DEPRECATE_SOON(
1284  "Use maybe version",
1285  Local<Script> Compile(Isolate* isolate, Source* source,
1286  CompileOptions options = kNoCompileOptions));
1287  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
1288  Local<Context> context, Source* source,
1289  CompileOptions options = kNoCompileOptions);
1290 
1302  static ScriptStreamingTask* StartStreamingScript(
1303  Isolate* isolate, StreamedSource* source,
1304  CompileOptions options = kNoCompileOptions);
1305 
1313  static V8_DEPRECATE_SOON(
1314  "Use maybe version",
1315  Local<Script> Compile(Isolate* isolate, StreamedSource* source,
1316  Handle<String> full_source_string,
1317  const ScriptOrigin& origin));
1318  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
1319  Local<Context> context, StreamedSource* source,
1320  Handle<String> full_source_string, const ScriptOrigin& origin);
1321 
1340  static uint32_t CachedDataVersionTag();
1341 
1350  static V8_DEPRECATE_SOON(
1351  "Use maybe version",
1352  Local<Script> CompileModule(Isolate* isolate, Source* source,
1353  CompileOptions options = kNoCompileOptions));
1354  static V8_WARN_UNUSED_RESULT MaybeLocal<Script> CompileModule(
1355  Local<Context> context, Source* source,
1356  CompileOptions options = kNoCompileOptions);
1357 
1368  static V8_DEPRECATE_SOON("Use maybe version",
1369  Local<Function> CompileFunctionInContext(
1370  Isolate* isolate, Source* source,
1371  Local<Context> context, size_t arguments_count,
1372  Local<String> arguments[],
1373  size_t context_extension_count,
1374  Local<Object> context_extensions[]));
1375  static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
1376  Local<Context> context, Source* source, size_t arguments_count,
1377  Local<String> arguments[], size_t context_extension_count,
1378  Local<Object> context_extensions[]);
1379 
1380  private:
1381  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
1382  Isolate* isolate, Source* source, CompileOptions options, bool is_module);
1383 };
1384 
1385 
1389 class V8_EXPORT Message {
1390  public:
1391  Local<String> Get() const;
1392 
1393  V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine()) const;
1394  V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
1395  Local<Context> context) const;
1396 
1401  ScriptOrigin GetScriptOrigin() const;
1402 
1407  Handle<Value> GetScriptResourceName() const;
1408 
1414  Handle<StackTrace> GetStackTrace() const;
1415 
1419  V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber()) const;
1420  V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
1421 
1426  int GetStartPosition() const;
1427 
1432  int GetEndPosition() const;
1433 
1438  V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn()) const;
1439  V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const;
1440 
1445  V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn()) const;
1446  V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
1447 
1452  bool IsSharedCrossOrigin() const;
1453 
1454  // TODO(1245381): Print to a string instead of on a FILE.
1455  static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1456 
1457  static const int kNoLineNumberInfo = 0;
1458  static const int kNoColumnInfo = 0;
1459  static const int kNoScriptIdInfo = 0;
1460 };
1461 
1462 
1468 class V8_EXPORT StackTrace {
1469  public:
1475  kLineNumber = 1,
1476  kColumnOffset = 1 << 1 | kLineNumber,
1477  kScriptName = 1 << 2,
1478  kFunctionName = 1 << 3,
1479  kIsEval = 1 << 4,
1480  kIsConstructor = 1 << 5,
1481  kScriptNameOrSourceURL = 1 << 6,
1482  kScriptId = 1 << 7,
1483  kExposeFramesAcrossSecurityOrigins = 1 << 8,
1484  kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
1485  kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
1486  };
1487 
1491  Local<StackFrame> GetFrame(uint32_t index) const;
1492 
1496  int GetFrameCount() const;
1497 
1501  Local<Array> AsArray();
1502 
1510  static Local<StackTrace> CurrentStackTrace(
1511  Isolate* isolate,
1512  int frame_limit,
1513  StackTraceOptions options = kOverview);
1514 };
1515 
1516 
1520 class V8_EXPORT StackFrame {
1521  public:
1528  int GetLineNumber() const;
1529 
1537  int GetColumn() const;
1538 
1545  int GetScriptId() const;
1546 
1551  Local<String> GetScriptName() const;
1552 
1559  Local<String> GetScriptNameOrSourceURL() const;
1560 
1564  Local<String> GetFunctionName() const;
1565 
1570  bool IsEval() const;
1571 
1576  bool IsConstructor() const;
1577 };
1578 
1579 
1580 // A StateTag represents a possible state of the VM.
1581 enum StateTag { JS, GC, COMPILER, OTHER, EXTERNAL, IDLE };
1582 
1583 
1584 // A RegisterState represents the current state of registers used
1585 // by the sampling profiler API.
1587  RegisterState() : pc(NULL), sp(NULL), fp(NULL) {}
1588  void* pc; // Instruction pointer.
1589  void* sp; // Stack pointer.
1590  void* fp; // Frame pointer.
1591 };
1592 
1593 
1594 // The output structure filled up by GetStackSample API function.
1595 struct SampleInfo {
1596  size_t frames_count;
1597  StateTag vm_state;
1598 };
1599 
1600 
1604 class V8_EXPORT JSON {
1605  public:
1613  static V8_DEPRECATE_SOON("Use maybe version",
1614  Local<Value> Parse(Local<String> json_string));
1615  static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
1616  Isolate* isolate, Local<String> json_string);
1617 };
1618 
1619 
1625 class V8_EXPORT NativeWeakMap : public Data {
1626  public:
1627  static Local<NativeWeakMap> New(Isolate* isolate);
1628  void Set(Handle<Value> key, Handle<Value> value);
1629  Local<Value> Get(Handle<Value> key);
1630  bool Has(Handle<Value> key);
1631  bool Delete(Handle<Value> key);
1632 };
1633 
1634 
1635 // --- Value ---
1636 
1637 
1641 class V8_EXPORT Value : public Data {
1642  public:
1647  V8_INLINE bool IsUndefined() const;
1648 
1653  V8_INLINE bool IsNull() const;
1654 
1658  bool IsTrue() const;
1659 
1663  bool IsFalse() const;
1664 
1669  bool IsName() const;
1670 
1675  V8_INLINE bool IsString() const;
1676 
1681  bool IsSymbol() const;
1682 
1686  bool IsFunction() const;
1687 
1691  bool IsArray() const;
1692 
1696  bool IsObject() const;
1697 
1701  bool IsBoolean() const;
1702 
1706  bool IsNumber() const;
1707 
1711  bool IsExternal() const;
1712 
1716  bool IsInt32() const;
1717 
1721  bool IsUint32() const;
1722 
1726  bool IsDate() const;
1727 
1731  bool IsArgumentsObject() const;
1732 
1736  bool IsBooleanObject() const;
1737 
1741  bool IsNumberObject() const;
1742 
1746  bool IsStringObject() const;
1747 
1752  bool IsSymbolObject() const;
1753 
1757  bool IsNativeError() const;
1758 
1762  bool IsRegExp() const;
1763 
1768  bool IsGeneratorFunction() const;
1769 
1774  bool IsGeneratorObject() const;
1775 
1780  bool IsPromise() const;
1781 
1786  bool IsMap() const;
1787 
1792  bool IsSet() const;
1793 
1798  bool IsMapIterator() const;
1799 
1804  bool IsSetIterator() const;
1805 
1810  bool IsWeakMap() const;
1811 
1816  bool IsWeakSet() const;
1817 
1822  bool IsArrayBuffer() const;
1823 
1828  bool IsArrayBufferView() const;
1829 
1834  bool IsTypedArray() const;
1835 
1840  bool IsUint8Array() const;
1841 
1846  bool IsUint8ClampedArray() const;
1847 
1852  bool IsInt8Array() const;
1853 
1858  bool IsUint16Array() const;
1859 
1864  bool IsInt16Array() const;
1865 
1870  bool IsUint32Array() const;
1871 
1876  bool IsInt32Array() const;
1877 
1882  bool IsFloat32Array() const;
1883 
1888  bool IsFloat64Array() const;
1889 
1894  bool IsDataView() const;
1895 
1896  V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
1897  Local<Context> context) const;
1898  V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
1899  Local<Context> context) const;
1900  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
1901  Local<Context> context) const;
1902  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
1903  Local<Context> context) const;
1904  V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
1905  Local<Context> context) const;
1906  V8_WARN_UNUSED_RESULT MaybeLocal<Integer> ToInteger(
1907  Local<Context> context) const;
1908  V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToUint32(
1909  Local<Context> context) const;
1910  V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
1911 
1912  V8_DEPRECATE_SOON("Use maybe version",
1913  Local<Boolean> ToBoolean(Isolate* isolate)) const;
1914  V8_DEPRECATE_SOON("Use maybe version",
1915  Local<Number> ToNumber(Isolate* isolate)) const;
1916  V8_DEPRECATE_SOON("Use maybe version",
1917  Local<String> ToString(Isolate* isolate)) const;
1918  V8_DEPRECATE_SOON("Use maybe version",
1919  Local<String> ToDetailString(Isolate* isolate)) const;
1920  V8_DEPRECATE_SOON("Use maybe version",
1921  Local<Object> ToObject(Isolate* isolate)) const;
1922  V8_DEPRECATE_SOON("Use maybe version",
1923  Local<Integer> ToInteger(Isolate* isolate)) const;
1924  V8_DEPRECATE_SOON("Use maybe version",
1925  Local<Uint32> ToUint32(Isolate* isolate)) const;
1926  V8_DEPRECATE_SOON("Use maybe version",
1927  Local<Int32> ToInt32(Isolate* isolate)) const;
1928 
1929  inline V8_DEPRECATE_SOON("Use maybe version",
1930  Local<Boolean> ToBoolean()) const;
1931  inline V8_DEPRECATE_SOON("Use maybe version", Local<Number> ToNumber()) const;
1932  inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString()) const;
1933  inline V8_DEPRECATE_SOON("Use maybe version",
1934  Local<String> ToDetailString()) const;
1935  inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject()) const;
1936  inline V8_DEPRECATE_SOON("Use maybe version",
1937  Local<Integer> ToInteger()) const;
1938  inline V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToUint32()) const;
1939  inline V8_DEPRECATE_SOON("Use maybe version", Local<Int32> ToInt32()) const;
1940 
1945  V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToArrayIndex()) const;
1946  V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex(
1947  Local<Context> context) const;
1948 
1949  V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(Local<Context> context) const;
1950  V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
1951  V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
1952  Local<Context> context) const;
1953  V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
1954  Local<Context> context) const;
1955  V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
1956 
1957  V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue()) const;
1958  V8_DEPRECATE_SOON("Use maybe version", double NumberValue()) const;
1959  V8_DEPRECATE_SOON("Use maybe version", int64_t IntegerValue()) const;
1960  V8_DEPRECATE_SOON("Use maybe version", uint32_t Uint32Value()) const;
1961  V8_DEPRECATE_SOON("Use maybe version", int32_t Int32Value()) const;
1962 
1964  V8_DEPRECATE_SOON("Use maybe version", bool Equals(Handle<Value> that)) const;
1965  V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context,
1966  Handle<Value> that) const;
1967  bool StrictEquals(Handle<Value> that) const;
1968  bool SameValue(Handle<Value> that) const;
1969 
1970  template <class T> V8_INLINE static Value* Cast(T* value);
1971 
1972  private:
1973  V8_INLINE bool QuickIsUndefined() const;
1974  V8_INLINE bool QuickIsNull() const;
1975  V8_INLINE bool QuickIsString() const;
1976  bool FullIsUndefined() const;
1977  bool FullIsNull() const;
1978  bool FullIsString() const;
1979 };
1980 
1981 
1985 class V8_EXPORT Primitive : public Value { };
1986 
1987 
1992 class V8_EXPORT Boolean : public Primitive {
1993  public:
1994  bool Value() const;
1995  V8_INLINE static Boolean* Cast(v8::Value* obj);
1996  V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
1997  private:
1998  static void CheckCast(v8::Value* obj);
1999 };
2000 
2001 
2005 class V8_EXPORT Name : public Primitive {
2006  public:
2014  int GetIdentityHash();
2015 
2016  V8_INLINE static Name* Cast(v8::Value* obj);
2017  private:
2018  static void CheckCast(v8::Value* obj);
2019 };
2020 
2021 
2022 enum class NewStringType { kNormal, kInternalized };
2023 
2024 
2028 class V8_EXPORT String : public Name {
2029  public:
2030  static const int kMaxLength = (1 << 28) - 16;
2031 
2032  enum Encoding {
2033  UNKNOWN_ENCODING = 0x1,
2034  TWO_BYTE_ENCODING = 0x0,
2035  ONE_BYTE_ENCODING = 0x4
2036  };
2040  int Length() const;
2041 
2046  int Utf8Length() const;
2047 
2053  bool IsOneByte() const;
2054 
2059  bool ContainsOnlyOneByte() const;
2060 
2087  NO_OPTIONS = 0,
2088  HINT_MANY_WRITES_EXPECTED = 1,
2089  NO_NULL_TERMINATION = 2,
2090  PRESERVE_ONE_BYTE_NULL = 4,
2091  // Used by WriteUtf8 to replace orphan surrogate code units with the
2092  // unicode replacement character. Needs to be set to guarantee valid UTF-8
2093  // output.
2094  REPLACE_INVALID_UTF8 = 8
2095  };
2096 
2097  // 16-bit character codes.
2098  int Write(uint16_t* buffer,
2099  int start = 0,
2100  int length = -1,
2101  int options = NO_OPTIONS) const;
2102  // One byte characters.
2103  int WriteOneByte(uint8_t* buffer,
2104  int start = 0,
2105  int length = -1,
2106  int options = NO_OPTIONS) const;
2107  // UTF-8 encoded characters.
2108  int WriteUtf8(char* buffer,
2109  int length = -1,
2110  int* nchars_ref = NULL,
2111  int options = NO_OPTIONS) const;
2112 
2116  V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
2117 
2121  bool IsExternal() const;
2122 
2126  bool IsExternalOneByte() const;
2127 
2128  class V8_EXPORT ExternalStringResourceBase { // NOLINT
2129  public:
2130  virtual ~ExternalStringResourceBase() {}
2131 
2132  protected:
2134 
2141  virtual void Dispose() { delete this; }
2142 
2143  private:
2144  // Disallow copying and assigning.
2146  void operator=(const ExternalStringResourceBase&);
2147 
2148  friend class v8::internal::Heap;
2149  };
2150 
2157  class V8_EXPORT ExternalStringResource
2158  : public ExternalStringResourceBase {
2159  public:
2165 
2169  virtual const uint16_t* data() const = 0;
2170 
2174  virtual size_t length() const = 0;
2175 
2176  protected:
2178  };
2179 
2191  : public ExternalStringResourceBase {
2192  public:
2199  virtual const char* data() const = 0;
2201  virtual size_t length() const = 0;
2202  protected:
2204  };
2205 
2211  V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
2212  Encoding* encoding_out) const;
2213 
2218  V8_INLINE ExternalStringResource* GetExternalStringResource() const;
2219 
2224  const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
2225 
2226  V8_INLINE static String* Cast(v8::Value* obj);
2227 
2228  // TODO(dcarney): remove with deprecation of New functions.
2229  enum NewStringType {
2230  kNormalString = static_cast<int>(v8::NewStringType::kNormal),
2231  kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
2232  };
2233 
2235  static V8_DEPRECATE_SOON(
2236  "Use maybe version",
2237  Local<String> NewFromUtf8(Isolate* isolate, const char* data,
2238  NewStringType type = kNormalString,
2239  int length = -1));
2240 
2243  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
2244  Isolate* isolate, const char* data, v8::NewStringType type,
2245  int length = -1);
2246 
2248  static V8_DEPRECATE_SOON(
2249  "Use maybe version",
2250  Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data,
2251  NewStringType type = kNormalString,
2252  int length = -1));
2253 
2256  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
2257  Isolate* isolate, const uint8_t* data, v8::NewStringType type,
2258  int length = -1);
2259 
2261  static V8_DEPRECATE_SOON(
2262  "Use maybe version",
2263  Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
2264  NewStringType type = kNormalString,
2265  int length = -1));
2266 
2269  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
2270  Isolate* isolate, const uint16_t* data, v8::NewStringType type,
2271  int length = -1);
2272 
2277  static Local<String> Concat(Handle<String> left, Handle<String> right);
2278 
2287  static V8_DEPRECATE_SOON(
2288  "Use maybe version",
2289  Local<String> NewExternal(Isolate* isolate,
2290  ExternalStringResource* resource));
2291  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
2292  Isolate* isolate, ExternalStringResource* resource);
2293 
2303  bool MakeExternal(ExternalStringResource* resource);
2304 
2313  static V8_DEPRECATE_SOON(
2314  "Use maybe version",
2315  Local<String> NewExternal(Isolate* isolate,
2316  ExternalOneByteStringResource* resource));
2317  static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
2318  Isolate* isolate, ExternalOneByteStringResource* resource);
2319 
2329  bool MakeExternal(ExternalOneByteStringResource* resource);
2330 
2334  bool CanMakeExternal();
2335 
2343  class V8_EXPORT Utf8Value {
2344  public:
2345  explicit Utf8Value(Handle<v8::Value> obj);
2346  ~Utf8Value();
2347  char* operator*() { return str_; }
2348  const char* operator*() const { return str_; }
2349  int length() const { return length_; }
2350  private:
2351  char* str_;
2352  int length_;
2353 
2354  // Disallow copying and assigning.
2355  Utf8Value(const Utf8Value&);
2356  void operator=(const Utf8Value&);
2357  };
2358 
2365  class V8_EXPORT Value {
2366  public:
2367  explicit Value(Handle<v8::Value> obj);
2368  ~Value();
2369  uint16_t* operator*() { return str_; }
2370  const uint16_t* operator*() const { return str_; }
2371  int length() const { return length_; }
2372  private:
2373  uint16_t* str_;
2374  int length_;
2375 
2376  // Disallow copying and assigning.
2377  Value(const Value&);
2378  void operator=(const Value&);
2379  };
2380 
2381  private:
2382  void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
2383  Encoding encoding) const;
2384  void VerifyExternalStringResource(ExternalStringResource* val) const;
2385  static void CheckCast(v8::Value* obj);
2386 };
2387 
2388 
2394 class V8_EXPORT Symbol : public Name {
2395  public:
2396  // Returns the print name string of the symbol, or undefined if none.
2397  Local<Value> Name() const;
2398 
2399  // Create a symbol. If name is not empty, it will be used as the description.
2400  static Local<Symbol> New(
2401  Isolate *isolate, Local<String> name = Local<String>());
2402 
2403  // Access global symbol registry.
2404  // Note that symbols created this way are never collected, so
2405  // they should only be used for statically fixed properties.
2406  // Also, there is only one global name space for the names used as keys.
2407  // To minimize the potential for clashes, use qualified names as keys.
2408  static Local<Symbol> For(Isolate *isolate, Local<String> name);
2409 
2410  // Retrieve a global symbol. Similar to |For|, but using a separate
2411  // registry that is not accessible by (and cannot clash with) JavaScript code.
2412  static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
2413 
2414  // Well-known symbols
2415  static Local<Symbol> GetIterator(Isolate* isolate);
2416  static Local<Symbol> GetUnscopables(Isolate* isolate);
2417  static Local<Symbol> GetToStringTag(Isolate* isolate);
2418 
2419  V8_INLINE static Symbol* Cast(v8::Value* obj);
2420 
2421  private:
2422  Symbol();
2423  static void CheckCast(v8::Value* obj);
2424 };
2425 
2426 
2432 class V8_EXPORT Private : public Data {
2433  public:
2434  // Returns the print name string of the private symbol, or undefined if none.
2435  Local<Value> Name() const;
2436 
2437  // Create a private symbol. If name is not empty, it will be the description.
2438  static Local<Private> New(
2439  Isolate *isolate, Local<String> name = Local<String>());
2440 
2441  // Retrieve a global private symbol. If a symbol with this name has not
2442  // been retrieved in the same isolate before, it is created.
2443  // Note that private symbols created this way are never collected, so
2444  // they should only be used for statically fixed properties.
2445  // Also, there is only one global name space for the names used as keys.
2446  // To minimize the potential for clashes, use qualified names as keys,
2447  // e.g., "Class#property".
2448  static Local<Private> ForApi(Isolate *isolate, Local<String> name);
2449 
2450  private:
2451  Private();
2452 };
2453 
2454 
2458 class V8_EXPORT Number : public Primitive {
2459  public:
2460  double Value() const;
2461  static Local<Number> New(Isolate* isolate, double value);
2462  V8_INLINE static Number* Cast(v8::Value* obj);
2463  private:
2464  Number();
2465  static void CheckCast(v8::Value* obj);
2466 };
2467 
2468 
2472 class V8_EXPORT Integer : public Number {
2473  public:
2474  static Local<Integer> New(Isolate* isolate, int32_t value);
2475  static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
2476  int64_t Value() const;
2477  V8_INLINE static Integer* Cast(v8::Value* obj);
2478  private:
2479  Integer();
2480  static void CheckCast(v8::Value* obj);
2481 };
2482 
2483 
2487 class V8_EXPORT Int32 : public Integer {
2488  public:
2489  int32_t Value() const;
2490  V8_INLINE static Int32* Cast(v8::Value* obj);
2491 
2492  private:
2493  Int32();
2494  static void CheckCast(v8::Value* obj);
2495 };
2496 
2497 
2501 class V8_EXPORT Uint32 : public Integer {
2502  public:
2503  uint32_t Value() const;
2504  V8_INLINE static Uint32* Cast(v8::Value* obj);
2505 
2506  private:
2507  Uint32();
2508  static void CheckCast(v8::Value* obj);
2509 };
2510 
2511 
2512 enum PropertyAttribute {
2513  None = 0,
2514  ReadOnly = 1 << 0,
2515  DontEnum = 1 << 1,
2516  DontDelete = 1 << 2
2517 };
2518 
2524 typedef void (*AccessorGetterCallback)(
2525  Local<String> property,
2526  const PropertyCallbackInfo<Value>& info);
2527 typedef void (*AccessorNameGetterCallback)(
2528  Local<Name> property,
2529  const PropertyCallbackInfo<Value>& info);
2530 
2531 
2532 typedef void (*AccessorSetterCallback)(
2533  Local<String> property,
2534  Local<Value> value,
2535  const PropertyCallbackInfo<void>& info);
2536 typedef void (*AccessorNameSetterCallback)(
2537  Local<Name> property,
2538  Local<Value> value,
2539  const PropertyCallbackInfo<void>& info);
2540 
2541 
2552  DEFAULT = 0,
2553  ALL_CAN_READ = 1,
2554  ALL_CAN_WRITE = 1 << 1,
2555  PROHIBITS_OVERWRITING = 1 << 2
2556 };
2557 
2558 
2562 class V8_EXPORT Object : public Value {
2563  public:
2564  V8_DEPRECATE_SOON("Use maybe version",
2565  bool Set(Handle<Value> key, Handle<Value> value));
2566  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
2567  Local<Value> key, Local<Value> value);
2568 
2569  V8_DEPRECATE_SOON("Use maybe version",
2570  bool Set(uint32_t index, Handle<Value> value));
2571  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
2572  Local<Value> value);
2573 
2574  // Sets an own property on this object bypassing interceptors and
2575  // overriding accessors or read-only properties.
2576  //
2577  // Note that if the object has an interceptor the property will be set
2578  // locally, but since the interceptor takes precedence the local property
2579  // will only be returned if the interceptor doesn't return a value.
2580  //
2581  // Note also that this only works for named properties.
2582  V8_DEPRECATE_SOON("Use maybe version",
2583  bool ForceSet(Handle<Value> key, Handle<Value> value,
2584  PropertyAttribute attribs = None));
2585  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2586  Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
2587  Local<Value> value, PropertyAttribute attribs = None);
2588 
2589  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Handle<Value> key));
2590  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
2591  Local<Value> key);
2592 
2593  V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
2594  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
2595  uint32_t index);
2596 
2602  V8_DEPRECATE_SOON("Use maybe version",
2603  PropertyAttribute GetPropertyAttributes(Handle<Value> key));
2604  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetPropertyAttributes(
2605  Local<Context> context, Local<Value> key);
2606 
2610  V8_DEPRECATE_SOON("Use maybe version",
2611  Local<Value> GetOwnPropertyDescriptor(Local<String> key));
2612  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
2613  Local<Context> context, Local<String> key);
2614 
2615  V8_DEPRECATE_SOON("Use maybe version", bool Has(Handle<Value> key));
2616  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
2617  Local<Value> key);
2618 
2619  V8_DEPRECATE_SOON("Use maybe version", bool Delete(Handle<Value> key));
2620  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2621  Maybe<bool> Delete(Local<Context> context, Local<Value> key);
2622 
2623  V8_DEPRECATE_SOON("Use maybe version", bool Has(uint32_t index));
2624  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
2625 
2626  V8_DEPRECATE_SOON("Use maybe version", bool Delete(uint32_t index));
2627  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2628  Maybe<bool> Delete(Local<Context> context, uint32_t index);
2629 
2630  V8_DEPRECATE_SOON("Use maybe version",
2631  bool SetAccessor(Handle<String> name,
2632  AccessorGetterCallback getter,
2633  AccessorSetterCallback setter = 0,
2634  Handle<Value> data = Handle<Value>(),
2635  AccessControl settings = DEFAULT,
2636  PropertyAttribute attribute = None));
2637  V8_DEPRECATE_SOON("Use maybe version",
2638  bool SetAccessor(Handle<Name> name,
2639  AccessorNameGetterCallback getter,
2640  AccessorNameSetterCallback setter = 0,
2641  Handle<Value> data = Handle<Value>(),
2642  AccessControl settings = DEFAULT,
2643  PropertyAttribute attribute = None));
2644  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
2645  Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
2646  AccessorNameGetterCallback getter,
2647  AccessorNameSetterCallback setter = 0,
2649  AccessControl settings = DEFAULT,
2650  PropertyAttribute attribute = None);
2651 
2652  void SetAccessorProperty(Local<Name> name,
2653  Local<Function> getter,
2655  PropertyAttribute attribute = None,
2656  AccessControl settings = DEFAULT);
2657 
2664  // TODO(dcarney): convert these or remove?
2665  bool HasPrivate(Handle<Private> key);
2666  bool SetPrivate(Handle<Private> key, Handle<Value> value);
2667  bool DeletePrivate(Handle<Private> key);
2668  Local<Value> GetPrivate(Handle<Private> key);
2669 
2676  V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames());
2677  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
2678  Local<Context> context);
2679 
2685  V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetOwnPropertyNames());
2686  V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
2687  Local<Context> context);
2688 
2694  Local<Value> GetPrototype();
2695 
2701  V8_DEPRECATE_SOON("Use maybe version",
2702  bool SetPrototype(Handle<Value> prototype));
2703  V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
2704  Local<Value> prototype);
2705 
2710  Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl);
2711 
2717  V8_DEPRECATE_SOON("Use maybe version", Local<String> ObjectProtoToString());
2718  V8_WARN_UNUSED_RESULT MaybeLocal<String> ObjectProtoToString(
2719  Local<Context> context);
2720 
2724  Local<String> GetConstructorName();
2725 
2727  int InternalFieldCount();
2728 
2730  V8_INLINE static int InternalFieldCount(
2731  const PersistentBase<Object>& object) {
2732  return object.val_->InternalFieldCount();
2733  }
2734 
2736  V8_INLINE Local<Value> GetInternalField(int index);
2737 
2739  void SetInternalField(int index, Handle<Value> value);
2740 
2746  V8_INLINE void* GetAlignedPointerFromInternalField(int index);
2747 
2749  V8_INLINE static void* GetAlignedPointerFromInternalField(
2750  const PersistentBase<Object>& object, int index) {
2751  return object.val_->GetAlignedPointerFromInternalField(index);
2752  }
2753 
2759  void SetAlignedPointerInInternalField(int index, void* value);
2760 
2761  // Testers for local properties.
2762  V8_DEPRECATE_SOON("Use maybe version",
2763  bool HasOwnProperty(Handle<String> key));
2764  V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
2765  Local<Name> key);
2766  V8_DEPRECATE_SOON("Use maybe version",
2767  bool HasRealNamedProperty(Handle<String> key));
2768  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
2769  Local<Name> key);
2770  V8_DEPRECATE_SOON("Use maybe version",
2771  bool HasRealIndexedProperty(uint32_t index));
2772  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty(
2773  Local<Context> context, uint32_t index);
2774  V8_DEPRECATE_SOON("Use maybe version",
2775  bool HasRealNamedCallbackProperty(Handle<String> key));
2776  V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty(
2777  Local<Context> context, Local<Name> key);
2778 
2783  V8_DEPRECATE_SOON(
2784  "Use maybe version",
2785  Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key));
2786  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(
2787  Local<Context> context, Local<Name> key);
2788 
2794  V8_DEPRECATE_SOON(
2795  "Use maybe version",
2796  Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
2797  Handle<String> key));
2798  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute>
2799  GetRealNamedPropertyAttributesInPrototypeChain(Local<Context> context,
2800  Local<Name> key);
2801 
2807  V8_DEPRECATE_SOON("Use maybe version",
2808  Local<Value> GetRealNamedProperty(Handle<String> key));
2809  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty(
2810  Local<Context> context, Local<Name> key);
2811 
2817  V8_DEPRECATE_SOON("Use maybe version",
2818  Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
2819  Handle<String> key));
2820  V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
2821  Local<Context> context, Local<Name> key);
2822 
2824  bool HasNamedLookupInterceptor();
2825 
2827  bool HasIndexedLookupInterceptor();
2828 
2834  V8_DEPRECATE_SOON("No alternative", void TurnOnAccessCheck());
2835 
2843  int GetIdentityHash();
2844 
2851  // TODO(dcarney): convert these to take a isolate and optionally bailout?
2852  bool SetHiddenValue(Handle<String> key, Handle<Value> value);
2853  Local<Value> GetHiddenValue(Handle<String> key);
2854  bool DeleteHiddenValue(Handle<String> key);
2855 
2860  // TODO(dcarney): take an isolate and optionally bail out?
2861  Local<Object> Clone();
2862 
2866  Local<Context> CreationContext();
2867 
2873  bool IsCallable();
2874 
2879  V8_DEPRECATE_SOON("Use maybe version",
2880  Local<Value> CallAsFunction(Handle<Value> recv, int argc,
2881  Handle<Value> argv[]));
2882  V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsFunction(Local<Context> context,
2883  Handle<Value> recv,
2884  int argc,
2885  Handle<Value> argv[]);
2886 
2892  V8_DEPRECATE_SOON("Use maybe version",
2893  Local<Value> CallAsConstructor(int argc,
2894  Handle<Value> argv[]));
2895  V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsConstructor(
2896  Local<Context> context, int argc, Local<Value> argv[]);
2897 
2901  V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate());
2902 
2903  static Local<Object> New(Isolate* isolate);
2904 
2905  V8_INLINE static Object* Cast(Value* obj);
2906 
2907  private:
2908  Object();
2909  static void CheckCast(Value* obj);
2910  Local<Value> SlowGetInternalField(int index);
2911  void* SlowGetAlignedPointerFromInternalField(int index);
2912 };
2913 
2914 
2918 class V8_EXPORT Array : public Object {
2919  public:
2920  uint32_t Length() const;
2921 
2926  V8_DEPRECATE_SOON("Use maybe version",
2927  Local<Object> CloneElementAt(uint32_t index));
2928  V8_WARN_UNUSED_RESULT MaybeLocal<Object> CloneElementAt(
2929  Local<Context> context, uint32_t index);
2930 
2935  static Local<Array> New(Isolate* isolate, int length = 0);
2936 
2937  V8_INLINE static Array* Cast(Value* obj);
2938  private:
2939  Array();
2940  static void CheckCast(Value* obj);
2941 };
2942 
2943 
2944 template<typename T>
2945 class ReturnValue {
2946  public:
2947  template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
2948  : value_(that.value_) {
2949  TYPE_CHECK(T, S);
2950  }
2951  // Handle setters
2952  template <typename S> V8_INLINE void Set(const Persistent<S>& handle);
2953  template <typename S> V8_INLINE void Set(const Handle<S> handle);
2954  // Fast primitive setters
2955  V8_INLINE void Set(bool value);
2956  V8_INLINE void Set(double i);
2957  V8_INLINE void Set(int32_t i);
2958  V8_INLINE void Set(uint32_t i);
2959  // Fast JS primitive setters
2960  V8_INLINE void SetNull();
2961  V8_INLINE void SetUndefined();
2962  V8_INLINE void SetEmptyString();
2963  // Convenience getter for Isolate
2964  V8_INLINE Isolate* GetIsolate();
2965 
2966  // Pointer setter: Uncompilable to prevent inadvertent misuse.
2967  template <typename S>
2968  V8_INLINE void Set(S* whatever);
2969 
2970  private:
2971  template<class F> friend class ReturnValue;
2972  template<class F> friend class FunctionCallbackInfo;
2973  template<class F> friend class PropertyCallbackInfo;
2974  template <class F, class G, class H>
2975  friend class PersistentValueMapBase;
2976  V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; }
2977  V8_INLINE internal::Object* GetDefaultValue();
2978  V8_INLINE explicit ReturnValue(internal::Object** slot);
2979  internal::Object** value_;
2980 };
2981 
2982 
2989 template<typename T>
2990 class FunctionCallbackInfo {
2991  public:
2992  V8_INLINE int Length() const;
2993  V8_INLINE Local<Value> operator[](int i) const;
2994  V8_INLINE Local<Function> Callee() const;
2995  V8_INLINE Local<Object> This() const;
2996  V8_INLINE Local<Object> Holder() const;
2997  V8_INLINE bool IsConstructCall() const;
2998  V8_INLINE Local<Value> Data() const;
2999  V8_INLINE Isolate* GetIsolate() const;
3000  V8_INLINE ReturnValue<T> GetReturnValue() const;
3001  // This shouldn't be public, but the arm compiler needs it.
3002  static const int kArgsLength = 7;
3003 
3004  protected:
3005  friend class internal::FunctionCallbackArguments;
3006  friend class internal::CustomArguments<FunctionCallbackInfo>;
3007  static const int kHolderIndex = 0;
3008  static const int kIsolateIndex = 1;
3009  static const int kReturnValueDefaultValueIndex = 2;
3010  static const int kReturnValueIndex = 3;
3011  static const int kDataIndex = 4;
3012  static const int kCalleeIndex = 5;
3013  static const int kContextSaveIndex = 6;
3014 
3015  V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
3016  internal::Object** values,
3017  int length,
3018  bool is_construct_call);
3019  internal::Object** implicit_args_;
3020  internal::Object** values_;
3021  int length_;
3022  int is_construct_call_;
3023 };
3024 
3025 
3030 template<typename T>
3031 class PropertyCallbackInfo {
3032  public:
3033  V8_INLINE Isolate* GetIsolate() const;
3034  V8_INLINE Local<Value> Data() const;
3035  V8_INLINE Local<Object> This() const;
3036  V8_INLINE Local<Object> Holder() const;
3037  V8_INLINE ReturnValue<T> GetReturnValue() const;
3038  // This shouldn't be public, but the arm compiler needs it.
3039  static const int kArgsLength = 6;
3040 
3041  protected:
3042  friend class MacroAssembler;
3043  friend class internal::PropertyCallbackArguments;
3044  friend class internal::CustomArguments<PropertyCallbackInfo>;
3045  static const int kHolderIndex = 0;
3046  static const int kIsolateIndex = 1;
3047  static const int kReturnValueDefaultValueIndex = 2;
3048  static const int kReturnValueIndex = 3;
3049  static const int kDataIndex = 4;
3050  static const int kThisIndex = 5;
3051 
3052  V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
3053  internal::Object** args_;
3054 };
3055 
3056 
3057 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
3058 
3059 
3063 class V8_EXPORT Function : public Object {
3064  public:
3069  static Local<Function> New(Isolate* isolate,
3070  FunctionCallback callback,
3071  Local<Value> data = Local<Value>(),
3072  int length = 0);
3073 
3074  V8_DEPRECATE_SOON("Use maybe version",
3075  Local<Object> NewInstance(int argc,
3076  Handle<Value> argv[])) const;
3077  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
3078  Local<Context> context, int argc, Handle<Value> argv[]) const;
3079 
3080  V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()) const;
3081  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
3082  Local<Context> context) const {
3083  return NewInstance(context, 0, nullptr);
3084  }
3085 
3086  V8_DEPRECATE_SOON("Use maybe version",
3087  Local<Value> Call(Handle<Value> recv, int argc,
3088  Handle<Value> argv[]));
3089  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
3090  Handle<Value> recv, int argc,
3091  Handle<Value> argv[]);
3092 
3093  void SetName(Handle<String> name);
3094  Handle<Value> GetName() const;
3095 
3102  Handle<Value> GetInferredName() const;
3103 
3108  Handle<Value> GetDisplayName() const;
3109 
3114  int GetScriptLineNumber() const;
3119  int GetScriptColumnNumber() const;
3120 
3124  bool IsBuiltin() const;
3125 
3129  int ScriptId() const;
3130 
3135  Local<Value> GetBoundFunction() const;
3136 
3137  ScriptOrigin GetScriptOrigin() const;
3138  V8_INLINE static Function* Cast(Value* obj);
3139  static const int kLineOffsetNotFound;
3140 
3141  private:
3142  Function();
3143  static void CheckCast(Value* obj);
3144 };
3145 
3146 
3151 class V8_EXPORT Promise : public Object {
3152  public:
3153  class V8_EXPORT Resolver : public Object {
3154  public:
3158  static V8_DEPRECATE_SOON("Use maybe version",
3159  Local<Resolver> New(Isolate* isolate));
3160  static V8_WARN_UNUSED_RESULT MaybeLocal<Resolver> New(
3161  Local<Context> context);
3162 
3166  Local<Promise> GetPromise();
3167 
3172  V8_DEPRECATE_SOON("Use maybe version", void Resolve(Handle<Value> value));
3173  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
3174  Maybe<bool> Resolve(Local<Context> context, Handle<Value> value);
3175 
3176  V8_DEPRECATE_SOON("Use maybe version", void Reject(Handle<Value> value));
3177  // TODO(dcarney): mark V8_WARN_UNUSED_RESULT
3178  Maybe<bool> Reject(Local<Context> context, Handle<Value> value);
3179 
3180  V8_INLINE static Resolver* Cast(Value* obj);
3181 
3182  private:
3183  Resolver();
3184  static void CheckCast(Value* obj);
3185  };
3186 
3193  V8_DEPRECATE_SOON("Use maybe version",
3194  Local<Promise> Chain(Handle<Function> handler));
3195  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(Local<Context> context,
3196  Handle<Function> handler);
3197 
3198  V8_DEPRECATE_SOON("Use maybe version",
3199  Local<Promise> Catch(Handle<Function> handler));
3200  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context,
3201  Handle<Function> handler);
3202 
3203  V8_DEPRECATE_SOON("Use maybe version",
3204  Local<Promise> Then(Handle<Function> handler));
3205  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
3206  Handle<Function> handler);
3207 
3212  bool HasHandler();
3213 
3214  V8_INLINE static Promise* Cast(Value* obj);
3215 
3216  private:
3217  Promise();
3218  static void CheckCast(Value* obj);
3219 };
3220 
3221 
3222 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
3223 // The number of required internal fields can be defined by embedder.
3224 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
3225 #endif
3226 
3227 
3228 enum class ArrayBufferCreationMode { kInternalized, kExternalized };
3229 
3230 
3235 class V8_EXPORT ArrayBuffer : public Object {
3236  public:
3244  class V8_EXPORT Allocator { // NOLINT
3245  public:
3246  virtual ~Allocator() {}
3247 
3252  virtual void* Allocate(size_t length) = 0;
3253 
3258  virtual void* AllocateUninitialized(size_t length) = 0;
3263  virtual void Free(void* data, size_t length) = 0;
3264  };
3265 
3276  class V8_EXPORT Contents { // NOLINT
3277  public:
3278  Contents() : data_(NULL), byte_length_(0) {}
3279 
3280  void* Data() const { return data_; }
3281  size_t ByteLength() const { return byte_length_; }
3282 
3283  private:
3284  void* data_;
3285  size_t byte_length_;
3286 
3287  friend class ArrayBuffer;
3288  };
3289 
3290 
3294  size_t ByteLength() const;
3295 
3302  static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
3303 
3310  static Local<ArrayBuffer> New(
3311  Isolate* isolate, void* data, size_t byte_length,
3312  ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
3313 
3318  bool IsExternal() const;
3319 
3323  bool IsNeuterable() const;
3324 
3331  void Neuter();
3332 
3342  Contents Externalize();
3343 
3354  Contents GetContents();
3355 
3356  V8_INLINE static ArrayBuffer* Cast(Value* obj);
3357 
3358  static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
3359 
3360  private:
3361  ArrayBuffer();
3362  static void CheckCast(Value* obj);
3363 };
3364 
3365 
3366 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
3367 // The number of required internal fields can be defined by embedder.
3368 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
3369 #endif
3370 
3371 
3378 class V8_EXPORT ArrayBufferView : public Object {
3379  public:
3383  Local<ArrayBuffer> Buffer();
3387  size_t ByteOffset();
3391  size_t ByteLength();
3392 
3402  size_t CopyContents(void* dest, size_t byte_length);
3403 
3408  bool HasBuffer() const;
3409 
3410  V8_INLINE static ArrayBufferView* Cast(Value* obj);
3411 
3412  static const int kInternalFieldCount =
3413  V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
3414 
3415  private:
3416  ArrayBufferView();
3417  static void CheckCast(Value* obj);
3418 };
3419 
3420 
3426 class V8_EXPORT TypedArray : public ArrayBufferView {
3427  public:
3432  size_t Length();
3433 
3434  V8_INLINE static TypedArray* Cast(Value* obj);
3435 
3436  private:
3437  TypedArray();
3438  static void CheckCast(Value* obj);
3439 };
3440 
3441 
3446 class V8_EXPORT Uint8Array : public TypedArray {
3447  public:
3448  static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
3449  size_t byte_offset, size_t length);
3450  V8_INLINE static Uint8Array* Cast(Value* obj);
3451 
3452  private:
3453  Uint8Array();
3454  static void CheckCast(Value* obj);
3455 };
3456 
3457 
3462 class V8_EXPORT Uint8ClampedArray : public TypedArray {
3463  public:
3464  static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
3465  size_t byte_offset, size_t length);
3466  V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
3467 
3468  private:
3470  static void CheckCast(Value* obj);
3471 };
3472 
3477 class V8_EXPORT Int8Array : public TypedArray {
3478  public:
3479  static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
3480  size_t byte_offset, size_t length);
3481  V8_INLINE static Int8Array* Cast(Value* obj);
3482 
3483  private:
3484  Int8Array();
3485  static void CheckCast(Value* obj);
3486 };
3487 
3488 
3493 class V8_EXPORT Uint16Array : public TypedArray {
3494  public:
3495  static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
3496  size_t byte_offset, size_t length);
3497  V8_INLINE static Uint16Array* Cast(Value* obj);
3498 
3499  private:
3500  Uint16Array();
3501  static void CheckCast(Value* obj);
3502 };
3503 
3504 
3509 class V8_EXPORT Int16Array : public TypedArray {
3510  public:
3511  static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
3512  size_t byte_offset, size_t length);
3513  V8_INLINE static Int16Array* Cast(Value* obj);
3514 
3515  private:
3516  Int16Array();
3517  static void CheckCast(Value* obj);
3518 };
3519 
3520 
3525 class V8_EXPORT Uint32Array : public TypedArray {
3526  public:
3527  static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
3528  size_t byte_offset, size_t length);
3529  V8_INLINE static Uint32Array* Cast(Value* obj);
3530 
3531  private:
3532  Uint32Array();
3533  static void CheckCast(Value* obj);
3534 };
3535 
3536 
3541 class V8_EXPORT Int32Array : public TypedArray {
3542  public:
3543  static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
3544  size_t byte_offset, size_t length);
3545  V8_INLINE static Int32Array* Cast(Value* obj);
3546 
3547  private:
3548  Int32Array();
3549  static void CheckCast(Value* obj);
3550 };
3551 
3552 
3557 class V8_EXPORT Float32Array : public TypedArray {
3558  public:
3559  static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
3560  size_t byte_offset, size_t length);
3561  V8_INLINE static Float32Array* Cast(Value* obj);
3562 
3563  private:
3564  Float32Array();
3565  static void CheckCast(Value* obj);
3566 };
3567 
3568 
3573 class V8_EXPORT Float64Array : public TypedArray {
3574  public:
3575  static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
3576  size_t byte_offset, size_t length);
3577  V8_INLINE static Float64Array* Cast(Value* obj);
3578 
3579  private:
3580  Float64Array();
3581  static void CheckCast(Value* obj);
3582 };
3583 
3584 
3589 class V8_EXPORT DataView : public ArrayBufferView {
3590  public:
3591  static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
3592  size_t byte_offset, size_t length);
3593  V8_INLINE static DataView* Cast(Value* obj);
3594 
3595  private:
3596  DataView();
3597  static void CheckCast(Value* obj);
3598 };
3599 
3600 
3604 class V8_EXPORT Date : public Object {
3605  public:
3606  static V8_DEPRECATE_SOON("Use maybe version.",
3607  Local<Value> New(Isolate* isolate, double time));
3608  static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
3609  double time);
3610 
3615  double ValueOf() const;
3616 
3617  V8_INLINE static Date* Cast(v8::Value* obj);
3618 
3631  static void DateTimeConfigurationChangeNotification(Isolate* isolate);
3632 
3633  private:
3634  static void CheckCast(v8::Value* obj);
3635 };
3636 
3637 
3641 class V8_EXPORT NumberObject : public Object {
3642  public:
3643  static Local<Value> New(Isolate* isolate, double value);
3644 
3645  double ValueOf() const;
3646 
3647  V8_INLINE static NumberObject* Cast(v8::Value* obj);
3648 
3649  private:
3650  static void CheckCast(v8::Value* obj);
3651 };
3652 
3653 
3657 class V8_EXPORT BooleanObject : public Object {
3658  public:
3659  static Local<Value> New(bool value);
3660 
3661  bool ValueOf() const;
3662 
3663  V8_INLINE static BooleanObject* Cast(v8::Value* obj);
3664 
3665  private:
3666  static void CheckCast(v8::Value* obj);
3667 };
3668 
3669 
3673 class V8_EXPORT StringObject : public Object {
3674  public:
3675  static Local<Value> New(Handle<String> value);
3676 
3677  Local<String> ValueOf() const;
3678 
3679  V8_INLINE static StringObject* Cast(v8::Value* obj);
3680 
3681  private:
3682  static void CheckCast(v8::Value* obj);
3683 };
3684 
3685 
3691 class V8_EXPORT SymbolObject : public Object {
3692  public:
3693  static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
3694 
3695  Local<Symbol> ValueOf() const;
3696 
3697  V8_INLINE static SymbolObject* Cast(v8::Value* obj);
3698 
3699  private:
3700  static void CheckCast(v8::Value* obj);
3701 };
3702 
3703 
3707 class V8_EXPORT RegExp : public Object {
3708  public:
3713  enum Flags {
3714  kNone = 0,
3715  kGlobal = 1,
3716  kIgnoreCase = 2,
3717  kMultiline = 4
3718  };
3719 
3730  static V8_DEPRECATE_SOON("Use maybe version",
3731  Local<RegExp> New(Handle<String> pattern,
3732  Flags flags));
3733  static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> New(Local<Context> context,
3734  Handle<String> pattern,
3735  Flags flags);
3736 
3741  Local<String> GetSource() const;
3742 
3746  Flags GetFlags() const;
3747 
3748  V8_INLINE static RegExp* Cast(v8::Value* obj);
3749 
3750  private:
3751  static void CheckCast(v8::Value* obj);
3752 };
3753 
3754 
3759 class V8_EXPORT External : public Value {
3760  public:
3761  static Local<External> New(Isolate* isolate, void* value);
3762  V8_INLINE static External* Cast(Value* obj);
3763  void* Value() const;
3764  private:
3765  static void CheckCast(v8::Value* obj);
3766 };
3767 
3768 
3769 // --- Templates ---
3770 
3771 
3775 class V8_EXPORT Template : public Data {
3776  public:
3778  void Set(Handle<Name> name, Handle<Data> value,
3779  PropertyAttribute attributes = None);
3780  V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
3781 
3782  void SetAccessorProperty(
3783  Local<Name> name,
3786  PropertyAttribute attribute = None,
3787  AccessControl settings = DEFAULT);
3788 
3816  void SetNativeDataProperty(Local<String> name,
3817  AccessorGetterCallback getter,
3818  AccessorSetterCallback setter = 0,
3819  // TODO(dcarney): gcc can't handle Local below
3820  Handle<Value> data = Handle<Value>(),
3821  PropertyAttribute attribute = None,
3822  Local<AccessorSignature> signature =
3824  AccessControl settings = DEFAULT);
3825  void SetNativeDataProperty(Local<Name> name,
3826  AccessorNameGetterCallback getter,
3827  AccessorNameSetterCallback setter = 0,
3828  // TODO(dcarney): gcc can't handle Local below
3829  Handle<Value> data = Handle<Value>(),
3830  PropertyAttribute attribute = None,
3831  Local<AccessorSignature> signature =
3833  AccessControl settings = DEFAULT);
3834 
3835  private:
3836  Template();
3837 
3838  friend class ObjectTemplate;
3839  friend class FunctionTemplate;
3840 };
3841 
3842 
3848  Local<String> property,
3849  const PropertyCallbackInfo<Value>& info);
3850 
3851 
3857  Local<String> property,
3858  Local<Value> value,
3859  const PropertyCallbackInfo<Value>& info);
3860 
3861 
3868  Local<String> property,
3869  const PropertyCallbackInfo<Integer>& info);
3870 
3871 
3878  Local<String> property,
3879  const PropertyCallbackInfo<Boolean>& info);
3880 
3881 
3887  const PropertyCallbackInfo<Array>& info);
3888 
3889 
3890 // TODO(dcarney): Deprecate and remove previous typedefs, and replace
3891 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
3897  Local<Name> property, const PropertyCallbackInfo<Value>& info);
3898 
3899 
3905  Local<Name> property, Local<Value> value,
3906  const PropertyCallbackInfo<Value>& info);
3907 
3908 
3915  Local<Name> property, const PropertyCallbackInfo<Integer>& info);
3916 
3917 
3924  Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
3925 
3926 
3932  const PropertyCallbackInfo<Array>& info);
3933 
3934 
3940  uint32_t index,
3941  const PropertyCallbackInfo<Value>& info);
3942 
3943 
3949  uint32_t index,
3950  Local<Value> value,
3951  const PropertyCallbackInfo<Value>& info);
3952 
3953 
3959  uint32_t index,
3960  const PropertyCallbackInfo<Integer>& info);
3961 
3962 
3969  uint32_t index,
3970  const PropertyCallbackInfo<Boolean>& info);
3971 
3972 
3978  const PropertyCallbackInfo<Array>& info);
3979 
3980 
3985  ACCESS_GET,
3986  ACCESS_SET,
3987  ACCESS_HAS,
3988  ACCESS_DELETE,
3989  ACCESS_KEYS
3990 };
3991 
3992 
3998  Local<Value> key,
3999  AccessType type,
4000  Local<Value> data);
4001 
4002 
4008  uint32_t index,
4009  AccessType type,
4010  Local<Value> data);
4011 
4012 
4108 class V8_EXPORT FunctionTemplate : public Template {
4109  public:
4111  static Local<FunctionTemplate> New(
4112  Isolate* isolate,
4113  FunctionCallback callback = 0,
4114  Handle<Value> data = Handle<Value>(),
4115  Handle<Signature> signature = Handle<Signature>(),
4116  int length = 0);
4117 
4119  V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction());
4120  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
4121  Local<Context> context);
4122 
4128  void SetCallHandler(FunctionCallback callback,
4129  Handle<Value> data = Handle<Value>());
4130 
4132  void SetLength(int length);
4133 
4135  Local<ObjectTemplate> InstanceTemplate();
4136 
4138  void Inherit(Handle<FunctionTemplate> parent);
4139 
4144  Local<ObjectTemplate> PrototypeTemplate();
4145 
4151  void SetClassName(Handle<String> name);
4152 
4153 
4158  void SetAcceptAnyReceiver(bool value);
4159 
4172  void SetHiddenPrototype(bool value);
4173 
4178  void ReadOnlyPrototype();
4179 
4184  void RemovePrototype();
4185 
4190  bool HasInstance(Handle<Value> object);
4191 
4192  private:
4193  FunctionTemplate();
4194  friend class Context;
4195  friend class ObjectTemplate;
4196 };
4197 
4198 
4199 enum class PropertyHandlerFlags {
4200  kNone = 0,
4201  // See ALL_CAN_READ above.
4202  kAllCanRead = 1,
4203  // Will not call into interceptor for properties on the receiver or prototype
4204  // chain. Currently only valid for named interceptors.
4205  kNonMasking = 1 << 1,
4206  // Will not call into interceptor for symbol lookup. Only meaningful for
4207  // named interceptors.
4208  kOnlyInterceptStrings = 1 << 2,
4209 };
4210 
4211 
4220  Handle<Value> data = Handle<Value>(),
4221  PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
4222  : getter(getter),
4223  setter(setter),
4224  query(query),
4225  deleter(deleter),
4226  enumerator(enumerator),
4227  data(data),
4228  flags(flags) {}
4229 
4235  Handle<Value> data;
4236  PropertyHandlerFlags flags;
4237 };
4238 
4239 
4243  IndexedPropertyGetterCallback getter = 0,
4244  IndexedPropertySetterCallback setter = 0,
4245  IndexedPropertyQueryCallback query = 0,
4246  IndexedPropertyDeleterCallback deleter = 0,
4247  IndexedPropertyEnumeratorCallback enumerator = 0,
4248  Handle<Value> data = Handle<Value>(),
4249  PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
4250  : getter(getter),
4251  setter(setter),
4252  query(query),
4253  deleter(deleter),
4254  enumerator(enumerator),
4255  data(data),
4256  flags(flags) {}
4257 
4263  Handle<Value> data;
4264  PropertyHandlerFlags flags;
4265 };
4266 
4267 
4274 class V8_EXPORT ObjectTemplate : public Template {
4275  public:
4277  static Local<ObjectTemplate> New(
4278  Isolate* isolate,
4280  static V8_DEPRECATE_SOON("Use isolate version", Local<ObjectTemplate> New());
4281 
4283  V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
4284  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
4285 
4315  void SetAccessor(Handle<String> name,
4316  AccessorGetterCallback getter,
4317  AccessorSetterCallback setter = 0,
4318  Handle<Value> data = Handle<Value>(),
4319  AccessControl settings = DEFAULT,
4320  PropertyAttribute attribute = None,
4321  Handle<AccessorSignature> signature =
4323  void SetAccessor(Handle<Name> name,
4324  AccessorNameGetterCallback getter,
4325  AccessorNameSetterCallback setter = 0,
4326  Handle<Value> data = Handle<Value>(),
4327  AccessControl settings = DEFAULT,
4328  PropertyAttribute attribute = None,
4329  Handle<AccessorSignature> signature =
4331 
4352  // TODO(dcarney): deprecate
4353  void SetNamedPropertyHandler(
4355  NamedPropertySetterCallback setter = 0,
4356  NamedPropertyQueryCallback query = 0,
4357  NamedPropertyDeleterCallback deleter = 0,
4358  NamedPropertyEnumeratorCallback enumerator = 0,
4359  Handle<Value> data = Handle<Value>());
4360  void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
4361 
4378  void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
4379  // TODO(dcarney): deprecate
4380  void SetIndexedPropertyHandler(
4382  IndexedPropertySetterCallback setter = 0,
4383  IndexedPropertyQueryCallback query = 0,
4384  IndexedPropertyDeleterCallback deleter = 0,
4385  IndexedPropertyEnumeratorCallback enumerator = 0,
4386  Handle<Value> data = Handle<Value>()) {
4387  SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
4388  deleter, enumerator, data));
4389  }
4396  void SetCallAsFunctionHandler(FunctionCallback callback,
4397  Handle<Value> data = Handle<Value>());
4398 
4407  void MarkAsUndetectable();
4408 
4420  void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
4421  IndexedSecurityCallback indexed_handler,
4422  Handle<Value> data = Handle<Value>(),
4423  bool turned_on_by_default = true);
4424 
4429  int InternalFieldCount();
4430 
4435  void SetInternalFieldCount(int value);
4436 
4437  private:
4438  ObjectTemplate();
4439  static Local<ObjectTemplate> New(internal::Isolate* isolate,
4440  Handle<FunctionTemplate> constructor);
4441  friend class FunctionTemplate;
4442 };
4443 
4444 
4448 class V8_EXPORT Signature : public Data {
4449  public:
4450  static Local<Signature> New(
4451  Isolate* isolate,
4453 
4454  private:
4455  Signature();
4456 };
4457 
4458 
4463 class V8_EXPORT AccessorSignature : public Data {
4464  public:
4465  static Local<AccessorSignature> New(Isolate* isolate,
4466  Handle<FunctionTemplate> receiver =
4468 
4469  private:
4471 };
4472 
4473 
4478 class V8_EXPORT TypeSwitch : public Data {
4479  public:
4481  static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
4482  int match(Handle<Value> value);
4483  private:
4484  TypeSwitch();
4485 };
4486 
4487 
4488 // --- Extensions ---
4489 
4492  public:
4493  ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
4494  ExternalOneByteStringResourceImpl(const char* data, size_t length)
4495  : data_(data), length_(length) {}
4496  const char* data() const { return data_; }
4497  size_t length() const { return length_; }
4498 
4499  private:
4500  const char* data_;
4501  size_t length_;
4502 };
4503 
4507 class V8_EXPORT Extension { // NOLINT
4508  public:
4509  // Note that the strings passed into this constructor must live as long
4510  // as the Extension itself.
4511  Extension(const char* name,
4512  const char* source = 0,
4513  int dep_count = 0,
4514  const char** deps = 0,
4515  int source_length = -1);
4516  virtual ~Extension() { }
4517  virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
4518  v8::Isolate* isolate, v8::Handle<v8::String> name) {
4520  }
4521 
4522  const char* name() const { return name_; }
4523  size_t source_length() const { return source_length_; }
4524  const String::ExternalOneByteStringResource* source() const {
4525  return &source_; }
4526  int dependency_count() { return dep_count_; }
4527  const char** dependencies() { return deps_; }
4528  void set_auto_enable(bool value) { auto_enable_ = value; }
4529  bool auto_enable() { return auto_enable_; }
4530 
4531  private:
4532  const char* name_;
4533  size_t source_length_; // expected to initialize before source_
4535  int dep_count_;
4536  const char** deps_;
4537  bool auto_enable_;
4538 
4539  // Disallow copying and assigning.
4540  Extension(const Extension&);
4541  void operator=(const Extension&);
4542 };
4543 
4544 
4545 void V8_EXPORT RegisterExtension(Extension* extension);
4546 
4547 
4548 // --- Statics ---
4549 
4550 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
4551 V8_INLINE Handle<Primitive> Null(Isolate* isolate);
4552 V8_INLINE Handle<Boolean> True(Isolate* isolate);
4553 V8_INLINE Handle<Boolean> False(Isolate* isolate);
4554 
4555 
4565 class V8_EXPORT ResourceConstraints {
4566  public:
4568 
4578  void ConfigureDefaults(uint64_t physical_memory,
4579  uint64_t virtual_memory_limit);
4580 
4581  // Deprecated, will be removed soon.
4582  V8_DEPRECATED("Use two-args version instead",
4583  void ConfigureDefaults(uint64_t physical_memory,
4584  uint64_t virtual_memory_limit,
4585  uint32_t number_of_processors));
4586 
4587  int max_semi_space_size() const { return max_semi_space_size_; }
4588  void set_max_semi_space_size(int value) { max_semi_space_size_ = value; }
4589  int max_old_space_size() const { return max_old_space_size_; }
4590  void set_max_old_space_size(int value) { max_old_space_size_ = value; }
4591  int max_executable_size() const { return max_executable_size_; }
4592  void set_max_executable_size(int value) { max_executable_size_ = value; }
4593  uint32_t* stack_limit() const { return stack_limit_; }
4594  // Sets an address beyond which the VM's stack may not grow.
4595  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
4596  V8_DEPRECATED("Unused, will be removed", int max_available_threads() const) {
4597  return max_available_threads_;
4598  }
4599  // Set the number of threads available to V8, assuming at least 1.
4600  V8_DEPRECATED("Unused, will be removed",
4601  void set_max_available_threads(int value)) {
4602  max_available_threads_ = value;
4603  }
4604  size_t code_range_size() const { return code_range_size_; }
4605  void set_code_range_size(size_t value) {
4606  code_range_size_ = value;
4607  }
4608 
4609  private:
4610  int max_semi_space_size_;
4611  int max_old_space_size_;
4612  int max_executable_size_;
4613  uint32_t* stack_limit_;
4614  int max_available_threads_;
4615  size_t code_range_size_;
4616 };
4617 
4618 
4619 // --- Exceptions ---
4620 
4621 
4622 typedef void (*FatalErrorCallback)(const char* location, const char* message);
4623 
4624 
4625 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
4626 
4627 // --- Tracing ---
4628 
4629 typedef void (*LogEventCallback)(const char* name, int event);
4630 
4635 class V8_EXPORT Exception {
4636  public:
4637  static Local<Value> RangeError(Handle<String> message);
4638  static Local<Value> ReferenceError(Handle<String> message);
4639  static Local<Value> SyntaxError(Handle<String> message);
4640  static Local<Value> TypeError(Handle<String> message);
4641  static Local<Value> Error(Handle<String> message);
4642 
4648  static Local<Message> CreateMessage(Handle<Value> exception);
4649 
4654  static Local<StackTrace> GetStackTrace(Handle<Value> exception);
4655 };
4656 
4657 
4658 // --- Counters Callbacks ---
4659 
4660 typedef int* (*CounterLookupCallback)(const char* name);
4661 
4662 typedef void* (*CreateHistogramCallback)(const char* name,
4663  int min,
4664  int max,
4665  size_t buckets);
4666 
4667 typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
4668 
4669 // --- Memory Allocation Callback ---
4670 enum ObjectSpace {
4671  kObjectSpaceNewSpace = 1 << 0,
4672  kObjectSpaceOldSpace = 1 << 1,
4673  kObjectSpaceCodeSpace = 1 << 2,
4674  kObjectSpaceMapSpace = 1 << 3,
4675  kObjectSpaceLoSpace = 1 << 4,
4676  kObjectSpaceAll = kObjectSpaceNewSpace | kObjectSpaceOldSpace |
4677  kObjectSpaceCodeSpace | kObjectSpaceMapSpace |
4678  kObjectSpaceLoSpace
4679 };
4680 
4681  enum AllocationAction {
4682  kAllocationActionAllocate = 1 << 0,
4683  kAllocationActionFree = 1 << 1,
4684  kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree
4685  };
4686 
4687 typedef void (*MemoryAllocationCallback)(ObjectSpace space,
4688  AllocationAction action,
4689  int size);
4690 
4691 // --- Leave Script Callback ---
4692 typedef void (*CallCompletedCallback)();
4693 
4694 // --- Promise Reject Callback ---
4695 enum PromiseRejectEvent {
4696  kPromiseRejectWithNoHandler = 0,
4697  kPromiseHandlerAddedAfterReject = 1
4698 };
4699 
4701  public:
4702  PromiseRejectMessage(Handle<Promise> promise, PromiseRejectEvent event,
4703  Handle<Value> value, Handle<StackTrace> stack_trace)
4704  : promise_(promise),
4705  event_(event),
4706  value_(value),
4707  stack_trace_(stack_trace) {}
4708 
4709  V8_INLINE Handle<Promise> GetPromise() const { return promise_; }
4710  V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
4711  V8_INLINE Handle<Value> GetValue() const { return value_; }
4712 
4713  // DEPRECATED. Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()
4714  V8_INLINE Handle<StackTrace> GetStackTrace() const { return stack_trace_; }
4715 
4716  private:
4717  Handle<Promise> promise_;
4718  PromiseRejectEvent event_;
4719  Handle<Value> value_;
4720  Handle<StackTrace> stack_trace_;
4721 };
4722 
4723 typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
4724 
4725 // --- Microtask Callback ---
4726 typedef void (*MicrotaskCallback)(void* data);
4727 
4728 // --- Failed Access Check Callback ---
4729 typedef void (*FailedAccessCheckCallback)(Local<Object> target,
4730  AccessType type,
4731  Local<Value> data);
4732 
4733 // --- AllowCodeGenerationFromStrings callbacks ---
4734 
4740 
4741 // --- Garbage Collection Callbacks ---
4742 
4750 enum GCType {
4751  kGCTypeScavenge = 1 << 0,
4752  kGCTypeMarkSweepCompact = 1 << 1,
4753  kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact
4754 };
4755 
4756 enum GCCallbackFlags {
4757  kNoGCCallbackFlags = 0,
4758  kGCCallbackFlagCompacted = 1 << 0,
4759  kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
4760  kGCCallbackFlagForced = 1 << 2
4761 };
4762 
4763 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
4764 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
4765 
4766 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
4767 
4768 
4775 class V8_EXPORT HeapStatistics {
4776  public:
4777  HeapStatistics();
4778  size_t total_heap_size() { return total_heap_size_; }
4779  size_t total_heap_size_executable() { return total_heap_size_executable_; }
4780  size_t total_physical_size() { return total_physical_size_; }
4781  size_t total_available_size() { return total_available_size_; }
4782  size_t used_heap_size() { return used_heap_size_; }
4783  size_t heap_size_limit() { return heap_size_limit_; }
4784 
4785  private:
4786  size_t total_heap_size_;
4787  size_t total_heap_size_executable_;
4788  size_t total_physical_size_;
4789  size_t total_available_size_;
4790  size_t used_heap_size_;
4791  size_t heap_size_limit_;
4792 
4793  friend class V8;
4794  friend class Isolate;
4795 };
4796 
4797 
4798 class V8_EXPORT HeapSpaceStatistics {
4799  public:
4801  const char* space_name() { return space_name_; }
4802  size_t space_size() { return space_size_; }
4803  size_t space_used_size() { return space_used_size_; }
4804  size_t space_available_size() { return space_available_size_; }
4805  size_t physical_space_size() { return physical_space_size_; }
4806 
4807  private:
4808  const char* space_name_;
4809  size_t space_size_;
4810  size_t space_used_size_;
4811  size_t space_available_size_;
4812  size_t physical_space_size_;
4813 
4814  friend class Isolate;
4815 };
4816 
4817 
4818 class RetainedObjectInfo;
4819 
4820 
4832 typedef void (*FunctionEntryHook)(uintptr_t function,
4833  uintptr_t return_addr_location);
4834 
4841  enum EventType {
4842  CODE_ADDED,
4843  CODE_MOVED,
4844  CODE_REMOVED,
4845  CODE_ADD_LINE_POS_INFO,
4846  CODE_START_LINE_INFO_RECORDING,
4847  CODE_END_LINE_INFO_RECORDING
4848  };
4849  // Definition of the code position type. The "POSITION" type means the place
4850  // in the source code which are of interest when making stack traces to
4851  // pin-point the source location of a stack frame as close as possible.
4852  // The "STATEMENT_POSITION" means the place at the beginning of each
4853  // statement, and is used to indicate possible break locations.
4854  enum PositionType { POSITION, STATEMENT_POSITION };
4855 
4856  // Type of event.
4857  EventType type;
4858  // Start of the instructions.
4859  void* code_start;
4860  // Size of the instructions.
4861  size_t code_len;
4862  // Script info for CODE_ADDED event.
4863  Handle<UnboundScript> script;
4864  // User-defined data for *_LINE_INFO_* event. It's used to hold the source
4865  // code line information which is returned from the
4866  // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
4867  // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
4868  void* user_data;
4869 
4870  struct name_t {
4871  // Name of the object associated with the code, note that the string is not
4872  // zero-terminated.
4873  const char* str;
4874  // Number of chars in str.
4875  size_t len;
4876  };
4877 
4878  struct line_info_t {
4879  // PC offset
4880  size_t offset;
4881  // Code postion
4882  size_t pos;
4883  // The position type.
4884  PositionType position_type;
4885  };
4886 
4887  union {
4888  // Only valid for CODE_ADDED.
4889  struct name_t name;
4890 
4891  // Only valid for CODE_ADD_LINE_POS_INFO
4892  struct line_info_t line_info;
4893 
4894  // New location of instructions. Only valid for CODE_MOVED.
4895  void* new_code_start;
4896  };
4897 };
4898 
4903  kJitCodeEventDefault = 0,
4904  // Generate callbacks for already existent code.
4905  kJitCodeEventEnumExisting = 1
4906 };
4907 
4908 
4914 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
4915 
4916 
4920 class V8_EXPORT ExternalResourceVisitor { // NOLINT
4921  public:
4922  virtual ~ExternalResourceVisitor() {}
4923  virtual void VisitExternalString(Handle<String> string) {}
4924 };
4925 
4926 
4930 class V8_EXPORT PersistentHandleVisitor { // NOLINT
4931  public:
4932  virtual ~PersistentHandleVisitor() {}
4933  virtual void VisitPersistentHandle(Persistent<Value>* value,
4934  uint16_t class_id) {}
4935 };
4936 
4937 
4946 class V8_EXPORT Isolate {
4947  public:
4951  struct CreateParams {
4952  CreateParams()
4953  : entry_hook(NULL),
4954  code_event_handler(NULL),
4955  snapshot_blob(NULL),
4956  counter_lookup_callback(NULL),
4957  create_histogram_callback(NULL),
4958  add_histogram_sample_callback(NULL),
4959  array_buffer_allocator(NULL) {}
4960 
4969 
4975 
4980 
4985 
4986 
4991  CounterLookupCallback counter_lookup_callback;
4992 
4999  CreateHistogramCallback create_histogram_callback;
5000  AddHistogramSampleCallback add_histogram_sample_callback;
5001 
5007  };
5008 
5009 
5014  class V8_EXPORT Scope {
5015  public:
5016  explicit Scope(Isolate* isolate) : isolate_(isolate) {
5017  isolate->Enter();
5018  }
5019 
5020  ~Scope() { isolate_->Exit(); }
5021 
5022  private:
5023  Isolate* const isolate_;
5024 
5025  // Prevent copying of Scope objects.
5026  Scope(const Scope&);
5027  Scope& operator=(const Scope&);
5028  };
5029 
5030 
5035  public:
5036  enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
5037 
5038  DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
5040 
5041  private:
5042  bool on_failure_;
5043  void* internal_;
5044 
5045  // Prevent copying of Scope objects.
5049  };
5050 
5051 
5056  public:
5057  explicit AllowJavascriptExecutionScope(Isolate* isolate);
5059 
5060  private:
5061  void* internal_throws_;
5062  void* internal_assert_;
5063 
5064  // Prevent copying of Scope objects.
5066  AllowJavascriptExecutionScope& operator=(
5068  };
5069 
5075  public:
5076  explicit SuppressMicrotaskExecutionScope(Isolate* isolate);
5078 
5079  private:
5080  internal::Isolate* isolate_;
5081 
5082  // Prevent copying of Scope objects.
5086  };
5087 
5093  kFullGarbageCollection,
5094  kMinorGarbageCollection
5095  };
5096 
5103  kUseAsm = 0,
5104  kBreakIterator = 1,
5105  kLegacyConst = 2,
5106  kMarkDequeOverflow = 3,
5107  kStoreBufferOverflow = 4,
5108  kSlotsBufferOverflow = 5,
5109  kObjectObserve = 6,
5110  kForcedGC = 7,
5111  kUseCounterFeatureCount // This enum value must be last.
5112  };
5113 
5114  typedef void (*UseCounterCallback)(Isolate* isolate,
5115  UseCounterFeature feature);
5116 
5117 
5127  static Isolate* New(const CreateParams& params);
5128 
5129  static V8_DEPRECATE_SOON("Always pass CreateParams", Isolate* New());
5130 
5137  static Isolate* GetCurrent();
5138 
5149  void Enter();
5150 
5158  void Exit();
5159 
5164  void Dispose();
5165 
5170  V8_INLINE void SetData(uint32_t slot, void* data);
5171 
5176  V8_INLINE void* GetData(uint32_t slot);
5177 
5182  V8_INLINE static uint32_t GetNumberOfDataSlots();
5183 
5187  void GetHeapStatistics(HeapStatistics* heap_statistics);
5188 
5192  size_t NumberOfHeapSpaces();
5193 
5203  bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
5204  size_t index);
5205 
5218  void GetStackSample(const RegisterState& state, void** frames,
5219  size_t frames_limit, SampleInfo* sample_info);
5220 
5234  V8_INLINE int64_t
5235  AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
5236 
5241  HeapProfiler* GetHeapProfiler();
5242 
5248  CpuProfiler* GetCpuProfiler();
5249 
5251  bool InContext();
5252 
5254  Local<Context> GetCurrentContext();
5255 
5261  Local<Context> GetCallingContext();
5262 
5264  Local<Context> GetEnteredContext();
5265 
5272  Local<Value> ThrowException(Local<Value> exception);
5273 
5285  template<typename T> void SetObjectGroupId(const Persistent<T>& object,
5286  UniqueId id);
5287 
5295  template<typename T> void SetReferenceFromGroup(UniqueId id,
5296  const Persistent<T>& child);
5297 
5304  template<typename T, typename S>
5305  void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
5306 
5307  typedef void (*GCPrologueCallback)(Isolate* isolate,
5308  GCType type,
5309  GCCallbackFlags flags);
5310  typedef void (*GCEpilogueCallback)(Isolate* isolate,
5311  GCType type,
5312  GCCallbackFlags flags);
5313 
5323  void AddGCPrologueCallback(
5324  GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
5325 
5330  void RemoveGCPrologueCallback(GCPrologueCallback callback);
5331 
5341  void AddGCEpilogueCallback(
5342  GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
5343 
5348  void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
5349 
5350 
5358  void TerminateExecution();
5359 
5368  bool IsExecutionTerminating();
5369 
5384  void CancelTerminateExecution();
5385 
5394  void RequestInterrupt(InterruptCallback callback, void* data);
5395 
5406  void RequestGarbageCollectionForTesting(GarbageCollectionType type);
5407 
5411  void SetEventLogger(LogEventCallback that);
5412 
5420  void AddCallCompletedCallback(CallCompletedCallback callback);
5421 
5425  void RemoveCallCompletedCallback(CallCompletedCallback callback);
5426 
5427 
5432  void SetPromiseRejectCallback(PromiseRejectCallback callback);
5433 
5438  void RunMicrotasks();
5439 
5443  void EnqueueMicrotask(Handle<Function> microtask);
5444 
5448  void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
5449 
5454  void SetAutorunMicrotasks(bool autorun);
5455 
5460  bool WillAutorunMicrotasks() const;
5461 
5465  void SetUseCounterCallback(UseCounterCallback callback);
5466 
5471  void SetCounterFunction(CounterLookupCallback);
5472 
5479  void SetCreateHistogramFunction(CreateHistogramCallback);
5480  void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
5481 
5496  bool IdleNotificationDeadline(double deadline_in_seconds);
5497 
5498  V8_DEPRECATE_SOON("use IdleNotificationDeadline()",
5499  bool IdleNotification(int idle_time_in_ms));
5500 
5505  void LowMemoryNotification();
5506 
5516  int ContextDisposedNotification(bool dependant_context = true);
5517 
5540  void SetJitCodeEventHandler(JitCodeEventOptions options,
5541  JitCodeEventHandler event_handler);
5542 
5552  void SetStackLimit(uintptr_t stack_limit);
5553 
5567  void GetCodeRange(void** start, size_t* length_in_bytes);
5568 
5570  void SetFatalErrorHandler(FatalErrorCallback that);
5571 
5576  void SetAllowCodeGenerationFromStringsCallback(
5578 
5583  bool IsDead();
5584 
5594  bool AddMessageListener(MessageCallback that,
5595  Handle<Value> data = Handle<Value>());
5596 
5600  void RemoveMessageListeners(MessageCallback that);
5601 
5603  void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
5604 
5609  void SetCaptureStackTraceForUncaughtExceptions(
5610  bool capture, int frame_limit = 10,
5611  StackTrace::StackTraceOptions options = StackTrace::kOverview);
5612 
5617  void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
5618  ObjectSpace space, AllocationAction action);
5619 
5623  void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
5624 
5630  void VisitExternalResources(ExternalResourceVisitor* visitor);
5631 
5636  void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
5637 
5645  void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
5646 
5647  private:
5648  template <class K, class V, class Traits>
5649  friend class PersistentValueMapBase;
5650 
5651  Isolate();
5652  Isolate(const Isolate&);
5653  ~Isolate();
5654  Isolate& operator=(const Isolate&);
5655  void* operator new(size_t size);
5656  void operator delete(void*, size_t);
5657 
5658  void SetObjectGroupId(internal::Object** object, UniqueId id);
5659  void SetReferenceFromGroup(UniqueId id, internal::Object** object);
5660  void SetReference(internal::Object** parent, internal::Object** child);
5661  void CollectAllGarbage(const char* gc_reason);
5662 };
5663 
5664 class V8_EXPORT StartupData {
5665  public:
5666  const char* data;
5667  int raw_size;
5668 };
5669 
5670 
5675 typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
5676 
5677 
5691 typedef uintptr_t (*ReturnAddressLocationResolver)(
5692  uintptr_t return_addr_location);
5693 
5694 
5698 class V8_EXPORT V8 {
5699  public:
5701  V8_INLINE static V8_DEPRECATE_SOON(
5702  "Use isolate version",
5703  void SetFatalErrorHandler(FatalErrorCallback that));
5704 
5709  V8_INLINE static V8_DEPRECATE_SOON(
5710  "Use isolate version", void SetAllowCodeGenerationFromStringsCallback(
5712 
5719  static V8_DEPRECATE_SOON(
5720  "Use isolate version",
5721  void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator));
5722 
5727  V8_INLINE static V8_DEPRECATE_SOON("no alternative", bool IsDead());
5728 
5744  static void SetNativesDataBlob(StartupData* startup_blob);
5745  static void SetSnapshotDataBlob(StartupData* startup_blob);
5746 
5752  static StartupData CreateSnapshotDataBlob(const char* custom_source = NULL);
5753 
5763  V8_INLINE static V8_DEPRECATE_SOON(
5764  "Use isolate version",
5765  bool AddMessageListener(MessageCallback that,
5766  Handle<Value> data = Handle<Value>()));
5767 
5771  V8_INLINE static V8_DEPRECATE_SOON(
5772  "Use isolate version", void RemoveMessageListeners(MessageCallback that));
5773 
5778  V8_INLINE static V8_DEPRECATE_SOON(
5779  "Use isolate version",
5780  void SetCaptureStackTraceForUncaughtExceptions(
5781  bool capture, int frame_limit = 10,
5782  StackTrace::StackTraceOptions options = StackTrace::kOverview));
5783 
5787  static void SetFlagsFromString(const char* str, int length);
5788 
5792  static void SetFlagsFromCommandLine(int* argc,
5793  char** argv,
5794  bool remove_flags);
5795 
5797  static const char* GetVersion();
5798 
5800  V8_INLINE static V8_DEPRECATE_SOON(
5801  "Use isolate version",
5802  void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback));
5803 
5814  static V8_DEPRECATE_SOON(
5815  "Use isolate version",
5816  void AddGCPrologueCallback(GCPrologueCallback callback,
5817  GCType gc_type_filter = kGCTypeAll));
5818 
5823  V8_INLINE static V8_DEPRECATE_SOON(
5824  "Use isolate version",
5825  void RemoveGCPrologueCallback(GCPrologueCallback callback));
5826 
5837  static V8_DEPRECATE_SOON(
5838  "Use isolate version",
5839  void AddGCEpilogueCallback(GCEpilogueCallback callback,
5840  GCType gc_type_filter = kGCTypeAll));
5841 
5846  V8_INLINE static V8_DEPRECATE_SOON(
5847  "Use isolate version",
5848  void RemoveGCEpilogueCallback(GCEpilogueCallback callback));
5849 
5854  V8_INLINE static V8_DEPRECATE_SOON(
5855  "Use isolate version",
5856  void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
5857  ObjectSpace space,
5858  AllocationAction action));
5859 
5863  V8_INLINE static V8_DEPRECATE_SOON(
5864  "Use isolate version",
5865  void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback));
5866 
5871  static bool Initialize();
5872 
5877  static void SetEntropySource(EntropySource source);
5878 
5883  static void SetReturnAddressLocationResolver(
5884  ReturnAddressLocationResolver return_address_resolver);
5885 
5895  V8_INLINE static V8_DEPRECATE_SOON("Use isolate version",
5896  void TerminateExecution(Isolate* isolate));
5897 
5908  V8_INLINE static V8_DEPRECATE_SOON(
5909  "Use isolate version",
5910  bool IsExecutionTerminating(Isolate* isolate = NULL));
5911 
5928  V8_INLINE static V8_DEPRECATE_SOON(
5929  "Use isolate version", void CancelTerminateExecution(Isolate* isolate));
5930 
5940  static bool Dispose();
5941 
5947  V8_INLINE static V8_DEPRECATE_SOON(
5948  "Use isoalte version",
5949  void VisitExternalResources(ExternalResourceVisitor* visitor));
5950 
5955  V8_INLINE static V8_DEPRECATE_SOON(
5956  "Use isolate version",
5957  void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor));
5958 
5963  V8_INLINE static V8_DEPRECATE_SOON(
5964  "Use isolate version",
5965  void VisitHandlesWithClassIds(Isolate* isolate,
5966  PersistentHandleVisitor* visitor));
5967 
5975  V8_INLINE static V8_DEPRECATE_SOON(
5976  "Use isolate version",
5977  void VisitHandlesForPartialDependence(Isolate* isolate,
5978  PersistentHandleVisitor* visitor));
5979 
5987  static bool InitializeICU(const char* icu_data_file = NULL);
5988 
5993  static void InitializePlatform(Platform* platform);
5994 
5999  static void ShutdownPlatform();
6000 
6001  private:
6002  V8();
6003 
6004  static internal::Object** GlobalizeReference(internal::Isolate* isolate,
6005  internal::Object** handle);
6006  static internal::Object** CopyPersistent(internal::Object** handle);
6007  static void DisposeGlobal(internal::Object** global_handle);
6008  typedef WeakCallbackData<Value, void>::Callback WeakCallback;
6009  static void MakeWeak(internal::Object** global_handle, void* data,
6010  WeakCallback weak_callback);
6011  static void MakeWeak(internal::Object** global_handle, void* data,
6012  WeakCallbackInfo<void>::Callback weak_callback,
6013  WeakCallbackType type);
6014  static void MakeWeak(internal::Object** global_handle, void* data,
6015  // Must be 0 or -1.
6016  int internal_field_index1,
6017  // Must be 1 or -1.
6018  int internal_field_index2,
6019  WeakCallbackInfo<void>::Callback weak_callback);
6020  static void* ClearWeak(internal::Object** global_handle);
6021  static void Eternalize(Isolate* isolate,
6022  Value* handle,
6023  int* index);
6024  static Local<Value> GetEternal(Isolate* isolate, int index);
6025 
6026  static void FromJustIsNothing();
6027  static void ToLocalEmpty();
6028  static void InternalFieldOutOfBounds(int index);
6029  template <class T> friend class Local;
6030  template <class T>
6031  friend class MaybeLocal;
6032  template <class T>
6033  friend class Maybe;
6034  template <class T>
6035  friend class WeakCallbackInfo;
6036  template <class T> friend class Eternal;
6037  template <class T> friend class PersistentBase;
6038  template <class T, class M> friend class Persistent;
6039  friend class Context;
6040 };
6041 
6042 
6053 template <class T>
6054 class Maybe {
6055  public:
6056  V8_INLINE bool IsNothing() const { return !has_value; }
6057  V8_INLINE bool IsJust() const { return has_value; }
6058 
6059  // Will crash if the Maybe<> is nothing.
6060  V8_INLINE T FromJust() const {
6061  if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
6062  return value;
6063  }
6064 
6065  V8_INLINE T FromMaybe(const T& default_value) const {
6066  return has_value ? value : default_value;
6067  }
6068 
6069  V8_INLINE bool operator==(const Maybe& other) const {
6070  return (IsJust() == other.IsJust()) &&
6071  (!IsJust() || FromJust() == other.FromJust());
6072  }
6073 
6074  V8_INLINE bool operator!=(const Maybe& other) const {
6075  return !operator==(other);
6076  }
6077 
6078  private:
6079  Maybe() : has_value(false) {}
6080  explicit Maybe(const T& t) : has_value(true), value(t) {}
6081 
6082  bool has_value;
6083  T value;
6084 
6085  template <class U>
6086  friend Maybe<U> Nothing();
6087  template <class U>
6088  friend Maybe<U> Just(const U& u);
6089 };
6090 
6091 
6092 template <class T>
6093 inline Maybe<T> Nothing() {
6094  return Maybe<T>();
6095 }
6096 
6097 
6098 template <class T>
6099 inline Maybe<T> Just(const T& t) {
6100  return Maybe<T>(t);
6101 }
6102 
6103 
6107 class V8_EXPORT TryCatch {
6108  public:
6114  V8_DEPRECATE_SOON("Use isolate version", TryCatch());
6115 
6121  TryCatch(Isolate* isolate);
6122 
6126  ~TryCatch();
6127 
6131  bool HasCaught() const;
6132 
6141  bool CanContinue() const;
6142 
6155  bool HasTerminated() const;
6156 
6164  Handle<Value> ReThrow();
6165 
6172  Local<Value> Exception() const;
6173 
6178  V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace()) const;
6179  V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
6180  Local<Context> context) const;
6181 
6189  Local<v8::Message> Message() const;
6190 
6201  void Reset();
6202 
6211  void SetVerbose(bool value);
6212 
6218  void SetCaptureMessage(bool value);
6219 
6231  static void* JSStackComparableAddress(v8::TryCatch* handler) {
6232  if (handler == NULL) return NULL;
6233  return handler->js_stack_comparable_address_;
6234  }
6235 
6236  private:
6237  void ResetInternal();
6238 
6239  // Make it hard to create heap-allocated TryCatch blocks.
6240  TryCatch(const TryCatch&);
6241  void operator=(const TryCatch&);
6242  void* operator new(size_t size);
6243  void operator delete(void*, size_t);
6244 
6245  v8::internal::Isolate* isolate_;
6246  v8::TryCatch* next_;
6247  void* exception_;
6248  void* message_obj_;
6249  void* js_stack_comparable_address_;
6250  bool is_verbose_ : 1;
6251  bool can_continue_ : 1;
6252  bool capture_message_ : 1;
6253  bool rethrow_ : 1;
6254  bool has_terminated_ : 1;
6255 
6256  friend class v8::internal::Isolate;
6257 };
6258 
6259 
6260 // --- Context ---
6261 
6262 
6266 class V8_EXPORT ExtensionConfiguration {
6267  public:
6268  ExtensionConfiguration() : name_count_(0), names_(NULL) { }
6269  ExtensionConfiguration(int name_count, const char* names[])
6270  : name_count_(name_count), names_(names) { }
6271 
6272  const char** begin() const { return &names_[0]; }
6273  const char** end() const { return &names_[name_count_]; }
6274 
6275  private:
6276  const int name_count_;
6277  const char** names_;
6278 };
6279 
6280 
6285 class V8_EXPORT Context {
6286  public:
6300 
6305  void DetachGlobal();
6306 
6325  static Local<Context> New(
6326  Isolate* isolate,
6327  ExtensionConfiguration* extensions = NULL,
6328  Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
6329  Handle<Value> global_object = Handle<Value>());
6330 
6335  void SetSecurityToken(Handle<Value> token);
6336 
6338  void UseDefaultSecurityToken();
6339 
6341  Handle<Value> GetSecurityToken();
6342 
6349  void Enter();
6350 
6355  void Exit();
6356 
6358  v8::Isolate* GetIsolate();
6359 
6365  enum EmbedderDataFields { kDebugIdIndex = 0 };
6366 
6372  V8_INLINE Local<Value> GetEmbedderData(int index);
6373 
6379  void SetEmbedderData(int index, Handle<Value> value);
6380 
6387  V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
6388 
6394  void SetAlignedPointerInEmbedderData(int index, void* value);
6395 
6409  void AllowCodeGenerationFromStrings(bool allow);
6410 
6415  bool IsCodeGenerationFromStringsAllowed();
6416 
6422  void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
6423 
6428  class Scope {
6429  public:
6430  explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
6431  context_->Enter();
6432  }
6433  V8_INLINE ~Scope() { context_->Exit(); }
6434 
6435  private:
6436  Handle<Context> context_;
6437  };
6438 
6439  private:
6440  friend class Value;
6441  friend class Script;
6442  friend class Object;
6443  friend class Function;
6444 
6445  Local<Value> SlowGetEmbedderData(int index);
6446  void* SlowGetAlignedPointerFromEmbedderData(int index);
6447 };
6448 
6449 
6526 class V8_EXPORT Unlocker {
6527  public:
6531  V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
6532 
6533  ~Unlocker();
6534  private:
6535  void Initialize(Isolate* isolate);
6536 
6537  internal::Isolate* isolate_;
6538 };
6539 
6540 
6541 class V8_EXPORT Locker {
6542  public:
6546  V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
6547 
6548  ~Locker();
6549 
6554  static bool IsLocked(Isolate* isolate);
6555 
6559  static bool IsActive();
6560 
6561  private:
6562  void Initialize(Isolate* isolate);
6563 
6564  bool has_lock_;
6565  bool top_level_;
6566  internal::Isolate* isolate_;
6567 
6568  // Disallow copying and assigning.
6569  Locker(const Locker&);
6570  void operator=(const Locker&);
6571 };
6572 
6573 
6574 // --- Implementation ---
6575 
6576 
6577 namespace internal {
6578 
6579 const int kApiPointerSize = sizeof(void*); // NOLINT
6580 const int kApiIntSize = sizeof(int); // NOLINT
6581 const int kApiInt64Size = sizeof(int64_t); // NOLINT
6582 
6583 // Tag information for HeapObject.
6584 const int kHeapObjectTag = 1;
6585 const int kHeapObjectTagSize = 2;
6586 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
6587 
6588 // Tag information for Smi.
6589 const int kSmiTag = 0;
6590 const int kSmiTagSize = 1;
6591 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
6592 
6593 template <size_t ptr_size> struct SmiTagging;
6594 
6595 template<int kSmiShiftSize>
6596 V8_INLINE internal::Object* IntToSmi(int value) {
6597  int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
6598  uintptr_t tagged_value =
6599  (static_cast<uintptr_t>(value) << smi_shift_bits) | kSmiTag;
6600  return reinterpret_cast<internal::Object*>(tagged_value);
6601 }
6602 
6603 // Smi constants for 32-bit systems.
6604 template <> struct SmiTagging<4> {
6605  enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
6606  static int SmiShiftSize() { return kSmiShiftSize; }
6607  static int SmiValueSize() { return kSmiValueSize; }
6608  V8_INLINE static int SmiToInt(const internal::Object* value) {
6609  int shift_bits = kSmiTagSize + kSmiShiftSize;
6610  // Throw away top 32 bits and shift down (requires >> to be sign extending).
6611  return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
6612  }
6613  V8_INLINE static internal::Object* IntToSmi(int value) {
6614  return internal::IntToSmi<kSmiShiftSize>(value);
6615  }
6616  V8_INLINE static bool IsValidSmi(intptr_t value) {
6617  // To be representable as an tagged small integer, the two
6618  // most-significant bits of 'value' must be either 00 or 11 due to
6619  // sign-extension. To check this we add 01 to the two
6620  // most-significant bits, and check if the most-significant bit is 0
6621  //
6622  // CAUTION: The original code below:
6623  // bool result = ((value + 0x40000000) & 0x80000000) == 0;
6624  // may lead to incorrect results according to the C language spec, and
6625  // in fact doesn't work correctly with gcc4.1.1 in some cases: The
6626  // compiler may produce undefined results in case of signed integer
6627  // overflow. The computation must be done w/ unsigned ints.
6628  return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
6629  }
6630 };
6631 
6632 // Smi constants for 64-bit systems.
6633 template <> struct SmiTagging<8> {
6634  enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
6635  static int SmiShiftSize() { return kSmiShiftSize; }
6636  static int SmiValueSize() { return kSmiValueSize; }
6637  V8_INLINE static int SmiToInt(const internal::Object* value) {
6638  int shift_bits = kSmiTagSize + kSmiShiftSize;
6639  // Shift down and throw away top 32 bits.
6640  return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
6641  }
6642  V8_INLINE static internal::Object* IntToSmi(int value) {
6643  return internal::IntToSmi<kSmiShiftSize>(value);
6644  }
6645  V8_INLINE static bool IsValidSmi(intptr_t value) {
6646  // To be representable as a long smi, the value must be a 32-bit integer.
6647  return (value == static_cast<int32_t>(value));
6648  }
6649 };
6650 
6652 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
6653 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
6654 V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
6655 V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
6656 
6662 class Internals {
6663  public:
6664  // These values match non-compiler-dependent values defined within
6665  // the implementation of v8.
6666  static const int kHeapObjectMapOffset = 0;
6667  static const int kMapInstanceTypeAndBitFieldOffset =
6668  1 * kApiPointerSize + kApiIntSize;
6669  static const int kStringResourceOffset = 3 * kApiPointerSize;
6670 
6671  static const int kOddballKindOffset = 3 * kApiPointerSize;
6672  static const int kForeignAddressOffset = kApiPointerSize;
6673  static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
6674  static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
6675  static const int kContextHeaderSize = 2 * kApiPointerSize;
6676  static const int kContextEmbedderDataIndex = 77;
6677  static const int kFullStringRepresentationMask = 0x07;
6678  static const int kStringEncodingMask = 0x4;
6679  static const int kExternalTwoByteRepresentationTag = 0x02;
6680  static const int kExternalOneByteRepresentationTag = 0x06;
6681 
6682  static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
6683  static const int kAmountOfExternalAllocatedMemoryOffset =
6684  4 * kApiPointerSize;
6685  static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset =
6686  kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size;
6687  static const int kIsolateRootsOffset =
6688  kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset + kApiInt64Size +
6689  kApiPointerSize;
6690  static const int kUndefinedValueRootIndex = 5;
6691  static const int kNullValueRootIndex = 7;
6692  static const int kTrueValueRootIndex = 8;
6693  static const int kFalseValueRootIndex = 9;
6694  static const int kEmptyStringRootIndex = 10;
6695 
6696  // The external allocation limit should be below 256 MB on all architectures
6697  // to avoid that resource-constrained embedders run low on memory.
6698  static const int kExternalAllocationLimit = 192 * 1024 * 1024;
6699 
6700  static const int kNodeClassIdOffset = 1 * kApiPointerSize;
6701  static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
6702  static const int kNodeStateMask = 0x7;
6703  static const int kNodeStateIsWeakValue = 2;
6704  static const int kNodeStateIsPendingValue = 3;
6705  static const int kNodeStateIsNearDeathValue = 4;
6706  static const int kNodeIsIndependentShift = 3;
6707  static const int kNodeIsPartiallyDependentShift = 4;
6708 
6709  static const int kJSObjectType = 0xbe;
6710  static const int kFirstNonstringType = 0x80;
6711  static const int kOddballType = 0x83;
6712  static const int kForeignType = 0x86;
6713 
6714  static const int kUndefinedOddballKind = 5;
6715  static const int kNullOddballKind = 3;
6716 
6717  static const uint32_t kNumIsolateDataSlots = 4;
6718 
6719  V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
6720  V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
6721 #ifdef V8_ENABLE_CHECKS
6722  CheckInitializedImpl(isolate);
6723 #endif
6724  }
6725 
6726  V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
6727  return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
6728  kHeapObjectTag);
6729  }
6730 
6731  V8_INLINE static int SmiValue(const internal::Object* value) {
6732  return PlatformSmiTagging::SmiToInt(value);
6733  }
6734 
6735  V8_INLINE static internal::Object* IntToSmi(int value) {
6736  return PlatformSmiTagging::IntToSmi(value);
6737  }
6738 
6739  V8_INLINE static bool IsValidSmi(intptr_t value) {
6740  return PlatformSmiTagging::IsValidSmi(value);
6741  }
6742 
6743  V8_INLINE static int GetInstanceType(const internal::Object* obj) {
6744  typedef internal::Object O;
6745  O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
6746  // Map::InstanceType is defined so that it will always be loaded into
6747  // the LS 8 bits of one 16-bit word, regardless of endianess.
6748  return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
6749  }
6750 
6751  V8_INLINE static int GetOddballKind(const internal::Object* obj) {
6752  typedef internal::Object O;
6753  return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
6754  }
6755 
6756  V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
6757  int representation = (instance_type & kFullStringRepresentationMask);
6758  return representation == kExternalTwoByteRepresentationTag;
6759  }
6760 
6761  V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
6762  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
6763  return *addr & static_cast<uint8_t>(1U << shift);
6764  }
6765 
6766  V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
6767  bool value, int shift) {
6768  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
6769  uint8_t mask = static_cast<uint8_t>(1U << shift);
6770  *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
6771  }
6772 
6773  V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
6774  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
6775  return *addr & kNodeStateMask;
6776  }
6777 
6778  V8_INLINE static void UpdateNodeState(internal::Object** obj,
6779  uint8_t value) {
6780  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
6781  *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
6782  }
6783 
6784  V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
6785  uint32_t slot,
6786  void* data) {
6787  uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
6788  kIsolateEmbedderDataOffset + slot * kApiPointerSize;
6789  *reinterpret_cast<void**>(addr) = data;
6790  }
6791 
6792  V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
6793  uint32_t slot) {
6794  const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
6795  kIsolateEmbedderDataOffset + slot * kApiPointerSize;
6796  return *reinterpret_cast<void* const*>(addr);
6797  }
6798 
6799  V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
6800  int index) {
6801  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
6802  return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
6803  }
6804 
6805  template <typename T>
6806  V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
6807  const uint8_t* addr =
6808  reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
6809  return *reinterpret_cast<const T*>(addr);
6810  }
6811 
6812  template <typename T>
6813  V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
6814  typedef internal::Object O;
6815  typedef internal::Internals I;
6816  O* ctx = *reinterpret_cast<O* const*>(context);
6817  int embedder_data_offset = I::kContextHeaderSize +
6818  (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
6819  O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
6820  int value_offset =
6821  I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
6822  return I::ReadField<T>(embedder_data, value_offset);
6823  }
6824 };
6825 
6826 } // namespace internal
6827 
6828 
6829 template <class T>
6831  return New(isolate, that.val_);
6832 }
6833 
6834 template <class T>
6835 Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
6836  return New(isolate, that.val_);
6837 }
6838 
6839 
6840 template <class T>
6841 Local<T> Local<T>::New(Isolate* isolate, T* that) {
6842  if (that == NULL) return Local<T>();
6843  T* that_ptr = that;
6844  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
6845  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
6846  reinterpret_cast<internal::Isolate*>(isolate), *p)));
6847 }
6848 
6849 
6850 template<class T>
6851 template<class S>
6852 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
6853  TYPE_CHECK(T, S);
6854  V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
6855 }
6856 
6857 
6858 template<class T>
6859 Local<T> Eternal<T>::Get(Isolate* isolate) {
6860  return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
6861 }
6862 
6863 
6864 template <class T>
6865 Local<T> MaybeLocal<T>::ToLocalChecked() {
6866  if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
6867  return Local<T>(val_);
6868 }
6869 
6870 
6871 template <class T>
6872 void* WeakCallbackInfo<T>::GetInternalField(int index) const {
6873 #ifdef V8_ENABLE_CHECKS
6874  if (index < 0 || index >= kInternalFieldsInWeakCallback) {
6875  V8::InternalFieldOutOfBounds(index);
6876  }
6877 #endif
6878  return internal_fields_[index];
6879 }
6880 
6881 
6882 template <class T>
6883 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
6884  if (that == NULL) return NULL;
6885  internal::Object** p = reinterpret_cast<internal::Object**>(that);
6886  return reinterpret_cast<T*>(
6887  V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
6888  p));
6889 }
6890 
6891 
6892 template <class T, class M>
6893 template <class S, class M2>
6894 void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
6895  TYPE_CHECK(T, S);
6896  this->Reset();
6897  if (that.IsEmpty()) return;
6898  internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
6899  this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
6900  M::Copy(that, this);
6901 }
6902 
6903 
6904 template <class T>
6905 bool PersistentBase<T>::IsIndependent() const {
6906  typedef internal::Internals I;
6907  if (this->IsEmpty()) return false;
6908  return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
6909  I::kNodeIsIndependentShift);
6910 }
6911 
6912 
6913 template <class T>
6915  typedef internal::Internals I;
6916  if (this->IsEmpty()) return false;
6917  uint8_t node_state =
6918  I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
6919  return node_state == I::kNodeStateIsNearDeathValue ||
6920  node_state == I::kNodeStateIsPendingValue;
6921 }
6922 
6923 
6924 template <class T>
6926  typedef internal::Internals I;
6927  if (this->IsEmpty()) return false;
6928  return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
6929  I::kNodeStateIsWeakValue;
6930 }
6931 
6932 
6933 template <class T>
6935  if (this->IsEmpty()) return;
6936  V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
6937  val_ = 0;
6938 }
6939 
6940 
6941 template <class T>
6942 template <class S>
6943 void PersistentBase<T>::Reset(Isolate* isolate, const Handle<S>& other) {
6944  TYPE_CHECK(T, S);
6945  Reset();
6946  if (other.IsEmpty()) return;
6947  this->val_ = New(isolate, other.val_);
6948 }
6949 
6950 
6951 template <class T>
6952 template <class S>
6953 void PersistentBase<T>::Reset(Isolate* isolate,
6954  const PersistentBase<S>& other) {
6955  TYPE_CHECK(T, S);
6956  Reset();
6957  if (other.IsEmpty()) return;
6958  this->val_ = New(isolate, other.val_);
6959 }
6960 
6961 
6962 template <class T>
6963 template <typename S, typename P>
6964 void PersistentBase<T>::SetWeak(
6965  P* parameter,
6966  typename WeakCallbackData<S, P>::Callback callback) {
6967  TYPE_CHECK(S, T);
6968  typedef typename WeakCallbackData<Value, void>::Callback Callback;
6969  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
6970  reinterpret_cast<Callback>(callback));
6971 }
6972 
6973 
6974 template <class T>
6975 template <typename P>
6976 void PersistentBase<T>::SetWeak(
6977  P* parameter,
6978  typename WeakCallbackData<T, P>::Callback callback) {
6979  SetWeak<T, P>(parameter, callback);
6980 }
6981 
6982 
6983 template <class T>
6984 template <typename P>
6985 void PersistentBase<T>::SetPhantom(
6986  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
6987  int internal_field_index1, int internal_field_index2) {
6988  typedef typename WeakCallbackInfo<void>::Callback Callback;
6989  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
6990  internal_field_index1, internal_field_index2,
6991  reinterpret_cast<Callback>(callback));
6992 }
6993 
6994 
6995 template <class T>
6996 template <typename P>
6997 V8_INLINE void PersistentBase<T>::SetWeak(
6998  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
6999  WeakCallbackType type) {
7000  typedef typename WeakCallbackInfo<void>::Callback Callback;
7001  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
7002  reinterpret_cast<Callback>(callback), type);
7003 }
7004 
7005 
7006 template <class T>
7007 template <typename P>
7008 P* PersistentBase<T>::ClearWeak() {
7009  return reinterpret_cast<P*>(
7010  V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
7011 }
7012 
7013 
7014 template <class T>
7016  typedef internal::Internals I;
7017  if (this->IsEmpty()) return;
7018  I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
7019  true,
7020  I::kNodeIsIndependentShift);
7021 }
7022 
7023 
7024 template <class T>
7026  typedef internal::Internals I;
7027  if (this->IsEmpty()) return;
7028  I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
7029  true,
7030  I::kNodeIsPartiallyDependentShift);
7031 }
7032 
7033 
7034 template <class T>
7035 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
7036  typedef internal::Internals I;
7037  if (this->IsEmpty()) return;
7038  internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
7039  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
7040  *reinterpret_cast<uint16_t*>(addr) = class_id;
7041 }
7042 
7043 
7044 template <class T>
7046  typedef internal::Internals I;
7047  if (this->IsEmpty()) return 0;
7048  internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
7049  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
7050  return *reinterpret_cast<uint16_t*>(addr);
7051 }
7052 
7053 
7054 template<typename T>
7055 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
7056 
7057 template<typename T>
7058 template<typename S>
7059 void ReturnValue<T>::Set(const Persistent<S>& handle) {
7060  TYPE_CHECK(T, S);
7061  if (V8_UNLIKELY(handle.IsEmpty())) {
7062  *value_ = GetDefaultValue();
7063  } else {
7064  *value_ = *reinterpret_cast<internal::Object**>(*handle);
7065  }
7066 }
7067 
7068 template<typename T>
7069 template<typename S>
7070 void ReturnValue<T>::Set(const Handle<S> handle) {
7071  TYPE_CHECK(T, S);
7072  if (V8_UNLIKELY(handle.IsEmpty())) {
7073  *value_ = GetDefaultValue();
7074  } else {
7075  *value_ = *reinterpret_cast<internal::Object**>(*handle);
7076  }
7077 }
7078 
7079 template<typename T>
7080 void ReturnValue<T>::Set(double i) {
7081  TYPE_CHECK(T, Number);
7082  Set(Number::New(GetIsolate(), i));
7083 }
7084 
7085 template<typename T>
7086 void ReturnValue<T>::Set(int32_t i) {
7087  TYPE_CHECK(T, Integer);
7088  typedef internal::Internals I;
7089  if (V8_LIKELY(I::IsValidSmi(i))) {
7090  *value_ = I::IntToSmi(i);
7091  return;
7092  }
7093  Set(Integer::New(GetIsolate(), i));
7094 }
7095 
7096 template<typename T>
7097 void ReturnValue<T>::Set(uint32_t i) {
7098  TYPE_CHECK(T, Integer);
7099  // Can't simply use INT32_MAX here for whatever reason.
7100  bool fits_into_int32_t = (i & (1U << 31)) == 0;
7101  if (V8_LIKELY(fits_into_int32_t)) {
7102  Set(static_cast<int32_t>(i));
7103  return;
7104  }
7105  Set(Integer::NewFromUnsigned(GetIsolate(), i));
7106 }
7107 
7108 template<typename T>
7109 void ReturnValue<T>::Set(bool value) {
7110  TYPE_CHECK(T, Boolean);
7111  typedef internal::Internals I;
7112  int root_index;
7113  if (value) {
7114  root_index = I::kTrueValueRootIndex;
7115  } else {
7116  root_index = I::kFalseValueRootIndex;
7117  }
7118  *value_ = *I::GetRoot(GetIsolate(), root_index);
7119 }
7120 
7121 template<typename T>
7122 void ReturnValue<T>::SetNull() {
7123  TYPE_CHECK(T, Primitive);
7124  typedef internal::Internals I;
7125  *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
7126 }
7127 
7128 template<typename T>
7129 void ReturnValue<T>::SetUndefined() {
7130  TYPE_CHECK(T, Primitive);
7131  typedef internal::Internals I;
7132  *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
7133 }
7134 
7135 template<typename T>
7136 void ReturnValue<T>::SetEmptyString() {
7137  TYPE_CHECK(T, String);
7138  typedef internal::Internals I;
7139  *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
7140 }
7141 
7142 template<typename T>
7143 Isolate* ReturnValue<T>::GetIsolate() {
7144  // Isolate is always the pointer below the default value on the stack.
7145  return *reinterpret_cast<Isolate**>(&value_[-2]);
7146 }
7147 
7148 template<typename T>
7149 template<typename S>
7150 void ReturnValue<T>::Set(S* whatever) {
7151  // Uncompilable to prevent inadvertent misuse.
7152  TYPE_CHECK(S*, Primitive);
7153 }
7154 
7155 template<typename T>
7156 internal::Object* ReturnValue<T>::GetDefaultValue() {
7157  // Default value is always the pointer below value_ on the stack.
7158  return value_[-1];
7159 }
7160 
7161 
7162 template<typename T>
7163 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
7164  internal::Object** values,
7165  int length,
7166  bool is_construct_call)
7167  : implicit_args_(implicit_args),
7168  values_(values),
7169  length_(length),
7170  is_construct_call_(is_construct_call) { }
7171 
7172 
7173 template<typename T>
7174 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
7175  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
7176  return Local<Value>(reinterpret_cast<Value*>(values_ - i));
7177 }
7178 
7179 
7180 template<typename T>
7181 Local<Function> FunctionCallbackInfo<T>::Callee() const {
7182  return Local<Function>(reinterpret_cast<Function*>(
7183  &implicit_args_[kCalleeIndex]));
7184 }
7185 
7186 
7187 template<typename T>
7188 Local<Object> FunctionCallbackInfo<T>::This() const {
7189  return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
7190 }
7191 
7192 
7193 template<typename T>
7194 Local<Object> FunctionCallbackInfo<T>::Holder() const {
7195  return Local<Object>(reinterpret_cast<Object*>(
7196  &implicit_args_[kHolderIndex]));
7197 }
7198 
7199 
7200 template<typename T>
7201 Local<Value> FunctionCallbackInfo<T>::Data() const {
7202  return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
7203 }
7204 
7205 
7206 template<typename T>
7207 Isolate* FunctionCallbackInfo<T>::GetIsolate() const {
7208  return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
7209 }
7210 
7211 
7212 template<typename T>
7213 ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const {
7214  return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
7215 }
7216 
7217 
7218 template<typename T>
7219 bool FunctionCallbackInfo<T>::IsConstructCall() const {
7220  return is_construct_call_ & 0x1;
7221 }
7222 
7223 
7224 template<typename T>
7225 int FunctionCallbackInfo<T>::Length() const {
7226  return length_;
7227 }
7228 
7229 
7230 Handle<Value> ScriptOrigin::ResourceName() const {
7231  return resource_name_;
7232 }
7233 
7234 
7235 Handle<Integer> ScriptOrigin::ResourceLineOffset() const {
7236  return resource_line_offset_;
7237 }
7238 
7239 
7240 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
7241  return resource_column_offset_;
7242 }
7243 
7244 
7246  return resource_is_embedder_debug_script_;
7247 }
7248 
7249 
7250 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const {
7251  return resource_is_shared_cross_origin_;
7252 }
7253 
7254 
7255 Handle<Integer> ScriptOrigin::ScriptID() const {
7256  return script_id_;
7257 }
7258 
7259 
7260 Handle<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
7261 
7262 
7263 ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
7264  CachedData* data)
7265  : source_string(string),
7266  resource_name(origin.ResourceName()),
7267  resource_line_offset(origin.ResourceLineOffset()),
7268  resource_column_offset(origin.ResourceColumnOffset()),
7269  resource_is_embedder_debug_script(origin.ResourceIsEmbedderDebugScript()),
7270  resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()),
7271  source_map_url(origin.SourceMapUrl()),
7272  cached_data(data) {}
7273 
7274 
7275 ScriptCompiler::Source::Source(Local<String> string,
7276  CachedData* data)
7277  : source_string(string), cached_data(data) {}
7278 
7279 
7280 ScriptCompiler::Source::~Source() {
7281  delete cached_data;
7282 }
7283 
7284 
7285 const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
7286  const {
7287  return cached_data;
7288 }
7289 
7290 
7291 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) {
7292  return value ? True(isolate) : False(isolate);
7293 }
7294 
7295 
7296 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) {
7297  Set(v8::String::NewFromUtf8(isolate, name), value);
7298 }
7299 
7300 
7302 #ifndef V8_ENABLE_CHECKS
7303  typedef internal::Object O;
7304  typedef internal::HeapObject HO;
7305  typedef internal::Internals I;
7306  O* obj = *reinterpret_cast<O**>(this);
7307  // Fast path: If the object is a plain JSObject, which is the common case, we
7308  // know where to find the internal fields and can return the value directly.
7309  if (I::GetInstanceType(obj) == I::kJSObjectType) {
7310  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
7311  O* value = I::ReadField<O*>(obj, offset);
7312  O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
7313  return Local<Value>(reinterpret_cast<Value*>(result));
7314  }
7315 #endif
7316  return SlowGetInternalField(index);
7317 }
7318 
7319 
7321 #ifndef V8_ENABLE_CHECKS
7322  typedef internal::Object O;
7323  typedef internal::Internals I;
7324  O* obj = *reinterpret_cast<O**>(this);
7325  // Fast path: If the object is a plain JSObject, which is the common case, we
7326  // know where to find the internal fields and can return the value directly.
7327  if (V8_LIKELY(I::GetInstanceType(obj) == I::kJSObjectType)) {
7328  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
7329  return I::ReadField<void*>(obj, offset);
7330  }
7331 #endif
7332  return SlowGetAlignedPointerFromInternalField(index);
7333 }
7334 
7335 
7336 String* String::Cast(v8::Value* value) {
7337 #ifdef V8_ENABLE_CHECKS
7338  CheckCast(value);
7339 #endif
7340  return static_cast<String*>(value);
7341 }
7342 
7343 
7345  typedef internal::Object* S;
7346  typedef internal::Internals I;
7347  I::CheckInitialized(isolate);
7348  S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
7349  return Local<String>(reinterpret_cast<String*>(slot));
7350 }
7351 
7352 
7354  typedef internal::Object O;
7355  typedef internal::Internals I;
7356  O* obj = *reinterpret_cast<O* const*>(this);
7358  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
7359  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
7360  result = reinterpret_cast<String::ExternalStringResource*>(value);
7361  } else {
7362  result = NULL;
7363  }
7364 #ifdef V8_ENABLE_CHECKS
7365  VerifyExternalStringResource(result);
7366 #endif
7367  return result;
7368 }
7369 
7370 
7372  String::Encoding* encoding_out) const {
7373  typedef internal::Object O;
7374  typedef internal::Internals I;
7375  O* obj = *reinterpret_cast<O* const*>(this);
7376  int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
7377  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
7378  ExternalStringResourceBase* resource = NULL;
7379  if (type == I::kExternalOneByteRepresentationTag ||
7380  type == I::kExternalTwoByteRepresentationTag) {
7381  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
7382  resource = static_cast<ExternalStringResourceBase*>(value);
7383  }
7384 #ifdef V8_ENABLE_CHECKS
7385  VerifyExternalStringResourceBase(resource, *encoding_out);
7386 #endif
7387  return resource;
7388 }
7389 
7390 
7391 bool Value::IsUndefined() const {
7392 #ifdef V8_ENABLE_CHECKS
7393  return FullIsUndefined();
7394 #else
7395  return QuickIsUndefined();
7396 #endif
7397 }
7398 
7399 bool Value::QuickIsUndefined() const {
7400  typedef internal::Object O;
7401  typedef internal::Internals I;
7402  O* obj = *reinterpret_cast<O* const*>(this);
7403  if (!I::HasHeapObjectTag(obj)) return false;
7404  if (I::GetInstanceType(obj) != I::kOddballType) return false;
7405  return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
7406 }
7407 
7408 
7409 bool Value::IsNull() const {
7410 #ifdef V8_ENABLE_CHECKS
7411  return FullIsNull();
7412 #else
7413  return QuickIsNull();
7414 #endif
7415 }
7416 
7417 bool Value::QuickIsNull() const {
7418  typedef internal::Object O;
7419  typedef internal::Internals I;
7420  O* obj = *reinterpret_cast<O* const*>(this);
7421  if (!I::HasHeapObjectTag(obj)) return false;
7422  if (I::GetInstanceType(obj) != I::kOddballType) return false;
7423  return (I::GetOddballKind(obj) == I::kNullOddballKind);
7424 }
7425 
7426 
7427 bool Value::IsString() const {
7428 #ifdef V8_ENABLE_CHECKS
7429  return FullIsString();
7430 #else
7431  return QuickIsString();
7432 #endif
7433 }
7434 
7435 bool Value::QuickIsString() const {
7436  typedef internal::Object O;
7437  typedef internal::Internals I;
7438  O* obj = *reinterpret_cast<O* const*>(this);
7439  if (!I::HasHeapObjectTag(obj)) return false;
7440  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
7441 }
7442 
7443 
7444 template <class T> Value* Value::Cast(T* value) {
7445  return static_cast<Value*>(value);
7446 }
7447 
7448 
7449 Local<Boolean> Value::ToBoolean() const {
7450  return ToBoolean(Isolate::GetCurrent());
7451 }
7452 
7453 
7454 Local<Number> Value::ToNumber() const {
7455  return ToNumber(Isolate::GetCurrent());
7456 }
7457 
7458 
7459 Local<String> Value::ToString() const {
7460  return ToString(Isolate::GetCurrent());
7461 }
7462 
7463 
7464 Local<String> Value::ToDetailString() const {
7465  return ToDetailString(Isolate::GetCurrent());
7466 }
7467 
7468 
7469 Local<Object> Value::ToObject() const {
7470  return ToObject(Isolate::GetCurrent());
7471 }
7472 
7473 
7474 Local<Integer> Value::ToInteger() const {
7475  return ToInteger(Isolate::GetCurrent());
7476 }
7477 
7478 
7479 Local<Uint32> Value::ToUint32() const {
7480  return ToUint32(Isolate::GetCurrent());
7481 }
7482 
7483 
7484 Local<Int32> Value::ToInt32() const { return ToInt32(Isolate::GetCurrent()); }
7485 
7486 
7487 Boolean* Boolean::Cast(v8::Value* value) {
7488 #ifdef V8_ENABLE_CHECKS
7489  CheckCast(value);
7490 #endif
7491  return static_cast<Boolean*>(value);
7492 }
7493 
7494 
7495 Name* Name::Cast(v8::Value* value) {
7496 #ifdef V8_ENABLE_CHECKS
7497  CheckCast(value);
7498 #endif
7499  return static_cast<Name*>(value);
7500 }
7501 
7502 
7503 Symbol* Symbol::Cast(v8::Value* value) {
7504 #ifdef V8_ENABLE_CHECKS
7505  CheckCast(value);
7506 #endif
7507  return static_cast<Symbol*>(value);
7508 }
7509 
7510 
7511 Number* Number::Cast(v8::Value* value) {
7512 #ifdef V8_ENABLE_CHECKS
7513  CheckCast(value);
7514 #endif
7515  return static_cast<Number*>(value);
7516 }
7517 
7518 
7519 Integer* Integer::Cast(v8::Value* value) {
7520 #ifdef V8_ENABLE_CHECKS
7521  CheckCast(value);
7522 #endif
7523  return static_cast<Integer*>(value);
7524 }
7525 
7526 
7527 Int32* Int32::Cast(v8::Value* value) {
7528 #ifdef V8_ENABLE_CHECKS
7529  CheckCast(value);
7530 #endif
7531  return static_cast<Int32*>(value);
7532 }
7533 
7534 
7535 Uint32* Uint32::Cast(v8::Value* value) {
7536 #ifdef V8_ENABLE_CHECKS
7537  CheckCast(value);
7538 #endif
7539  return static_cast<Uint32*>(value);
7540 }
7541 
7542 
7543 Date* Date::Cast(v8::Value* value) {
7544 #ifdef V8_ENABLE_CHECKS
7545  CheckCast(value);
7546 #endif
7547  return static_cast<Date*>(value);
7548 }
7549 
7550 
7551 StringObject* StringObject::Cast(v8::Value* value) {
7552 #ifdef V8_ENABLE_CHECKS
7553  CheckCast(value);
7554 #endif
7555  return static_cast<StringObject*>(value);
7556 }
7557 
7558 
7559 SymbolObject* SymbolObject::Cast(v8::Value* value) {
7560 #ifdef V8_ENABLE_CHECKS
7561  CheckCast(value);
7562 #endif
7563  return static_cast<SymbolObject*>(value);
7564 }
7565 
7566 
7567 NumberObject* NumberObject::Cast(v8::Value* value) {
7568 #ifdef V8_ENABLE_CHECKS
7569  CheckCast(value);
7570 #endif
7571  return static_cast<NumberObject*>(value);
7572 }
7573 
7574 
7575 BooleanObject* BooleanObject::Cast(v8::Value* value) {
7576 #ifdef V8_ENABLE_CHECKS
7577  CheckCast(value);
7578 #endif
7579  return static_cast<BooleanObject*>(value);
7580 }
7581 
7582 
7583 RegExp* RegExp::Cast(v8::Value* value) {
7584 #ifdef V8_ENABLE_CHECKS
7585  CheckCast(value);
7586 #endif
7587  return static_cast<RegExp*>(value);
7588 }
7589 
7590 
7591 Object* Object::Cast(v8::Value* value) {
7592 #ifdef V8_ENABLE_CHECKS
7593  CheckCast(value);
7594 #endif
7595  return static_cast<Object*>(value);
7596 }
7597 
7598 
7599 Array* Array::Cast(v8::Value* value) {
7600 #ifdef V8_ENABLE_CHECKS
7601  CheckCast(value);
7602 #endif
7603  return static_cast<Array*>(value);
7604 }
7605 
7606 
7607 Promise* Promise::Cast(v8::Value* value) {
7608 #ifdef V8_ENABLE_CHECKS
7609  CheckCast(value);
7610 #endif
7611  return static_cast<Promise*>(value);
7612 }
7613 
7614 
7615 Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
7616 #ifdef V8_ENABLE_CHECKS
7617  CheckCast(value);
7618 #endif
7619  return static_cast<Promise::Resolver*>(value);
7620 }
7621 
7622 
7623 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
7624 #ifdef V8_ENABLE_CHECKS
7625  CheckCast(value);
7626 #endif
7627  return static_cast<ArrayBuffer*>(value);
7628 }
7629 
7630 
7631 ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) {
7632 #ifdef V8_ENABLE_CHECKS
7633  CheckCast(value);
7634 #endif
7635  return static_cast<ArrayBufferView*>(value);
7636 }
7637 
7638 
7639 TypedArray* TypedArray::Cast(v8::Value* value) {
7640 #ifdef V8_ENABLE_CHECKS
7641  CheckCast(value);
7642 #endif
7643  return static_cast<TypedArray*>(value);
7644 }
7645 
7646 
7647 Uint8Array* Uint8Array::Cast(v8::Value* value) {
7648 #ifdef V8_ENABLE_CHECKS
7649  CheckCast(value);
7650 #endif
7651  return static_cast<Uint8Array*>(value);
7652 }
7653 
7654 
7655 Int8Array* Int8Array::Cast(v8::Value* value) {
7656 #ifdef V8_ENABLE_CHECKS
7657  CheckCast(value);
7658 #endif
7659  return static_cast<Int8Array*>(value);
7660 }
7661 
7662 
7663 Uint16Array* Uint16Array::Cast(v8::Value* value) {
7664 #ifdef V8_ENABLE_CHECKS
7665  CheckCast(value);
7666 #endif
7667  return static_cast<Uint16Array*>(value);
7668 }
7669 
7670 
7671 Int16Array* Int16Array::Cast(v8::Value* value) {
7672 #ifdef V8_ENABLE_CHECKS
7673  CheckCast(value);
7674 #endif
7675  return static_cast<Int16Array*>(value);
7676 }
7677 
7678 
7679 Uint32Array* Uint32Array::Cast(v8::Value* value) {
7680 #ifdef V8_ENABLE_CHECKS
7681  CheckCast(value);
7682 #endif
7683  return static_cast<Uint32Array*>(value);
7684 }
7685 
7686 
7687 Int32Array* Int32Array::Cast(v8::Value* value) {
7688 #ifdef V8_ENABLE_CHECKS
7689  CheckCast(value);
7690 #endif
7691  return static_cast<Int32Array*>(value);
7692 }
7693 
7694 
7695 Float32Array* Float32Array::Cast(v8::Value* value) {
7696 #ifdef V8_ENABLE_CHECKS
7697  CheckCast(value);
7698 #endif
7699  return static_cast<Float32Array*>(value);
7700 }
7701 
7702 
7703 Float64Array* Float64Array::Cast(v8::Value* value) {
7704 #ifdef V8_ENABLE_CHECKS
7705  CheckCast(value);
7706 #endif
7707  return static_cast<Float64Array*>(value);
7708 }
7709 
7710 
7711 Uint8ClampedArray* Uint8ClampedArray::Cast(v8::Value* value) {
7712 #ifdef V8_ENABLE_CHECKS
7713  CheckCast(value);
7714 #endif
7715  return static_cast<Uint8ClampedArray*>(value);
7716 }
7717 
7718 
7719 DataView* DataView::Cast(v8::Value* value) {
7720 #ifdef V8_ENABLE_CHECKS
7721  CheckCast(value);
7722 #endif
7723  return static_cast<DataView*>(value);
7724 }
7725 
7726 
7727 Function* Function::Cast(v8::Value* value) {
7728 #ifdef V8_ENABLE_CHECKS
7729  CheckCast(value);
7730 #endif
7731  return static_cast<Function*>(value);
7732 }
7733 
7734 
7735 External* External::Cast(v8::Value* value) {
7736 #ifdef V8_ENABLE_CHECKS
7737  CheckCast(value);
7738 #endif
7739  return static_cast<External*>(value);
7740 }
7741 
7742 
7743 template<typename T>
7744 Isolate* PropertyCallbackInfo<T>::GetIsolate() const {
7745  return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
7746 }
7747 
7748 
7749 template<typename T>
7750 Local<Value> PropertyCallbackInfo<T>::Data() const {
7751  return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
7752 }
7753 
7754 
7755 template<typename T>
7756 Local<Object> PropertyCallbackInfo<T>::This() const {
7757  return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
7758 }
7759 
7760 
7761 template<typename T>
7762 Local<Object> PropertyCallbackInfo<T>::Holder() const {
7763  return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
7764 }
7765 
7766 
7767 template<typename T>
7768 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
7769  return ReturnValue<T>(&args_[kReturnValueIndex]);
7770 }
7771 
7772 
7773 Handle<Primitive> Undefined(Isolate* isolate) {
7774  typedef internal::Object* S;
7775  typedef internal::Internals I;
7776  I::CheckInitialized(isolate);
7777  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
7778  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
7779 }
7780 
7781 
7782 Handle<Primitive> Null(Isolate* isolate) {
7783  typedef internal::Object* S;
7784  typedef internal::Internals I;
7785  I::CheckInitialized(isolate);
7786  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
7787  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
7788 }
7789 
7790 
7791 Handle<Boolean> True(Isolate* isolate) {
7792  typedef internal::Object* S;
7793  typedef internal::Internals I;
7794  I::CheckInitialized(isolate);
7795  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
7796  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
7797 }
7798 
7799 
7800 Handle<Boolean> False(Isolate* isolate) {
7801  typedef internal::Object* S;
7802  typedef internal::Internals I;
7803  I::CheckInitialized(isolate);
7804  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
7805  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
7806 }
7807 
7808 
7809 void Isolate::SetData(uint32_t slot, void* data) {
7810  typedef internal::Internals I;
7811  I::SetEmbedderData(this, slot, data);
7812 }
7813 
7814 
7815 void* Isolate::GetData(uint32_t slot) {
7816  typedef internal::Internals I;
7817  return I::GetEmbedderData(this, slot);
7818 }
7819 
7820 
7822  typedef internal::Internals I;
7823  return I::kNumIsolateDataSlots;
7824 }
7825 
7826 
7828  int64_t change_in_bytes) {
7829  typedef internal::Internals I;
7830  int64_t* amount_of_external_allocated_memory =
7831  reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
7832  I::kAmountOfExternalAllocatedMemoryOffset);
7833  int64_t* amount_of_external_allocated_memory_at_last_global_gc =
7834  reinterpret_cast<int64_t*>(
7835  reinterpret_cast<uint8_t*>(this) +
7836  I::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset);
7837  int64_t amount = *amount_of_external_allocated_memory + change_in_bytes;
7838  if (change_in_bytes > 0 &&
7839  amount - *amount_of_external_allocated_memory_at_last_global_gc >
7840  I::kExternalAllocationLimit) {
7841  CollectAllGarbage("external memory allocation limit reached.");
7842  }
7843  *amount_of_external_allocated_memory = amount;
7844  return *amount_of_external_allocated_memory;
7845 }
7846 
7847 
7848 template<typename T>
7850  UniqueId id) {
7851  TYPE_CHECK(Value, T);
7852  SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id);
7853 }
7854 
7855 
7856 template<typename T>
7858  const Persistent<T>& object) {
7859  TYPE_CHECK(Value, T);
7860  SetReferenceFromGroup(id,
7861  reinterpret_cast<v8::internal::Object**>(object.val_));
7862 }
7863 
7864 
7865 template<typename T, typename S>
7867  const Persistent<S>& child) {
7868  TYPE_CHECK(Object, T);
7869  TYPE_CHECK(Value, S);
7870  SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_),
7871  reinterpret_cast<v8::internal::Object**>(child.val_));
7872 }
7873 
7874 
7876 #ifndef V8_ENABLE_CHECKS
7877  typedef internal::Object O;
7878  typedef internal::HeapObject HO;
7879  typedef internal::Internals I;
7880  HO* context = *reinterpret_cast<HO**>(this);
7881  O** result =
7882  HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
7883  return Local<Value>(reinterpret_cast<Value*>(result));
7884 #else
7885  return SlowGetEmbedderData(index);
7886 #endif
7887 }
7888 
7889 
7891 #ifndef V8_ENABLE_CHECKS
7892  typedef internal::Internals I;
7893  return I::ReadEmbedderData<void*>(this, index);
7894 #else
7895  return SlowGetAlignedPointerFromEmbedderData(index);
7896 #endif
7897 }
7898 
7899 
7900 void V8::SetAllowCodeGenerationFromStringsCallback(
7902  Isolate* isolate = Isolate::GetCurrent();
7903  isolate->SetAllowCodeGenerationFromStringsCallback(callback);
7904 }
7905 
7906 
7907 bool V8::IsDead() {
7908  Isolate* isolate = Isolate::GetCurrent();
7909  return isolate->IsDead();
7910 }
7911 
7912 
7913 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
7914  Isolate* isolate = Isolate::GetCurrent();
7915  return isolate->AddMessageListener(that, data);
7916 }
7917 
7918 
7919 void V8::RemoveMessageListeners(MessageCallback that) {
7920  Isolate* isolate = Isolate::GetCurrent();
7921  isolate->RemoveMessageListeners(that);
7922 }
7923 
7924 
7925 void V8::SetFailedAccessCheckCallbackFunction(
7926  FailedAccessCheckCallback callback) {
7927  Isolate* isolate = Isolate::GetCurrent();
7928  isolate->SetFailedAccessCheckCallbackFunction(callback);
7929 }
7930 
7931 
7932 void V8::SetCaptureStackTraceForUncaughtExceptions(
7933  bool capture, int frame_limit, StackTrace::StackTraceOptions options) {
7934  Isolate* isolate = Isolate::GetCurrent();
7935  isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit,
7936  options);
7937 }
7938 
7939 
7940 void V8::SetFatalErrorHandler(FatalErrorCallback callback) {
7941  Isolate* isolate = Isolate::GetCurrent();
7942  isolate->SetFatalErrorHandler(callback);
7943 }
7944 
7945 
7946 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) {
7947  Isolate* isolate = Isolate::GetCurrent();
7948  isolate->RemoveGCPrologueCallback(
7949  reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
7950 }
7951 
7952 
7953 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) {
7954  Isolate* isolate = Isolate::GetCurrent();
7955  isolate->RemoveGCEpilogueCallback(
7956  reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
7957 }
7958 
7959 
7960 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
7961  ObjectSpace space,
7962  AllocationAction action) {
7963  Isolate* isolate = Isolate::GetCurrent();
7964  isolate->AddMemoryAllocationCallback(callback, space, action);
7965 }
7966 
7967 
7968 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
7969  Isolate* isolate = Isolate::GetCurrent();
7970  isolate->RemoveMemoryAllocationCallback(callback);
7971 }
7972 
7973 
7974 void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }
7975 
7976 
7977 bool V8::IsExecutionTerminating(Isolate* isolate) {
7978  if (isolate == NULL) {
7979  isolate = Isolate::GetCurrent();
7980  }
7981  return isolate->IsExecutionTerminating();
7982 }
7983 
7984 
7985 void V8::CancelTerminateExecution(Isolate* isolate) {
7986  isolate->CancelTerminateExecution();
7987 }
7988 
7989 
7990 void V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
7991  Isolate* isolate = Isolate::GetCurrent();
7992  isolate->VisitExternalResources(visitor);
7993 }
7994 
7995 
7996 void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
7997  Isolate* isolate = Isolate::GetCurrent();
7998  isolate->VisitHandlesWithClassIds(visitor);
7999 }
8000 
8001 
8002 void V8::VisitHandlesWithClassIds(Isolate* isolate,
8003  PersistentHandleVisitor* visitor) {
8004  isolate->VisitHandlesWithClassIds(visitor);
8005 }
8006 
8007 
8008 void V8::VisitHandlesForPartialDependence(Isolate* isolate,
8009  PersistentHandleVisitor* visitor) {
8010  isolate->VisitHandlesForPartialDependence(visitor);
8011 }
8012 
8025 } // namespace v8
8026 
8027 
8028 #undef TYPE_CHECK
8029 
8030 
8031 #endif // V8_H_
Definition: v8.h:2365
Definition: v8.h:6526
void(* NamedPropertyDeleterCallback)(Local< String > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:3877
Definition: v8.h:118
size_t length() const
Definition: v8.h:4497
V8_INLINE bool IsString() const
Definition: v8.h:7427
JitCodeEventHandler code_event_handler
Definition: v8.h:4974
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:3968
V8_INLINE Unlocker(Isolate *isolate)
Definition: v8.h:6531
V8_INLINE void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:7890
Definition: v8.h:1604
Definition: v8.h:5664
V8_INLINE Global(Isolate *isolate, Handle< S > that)
Definition: v8.h:793
Definition: v8.h:6285
V8_INLINE void Clear()
Definition: v8.h:232
Definition: v8.h:4920
V8_INLINE void * GetData(uint32_t slot)
Definition: v8.h:7815
Definition: v8.h:862
V8_INLINE void Reset()
Definition: v8.h:6934
Definition: v8.h:1137
V8_INLINE Local< Value > GetInternalField(int index)
Definition: v8.h:7301
V8_INLINE Persistent(const Persistent &that)
Definition: v8.h:720
bool(* IndexedSecurityCallback)(Local< Object > host, uint32_t index, AccessType type, Local< Value > data)
Definition: v8.h:4007
void(* NamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3886
Definition: v8.h:5698
Definition: v8.h:6593
Definition: v8.h:1641
void Set(Handle< Name > name, Handle< Data > value, PropertyAttribute attributes=None)
Definition: v8.h:3151
V8_INLINE Global(Global &&other)
Definition: v8.h:810
Definition: v8.h:1468
Definition: v8-util.h:417
Definition: v8.h:2005
Definition: v8.h:978
Definition: v8.h:6428
Definition: v8-profiler.h:580
Definition: v8.h:4635
Definition: v8.h:4878
const char * data() const
Definition: v8.h:4496
Definition: v8.h:2472
Definition: v8.h:969
Definition: v8.h:2562
V8_INLINE Global()
Definition: v8.h:786
Definition: v8.h:3657
Definition: v8.h:4274
void(* GenericNamedPropertyDeleterCallback)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:3923
void(* NamedPropertySetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3856
Definition: v8.h:4507
Definition: v8.h:1389
CounterLookupCallback counter_lookup_callback
Definition: v8.h:4991
Definition: v8.h:4775
Definition: v8.h:4798
WriteOptions
Definition: v8.h:2086
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, v8::NewStringType type, int length=-1)
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:269
Definition: v8.h:3573
Definition: v8.h:1102
Flags
Definition: v8.h:3713
Definition: v8.h:3557
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:245
static V8_INLINE int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8.h:2730
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2524
Definition: v8.h:114
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:7045
V8_INLINE void SetData(uint32_t slot, void *data)
Definition: v8.h:7809
V8_INLINE void MarkPartiallyDependent()
Definition: v8.h:7025
static Isolate * GetCurrent()
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:7035
Definition: v8.h:125
V8_INLINE ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:7353
V8_INLINE int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Definition: v8.h:7827
V8_INLINE Global & operator=(Global< S > &&rhs)
Definition: v8.h:818
V8_INLINE ~Persistent()
Definition: v8.h:741
Definition: v8.h:2432
V8_INLINE Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:710
Definition: v8.h:1992
JitCodeEventOptions
Definition: v8.h:4902
V8_INLINE bool IsNearDeath() const
Definition: v8.h:6914
Definition: v8.h:2343
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:5675
void Enter()
StartupData * snapshot_blob
Definition: v8.h:4984
Definition: v8.h:4700
Definition: v8.h:3707
V8_INLINE Handle< Boolean > ResourceIsEmbedderDebugScript() const
Definition: v8.h:7245
V8_INLINE ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:7371
virtual ~ExternalStringResource()
Definition: v8.h:2164
void(* GenericNamedPropertyQueryCallback)(Local< Name > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:3914
Definition: v8.h:3153
void(* GenericNamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3931
virtual void Dispose()
Definition: v8.h:2141
Definition: v8.h:3235
Definition: v8.h:129
Definition: libplatform.h:10
static void * JSStackComparableAddress(v8::TryCatch *handler)
Definition: v8.h:6231
Definition: v8.h:4870
V8_INLINE Persistent(Isolate *isolate, Handle< S > that)
Definition: v8.h:700
Definition: v8.h:145
Definition: v8.h:3063
Definition: v8.h:4930
Definition: v8.h:944
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
Definition: v8.h:7866
Definition: v8.h:2028
AccessType
Definition: v8.h:3984
Definition: v8.h:4463
Definition: v8.h:1586
Definition: v8.h:3589
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3939
V8_INLINE Locker(Isolate *isolate)
Definition: v8.h:6546
Definition: v8.h:2501
Definition: v8.h:6662
Definition: v8-profiler.h:424
void(* NamedPropertyGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3847
Definition: v8.h:3525
Definition: v8.h:4840
void SetAllowCodeGenerationFromStringsCallback(AllowCodeGenerationFromStringsCallback callback)
Definition: v8.h:4108
Definition: v8.h:2458
void SetObjectGroupId(const Persistent< T > &object, UniqueId id)
Definition: v8.h:7849
Definition: v8.h:1093
StackTraceOptions
Definition: v8.h:1474
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3948
EmbedderDataFields
Definition: v8.h:6365
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:4213
Definition: v8.h:4478
ArrayBuffer::Allocator * array_buffer_allocator
Definition: v8.h:5006
Definition: v8.h:4565
Definition: v8.h:3641
Definition: v8.h:1053
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3977
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:3958
V8_INLINE bool IsEmpty() const
Definition: v8.h:227
Definition: v8.h:2394
Definition: v8.h:1595
Definition: v8.h:2918
static V8_INLINE v8::Local< v8::String > Empty(Isolate *isolate)
Definition: v8.h:7344
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:4914
static V8_INLINE uint32_t GetNumberOfDataSlots()
Definition: v8.h:7821
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:7320
Definition: v8.h:3378
FunctionEntryHook entry_hook
Definition: v8.h:4968
V8_INLINE V8_DEPRECATE_SOON("use WeakCallbackInfo version", void SetWeak(P *parameter, typename WeakCallbackData< T, P >::Callback callback))
Definition: v8.h:130
Definition: v8.h:3446
Definition: v8.h:1520
Definition: v8.h:85
void(* GenericNamedPropertyGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3896
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:6830
Definition: v8.h:1625
Global Pass()
Definition: v8.h:830
Definition: v8-util.h:159
V8_INLINE Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:803
Definition: v8.h:3426
Definition: v8.h:3775
V8_INLINE Persistent()
Definition: v8.h:694
V8_INLINE void MarkIndependent()
Definition: v8.h:7015
GarbageCollectionType
Definition: v8.h:5092
Definition: v8.h:3276
Definition: v8.h:3462
Definition: v8.h:116
void SetReferenceFromGroup(UniqueId id, const Persistent< T > &child)
Definition: v8.h:7857
Definition: v8.h:6107
Definition: v8.h:1985
virtual ~ExternalOneByteStringResource()
Definition: v8.h:2197
Definition: v8-util.h:559
Definition: v8.h:3604
Definition: v8.h:155
Definition: v8.h:3244
Definition: v8.h:3541
Definition: v8.h:448
Definition: v8.h:4946
Definition: v8.h:3691
Definition: v8.h:3759
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:2749
GCType
Definition: v8.h:4750
Definition: v8.h:2487
Definition: v8.h:5014
bool(* NamedSecurityCallback)(Local< Object > host, Local< Value > key, AccessType type, Local< Value > data)
Definition: v8.h:3997
Definition: v8-platform.h:28
Definition: v8.h:3477
Definition: v8.h:915
Definition: v8.h:112
Definition: v8.h:3509
Definition: v8.h:3493
Definition: v8.h:3673
Definition: v8.h:6266
Definition: v8.h:136
CreateHistogramCallback create_histogram_callback
Definition: v8.h:4999
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:925
V8_INLINE bool IsNull() const
Definition: v8.h:7409
V8_INLINE Local(Local< S > that)
Definition: v8.h:214
void(* GenericNamedPropertySetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3904
Definition: v8.h:6541
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:5691
Definition: v8.h:670
Definition: v8.h:4951
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Definition: v8.h:4739
Definition: v8.h:403
Definition: v8-util.h:350
UseCounterFeature
Definition: v8.h:5102
AccessControl
Definition: v8.h:2551
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
Definition: v8.h:4832
Definition: v8.h:109
Definition: v8.h:1020
V8_INLINE bool IsUndefined() const
Definition: v8.h:7391
ResourceConstraints constraints
Definition: v8.h:4979
void(* NamedPropertyQueryCallback)(Local< String > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:3867
V8_INLINE bool IsWeak() const
Definition: v8.h:6925
V8_INLINE Local< Value > GetEmbedderData(int index)
Definition: v8.h:7875
Definition: v8.h:4448
Definition: v8.h:111
Definition: v8-profiler.h:181
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:4241