v8  3.28.71(node0.12.18)
V8 is Google's open source JavaScript engine
v8.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
15 #ifndef V8_H_
16 #define V8_H_
17 
18 #include "v8stdint.h"
19 
20 // We reserve the V8_* prefix for macros defined in V8 public API and
21 // assume there are no name conflicts with the embedder's code.
22 
23 #ifdef V8_OS_WIN
24 
25 // Setup for Windows DLL export/import. When building the V8 DLL the
26 // BUILDING_V8_SHARED needs to be defined. When building a program which uses
27 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
28 // static library or building a program which uses the V8 static library neither
29 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
30 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
31 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
32  build configuration to ensure that at most one of these is set
33 #endif
34 
35 #ifdef BUILDING_V8_SHARED
36 # define V8_EXPORT __declspec(dllexport)
37 #elif USING_V8_SHARED
38 # define V8_EXPORT __declspec(dllimport)
39 #else
40 # define V8_EXPORT
41 #endif // BUILDING_V8_SHARED
42 
43 #else // V8_OS_WIN
44 
45 // Setup for Linux shared library export.
46 #if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED)
47 # ifdef BUILDING_V8_SHARED
48 # define V8_EXPORT __attribute__ ((visibility("default")))
49 # else
50 # define V8_EXPORT
51 # endif
52 #else
53 # define V8_EXPORT
54 #endif
55 
56 #endif // V8_OS_WIN
57 
61 namespace v8 {
62 
63 class AccessorSignature;
64 class Array;
65 class Boolean;
66 class BooleanObject;
67 class Context;
68 class CpuProfiler;
69 class Data;
70 class Date;
71 class DeclaredAccessorDescriptor;
72 class External;
73 class Function;
74 class FunctionTemplate;
75 class HeapProfiler;
76 class ImplementationUtilities;
77 class Int32;
78 class Integer;
79 class Isolate;
80 class Number;
81 class NumberObject;
82 class Object;
83 class ObjectOperationDescriptor;
84 class ObjectTemplate;
85 class Platform;
86 class Primitive;
87 class RawOperationDescriptor;
88 class Script;
89 class Signature;
90 class StackFrame;
91 class StackTrace;
92 class String;
93 class StringObject;
94 class Symbol;
95 class SymbolObject;
96 class Private;
97 class Uint32;
98 class Utils;
99 class Value;
100 template <class T> class Handle;
101 template <class T> class Local;
102 template <class T> class Eternal;
103 template<class T> class NonCopyablePersistentTraits;
104 template<class T> class PersistentBase;
105 template<class T,
107 template<class T> class UniquePersistent;
108 template<class K, class V, class T> class PersistentValueMap;
109 template<class V, class T> class PersistentValueVector;
110 template<class T, class P> class WeakCallbackObject;
111 class FunctionTemplate;
112 class ObjectTemplate;
113 class Data;
114 template<typename T> class FunctionCallbackInfo;
115 template<typename T> class PropertyCallbackInfo;
116 class StackTrace;
117 class StackFrame;
118 class Isolate;
122 class CallHandlerHelper;
124 template<typename T> class ReturnValue;
125 
126 namespace internal {
127 class Arguments;
128 class Heap;
129 class HeapObject;
130 class Isolate;
131 class Object;
132 template<typename T> class CustomArguments;
133 class PropertyCallbackArguments;
134 class FunctionCallbackArguments;
135 class GlobalHandles;
136 }
137 
138 
142 class UniqueId {
143  public:
144  explicit UniqueId(intptr_t data)
145  : data_(data) {}
146 
147  bool operator==(const UniqueId& other) const {
148  return data_ == other.data_;
149  }
150 
151  bool operator!=(const UniqueId& other) const {
152  return data_ != other.data_;
153  }
154 
155  bool operator<(const UniqueId& other) const {
156  return data_ < other.data_;
157  }
158 
159  private:
160  intptr_t data_;
161 };
162 
163 // --- Handles ---
164 
165 #define TYPE_CHECK(T, S) \
166  while (false) { \
167  *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
168  }
169 
170 
196 template <class T> class Handle {
197  public:
201  V8_INLINE Handle() : val_(0) {}
202 
213  template <class S> V8_INLINE Handle(Handle<S> that)
214  : val_(reinterpret_cast<T*>(*that)) {
220  TYPE_CHECK(T, S);
221  }
222 
226  V8_INLINE bool IsEmpty() const { return val_ == 0; }
227 
231  V8_INLINE void Clear() { val_ = 0; }
232 
233  V8_INLINE T* operator->() const { return val_; }
234 
235  V8_INLINE T* operator*() const { return val_; }
236 
243  template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
244  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
245  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
246  if (a == 0) return b == 0;
247  if (b == 0) return false;
248  return *a == *b;
249  }
250 
251  template <class S> V8_INLINE bool operator==(
252  const PersistentBase<S>& that) const {
253  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
254  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
255  if (a == 0) return b == 0;
256  if (b == 0) return false;
257  return *a == *b;
258  }
259 
266  template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
267  return !operator==(that);
268  }
269 
270  template <class S> V8_INLINE bool operator!=(
271  const Persistent<S>& that) const {
272  return !operator==(that);
273  }
274 
275  template <class S> V8_INLINE static Handle<T> Cast(Handle<S> that) {
276 #ifdef V8_ENABLE_CHECKS
277  // If we're going to perform the type check then we have to check
278  // that the handle isn't empty before doing the checked cast.
279  if (that.IsEmpty()) return Handle<T>();
280 #endif
281  return Handle<T>(T::Cast(*that));
282  }
283 
284  template <class S> V8_INLINE Handle<S> As() {
285  return Handle<S>::Cast(*this);
286  }
287 
288  V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) {
289  return New(isolate, that.val_);
290  }
291  V8_INLINE static Handle<T> New(Isolate* isolate,
292  const PersistentBase<T>& that) {
293  return New(isolate, that.val_);
294  }
295 
296  private:
297  friend class Utils;
298  template<class F, class M> friend class Persistent;
299  template<class F> friend class PersistentBase;
300  template<class F> friend class Handle;
301  template<class F> friend class Local;
302  template<class F> friend class FunctionCallbackInfo;
303  template<class F> friend class PropertyCallbackInfo;
304  template<class F> friend class internal::CustomArguments;
305  friend Handle<Primitive> Undefined(Isolate* isolate);
306  friend Handle<Primitive> Null(Isolate* isolate);
307  friend Handle<Boolean> True(Isolate* isolate);
308  friend Handle<Boolean> False(Isolate* isolate);
309  friend class Context;
310  friend class HandleScope;
311  friend class Object;
312  friend class Private;
313 
317  V8_INLINE explicit Handle(T* val) : val_(val) {}
318 
319  V8_INLINE static Handle<T> New(Isolate* isolate, T* that);
320 
321  T* val_;
322 };
323 
324 
332 template <class T> class Local : public Handle<T> {
333  public:
334  V8_INLINE Local();
335  template <class S> V8_INLINE Local(Local<S> that)
336  : Handle<T>(reinterpret_cast<T*>(*that)) {
342  TYPE_CHECK(T, S);
343  }
344 
345 
346  template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
347 #ifdef V8_ENABLE_CHECKS
348  // If we're going to perform the type check then we have to check
349  // that the handle isn't empty before doing the checked cast.
350  if (that.IsEmpty()) return Local<T>();
351 #endif
352  return Local<T>(T::Cast(*that));
353  }
354  template <class S> V8_INLINE Local(Handle<S> that)
355  : Handle<T>(reinterpret_cast<T*>(*that)) {
356  TYPE_CHECK(T, S);
357  }
358 
359  template <class S> V8_INLINE Local<S> As() {
360  return Local<S>::Cast(*this);
361  }
362 
368  V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
369  V8_INLINE static Local<T> New(Isolate* isolate,
370  const PersistentBase<T>& that);
371 
372  private:
373  friend class Utils;
374  template<class F> friend class Eternal;
375  template<class F> friend class PersistentBase;
376  template<class F, class M> friend class Persistent;
377  template<class F> friend class Handle;
378  template<class F> friend class Local;
379  template<class F> friend class FunctionCallbackInfo;
380  template<class F> friend class PropertyCallbackInfo;
381  friend class String;
382  friend class Object;
383  friend class Context;
384  template<class F> friend class internal::CustomArguments;
385  friend class HandleScope;
386  friend class EscapableHandleScope;
387  template<class F1, class F2, class F3> friend class PersistentValueMap;
388  template<class F1, class F2> friend class PersistentValueVector;
389 
390  template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { }
391  V8_INLINE static Local<T> New(Isolate* isolate, T* that);
392 };
393 
394 
395 // Eternal handles are set-once handles that live for the life of the isolate.
396 template <class T> class Eternal {
397  public:
398  V8_INLINE Eternal() : index_(kInitialValue) { }
399  template<class S>
400  V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) {
401  Set(isolate, handle);
402  }
403  // Can only be safely called if already set.
404  V8_INLINE Local<T> Get(Isolate* isolate);
405  V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
406  template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
407 
408  private:
409  static const int kInitialValue = -1;
410  int index_;
411 };
412 
413 
414 template<class T, class P>
416  public:
417  typedef void (*Callback)(const WeakCallbackData<T, P>& data);
418 
419  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
420  V8_INLINE Local<T> GetValue() const { return handle_; }
421  V8_INLINE P* GetParameter() const { return parameter_; }
422 
423  private:
425  WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter)
426  : isolate_(isolate), handle_(handle), parameter_(parameter) { }
427  Isolate* isolate_;
428  Local<T> handle_;
429  P* parameter_;
430 };
431 
432 
446 template <class T> class PersistentBase {
447  public:
452  V8_INLINE void Reset();
457  template <class S>
458  V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
459 
464  template <class S>
465  V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
466 
467  V8_INLINE bool IsEmpty() const { return val_ == 0; }
468 
469  template <class S>
470  V8_INLINE bool operator==(const PersistentBase<S>& that) const {
471  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
472  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
473  if (a == 0) return b == 0;
474  if (b == 0) return false;
475  return *a == *b;
476  }
477 
478  template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
479  internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
480  internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
481  if (a == 0) return b == 0;
482  if (b == 0) return false;
483  return *a == *b;
484  }
485 
486  template <class S>
487  V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
488  return !operator==(that);
489  }
490 
491  template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
492  return !operator==(that);
493  }
494 
502  template<typename P>
503  V8_INLINE void SetWeak(
504  P* parameter,
505  typename WeakCallbackData<T, P>::Callback callback);
506 
507  template<typename S, typename P>
508  V8_INLINE void SetWeak(
509  P* parameter,
510  typename WeakCallbackData<S, P>::Callback callback);
511 
512  template<typename P>
513  V8_INLINE P* ClearWeak();
514 
515  // TODO(dcarney): remove this.
516  V8_INLINE void ClearWeak() { ClearWeak<void>(); }
517 
524  V8_INLINE void MarkIndependent();
525 
535 
536  V8_INLINE bool IsIndependent() const;
537 
539  V8_INLINE bool IsNearDeath() const;
540 
542  V8_INLINE bool IsWeak() const;
543 
548  V8_INLINE void SetWrapperClassId(uint16_t class_id);
549 
554  V8_INLINE uint16_t WrapperClassId() const;
555 
556  private:
557  friend class Isolate;
558  friend class Utils;
559  template<class F> friend class Handle;
560  template<class F> friend class Local;
561  template<class F1, class F2> friend class Persistent;
562  template<class F> friend class UniquePersistent;
563  template<class F> friend class PersistentBase;
564  template<class F> friend class ReturnValue;
565  template<class F1, class F2, class F3> friend class PersistentValueMap;
566  template<class F1, class F2> friend class PersistentValueVector;
567  friend class Object;
568 
569  explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
570  PersistentBase(PersistentBase& other); // NOLINT
571  void operator=(PersistentBase&);
572  V8_INLINE static T* New(Isolate* isolate, T* that);
573 
574  T* val_;
575 };
576 
577 
584 template<class T>
585 class NonCopyablePersistentTraits {
586  public:
588  static const bool kResetInDestructor = false;
589  template<class S, class M>
590  V8_INLINE static void Copy(const Persistent<S, M>& source,
591  NonCopyablePersistent* dest) {
592  Uncompilable<Object>();
593  }
594  // TODO(dcarney): come up with a good compile error here.
595  template<class O> V8_INLINE static void Uncompilable() {
596  TYPE_CHECK(O, Primitive);
597  }
598 };
599 
600 
605 template<class T>
608  static const bool kResetInDestructor = true;
609  template<class S, class M>
610  static V8_INLINE void Copy(const Persistent<S, M>& source,
611  CopyablePersistent* dest) {
612  // do nothing, just allow copy
613  }
614 };
615 
616 
625 template <class T, class M> class Persistent : public PersistentBase<T> {
626  public:
636  template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that)
637  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
638  TYPE_CHECK(T, S);
639  }
645  template <class S, class M2>
647  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
648  TYPE_CHECK(T, S);
649  }
657  Copy(that);
658  }
659  template <class S, class M2>
661  Copy(that);
662  }
663  V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
664  Copy(that);
665  return *this;
666  }
667  template <class S, class M2>
669  Copy(that);
670  return *this;
671  }
678  if (M::kResetInDestructor) this->Reset();
679  }
680 
681  // TODO(dcarney): this is pretty useless, fix or remove
682  template <class S>
683  V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
684 #ifdef V8_ENABLE_CHECKS
685  // If we're going to perform the type check then we have to check
686  // that the handle isn't empty before doing the checked cast.
687  if (!that.IsEmpty()) T::Cast(*that);
688 #endif
689  return reinterpret_cast<Persistent<T>&>(that);
690  }
691 
692  // TODO(dcarney): this is pretty useless, fix or remove
693  template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
694  return Persistent<S>::Cast(*this);
695  }
696 
697  // This will be removed.
698  V8_INLINE T* ClearAndLeak();
699 
700  private:
701  friend class Isolate;
702  friend class Utils;
703  template<class F> friend class Handle;
704  template<class F> friend class Local;
705  template<class F1, class F2> friend class Persistent;
706  template<class F> friend class ReturnValue;
707 
708  template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
709  V8_INLINE T* operator*() const { return this->val_; }
710  template<class S, class M2>
711  V8_INLINE void Copy(const Persistent<S, M2>& that);
712 };
713 
714 
720 template<class T>
721 class UniquePersistent : public PersistentBase<T> {
722  struct RValue {
723  V8_INLINE explicit RValue(UniquePersistent* obj) : object(obj) {}
724  UniquePersistent* object;
725  };
726 
727  public:
737  template <class S>
739  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
740  TYPE_CHECK(T, S);
741  }
747  template <class S>
749  : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
750  TYPE_CHECK(T, S);
751  }
756  : PersistentBase<T>(rvalue.object->val_) {
757  rvalue.object->val_ = 0;
758  }
763  template<class S>
765  TYPE_CHECK(T, S);
766  this->Reset();
767  this->val_ = rhs.val_;
768  rhs.val_ = 0;
769  return *this;
770  }
774  V8_INLINE operator RValue() { return RValue(this); }
778  UniquePersistent Pass() { return UniquePersistent(RValue(this)); }
779 
780  private:
783 };
784 
785 
801  public:
802  HandleScope(Isolate* isolate);
803 
804  ~HandleScope();
805 
809  static int NumberOfHandles(Isolate* isolate);
810 
812  return reinterpret_cast<Isolate*>(isolate_);
813  }
814 
815  protected:
817 
818  void Initialize(Isolate* isolate);
819 
820  static internal::Object** CreateHandle(internal::Isolate* isolate,
821  internal::Object* value);
822 
823  private:
824  // Uses heap_object to obtain the current Isolate.
825  static internal::Object** CreateHandle(internal::HeapObject* heap_object,
826  internal::Object* value);
827 
828  // Make it hard to create heap-allocated or illegal handle scopes by
829  // disallowing certain operations.
830  HandleScope(const HandleScope&);
831  void operator=(const HandleScope&);
832  void* operator new(size_t size);
833  void operator delete(void*, size_t);
834 
835  internal::Isolate* isolate_;
836  internal::Object** prev_next_;
837  internal::Object** prev_limit_;
838 
839  // Local::New uses CreateHandle with an Isolate* parameter.
840  template<class F> friend class Local;
841 
842  // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
843  // a HeapObject* in their shortcuts.
844  friend class Object;
845  friend class Context;
846 };
847 
848 
854  public:
855  EscapableHandleScope(Isolate* isolate);
857 
862  template <class T>
864  internal::Object** slot =
865  Escape(reinterpret_cast<internal::Object**>(*value));
866  return Local<T>(reinterpret_cast<T*>(slot));
867  }
868 
869  private:
870  internal::Object** Escape(internal::Object** escape_value);
871 
872  // Make it hard to create heap-allocated or illegal handle scopes by
873  // disallowing certain operations.
875  void operator=(const EscapableHandleScope&);
876  void* operator new(size_t size);
877  void operator delete(void*, size_t);
878 
879  internal::Object** escape_slot_;
880 };
881 
882 
887 template<class T>
888 struct Maybe {
889  Maybe() : has_value(false) {}
890  explicit Maybe(T t) : has_value(true), value(t) {}
891  Maybe(bool has, T t) : has_value(has), value(t) {}
892 
893  bool has_value;
894  T value;
895 };
896 
897 
898 // Convenience wrapper.
899 template <class T>
900 inline Maybe<T> maybe(T t) {
901  return Maybe<T>(t);
902 }
903 
904 
905 // --- Special objects ---
906 
907 
912  private:
913  Data();
914 };
915 
916 
921  public:
923  Handle<Value> resource_name,
924  Handle<Integer> resource_line_offset = Handle<Integer>(),
925  Handle<Integer> resource_column_offset = Handle<Integer>(),
926  Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
927  Handle<Integer> script_id = Handle<Integer>())
928  : resource_name_(resource_name),
929  resource_line_offset_(resource_line_offset),
930  resource_column_offset_(resource_column_offset),
931  resource_is_shared_cross_origin_(resource_is_shared_cross_origin),
932  script_id_(script_id) { }
938  private:
939  Handle<Value> resource_name_;
940  Handle<Integer> resource_line_offset_;
941  Handle<Integer> resource_column_offset_;
942  Handle<Boolean> resource_is_shared_cross_origin_;
943  Handle<Integer> script_id_;
944 };
945 
946 
951  public:
955  Local<Script> BindToCurrentContext();
956 
957  int GetId();
958  Handle<Value> GetScriptName();
959 
963  Handle<Value> GetSourceURL();
967  Handle<Value> GetSourceMappingURL();
968 
973  int GetLineNumber(int code_pos);
974 
975  static const int kNoScriptId = 0;
976 };
977 
978 
984  public:
988  static Local<Script> Compile(Handle<String> source,
989  ScriptOrigin* origin = NULL);
990 
991  // To be decprecated, use the Compile above.
992  static Local<Script> Compile(Handle<String> source,
993  Handle<String> file_name);
994 
1000  Local<Value> Run();
1001 
1005  Local<UnboundScript> GetUnboundScript();
1006 
1007  V8_DEPRECATED("Use GetUnboundScript()->GetId()",
1008  int GetId()) {
1009  return GetUnboundScript()->GetId();
1010  }
1011 };
1012 
1013 
1018  public:
1029  BufferOwned
1030  };
1031 
1032  CachedData() : data(NULL), length(0), buffer_policy(BufferNotOwned) {}
1033 
1034  // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
1035  // data and guarantees that it stays alive until the CachedData object is
1036  // destroyed. If the policy is BufferOwned, the given data will be deleted
1037  // (with delete[]) when the CachedData object is destroyed.
1038  CachedData(const uint8_t* data, int length,
1039  BufferPolicy buffer_policy = BufferNotOwned);
1040  ~CachedData();
1041  // TODO(marja): Async compilation; add constructors which take a callback
1042  // which will be called when V8 no longer needs the data.
1043  const uint8_t* data;
1044  int length;
1046 
1047  private:
1048  // Prevent copying. Not implemented.
1049  CachedData(const CachedData&);
1050  CachedData& operator=(const CachedData&);
1051  };
1052 
1056  class Source {
1057  public:
1058  // Source takes ownership of CachedData.
1059  V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1060  CachedData* cached_data = NULL);
1061  V8_INLINE Source(Local<String> source_string,
1062  CachedData* cached_data = NULL);
1063  V8_INLINE ~Source();
1064 
1065  // Ownership of the CachedData or its buffers is *not* transferred to the
1066  // caller. The CachedData object is alive as long as the Source object is
1067  // alive.
1068  V8_INLINE const CachedData* GetCachedData() const;
1069 
1070  private:
1071  friend class ScriptCompiler;
1072  // Prevent copying. Not implemented.
1073  Source(const Source&);
1074  Source& operator=(const Source&);
1075 
1076  Local<String> source_string;
1077 
1078  // Origin information
1079  Handle<Value> resource_name;
1080  Handle<Integer> resource_line_offset;
1081  Handle<Integer> resource_column_offset;
1082  Handle<Boolean> resource_is_shared_cross_origin;
1083 
1084  // Cached data from previous compilation (if a kConsume*Cache flag is
1085  // set), or hold newly generated cache data (kProduce*Cache flags) are
1086  // set when calling a compile method.
1087  CachedData* cached_data;
1088  };
1089 
1091  kNoCompileOptions = 0,
1096 
1097  // Support the previous API for a transition period.
1098  kProduceDataToCache
1099  };
1100 
1114  static Local<UnboundScript> CompileUnbound(
1115  Isolate* isolate, Source* source,
1116  CompileOptions options = kNoCompileOptions);
1117 
1129  static Local<Script> Compile(
1130  Isolate* isolate, Source* source,
1131  CompileOptions options = kNoCompileOptions);
1132 };
1133 
1134 
1139  public:
1140  Local<String> Get() const;
1141  Local<String> GetSourceLine() const;
1142 
1147  ScriptOrigin GetScriptOrigin() const;
1148 
1153  Handle<Value> GetScriptResourceName() const;
1154 
1160  Handle<StackTrace> GetStackTrace() const;
1161 
1165  int GetLineNumber() const;
1166 
1171  int GetStartPosition() const;
1172 
1177  int GetEndPosition() const;
1178 
1183  int GetStartColumn() const;
1184 
1189  int GetEndColumn() const;
1190 
1195  bool IsSharedCrossOrigin() const;
1196 
1197  // TODO(1245381): Print to a string instead of on a FILE.
1198  static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1199 
1200  static const int kNoLineNumberInfo = 0;
1201  static const int kNoColumnInfo = 0;
1202  static const int kNoScriptIdInfo = 0;
1203 };
1204 
1205 
1212  public:
1218  kLineNumber = 1,
1219  kColumnOffset = 1 << 1 | kLineNumber,
1220  kScriptName = 1 << 2,
1221  kFunctionName = 1 << 3,
1222  kIsEval = 1 << 4,
1223  kIsConstructor = 1 << 5,
1224  kScriptNameOrSourceURL = 1 << 6,
1225  kScriptId = 1 << 7,
1226  kExposeFramesAcrossSecurityOrigins = 1 << 8,
1227  kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
1228  kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
1229  };
1230 
1234  Local<StackFrame> GetFrame(uint32_t index) const;
1235 
1239  int GetFrameCount() const;
1240 
1244  Local<Array> AsArray();
1245 
1253  static Local<StackTrace> CurrentStackTrace(
1254  Isolate* isolate,
1255  int frame_limit,
1256  StackTraceOptions options = kOverview);
1257 };
1258 
1259 
1264  public:
1271  int GetLineNumber() const;
1272 
1280  int GetColumn() const;
1281 
1288  int GetScriptId() const;
1289 
1294  Local<String> GetScriptName() const;
1295 
1302  Local<String> GetScriptNameOrSourceURL() const;
1303 
1307  Local<String> GetFunctionName() const;
1308 
1313  bool IsEval() const;
1314 
1319  bool IsConstructor() const;
1320 };
1321 
1322 
1327  public:
1335  static Local<Value> Parse(Local<String> json_string);
1336 };
1337 
1338 
1339 // --- Value ---
1340 
1341 
1345 class V8_EXPORT Value : public Data {
1346  public:
1351  V8_INLINE bool IsUndefined() const;
1352 
1357  V8_INLINE bool IsNull() const;
1358 
1362  bool IsTrue() const;
1363 
1367  bool IsFalse() const;
1368 
1373  V8_INLINE bool IsString() const;
1374 
1379  bool IsSymbol() const;
1380 
1384  bool IsFunction() const;
1385 
1389  bool IsArray() const;
1390 
1394  bool IsObject() const;
1395 
1399  bool IsBoolean() const;
1400 
1404  bool IsNumber() const;
1405 
1409  bool IsExternal() const;
1410 
1414  bool IsInt32() const;
1415 
1419  bool IsUint32() const;
1420 
1424  bool IsDate() const;
1425 
1429  bool IsBooleanObject() const;
1430 
1434  bool IsNumberObject() const;
1435 
1439  bool IsStringObject() const;
1440 
1445  bool IsSymbolObject() const;
1446 
1450  bool IsNativeError() const;
1451 
1455  bool IsRegExp() const;
1456 
1461  bool IsPromise() const;
1462 
1467  bool IsArrayBuffer() const;
1468 
1473  bool IsArrayBufferView() const;
1474 
1479  bool IsTypedArray() const;
1480 
1485  bool IsUint8Array() const;
1486 
1491  bool IsUint8ClampedArray() const;
1492 
1497  bool IsInt8Array() const;
1498 
1503  bool IsUint16Array() const;
1504 
1509  bool IsInt16Array() const;
1510 
1515  bool IsUint32Array() const;
1516 
1521  bool IsInt32Array() const;
1522 
1527  bool IsFloat32Array() const;
1528 
1533  bool IsFloat64Array() const;
1534 
1539  bool IsDataView() const;
1540 
1541  Local<Boolean> ToBoolean() const;
1542  Local<Number> ToNumber() const;
1543  Local<String> ToString() const;
1544  Local<String> ToDetailString() const;
1545  Local<Object> ToObject() const;
1546  Local<Integer> ToInteger() const;
1547  Local<Uint32> ToUint32() const;
1548  Local<Int32> ToInt32() const;
1549 
1554  Local<Uint32> ToArrayIndex() const;
1555 
1556  bool BooleanValue() const;
1557  double NumberValue() const;
1558  int64_t IntegerValue() const;
1559  uint32_t Uint32Value() const;
1560  int32_t Int32Value() const;
1561 
1563  bool Equals(Handle<Value> that) const;
1564  bool StrictEquals(Handle<Value> that) const;
1565  bool SameValue(Handle<Value> that) const;
1566 
1567  template <class T> V8_INLINE static Value* Cast(T* value);
1568 
1569  private:
1570  V8_INLINE bool QuickIsUndefined() const;
1571  V8_INLINE bool QuickIsNull() const;
1572  V8_INLINE bool QuickIsString() const;
1573  bool FullIsUndefined() const;
1574  bool FullIsNull() const;
1575  bool FullIsString() const;
1576 };
1577 
1578 
1582 class V8_EXPORT Primitive : public Value { };
1583 
1584 
1589 class V8_EXPORT Boolean : public Primitive {
1590  public:
1591  bool Value() const;
1592  V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
1593 };
1594 
1595 
1599 class V8_EXPORT String : public Primitive {
1600  public:
1601  enum Encoding {
1602  UNKNOWN_ENCODING = 0x1,
1603  TWO_BYTE_ENCODING = 0x0,
1604  ASCII_ENCODING = 0x4,
1605  ONE_BYTE_ENCODING = 0x4
1606  };
1610  int Length() const;
1611 
1616  int Utf8Length() const;
1617 
1623  bool IsOneByte() const;
1624 
1629  bool ContainsOnlyOneByte() const;
1630 
1657  NO_OPTIONS = 0,
1658  HINT_MANY_WRITES_EXPECTED = 1,
1659  NO_NULL_TERMINATION = 2,
1660  PRESERVE_ASCII_NULL = 4,
1661  // Used by WriteUtf8 to replace orphan surrogate code units with the
1662  // unicode replacement character. Needs to be set to guarantee valid UTF-8
1663  // output.
1664  REPLACE_INVALID_UTF8 = 8
1665  };
1666 
1667  // 16-bit character codes.
1668  int Write(uint16_t* buffer,
1669  int start = 0,
1670  int length = -1,
1671  int options = NO_OPTIONS) const;
1672  // One byte characters.
1673  int WriteOneByte(uint8_t* buffer,
1674  int start = 0,
1675  int length = -1,
1676  int options = NO_OPTIONS) const;
1677  // UTF-8 encoded characters.
1678  int WriteUtf8(char* buffer,
1679  int length = -1,
1680  int* nchars_ref = NULL,
1681  int options = NO_OPTIONS) const;
1682 
1686  V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
1687 
1691  bool IsExternal() const;
1692 
1696  bool IsExternalAscii() const;
1697 
1699  public:
1701 
1702  protected:
1704 
1711  virtual void Dispose() { delete this; }
1712 
1713  private:
1714  // Disallow copying and assigning.
1716  void operator=(const ExternalStringResourceBase&);
1717 
1718  friend class v8::internal::Heap;
1719  };
1720 
1728  : public ExternalStringResourceBase {
1729  public:
1735 
1739  virtual const uint16_t* data() const = 0;
1740 
1744  virtual size_t length() const = 0;
1745 
1746  protected:
1748  };
1749 
1762  : public ExternalStringResourceBase {
1763  public:
1770  virtual const char* data() const = 0;
1772  virtual size_t length() const = 0;
1773  protected:
1775  };
1776 
1778 
1784  V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
1785  Encoding* encoding_out) const;
1786 
1791  V8_INLINE ExternalStringResource* GetExternalStringResource() const;
1792 
1797  const ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
1798 
1799  V8_INLINE static String* Cast(v8::Value* obj);
1800 
1802  kNormalString, kInternalizedString, kUndetectableString
1803  };
1804 
1806  static Local<String> NewFromUtf8(Isolate* isolate,
1807  const char* data,
1808  NewStringType type = kNormalString,
1809  int length = -1);
1810 
1812  static Local<String> NewFromOneByte(
1813  Isolate* isolate,
1814  const uint8_t* data,
1815  NewStringType type = kNormalString,
1816  int length = -1);
1817 
1819  static Local<String> NewFromTwoByte(
1820  Isolate* isolate,
1821  const uint16_t* data,
1822  NewStringType type = kNormalString,
1823  int length = -1);
1824 
1829  static Local<String> Concat(Handle<String> left, Handle<String> right);
1830 
1839  static Local<String> NewExternal(Isolate* isolate,
1840  ExternalStringResource* resource);
1841 
1851  bool MakeExternal(ExternalStringResource* resource);
1852 
1861  static Local<String> NewExternal(Isolate* isolate,
1862  ExternalAsciiStringResource* resource);
1863 
1873  bool MakeExternal(ExternalAsciiStringResource* resource);
1874 
1878  bool CanMakeExternal();
1879 
1888  public:
1889  explicit Utf8Value(Handle<v8::Value> obj);
1890  ~Utf8Value();
1891  char* operator*() { return str_; }
1892  const char* operator*() const { return str_; }
1893  int length() const { return length_; }
1894  private:
1895  char* str_;
1896  int length_;
1897 
1898  // Disallow copying and assigning.
1899  Utf8Value(const Utf8Value&);
1900  void operator=(const Utf8Value&);
1901  };
1902 
1910  public:
1911  explicit Value(Handle<v8::Value> obj);
1912  ~Value();
1913  uint16_t* operator*() { return str_; }
1914  const uint16_t* operator*() const { return str_; }
1915  int length() const { return length_; }
1916  private:
1917  uint16_t* str_;
1918  int length_;
1919 
1920  // Disallow copying and assigning.
1921  Value(const Value&);
1922  void operator=(const Value&);
1923  };
1924 
1925  private:
1926  void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
1927  Encoding encoding) const;
1928  void VerifyExternalStringResource(ExternalStringResource* val) const;
1929  static void CheckCast(v8::Value* obj);
1930 };
1931 
1932 
1938 class V8_EXPORT Symbol : public Primitive {
1939  public:
1940  // Returns the print name string of the symbol, or undefined if none.
1941  Local<Value> Name() const;
1942 
1943  // Create a symbol. If name is not empty, it will be used as the description.
1944  static Local<Symbol> New(
1945  Isolate *isolate, Local<String> name = Local<String>());
1946 
1947  // Access global symbol registry.
1948  // Note that symbols created this way are never collected, so
1949  // they should only be used for statically fixed properties.
1950  // Also, there is only one global name space for the names used as keys.
1951  // To minimize the potential for clashes, use qualified names as keys.
1952  static Local<Symbol> For(Isolate *isolate, Local<String> name);
1953 
1954  // Retrieve a global symbol. Similar to |For|, but using a separate
1955  // registry that is not accessible by (and cannot clash with) JavaScript code.
1956  static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
1957 
1958  V8_INLINE static Symbol* Cast(v8::Value* obj);
1959  private:
1960  Symbol();
1961  static void CheckCast(v8::Value* obj);
1962 };
1963 
1964 
1970 class V8_EXPORT Private : public Data {
1971  public:
1972  // Returns the print name string of the private symbol, or undefined if none.
1973  Local<Value> Name() const;
1974 
1975  // Create a private symbol. If name is not empty, it will be the description.
1976  static Local<Private> New(
1977  Isolate *isolate, Local<String> name = Local<String>());
1978 
1979  // Retrieve a global private symbol. If a symbol with this name has not
1980  // been retrieved in the same isolate before, it is created.
1981  // Note that private symbols created this way are never collected, so
1982  // they should only be used for statically fixed properties.
1983  // Also, there is only one global name space for the names used as keys.
1984  // To minimize the potential for clashes, use qualified names as keys,
1985  // e.g., "Class#property".
1986  static Local<Private> ForApi(Isolate *isolate, Local<String> name);
1987 
1988  private:
1989  Private();
1990 };
1991 
1992 
1996 class V8_EXPORT Number : public Primitive {
1997  public:
1998  double Value() const;
1999  static Local<Number> New(Isolate* isolate, double value);
2000  V8_INLINE static Number* Cast(v8::Value* obj);
2001  private:
2002  Number();
2003  static void CheckCast(v8::Value* obj);
2004 };
2005 
2006 
2010 class V8_EXPORT Integer : public Number {
2011  public:
2012  static Local<Integer> New(Isolate* isolate, int32_t value);
2013  static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
2014  int64_t Value() const;
2015  V8_INLINE static Integer* Cast(v8::Value* obj);
2016  private:
2017  Integer();
2018  static void CheckCast(v8::Value* obj);
2019 };
2020 
2021 
2025 class V8_EXPORT Int32 : public Integer {
2026  public:
2027  int32_t Value() const;
2028  private:
2029  Int32();
2030 };
2031 
2032 
2036 class V8_EXPORT Uint32 : public Integer {
2037  public:
2038  uint32_t Value() const;
2039  private:
2040  Uint32();
2041 };
2042 
2043 
2045  None = 0,
2046  ReadOnly = 1 << 0,
2047  DontEnum = 1 << 1,
2048  DontDelete = 1 << 2
2049 };
2050 
2061 
2062  // Legacy constant names
2072 };
2073 
2079 typedef void (*AccessorGetterCallback)(
2080  Local<String> property,
2081  const PropertyCallbackInfo<Value>& info);
2082 
2083 
2084 typedef void (*AccessorSetterCallback)(
2085  Local<String> property,
2086  Local<Value> value,
2087  const PropertyCallbackInfo<void>& info);
2088 
2089 
2100  DEFAULT = 0,
2102  ALL_CAN_WRITE = 1 << 1,
2104 };
2105 
2106 
2110 class V8_EXPORT Object : public Value {
2111  public:
2112  bool Set(Handle<Value> key, Handle<Value> value);
2113 
2114  bool Set(uint32_t index, Handle<Value> value);
2115 
2116  // Sets an own property on this object bypassing interceptors and
2117  // overriding accessors or read-only properties.
2118  //
2119  // Note that if the object has an interceptor the property will be set
2120  // locally, but since the interceptor takes precedence the local property
2121  // will only be returned if the interceptor doesn't return a value.
2122  //
2123  // Note also that this only works for named properties.
2124  bool ForceSet(Handle<Value> key,
2125  Handle<Value> value,
2126  PropertyAttribute attribs = None);
2127 
2128  Local<Value> Get(Handle<Value> key);
2129 
2130  Local<Value> Get(uint32_t index);
2131 
2137  PropertyAttribute GetPropertyAttributes(Handle<Value> key);
2138 
2142  Local<Value> GetOwnPropertyDescriptor(Local<String> key);
2143 
2144  bool Has(Handle<Value> key);
2145 
2146  bool Delete(Handle<Value> key);
2147 
2148  // Delete a property on this object bypassing interceptors and
2149  // ignoring dont-delete attributes.
2150  bool ForceDelete(Handle<Value> key);
2151 
2152  bool Has(uint32_t index);
2153 
2154  bool Delete(uint32_t index);
2155 
2156  bool SetAccessor(Handle<String> name,
2157  AccessorGetterCallback getter,
2158  AccessorSetterCallback setter = 0,
2159  Handle<Value> data = Handle<Value>(),
2160  AccessControl settings = DEFAULT,
2161  PropertyAttribute attribute = None);
2162 
2163  // This function is not yet stable and should not be used at this time.
2164  bool SetDeclaredAccessor(Local<String> name,
2166  PropertyAttribute attribute = None,
2167  AccessControl settings = DEFAULT);
2168 
2169  void SetAccessorProperty(Local<String> name,
2170  Local<Function> getter,
2172  PropertyAttribute attribute = None,
2173  AccessControl settings = DEFAULT);
2174 
2181  bool HasPrivate(Handle<Private> key);
2182  bool SetPrivate(Handle<Private> key, Handle<Value> value);
2183  bool DeletePrivate(Handle<Private> key);
2184  Local<Value> GetPrivate(Handle<Private> key);
2185 
2192  Local<Array> GetPropertyNames();
2193 
2199  Local<Array> GetOwnPropertyNames();
2200 
2206  Local<Value> GetPrototype();
2207 
2213  bool SetPrototype(Handle<Value> prototype);
2214 
2219  Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl);
2220 
2226  Local<String> ObjectProtoToString();
2227 
2231  Local<String> GetConstructorName();
2232 
2234  int InternalFieldCount();
2235 
2238  const PersistentBase<Object>& object) {
2239  return object.val_->InternalFieldCount();
2240  }
2241 
2243  V8_INLINE Local<Value> GetInternalField(int index);
2244 
2246  void SetInternalField(int index, Handle<Value> value);
2247 
2253  V8_INLINE void* GetAlignedPointerFromInternalField(int index);
2254 
2257  const PersistentBase<Object>& object, int index) {
2258  return object.val_->GetAlignedPointerFromInternalField(index);
2259  }
2260 
2266  void SetAlignedPointerInInternalField(int index, void* value);
2267 
2268  // Testers for local properties.
2269  bool HasOwnProperty(Handle<String> key);
2270  bool HasRealNamedProperty(Handle<String> key);
2271  bool HasRealIndexedProperty(uint32_t index);
2272  bool HasRealNamedCallbackProperty(Handle<String> key);
2273 
2278  Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key);
2279 
2285  Local<Value> GetRealNamedProperty(Handle<String> key);
2286 
2288  bool HasNamedLookupInterceptor();
2289 
2291  bool HasIndexedLookupInterceptor();
2292 
2298  void TurnOnAccessCheck();
2299 
2307  int GetIdentityHash();
2308 
2315  bool SetHiddenValue(Handle<String> key, Handle<Value> value);
2316  Local<Value> GetHiddenValue(Handle<String> key);
2317  bool DeleteHiddenValue(Handle<String> key);
2318 
2326  bool IsDirty();
2327 
2332  Local<Object> Clone();
2333 
2337  Local<Context> CreationContext();
2338 
2346  void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
2347  bool HasIndexedPropertiesInPixelData();
2348  uint8_t* GetIndexedPropertiesPixelData();
2349  int GetIndexedPropertiesPixelDataLength();
2350 
2358  void SetIndexedPropertiesToExternalArrayData(void* data,
2359  ExternalArrayType array_type,
2360  int number_of_elements);
2361  bool HasIndexedPropertiesInExternalArrayData();
2362  void* GetIndexedPropertiesExternalArrayData();
2363  ExternalArrayType GetIndexedPropertiesExternalArrayDataType();
2364  int GetIndexedPropertiesExternalArrayDataLength();
2365 
2371  bool IsCallable();
2372 
2377  Local<Value> CallAsFunction(Handle<Value> recv,
2378  int argc,
2379  Handle<Value> argv[]);
2380 
2386  Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
2387 
2388  static Local<Object> New(Isolate* isolate);
2389 
2390  V8_INLINE static Object* Cast(Value* obj);
2391 
2392  private:
2393  Object();
2394  static void CheckCast(Value* obj);
2395  Local<Value> SlowGetInternalField(int index);
2396  void* SlowGetAlignedPointerFromInternalField(int index);
2397 };
2398 
2399 
2403 class V8_EXPORT Array : public Object {
2404  public:
2405  uint32_t Length() const;
2406 
2411  Local<Object> CloneElementAt(uint32_t index);
2412 
2417  static Local<Array> New(Isolate* isolate, int length = 0);
2418 
2419  V8_INLINE static Array* Cast(Value* obj);
2420  private:
2421  Array();
2422  static void CheckCast(Value* obj);
2423 };
2424 
2425 
2426 template<typename T>
2427 class ReturnValue {
2428  public:
2429  template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
2430  : value_(that.value_) {
2431  TYPE_CHECK(T, S);
2432  }
2433  // Handle setters
2434  template <typename S> V8_INLINE void Set(const Persistent<S>& handle);
2435  template <typename S> V8_INLINE void Set(const Handle<S> handle);
2436  // Fast primitive setters
2437  V8_INLINE void Set(bool value);
2438  V8_INLINE void Set(double i);
2439  V8_INLINE void Set(int32_t i);
2440  V8_INLINE void Set(uint32_t i);
2441  // Fast JS primitive setters
2442  V8_INLINE void SetNull();
2443  V8_INLINE void SetUndefined();
2444  V8_INLINE void SetEmptyString();
2445  // Convenience getter for Isolate
2447 
2448  // Pointer setter: Uncompilable to prevent inadvertent misuse.
2449  template <typename S>
2450  V8_INLINE void Set(S* whatever);
2451 
2452  private:
2453  template<class F> friend class ReturnValue;
2454  template<class F> friend class FunctionCallbackInfo;
2455  template<class F> friend class PropertyCallbackInfo;
2456  template<class F, class G, class H> friend class PersistentValueMap;
2457  V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; }
2458  V8_INLINE internal::Object* GetDefaultValue();
2459  V8_INLINE explicit ReturnValue(internal::Object** slot);
2460  internal::Object** value_;
2461 };
2462 
2463 
2470 template<typename T>
2471 class FunctionCallbackInfo {
2472  public:
2473  V8_INLINE int Length() const;
2474  V8_INLINE Local<Value> operator[](int i) const;
2475  V8_INLINE Local<Function> Callee() const;
2476  V8_INLINE Local<Object> This() const;
2477  V8_INLINE Local<Object> Holder() const;
2478  V8_INLINE bool IsConstructCall() const;
2479  V8_INLINE Local<Value> Data() const;
2480  V8_INLINE Isolate* GetIsolate() const;
2481  V8_INLINE ReturnValue<T> GetReturnValue() const;
2482  // This shouldn't be public, but the arm compiler needs it.
2483  static const int kArgsLength = 7;
2484 
2485  protected:
2488  static const int kHolderIndex = 0;
2489  static const int kIsolateIndex = 1;
2490  static const int kReturnValueDefaultValueIndex = 2;
2491  static const int kReturnValueIndex = 3;
2492  static const int kDataIndex = 4;
2493  static const int kCalleeIndex = 5;
2494  static const int kContextSaveIndex = 6;
2495 
2496  V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
2497  internal::Object** values,
2498  int length,
2499  bool is_construct_call);
2500  internal::Object** implicit_args_;
2501  internal::Object** values_;
2502  int length_;
2504 };
2505 
2506 
2511 template<typename T>
2512 class PropertyCallbackInfo {
2513  public:
2514  V8_INLINE Isolate* GetIsolate() const;
2515  V8_INLINE Local<Value> Data() const;
2516  V8_INLINE Local<Object> This() const;
2517  V8_INLINE Local<Object> Holder() const;
2519  // This shouldn't be public, but the arm compiler needs it.
2520  static const int kArgsLength = 6;
2521 
2522  protected:
2523  friend class MacroAssembler;
2526  static const int kHolderIndex = 0;
2527  static const int kIsolateIndex = 1;
2528  static const int kReturnValueDefaultValueIndex = 2;
2529  static const int kReturnValueIndex = 3;
2530  static const int kDataIndex = 4;
2531  static const int kThisIndex = 5;
2532 
2533  V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
2534  internal::Object** args_;
2535 };
2536 
2537 
2538 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
2539 
2540 
2544 class V8_EXPORT Function : public Object {
2545  public:
2550  static Local<Function> New(Isolate* isolate,
2551  FunctionCallback callback,
2552  Local<Value> data = Local<Value>(),
2553  int length = 0);
2554 
2555  Local<Object> NewInstance() const;
2556  Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
2557  Local<Value> Call(Handle<Value> recv, int argc, Handle<Value> argv[]);
2558  void SetName(Handle<String> name);
2559  Handle<Value> GetName() const;
2560 
2567  Handle<Value> GetInferredName() const;
2568 
2573  Handle<Value> GetDisplayName() const;
2574 
2579  int GetScriptLineNumber() const;
2584  int GetScriptColumnNumber() const;
2585 
2589  bool IsBuiltin() const;
2590 
2594  int ScriptId() const;
2595 
2600  Local<Value> GetBoundFunction() const;
2601 
2602  ScriptOrigin GetScriptOrigin() const;
2603  V8_INLINE static Function* Cast(Value* obj);
2604  static const int kLineOffsetNotFound;
2605 
2606  private:
2607  Function();
2608  static void CheckCast(Value* obj);
2609 };
2610 
2611 
2616 class V8_EXPORT Promise : public Object {
2617  public:
2618  class V8_EXPORT Resolver : public Object {
2619  public:
2623  static Local<Resolver> New(Isolate* isolate);
2624 
2628  Local<Promise> GetPromise();
2629 
2634  void Resolve(Handle<Value> value);
2635  void Reject(Handle<Value> value);
2636 
2637  V8_INLINE static Resolver* Cast(Value* obj);
2638 
2639  private:
2640  Resolver();
2641  static void CheckCast(Value* obj);
2642  };
2643 
2650  Local<Promise> Chain(Handle<Function> handler);
2651  Local<Promise> Catch(Handle<Function> handler);
2652  Local<Promise> Then(Handle<Function> handler);
2653 
2654  V8_INLINE static Promise* Cast(Value* obj);
2655 
2656  private:
2657  Promise();
2658  static void CheckCast(Value* obj);
2659 };
2660 
2661 
2662 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
2663 // The number of required internal fields can be defined by embedder.
2664 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
2665 #endif
2666 
2671 class V8_EXPORT ArrayBuffer : public Object {
2672  public:
2680  class V8_EXPORT Allocator { // NOLINT
2681  public:
2682  virtual ~Allocator() {}
2683 
2688  virtual void* Allocate(size_t length) = 0;
2689 
2694  virtual void* AllocateUninitialized(size_t length) = 0;
2699  virtual void Free(void* data, size_t length) = 0;
2700  };
2701 
2712  class V8_EXPORT Contents { // NOLINT
2713  public:
2714  Contents() : data_(NULL), byte_length_(0) {}
2715 
2716  void* Data() const { return data_; }
2717  size_t ByteLength() const { return byte_length_; }
2718 
2719  private:
2720  void* data_;
2721  size_t byte_length_;
2722 
2723  friend class ArrayBuffer;
2724  };
2725 
2726 
2730  size_t ByteLength() const;
2731 
2738  static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
2739 
2746  static Local<ArrayBuffer> New(Isolate* isolate, void* data,
2747  size_t byte_length);
2748 
2753  bool IsExternal() const;
2754 
2761  void Neuter();
2762 
2772  Contents Externalize();
2773 
2774  V8_INLINE static ArrayBuffer* Cast(Value* obj);
2775 
2776  static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
2777 
2778  private:
2779  ArrayBuffer();
2780  static void CheckCast(Value* obj);
2781 };
2782 
2783 
2784 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
2785 // The number of required internal fields can be defined by embedder.
2786 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
2787 #endif
2788 
2789 
2797  public:
2801  Local<ArrayBuffer> Buffer();
2805  size_t ByteOffset();
2809  size_t ByteLength();
2810 
2811  V8_INLINE static ArrayBufferView* Cast(Value* obj);
2812 
2813  static const int kInternalFieldCount =
2815 
2816  private:
2817  ArrayBufferView();
2818  static void CheckCast(Value* obj);
2819 };
2820 
2821 
2828  public:
2833  size_t Length();
2834 
2835  V8_INLINE static TypedArray* Cast(Value* obj);
2836 
2837  private:
2838  TypedArray();
2839  static void CheckCast(Value* obj);
2840 };
2841 
2842 
2848  public:
2849  static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
2850  size_t byte_offset, size_t length);
2851  V8_INLINE static Uint8Array* Cast(Value* obj);
2852 
2853  private:
2854  Uint8Array();
2855  static void CheckCast(Value* obj);
2856 };
2857 
2858 
2864  public:
2865  static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
2866  size_t byte_offset, size_t length);
2867  V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
2868 
2869  private:
2871  static void CheckCast(Value* obj);
2872 };
2873 
2879  public:
2880  static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
2881  size_t byte_offset, size_t length);
2882  V8_INLINE static Int8Array* Cast(Value* obj);
2883 
2884  private:
2885  Int8Array();
2886  static void CheckCast(Value* obj);
2887 };
2888 
2889 
2895  public:
2896  static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
2897  size_t byte_offset, size_t length);
2898  V8_INLINE static Uint16Array* Cast(Value* obj);
2899 
2900  private:
2901  Uint16Array();
2902  static void CheckCast(Value* obj);
2903 };
2904 
2905 
2911  public:
2912  static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
2913  size_t byte_offset, size_t length);
2914  V8_INLINE static Int16Array* Cast(Value* obj);
2915 
2916  private:
2917  Int16Array();
2918  static void CheckCast(Value* obj);
2919 };
2920 
2921 
2927  public:
2928  static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
2929  size_t byte_offset, size_t length);
2930  V8_INLINE static Uint32Array* Cast(Value* obj);
2931 
2932  private:
2933  Uint32Array();
2934  static void CheckCast(Value* obj);
2935 };
2936 
2937 
2943  public:
2944  static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
2945  size_t byte_offset, size_t length);
2946  V8_INLINE static Int32Array* Cast(Value* obj);
2947 
2948  private:
2949  Int32Array();
2950  static void CheckCast(Value* obj);
2951 };
2952 
2953 
2959  public:
2960  static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
2961  size_t byte_offset, size_t length);
2962  V8_INLINE static Float32Array* Cast(Value* obj);
2963 
2964  private:
2965  Float32Array();
2966  static void CheckCast(Value* obj);
2967 };
2968 
2969 
2975  public:
2976  static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
2977  size_t byte_offset, size_t length);
2978  V8_INLINE static Float64Array* Cast(Value* obj);
2979 
2980  private:
2981  Float64Array();
2982  static void CheckCast(Value* obj);
2983 };
2984 
2985 
2991  public:
2992  static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
2993  size_t byte_offset, size_t length);
2994  V8_INLINE static DataView* Cast(Value* obj);
2995 
2996  private:
2997  DataView();
2998  static void CheckCast(Value* obj);
2999 };
3000 
3001 
3005 class V8_EXPORT Date : public Object {
3006  public:
3007  static Local<Value> New(Isolate* isolate, double time);
3008 
3013  double ValueOf() const;
3014 
3015  V8_INLINE static Date* Cast(v8::Value* obj);
3016 
3029  static void DateTimeConfigurationChangeNotification(Isolate* isolate);
3030 
3031  private:
3032  static void CheckCast(v8::Value* obj);
3033 };
3034 
3035 
3040  public:
3041  static Local<Value> New(Isolate* isolate, double value);
3042 
3043  double ValueOf() const;
3044 
3045  V8_INLINE static NumberObject* Cast(v8::Value* obj);
3046 
3047  private:
3048  static void CheckCast(v8::Value* obj);
3049 };
3050 
3051 
3056  public:
3057  static Local<Value> New(bool value);
3058 
3059  bool ValueOf() const;
3060 
3061  V8_INLINE static BooleanObject* Cast(v8::Value* obj);
3062 
3063  private:
3064  static void CheckCast(v8::Value* obj);
3065 };
3066 
3067 
3072  public:
3073  static Local<Value> New(Handle<String> value);
3074 
3075  Local<String> ValueOf() const;
3076 
3077  V8_INLINE static StringObject* Cast(v8::Value* obj);
3078 
3079  private:
3080  static void CheckCast(v8::Value* obj);
3081 };
3082 
3083 
3090  public:
3091  static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
3092 
3093  Local<Symbol> ValueOf() const;
3094 
3095  V8_INLINE static SymbolObject* Cast(v8::Value* obj);
3096 
3097  private:
3098  static void CheckCast(v8::Value* obj);
3099 };
3100 
3101 
3105 class V8_EXPORT RegExp : public Object {
3106  public:
3111  enum Flags {
3112  kNone = 0,
3113  kGlobal = 1,
3114  kIgnoreCase = 2,
3115  kMultiline = 4
3116  };
3117 
3128  static Local<RegExp> New(Handle<String> pattern, Flags flags);
3129 
3134  Local<String> GetSource() const;
3135 
3139  Flags GetFlags() const;
3140 
3141  V8_INLINE static RegExp* Cast(v8::Value* obj);
3142 
3143  private:
3144  static void CheckCast(v8::Value* obj);
3145 };
3146 
3147 
3152 class V8_EXPORT External : public Value {
3153  public:
3154  static Local<External> New(Isolate* isolate, void* value);
3155  V8_INLINE static External* Cast(Value* obj);
3156  void* Value() const;
3157  private:
3158  static void CheckCast(v8::Value* obj);
3159 };
3160 
3161 
3162 // --- Templates ---
3163 
3164 
3168 class V8_EXPORT Template : public Data {
3169  public:
3171  void Set(Handle<String> name, Handle<Data> value,
3172  PropertyAttribute attributes = None);
3173  V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
3174 
3175  void SetAccessorProperty(
3176  Local<String> name,
3179  PropertyAttribute attribute = None,
3180  AccessControl settings = DEFAULT);
3181 
3209  void SetNativeDataProperty(Local<String> name,
3210  AccessorGetterCallback getter,
3211  AccessorSetterCallback setter = 0,
3212  // TODO(dcarney): gcc can't handle Local below
3213  Handle<Value> data = Handle<Value>(),
3214  PropertyAttribute attribute = None,
3215  Local<AccessorSignature> signature =
3217  AccessControl settings = DEFAULT);
3218 
3219  // This function is not yet stable and should not be used at this time.
3220  bool SetDeclaredAccessor(Local<String> name,
3222  PropertyAttribute attribute = None,
3223  Local<AccessorSignature> signature =
3225  AccessControl settings = DEFAULT);
3226 
3227  private:
3228  Template();
3229 
3230  friend class ObjectTemplate;
3231  friend class FunctionTemplate;
3232 };
3233 
3234 
3240  Local<String> property,
3241  const PropertyCallbackInfo<Value>& info);
3242 
3243 
3249  Local<String> property,
3250  Local<Value> value,
3251  const PropertyCallbackInfo<Value>& info);
3252 
3253 
3260  Local<String> property,
3261  const PropertyCallbackInfo<Integer>& info);
3262 
3263 
3270  Local<String> property,
3271  const PropertyCallbackInfo<Boolean>& info);
3272 
3273 
3279  const PropertyCallbackInfo<Array>& info);
3280 
3281 
3287  uint32_t index,
3288  const PropertyCallbackInfo<Value>& info);
3289 
3290 
3296  uint32_t index,
3297  Local<Value> value,
3298  const PropertyCallbackInfo<Value>& info);
3299 
3300 
3306  uint32_t index,
3307  const PropertyCallbackInfo<Integer>& info);
3308 
3309 
3316  uint32_t index,
3317  const PropertyCallbackInfo<Boolean>& info);
3318 
3319 
3325  const PropertyCallbackInfo<Array>& info);
3326 
3327 
3337 };
3338 
3339 
3345  Local<Value> key,
3346  AccessType type,
3347  Local<Value> data);
3348 
3349 
3355  uint32_t index,
3356  AccessType type,
3357  Local<Value> data);
3358 
3359 
3453  public:
3455  static Local<FunctionTemplate> New(
3456  Isolate* isolate,
3457  FunctionCallback callback = 0,
3458  Handle<Value> data = Handle<Value>(),
3459  Handle<Signature> signature = Handle<Signature>(),
3460  int length = 0);
3461 
3463  Local<Function> GetFunction();
3464 
3470  void SetCallHandler(FunctionCallback callback,
3471  Handle<Value> data = Handle<Value>());
3472 
3474  void SetLength(int length);
3475 
3477  Local<ObjectTemplate> InstanceTemplate();
3478 
3480  void Inherit(Handle<FunctionTemplate> parent);
3481 
3486  Local<ObjectTemplate> PrototypeTemplate();
3487 
3493  void SetClassName(Handle<String> name);
3494 
3507  void SetHiddenPrototype(bool value);
3508 
3513  void ReadOnlyPrototype();
3514 
3519  void RemovePrototype();
3520 
3525  bool HasInstance(Handle<Value> object);
3526 
3527  private:
3528  FunctionTemplate();
3529  friend class Context;
3530  friend class ObjectTemplate;
3531 };
3532 
3533 
3541  public:
3543  static Local<ObjectTemplate> New(Isolate* isolate);
3544  // Will be deprecated soon.
3545  static Local<ObjectTemplate> New();
3546 
3548  Local<Object> NewInstance();
3549 
3579  void SetAccessor(Handle<String> name,
3580  AccessorGetterCallback getter,
3581  AccessorSetterCallback setter = 0,
3582  Handle<Value> data = Handle<Value>(),
3583  AccessControl settings = DEFAULT,
3584  PropertyAttribute attribute = None,
3585  Handle<AccessorSignature> signature =
3587 
3605  void SetNamedPropertyHandler(
3607  NamedPropertySetterCallback setter = 0,
3608  NamedPropertyQueryCallback query = 0,
3609  NamedPropertyDeleterCallback deleter = 0,
3610  NamedPropertyEnumeratorCallback enumerator = 0,
3611  Handle<Value> data = Handle<Value>());
3612 
3629  void SetIndexedPropertyHandler(
3631  IndexedPropertySetterCallback setter = 0,
3632  IndexedPropertyQueryCallback query = 0,
3633  IndexedPropertyDeleterCallback deleter = 0,
3634  IndexedPropertyEnumeratorCallback enumerator = 0,
3635  Handle<Value> data = Handle<Value>());
3636 
3643  void SetCallAsFunctionHandler(FunctionCallback callback,
3644  Handle<Value> data = Handle<Value>());
3645 
3654  void MarkAsUndetectable();
3655 
3667  void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
3668  IndexedSecurityCallback indexed_handler,
3669  Handle<Value> data = Handle<Value>(),
3670  bool turned_on_by_default = true);
3671 
3676  int InternalFieldCount();
3677 
3682  void SetInternalFieldCount(int value);
3683 
3684  private:
3685  ObjectTemplate();
3686  static Local<ObjectTemplate> New(internal::Isolate* isolate,
3687  Handle<FunctionTemplate> constructor);
3688  friend class FunctionTemplate;
3689 };
3690 
3691 
3696 class V8_EXPORT Signature : public Data {
3697  public:
3698  static Local<Signature> New(Isolate* isolate,
3699  Handle<FunctionTemplate> receiver =
3701  int argc = 0,
3702  Handle<FunctionTemplate> argv[] = 0);
3703 
3704  private:
3705  Signature();
3706 };
3707 
3708 
3714  public:
3715  static Local<AccessorSignature> New(Isolate* isolate,
3716  Handle<FunctionTemplate> receiver =
3718 
3719  private:
3721 };
3722 
3723 
3725  private:
3727 };
3728 
3729 
3731  public:
3732  // This function is not yet stable and should not be used at this time.
3733  static Local<RawOperationDescriptor> NewInternalFieldDereference(
3734  Isolate* isolate,
3735  int internal_field);
3736  private:
3738 };
3739 
3740 
3747 };
3748 
3749 
3751  public:
3752  Local<DeclaredAccessorDescriptor> NewHandleDereference(Isolate* isolate);
3753  Local<RawOperationDescriptor> NewRawDereference(Isolate* isolate);
3754  Local<RawOperationDescriptor> NewRawShift(Isolate* isolate,
3755  int16_t byte_offset);
3756  Local<DeclaredAccessorDescriptor> NewPointerCompare(Isolate* isolate,
3757  void* compare_value);
3758  Local<DeclaredAccessorDescriptor> NewPrimitiveValue(
3759  Isolate* isolate,
3761  uint8_t bool_offset = 0);
3762  Local<DeclaredAccessorDescriptor> NewBitmaskCompare8(Isolate* isolate,
3763  uint8_t bitmask,
3764  uint8_t compare_value);
3765  Local<DeclaredAccessorDescriptor> NewBitmaskCompare16(
3766  Isolate* isolate,
3767  uint16_t bitmask,
3768  uint16_t compare_value);
3769  Local<DeclaredAccessorDescriptor> NewBitmaskCompare32(
3770  Isolate* isolate,
3771  uint32_t bitmask,
3772  uint32_t compare_value);
3773 
3774  private:
3776 };
3777 
3778 
3783 class V8_EXPORT TypeSwitch : public Data {
3784  public:
3786  static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
3787  int match(Handle<Value> value);
3788  private:
3789  TypeSwitch();
3790 };
3791 
3792 
3793 // --- Extensions ---
3794 
3797  public:
3798  ExternalAsciiStringResourceImpl() : data_(0), length_(0) {}
3799  ExternalAsciiStringResourceImpl(const char* data, size_t length)
3800  : data_(data), length_(length) {}
3801  const char* data() const { return data_; }
3802  size_t length() const { return length_; }
3803 
3804  private:
3805  const char* data_;
3806  size_t length_;
3807 };
3808 
3812 class V8_EXPORT Extension { // NOLINT
3813  public:
3814  // Note that the strings passed into this constructor must live as long
3815  // as the Extension itself.
3816  Extension(const char* name,
3817  const char* source = 0,
3818  int dep_count = 0,
3819  const char** deps = 0,
3820  int source_length = -1);
3821  virtual ~Extension() { }
3823  v8::Isolate* isolate, v8::Handle<v8::String> name) {
3825  }
3826 
3827  const char* name() const { return name_; }
3828  size_t source_length() const { return source_length_; }
3830  return &source_; }
3831  int dependency_count() { return dep_count_; }
3832  const char** dependencies() { return deps_; }
3833  void set_auto_enable(bool value) { auto_enable_ = value; }
3834  bool auto_enable() { return auto_enable_; }
3835 
3836  private:
3837  const char* name_;
3838  size_t source_length_; // expected to initialize before source_
3840  int dep_count_;
3841  const char** deps_;
3842  bool auto_enable_;
3843 
3844  // Disallow copying and assigning.
3845  Extension(const Extension&);
3846  void operator=(const Extension&);
3847 };
3848 
3849 
3850 void V8_EXPORT RegisterExtension(Extension* extension);
3851 
3852 
3853 // --- Statics ---
3854 
3855 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
3856 V8_INLINE Handle<Primitive> Null(Isolate* isolate);
3857 V8_INLINE Handle<Boolean> True(Isolate* isolate);
3858 V8_INLINE Handle<Boolean> False(Isolate* isolate);
3859 
3860 
3871  public:
3873 
3885  void ConfigureDefaults(uint64_t physical_memory,
3886  uint64_t virtual_memory_limit,
3887  uint32_t number_of_processors);
3888 
3889  int max_semi_space_size() const { return max_semi_space_size_; }
3890  void set_max_semi_space_size(int value) { max_semi_space_size_ = value; }
3891  int max_old_space_size() const { return max_old_space_size_; }
3892  void set_max_old_space_size(int value) { max_old_space_size_ = value; }
3893  int max_executable_size() const { return max_executable_size_; }
3894  void set_max_executable_size(int value) { max_executable_size_ = value; }
3895  uint32_t* stack_limit() const { return stack_limit_; }
3896  // Sets an address beyond which the VM's stack may not grow.
3897  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
3898  int max_available_threads() const { return max_available_threads_; }
3899  // Set the number of threads available to V8, assuming at least 1.
3900  void set_max_available_threads(int value) {
3901  max_available_threads_ = value;
3902  }
3903  size_t code_range_size() const { return code_range_size_; }
3904  void set_code_range_size(size_t value) {
3905  code_range_size_ = value;
3906  }
3907 
3908  private:
3909  int max_semi_space_size_;
3910  int max_old_space_size_;
3911  int max_executable_size_;
3912  uint32_t* stack_limit_;
3913  int max_available_threads_;
3914  size_t code_range_size_;
3915 };
3916 
3917 
3921 bool V8_EXPORT SetResourceConstraints(Isolate* isolate,
3922  ResourceConstraints* constraints);
3923 
3924 
3925 // --- Exceptions ---
3926 
3927 
3928 typedef void (*FatalErrorCallback)(const char* location, const char* message);
3929 
3930 
3931 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
3932 
3933 // --- Tracing ---
3934 
3935 typedef void (*LogEventCallback)(const char* name, int event);
3936 
3942  public:
3943  static Local<Value> RangeError(Handle<String> message);
3944  static Local<Value> ReferenceError(Handle<String> message);
3945  static Local<Value> SyntaxError(Handle<String> message);
3946  static Local<Value> TypeError(Handle<String> message);
3947  static Local<Value> Error(Handle<String> message);
3948 };
3949 
3950 
3951 // --- Counters Callbacks ---
3952 
3953 typedef int* (*CounterLookupCallback)(const char* name);
3954 
3955 typedef void* (*CreateHistogramCallback)(const char* name,
3956  int min,
3957  int max,
3958  size_t buckets);
3959 
3960 typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
3961 
3962 // --- Memory Allocation Callback ---
3970 
3974  };
3975 
3980  };
3981 
3983  AllocationAction action,
3984  int size);
3985 
3986 // --- Leave Script Callback ---
3987 typedef void (*CallCompletedCallback)();
3988 
3989 // --- Microtask Callback ---
3990 typedef void (*MicrotaskCallback)(void* data);
3991 
3992 // --- Failed Access Check Callback ---
3994  AccessType type,
3995  Local<Value> data);
3996 
3997 // --- AllowCodeGenerationFromStrings callbacks ---
3998 
4004 
4005 // --- Garbage Collection Callbacks ---
4006 
4014 enum GCType {
4018 };
4019 
4025 };
4026 
4027 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
4028 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
4029 
4030 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
4031 
4032 
4040  public:
4041  HeapStatistics();
4042  size_t total_heap_size() { return total_heap_size_; }
4043  size_t total_heap_size_executable() { return total_heap_size_executable_; }
4044  size_t total_physical_size() { return total_physical_size_; }
4045  size_t used_heap_size() { return used_heap_size_; }
4046  size_t heap_size_limit() { return heap_size_limit_; }
4047 
4048  private:
4049  size_t total_heap_size_;
4050  size_t total_heap_size_executable_;
4051  size_t total_physical_size_;
4052  size_t used_heap_size_;
4053  size_t heap_size_limit_;
4054 
4055  friend class V8;
4056  friend class Isolate;
4057 };
4058 
4059 
4060 class RetainedObjectInfo;
4061 
4072  public:
4078  public:
4079  explicit Scope(Isolate* isolate) : isolate_(isolate) {
4080  isolate->Enter();
4081  }
4082 
4083  ~Scope() { isolate_->Exit(); }
4084 
4085  private:
4086  Isolate* const isolate_;
4087 
4088  // Prevent copying of Scope objects.
4089  Scope(const Scope&);
4090  Scope& operator=(const Scope&);
4091  };
4092 
4093 
4098  public:
4099  enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
4100 
4101  DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
4103 
4104  private:
4105  bool on_failure_;
4106  void* internal_;
4107 
4108  // Prevent copying of Scope objects.
4112  };
4113 
4114 
4119  public:
4120  explicit AllowJavascriptExecutionScope(Isolate* isolate);
4122 
4123  private:
4124  void* internal_throws_;
4125  void* internal_assert_;
4126 
4127  // Prevent copying of Scope objects.
4129  AllowJavascriptExecutionScope& operator=(
4131  };
4132 
4138  public:
4139  explicit SuppressMicrotaskExecutionScope(Isolate* isolate);
4141 
4142  private:
4143  internal::Isolate* isolate_;
4144 
4145  // Prevent copying of Scope objects.
4149  };
4150 
4157  kMinorGarbageCollection
4158  };
4159 
4166  kUseAsm = 0,
4167  kUseCounterFeatureCount // This enum value must be last.
4168  };
4169 
4170  typedef void (*UseCounterCallback)(Isolate* isolate,
4171  UseCounterFeature feature);
4172 
4173 
4181  static Isolate* New();
4182 
4187  static Isolate* GetCurrent();
4188 
4199  void Enter();
4200 
4208  void Exit();
4209 
4214  void Dispose();
4215 
4220  V8_INLINE void SetData(uint32_t slot, void* data);
4221 
4226  V8_INLINE void* GetData(uint32_t slot);
4227 
4232  V8_INLINE static uint32_t GetNumberOfDataSlots();
4233 
4237  void GetHeapStatistics(HeapStatistics* heap_statistics);
4238 
4252  V8_INLINE int64_t
4253  AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
4254 
4259  HeapProfiler* GetHeapProfiler();
4260 
4266  CpuProfiler* GetCpuProfiler();
4267 
4269  bool InContext();
4270 
4272  Local<Context> GetCurrentContext();
4273 
4279  Local<Context> GetCallingContext();
4280 
4282  Local<Context> GetEnteredContext();
4283 
4290  Local<Value> ThrowException(Local<Value> exception);
4291 
4303  template<typename T> void SetObjectGroupId(const Persistent<T>& object,
4304  UniqueId id);
4305 
4313  template<typename T> void SetReferenceFromGroup(UniqueId id,
4314  const Persistent<T>& child);
4315 
4322  template<typename T, typename S>
4323  void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
4324 
4325  typedef void (*GCPrologueCallback)(Isolate* isolate,
4326  GCType type,
4327  GCCallbackFlags flags);
4328  typedef void (*GCEpilogueCallback)(Isolate* isolate,
4329  GCType type,
4330  GCCallbackFlags flags);
4331 
4341  void AddGCPrologueCallback(
4342  GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
4343 
4348  void RemoveGCPrologueCallback(GCPrologueCallback callback);
4349 
4359  void AddGCEpilogueCallback(
4360  GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
4361 
4366  void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
4367 
4377  void RequestInterrupt(InterruptCallback callback, void* data);
4378 
4383  void ClearInterrupt();
4384 
4394  void RequestGarbageCollectionForTesting(GarbageCollectionType type);
4395 
4399  void SetEventLogger(LogEventCallback that);
4400 
4408  void AddCallCompletedCallback(CallCompletedCallback callback);
4409 
4413  void RemoveCallCompletedCallback(CallCompletedCallback callback);
4414 
4419  void RunMicrotasks();
4420 
4424  void EnqueueMicrotask(Handle<Function> microtask);
4425 
4429  void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
4430 
4435  void SetAutorunMicrotasks(bool autorun);
4436 
4441  bool WillAutorunMicrotasks() const;
4442 
4446  void SetUseCounterCallback(UseCounterCallback callback);
4447 
4452  void SetCounterFunction(CounterLookupCallback);
4453 
4460  void SetCreateHistogramFunction(CreateHistogramCallback);
4461  void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
4462 
4475  bool IdleNotification(int idle_time_in_ms);
4476 
4481  void LowMemoryNotification();
4482 
4489  int ContextDisposedNotification();
4490 
4491  private:
4492  template<class K, class V, class Traits> friend class PersistentValueMap;
4493 
4494  Isolate();
4495  Isolate(const Isolate&);
4496  ~Isolate();
4497  Isolate& operator=(const Isolate&);
4498  void* operator new(size_t size);
4499  void operator delete(void*, size_t);
4500 
4501  void SetObjectGroupId(internal::Object** object, UniqueId id);
4502  void SetReferenceFromGroup(UniqueId id, internal::Object** object);
4503  void SetReference(internal::Object** parent, internal::Object** child);
4504  void CollectAllGarbage(const char* gc_reason);
4505 };
4506 
4508  public:
4511  kBZip2
4512  };
4513 
4514  const char* data;
4517 };
4518 
4519 
4529  public:
4531  virtual ~StartupDataDecompressor();
4532  int Decompress();
4533 
4534  protected:
4535  virtual int DecompressData(char* raw_data,
4536  int* raw_data_size,
4537  const char* compressed_data,
4538  int compressed_data_size) = 0;
4539 
4540  private:
4541  char** raw_data;
4542 };
4543 
4544 
4549 typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
4550 
4551 
4565 typedef uintptr_t (*ReturnAddressLocationResolver)(
4566  uintptr_t return_addr_location);
4567 
4568 
4580 typedef void (*FunctionEntryHook)(uintptr_t function,
4581  uintptr_t return_addr_location);
4582 
4583 
4590  enum EventType {
4597  };
4598  // Definition of the code position type. The "POSITION" type means the place
4599  // in the source code which are of interest when making stack traces to
4600  // pin-point the source location of a stack frame as close as possible.
4601  // The "STATEMENT_POSITION" means the place at the beginning of each
4602  // statement, and is used to indicate possible break locations.
4606  };
4607 
4608  // Type of event.
4610  // Start of the instructions.
4611  void* code_start;
4612  // Size of the instructions.
4613  size_t code_len;
4614  // Script info for CODE_ADDED event.
4616  // User-defined data for *_LINE_INFO_* event. It's used to hold the source
4617  // code line information which is returned from the
4618  // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
4619  // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
4620  void* user_data;
4621 
4622  struct name_t {
4623  // Name of the object associated with the code, note that the string is not
4624  // zero-terminated.
4625  const char* str;
4626  // Number of chars in str.
4627  size_t len;
4628  };
4629 
4630  struct line_info_t {
4631  // PC offset
4632  size_t offset;
4633  // Code postion
4634  size_t pos;
4635  // The position type.
4637  };
4638 
4639  union {
4640  // Only valid for CODE_ADDED.
4641  struct name_t name;
4642 
4643  // Only valid for CODE_ADD_LINE_POS_INFO
4645 
4646  // New location of instructions. Only valid for CODE_MOVED.
4648  };
4649 };
4650 
4656  // Generate callbacks for already existent code.
4658 };
4659 
4660 
4666 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
4667 
4668 
4673  public:
4675  virtual void VisitExternalString(Handle<String> string) {}
4676 };
4677 
4678 
4683  public:
4686  uint16_t class_id) {}
4687 };
4688 
4689 
4693 class V8_EXPORT V8 {
4694  public:
4696  static void SetFatalErrorHandler(FatalErrorCallback that);
4697 
4702  static void SetAllowCodeGenerationFromStringsCallback(
4704 
4711  static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator);
4712 
4717  static bool IsDead();
4718 
4738  static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm();
4739  static int GetCompressedStartupDataCount();
4740  static void GetCompressedStartupData(StartupData* compressed_data);
4741  static void SetDecompressedStartupData(StartupData* decompressed_data);
4742 
4758  static void SetNativesDataBlob(StartupData* startup_blob);
4759  static void SetSnapshotDataBlob(StartupData* startup_blob);
4760 
4770  static bool AddMessageListener(MessageCallback that,
4771  Handle<Value> data = Handle<Value>());
4772 
4776  static void RemoveMessageListeners(MessageCallback that);
4777 
4782  static void SetCaptureStackTraceForUncaughtExceptions(
4783  bool capture,
4784  int frame_limit = 10,
4786 
4790  static void SetFlagsFromString(const char* str, int length);
4791 
4795  static void SetFlagsFromCommandLine(int* argc,
4796  char** argv,
4797  bool remove_flags);
4798 
4800  static const char* GetVersion();
4801 
4803  static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
4804 
4815  static void AddGCPrologueCallback(
4816  GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
4817 
4822  static void RemoveGCPrologueCallback(GCPrologueCallback callback);
4823 
4834  static void AddGCEpilogueCallback(
4835  GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
4836 
4841  static void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
4842 
4847  static void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
4848  ObjectSpace space,
4849  AllocationAction action);
4850 
4854  static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
4855 
4861  static bool Initialize();
4862 
4867  static void SetEntropySource(EntropySource source);
4868 
4873  static void SetReturnAddressLocationResolver(
4874  ReturnAddressLocationResolver return_address_resolver);
4875 
4889  static bool SetFunctionEntryHook(Isolate* isolate,
4890  FunctionEntryHook entry_hook);
4891 
4912  static void SetJitCodeEventHandler(JitCodeEventOptions options,
4913  JitCodeEventHandler event_handler);
4914 
4924  static void TerminateExecution(Isolate* isolate);
4925 
4936  static bool IsExecutionTerminating(Isolate* isolate = NULL);
4937 
4954  static void CancelTerminateExecution(Isolate* isolate);
4955 
4965  static bool Dispose();
4966 
4972  static void VisitExternalResources(ExternalResourceVisitor* visitor);
4973 
4978  static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
4979 
4987  static void VisitHandlesForPartialDependence(
4988  Isolate* isolate, PersistentHandleVisitor* visitor);
4989 
4997  static bool InitializeICU(const char* icu_data_file = NULL);
4998 
5003  static void InitializePlatform(Platform* platform);
5004 
5009  static void ShutdownPlatform();
5010 
5011  private:
5012  V8();
5013 
5014  static internal::Object** GlobalizeReference(internal::Isolate* isolate,
5015  internal::Object** handle);
5016  static internal::Object** CopyPersistent(internal::Object** handle);
5017  static void DisposeGlobal(internal::Object** global_handle);
5018  typedef WeakCallbackData<Value, void>::Callback WeakCallback;
5019  static void MakeWeak(internal::Object** global_handle,
5020  void* data,
5021  WeakCallback weak_callback);
5022  static void* ClearWeak(internal::Object** global_handle);
5023  static void Eternalize(Isolate* isolate,
5024  Value* handle,
5025  int* index);
5026  static Local<Value> GetEternal(Isolate* isolate, int index);
5027 
5028  template <class T> friend class Handle;
5029  template <class T> friend class Local;
5030  template <class T> friend class Eternal;
5031  template <class T> friend class PersistentBase;
5032  template <class T, class M> friend class Persistent;
5033  friend class Context;
5034 };
5035 
5036 
5041  public:
5047  TryCatch();
5048 
5052  ~TryCatch();
5053 
5057  bool HasCaught() const;
5058 
5067  bool CanContinue() const;
5068 
5081  bool HasTerminated() const;
5082 
5090  Handle<Value> ReThrow();
5091 
5098  Local<Value> Exception() const;
5099 
5104  Local<Value> StackTrace() const;
5105 
5113  Local<v8::Message> Message() const;
5114 
5125  void Reset();
5126 
5135  void SetVerbose(bool value);
5136 
5142  void SetCaptureMessage(bool value);
5143 
5155  static void* JSStackComparableAddress(v8::TryCatch* handler) {
5156  if (handler == NULL) return NULL;
5157  return handler->js_stack_comparable_address_;
5158  }
5159 
5160  private:
5161  void ResetInternal();
5162 
5163  // Make it hard to create heap-allocated TryCatch blocks.
5164  TryCatch(const TryCatch&);
5165  void operator=(const TryCatch&);
5166  void* operator new(size_t size);
5167  void operator delete(void*, size_t);
5168 
5169  v8::internal::Isolate* isolate_;
5170  v8::TryCatch* next_;
5171  void* exception_;
5172  void* message_obj_;
5173  void* message_script_;
5174  void* js_stack_comparable_address_;
5175  int message_start_pos_;
5176  int message_end_pos_;
5177  bool is_verbose_ : 1;
5178  bool can_continue_ : 1;
5179  bool capture_message_ : 1;
5180  bool rethrow_ : 1;
5181  bool has_terminated_ : 1;
5182 
5183  friend class v8::internal::Isolate;
5184 };
5185 
5186 
5187 // --- Context ---
5188 
5189 
5194  public:
5195  ExtensionConfiguration() : name_count_(0), names_(NULL) { }
5196  ExtensionConfiguration(int name_count, const char* names[])
5197  : name_count_(name_count), names_(names) { }
5198 
5199  const char** begin() const { return &names_[0]; }
5200  const char** end() const { return &names_[name_count_]; }
5201 
5202  private:
5203  const int name_count_;
5204  const char** names_;
5205 };
5206 
5207 
5213  public:
5226  Local<Object> Global();
5227 
5232  void DetachGlobal();
5233 
5252  static Local<Context> New(
5253  Isolate* isolate,
5254  ExtensionConfiguration* extensions = NULL,
5255  Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
5256  Handle<Value> global_object = Handle<Value>());
5257 
5262  void SetSecurityToken(Handle<Value> token);
5263 
5265  void UseDefaultSecurityToken();
5266 
5268  Handle<Value> GetSecurityToken();
5269 
5276  void Enter();
5277 
5282  void Exit();
5283 
5285  v8::Isolate* GetIsolate();
5286 
5292  V8_INLINE Local<Value> GetEmbedderData(int index);
5293 
5299  void SetEmbedderData(int index, Handle<Value> value);
5300 
5307  V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
5308 
5314  void SetAlignedPointerInEmbedderData(int index, void* value);
5315 
5329  void AllowCodeGenerationFromStrings(bool allow);
5330 
5335  bool IsCodeGenerationFromStringsAllowed();
5336 
5342  void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
5343 
5348  class Scope {
5349  public:
5350  explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
5351  context_->Enter();
5352  }
5353  V8_INLINE ~Scope() { context_->Exit(); }
5354 
5355  private:
5356  Handle<Context> context_;
5357  };
5358 
5359  private:
5360  friend class Value;
5361  friend class Script;
5362  friend class Object;
5363  friend class Function;
5364 
5365  Local<Value> SlowGetEmbedderData(int index);
5366  void* SlowGetAlignedPointerFromEmbedderData(int index);
5367 };
5368 
5369 
5447  public:
5451  V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
5452 
5453  ~Unlocker();
5454  private:
5455  void Initialize(Isolate* isolate);
5456 
5457  internal::Isolate* isolate_;
5458 };
5459 
5460 
5462  public:
5466  V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
5467 
5468  ~Locker();
5469 
5474  static bool IsLocked(Isolate* isolate);
5475 
5479  static bool IsActive();
5480 
5481  private:
5482  void Initialize(Isolate* isolate);
5483 
5484  bool has_lock_;
5485  bool top_level_;
5486  internal::Isolate* isolate_;
5487 
5488  static bool active_;
5489 
5490  // Disallow copying and assigning.
5491  Locker(const Locker&);
5492  void operator=(const Locker&);
5493 };
5494 
5495 
5496 // --- Implementation ---
5497 
5498 
5499 namespace internal {
5500 
5501 const int kApiPointerSize = sizeof(void*); // NOLINT
5502 const int kApiIntSize = sizeof(int); // NOLINT
5503 const int kApiInt64Size = sizeof(int64_t); // NOLINT
5504 
5505 // Tag information for HeapObject.
5506 const int kHeapObjectTag = 1;
5507 const int kHeapObjectTagSize = 2;
5508 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
5509 
5510 // Tag information for Smi.
5511 const int kSmiTag = 0;
5512 const int kSmiTagSize = 1;
5513 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
5514 
5515 template <size_t ptr_size> struct SmiTagging;
5516 
5517 template<int kSmiShiftSize>
5518 V8_INLINE internal::Object* IntToSmi(int value) {
5519  int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
5520  intptr_t tagged_value =
5521  (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag;
5522  return reinterpret_cast<internal::Object*>(tagged_value);
5523 }
5524 
5525 // Smi constants for 32-bit systems.
5526 template <> struct SmiTagging<4> {
5527  static const int kSmiShiftSize = 0;
5528  static const int kSmiValueSize = 31;
5529  V8_INLINE static int SmiToInt(const internal::Object* value) {
5530  int shift_bits = kSmiTagSize + kSmiShiftSize;
5531  // Throw away top 32 bits and shift down (requires >> to be sign extending).
5532  return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
5533  }
5534  V8_INLINE static internal::Object* IntToSmi(int value) {
5535  return internal::IntToSmi<kSmiShiftSize>(value);
5536  }
5537  V8_INLINE static bool IsValidSmi(intptr_t value) {
5538  // To be representable as an tagged small integer, the two
5539  // most-significant bits of 'value' must be either 00 or 11 due to
5540  // sign-extension. To check this we add 01 to the two
5541  // most-significant bits, and check if the most-significant bit is 0
5542  //
5543  // CAUTION: The original code below:
5544  // bool result = ((value + 0x40000000) & 0x80000000) == 0;
5545  // may lead to incorrect results according to the C language spec, and
5546  // in fact doesn't work correctly with gcc4.1.1 in some cases: The
5547  // compiler may produce undefined results in case of signed integer
5548  // overflow. The computation must be done w/ unsigned ints.
5549  return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
5550  }
5551 };
5552 
5553 // Smi constants for 64-bit systems.
5554 template <> struct SmiTagging<8> {
5555  static const int kSmiShiftSize = 31;
5556  static const int kSmiValueSize = 32;
5557  V8_INLINE static int SmiToInt(const internal::Object* value) {
5558  int shift_bits = kSmiTagSize + kSmiShiftSize;
5559  // Shift down and throw away top 32 bits.
5560  return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
5561  }
5562  V8_INLINE static internal::Object* IntToSmi(int value) {
5563  return internal::IntToSmi<kSmiShiftSize>(value);
5564  }
5565  V8_INLINE static bool IsValidSmi(intptr_t value) {
5566  // To be representable as a long smi, the value must be a 32-bit integer.
5567  return (value == static_cast<int32_t>(value));
5568  }
5569 };
5570 
5574 V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
5575 V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
5576 
5582 class Internals {
5583  public:
5584  // These values match non-compiler-dependent values defined within
5585  // the implementation of v8.
5586  static const int kHeapObjectMapOffset = 0;
5589  static const int kStringResourceOffset = 3 * kApiPointerSize;
5590 
5591  static const int kOddballKindOffset = 3 * kApiPointerSize;
5593  static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
5594  static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
5595  static const int kContextHeaderSize = 2 * kApiPointerSize;
5596  static const int kContextEmbedderDataIndex = 95;
5597  static const int kFullStringRepresentationMask = 0x07;
5598  static const int kStringEncodingMask = 0x4;
5599  static const int kExternalTwoByteRepresentationTag = 0x02;
5600  static const int kExternalAsciiRepresentationTag = 0x06;
5601 
5604  4 * kApiPointerSize;
5607  static const int kIsolateRootsOffset =
5610  static const int kUndefinedValueRootIndex = 5;
5611  static const int kNullValueRootIndex = 7;
5612  static const int kTrueValueRootIndex = 8;
5613  static const int kFalseValueRootIndex = 9;
5614  static const int kEmptyStringRootIndex = 164;
5615 
5616  // The external allocation limit should be below 256 MB on all architectures
5617  // to avoid that resource-constrained embedders run low on memory.
5618  static const int kExternalAllocationLimit = 192 * 1024 * 1024;
5619 
5620  static const int kNodeClassIdOffset = 1 * kApiPointerSize;
5621  static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
5622  static const int kNodeStateMask = 0xf;
5623  static const int kNodeStateIsWeakValue = 2;
5624  static const int kNodeStateIsPendingValue = 3;
5625  static const int kNodeStateIsNearDeathValue = 4;
5626  static const int kNodeIsIndependentShift = 4;
5627  static const int kNodeIsPartiallyDependentShift = 5;
5628 
5629  static const int kJSObjectType = 0xbc;
5630  static const int kFirstNonstringType = 0x80;
5631  static const int kOddballType = 0x83;
5632  static const int kForeignType = 0x88;
5633 
5634  static const int kUndefinedOddballKind = 5;
5635  static const int kNullOddballKind = 3;
5636 
5637  static const uint32_t kNumIsolateDataSlots = 4;
5638 
5639  V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
5640  V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
5641 #ifdef V8_ENABLE_CHECKS
5642  CheckInitializedImpl(isolate);
5643 #endif
5644  }
5645 
5646  V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
5647  return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
5648  kHeapObjectTag);
5649  }
5650 
5651  V8_INLINE static int SmiValue(const internal::Object* value) {
5652  return PlatformSmiTagging::SmiToInt(value);
5653  }
5654 
5655  V8_INLINE static internal::Object* IntToSmi(int value) {
5656  return PlatformSmiTagging::IntToSmi(value);
5657  }
5658 
5659  V8_INLINE static bool IsValidSmi(intptr_t value) {
5660  return PlatformSmiTagging::IsValidSmi(value);
5661  }
5662 
5663  V8_INLINE static int GetInstanceType(const internal::Object* obj) {
5664  typedef internal::Object O;
5665  O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
5666  // Map::InstanceType is defined so that it will always be loaded into
5667  // the LS 8 bits of one 16-bit word, regardless of endianess.
5668  return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
5669  }
5670 
5671  V8_INLINE static int GetOddballKind(const internal::Object* obj) {
5672  typedef internal::Object O;
5673  return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
5674  }
5675 
5676  V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
5677  int representation = (instance_type & kFullStringRepresentationMask);
5678  return representation == kExternalTwoByteRepresentationTag;
5679  }
5680 
5681  V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
5682  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5683  return *addr & static_cast<uint8_t>(1U << shift);
5684  }
5685 
5686  V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
5687  bool value, int shift) {
5688  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5689  uint8_t mask = static_cast<uint8_t>(1 << shift);
5690  *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
5691  }
5692 
5693  V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
5694  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5695  return *addr & kNodeStateMask;
5696  }
5697 
5698  V8_INLINE static void UpdateNodeState(internal::Object** obj,
5699  uint8_t value) {
5700  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5701  *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
5702  }
5703 
5704  V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
5705  uint32_t slot,
5706  void* data) {
5707  uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
5709  *reinterpret_cast<void**>(addr) = data;
5710  }
5711 
5712  V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
5713  uint32_t slot) {
5714  const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
5716  return *reinterpret_cast<void* const*>(addr);
5717  }
5718 
5719  V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
5720  int index) {
5721  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
5722  return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
5723  }
5724 
5725  template <typename T>
5726  V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
5727  const uint8_t* addr =
5728  reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
5729  return *reinterpret_cast<const T*>(addr);
5730  }
5731 
5732  template <typename T>
5733  V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
5734  typedef internal::Object O;
5735  typedef internal::Internals I;
5736  O* ctx = *reinterpret_cast<O* const*>(context);
5737  int embedder_data_offset = I::kContextHeaderSize +
5738  (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
5739  O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
5740  int value_offset =
5741  I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
5742  return I::ReadField<T>(embedder_data, value_offset);
5743  }
5744 };
5745 
5746 } // namespace internal
5747 
5748 
5749 template <class T>
5751 
5752 
5753 template <class T>
5755  return New(isolate, that.val_);
5756 }
5757 
5758 template <class T>
5760  return New(isolate, that.val_);
5761 }
5762 
5763 template <class T>
5764 Handle<T> Handle<T>::New(Isolate* isolate, T* that) {
5765  if (that == NULL) return Handle<T>();
5766  T* that_ptr = that;
5767  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
5768  return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
5769  reinterpret_cast<internal::Isolate*>(isolate), *p)));
5770 }
5771 
5772 
5773 template <class T>
5774 Local<T> Local<T>::New(Isolate* isolate, T* that) {
5775  if (that == NULL) return Local<T>();
5776  T* that_ptr = that;
5777  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
5778  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
5779  reinterpret_cast<internal::Isolate*>(isolate), *p)));
5780 }
5781 
5782 
5783 template<class T>
5784 template<class S>
5785 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
5786  TYPE_CHECK(T, S);
5787  V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
5788 }
5789 
5790 
5791 template<class T>
5793  return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
5794 }
5795 
5796 
5797 template <class T>
5798 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
5799  if (that == NULL) return NULL;
5800  internal::Object** p = reinterpret_cast<internal::Object**>(that);
5801  return reinterpret_cast<T*>(
5802  V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
5803  p));
5804 }
5805 
5806 
5807 template <class T, class M>
5808 template <class S, class M2>
5810  TYPE_CHECK(T, S);
5811  this->Reset();
5812  if (that.IsEmpty()) return;
5813  internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
5814  this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
5815  M::Copy(that, this);
5816 }
5817 
5818 
5819 template <class T>
5821  typedef internal::Internals I;
5822  if (this->IsEmpty()) return false;
5823  return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5824  I::kNodeIsIndependentShift);
5825 }
5826 
5827 
5828 template <class T>
5830  typedef internal::Internals I;
5831  if (this->IsEmpty()) return false;
5832  uint8_t node_state =
5833  I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
5834  return node_state == I::kNodeStateIsNearDeathValue ||
5835  node_state == I::kNodeStateIsPendingValue;
5836 }
5837 
5838 
5839 template <class T>
5841  typedef internal::Internals I;
5842  if (this->IsEmpty()) return false;
5843  return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
5844  I::kNodeStateIsWeakValue;
5845 }
5846 
5847 
5848 template <class T>
5850  if (this->IsEmpty()) return;
5851  V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
5852  val_ = 0;
5853 }
5854 
5855 
5856 template <class T>
5857 template <class S>
5858 void PersistentBase<T>::Reset(Isolate* isolate, const Handle<S>& other) {
5859  TYPE_CHECK(T, S);
5860  Reset();
5861  if (other.IsEmpty()) return;
5862  this->val_ = New(isolate, other.val_);
5863 }
5864 
5865 
5866 template <class T>
5867 template <class S>
5869  const PersistentBase<S>& other) {
5870  TYPE_CHECK(T, S);
5871  Reset();
5872  if (other.IsEmpty()) return;
5873  this->val_ = New(isolate, other.val_);
5874 }
5875 
5876 
5877 template <class T>
5878 template <typename S, typename P>
5880  P* parameter,
5881  typename WeakCallbackData<S, P>::Callback callback) {
5882  TYPE_CHECK(S, T);
5883  typedef typename WeakCallbackData<Value, void>::Callback Callback;
5884  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
5885  parameter,
5886  reinterpret_cast<Callback>(callback));
5887 }
5888 
5889 
5890 template <class T>
5891 template <typename P>
5893  P* parameter,
5894  typename WeakCallbackData<T, P>::Callback callback) {
5895  SetWeak<T, P>(parameter, callback);
5896 }
5897 
5898 
5899 template <class T>
5900 template<typename P>
5902  return reinterpret_cast<P*>(
5903  V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
5904 }
5905 
5906 
5907 template <class T>
5909  typedef internal::Internals I;
5910  if (this->IsEmpty()) return;
5911  I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5912  true,
5913  I::kNodeIsIndependentShift);
5914 }
5915 
5916 
5917 template <class T>
5919  typedef internal::Internals I;
5920  if (this->IsEmpty()) return;
5921  I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5922  true,
5923  I::kNodeIsPartiallyDependentShift);
5924 }
5925 
5926 
5927 template <class T, class M>
5929  T* old;
5930  old = this->val_;
5931  this->val_ = NULL;
5932  return old;
5933 }
5934 
5935 
5936 template <class T>
5937 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
5938  typedef internal::Internals I;
5939  if (this->IsEmpty()) return;
5940  internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
5941  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
5942  *reinterpret_cast<uint16_t*>(addr) = class_id;
5943 }
5944 
5945 
5946 template <class T>
5948  typedef internal::Internals I;
5949  if (this->IsEmpty()) return 0;
5950  internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
5951  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
5952  return *reinterpret_cast<uint16_t*>(addr);
5953 }
5954 
5955 
5956 template<typename T>
5957 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
5958 
5959 template<typename T>
5960 template<typename S>
5961 void ReturnValue<T>::Set(const Persistent<S>& handle) {
5962  TYPE_CHECK(T, S);
5963  if (V8_UNLIKELY(handle.IsEmpty())) {
5964  *value_ = GetDefaultValue();
5965  } else {
5966  *value_ = *reinterpret_cast<internal::Object**>(*handle);
5967  }
5968 }
5969 
5970 template<typename T>
5971 template<typename S>
5972 void ReturnValue<T>::Set(const Handle<S> handle) {
5973  TYPE_CHECK(T, S);
5974  if (V8_UNLIKELY(handle.IsEmpty())) {
5975  *value_ = GetDefaultValue();
5976  } else {
5977  *value_ = *reinterpret_cast<internal::Object**>(*handle);
5978  }
5979 }
5980 
5981 template<typename T>
5982 void ReturnValue<T>::Set(double i) {
5983  TYPE_CHECK(T, Number);
5984  Set(Number::New(GetIsolate(), i));
5985 }
5986 
5987 template<typename T>
5988 void ReturnValue<T>::Set(int32_t i) {
5989  TYPE_CHECK(T, Integer);
5990  typedef internal::Internals I;
5991  if (V8_LIKELY(I::IsValidSmi(i))) {
5992  *value_ = I::IntToSmi(i);
5993  return;
5994  }
5995  Set(Integer::New(GetIsolate(), i));
5996 }
5997 
5998 template<typename T>
5999 void ReturnValue<T>::Set(uint32_t i) {
6000  TYPE_CHECK(T, Integer);
6001  // Can't simply use INT32_MAX here for whatever reason.
6002  bool fits_into_int32_t = (i & (1U << 31)) == 0;
6003  if (V8_LIKELY(fits_into_int32_t)) {
6004  Set(static_cast<int32_t>(i));
6005  return;
6006  }
6007  Set(Integer::NewFromUnsigned(GetIsolate(), i));
6008 }
6009 
6010 template<typename T>
6011 void ReturnValue<T>::Set(bool value) {
6012  TYPE_CHECK(T, Boolean);
6013  typedef internal::Internals I;
6014  int root_index;
6015  if (value) {
6016  root_index = I::kTrueValueRootIndex;
6017  } else {
6018  root_index = I::kFalseValueRootIndex;
6019  }
6020  *value_ = *I::GetRoot(GetIsolate(), root_index);
6021 }
6022 
6023 template<typename T>
6025  TYPE_CHECK(T, Primitive);
6026  typedef internal::Internals I;
6027  *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
6028 }
6029 
6030 template<typename T>
6032  TYPE_CHECK(T, Primitive);
6033  typedef internal::Internals I;
6034  *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
6035 }
6036 
6037 template<typename T>
6039  TYPE_CHECK(T, String);
6040  typedef internal::Internals I;
6041  *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
6042 }
6043 
6044 template<typename T>
6046  // Isolate is always the pointer below the default value on the stack.
6047  return *reinterpret_cast<Isolate**>(&value_[-2]);
6048 }
6049 
6050 template<typename T>
6051 template<typename S>
6052 void ReturnValue<T>::Set(S* whatever) {
6053  // Uncompilable to prevent inadvertent misuse.
6054  TYPE_CHECK(S*, Primitive);
6055 }
6056 
6057 template<typename T>
6058 internal::Object* ReturnValue<T>::GetDefaultValue() {
6059  // Default value is always the pointer below value_ on the stack.
6060  return value_[-1];
6061 }
6062 
6063 
6064 template<typename T>
6065 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
6066  internal::Object** values,
6067  int length,
6068  bool is_construct_call)
6069  : implicit_args_(implicit_args),
6070  values_(values),
6071  length_(length),
6072  is_construct_call_(is_construct_call) { }
6073 
6074 
6075 template<typename T>
6077  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
6078  return Local<Value>(reinterpret_cast<Value*>(values_ - i));
6079 }
6080 
6081 
6082 template<typename T>
6084  return Local<Function>(reinterpret_cast<Function*>(
6085  &implicit_args_[kCalleeIndex]));
6086 }
6087 
6088 
6089 template<typename T>
6091  return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
6092 }
6093 
6094 
6095 template<typename T>
6097  return Local<Object>(reinterpret_cast<Object*>(
6098  &implicit_args_[kHolderIndex]));
6099 }
6100 
6101 
6102 template<typename T>
6104  return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
6105 }
6106 
6107 
6108 template<typename T>
6110  return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
6111 }
6112 
6113 
6114 template<typename T>
6116  return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
6117 }
6118 
6119 
6120 template<typename T>
6122  return is_construct_call_;
6123 }
6124 
6125 
6126 template<typename T>
6128  return length_;
6129 }
6130 
6131 
6133  return resource_name_;
6134 }
6135 
6136 
6138  return resource_line_offset_;
6139 }
6140 
6141 
6143  return resource_column_offset_;
6144 }
6145 
6146 
6148  return resource_is_shared_cross_origin_;
6149 }
6150 
6151 
6153  return script_id_;
6154 }
6155 
6156 
6158  CachedData* data)
6159  : source_string(string),
6160  resource_name(origin.ResourceName()),
6161  resource_line_offset(origin.ResourceLineOffset()),
6162  resource_column_offset(origin.ResourceColumnOffset()),
6163  resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()),
6164  cached_data(data) {}
6165 
6166 
6168  CachedData* data)
6169  : source_string(string), cached_data(data) {}
6170 
6171 
6173  delete cached_data;
6174 }
6175 
6176 
6178  const {
6179  return cached_data;
6180 }
6181 
6182 
6183 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) {
6184  return value ? True(isolate) : False(isolate);
6185 }
6186 
6187 
6188 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) {
6189  Set(v8::String::NewFromUtf8(isolate, name), value);
6190 }
6191 
6192 
6194 #ifndef V8_ENABLE_CHECKS
6195  typedef internal::Object O;
6196  typedef internal::HeapObject HO;
6197  typedef internal::Internals I;
6198  O* obj = *reinterpret_cast<O**>(this);
6199  // Fast path: If the object is a plain JSObject, which is the common case, we
6200  // know where to find the internal fields and can return the value directly.
6201  if (I::GetInstanceType(obj) == I::kJSObjectType) {
6202  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
6203  O* value = I::ReadField<O*>(obj, offset);
6204  O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
6205  return Local<Value>(reinterpret_cast<Value*>(result));
6206  }
6207 #endif
6208  return SlowGetInternalField(index);
6209 }
6210 
6211 
6213 #ifndef V8_ENABLE_CHECKS
6214  typedef internal::Object O;
6215  typedef internal::Internals I;
6216  O* obj = *reinterpret_cast<O**>(this);
6217  // Fast path: If the object is a plain JSObject, which is the common case, we
6218  // know where to find the internal fields and can return the value directly.
6219  if (V8_LIKELY(I::GetInstanceType(obj) == I::kJSObjectType)) {
6220  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
6221  return I::ReadField<void*>(obj, offset);
6222  }
6223 #endif
6224  return SlowGetAlignedPointerFromInternalField(index);
6225 }
6226 
6227 
6229 #ifdef V8_ENABLE_CHECKS
6230  CheckCast(value);
6231 #endif
6232  return static_cast<String*>(value);
6233 }
6234 
6235 
6237  typedef internal::Object* S;
6238  typedef internal::Internals I;
6239  I::CheckInitialized(isolate);
6240  S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
6241  return Local<String>(reinterpret_cast<String*>(slot));
6242 }
6243 
6244 
6246  typedef internal::Object O;
6247  typedef internal::Internals I;
6248  O* obj = *reinterpret_cast<O* const*>(this);
6250  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
6251  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
6252  result = reinterpret_cast<String::ExternalStringResource*>(value);
6253  } else {
6254  result = NULL;
6255  }
6256 #ifdef V8_ENABLE_CHECKS
6257  VerifyExternalStringResource(result);
6258 #endif
6259  return result;
6260 }
6261 
6262 
6264  String::Encoding* encoding_out) const {
6265  typedef internal::Object O;
6266  typedef internal::Internals I;
6267  O* obj = *reinterpret_cast<O* const*>(this);
6268  int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
6269  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
6270  ExternalStringResourceBase* resource = NULL;
6271  if (type == I::kExternalAsciiRepresentationTag ||
6272  type == I::kExternalTwoByteRepresentationTag) {
6273  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
6274  resource = static_cast<ExternalStringResourceBase*>(value);
6275  }
6276 #ifdef V8_ENABLE_CHECKS
6277  VerifyExternalStringResourceBase(resource, *encoding_out);
6278 #endif
6279  return resource;
6280 }
6281 
6282 
6283 bool Value::IsUndefined() const {
6284 #ifdef V8_ENABLE_CHECKS
6285  return FullIsUndefined();
6286 #else
6287  return QuickIsUndefined();
6288 #endif
6289 }
6290 
6291 bool Value::QuickIsUndefined() const {
6292  typedef internal::Object O;
6293  typedef internal::Internals I;
6294  O* obj = *reinterpret_cast<O* const*>(this);
6295  if (!I::HasHeapObjectTag(obj)) return false;
6296  if (I::GetInstanceType(obj) != I::kOddballType) return false;
6297  return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
6298 }
6299 
6300 
6301 bool Value::IsNull() const {
6302 #ifdef V8_ENABLE_CHECKS
6303  return FullIsNull();
6304 #else
6305  return QuickIsNull();
6306 #endif
6307 }
6308 
6309 bool Value::QuickIsNull() const {
6310  typedef internal::Object O;
6311  typedef internal::Internals I;
6312  O* obj = *reinterpret_cast<O* const*>(this);
6313  if (!I::HasHeapObjectTag(obj)) return false;
6314  if (I::GetInstanceType(obj) != I::kOddballType) return false;
6315  return (I::GetOddballKind(obj) == I::kNullOddballKind);
6316 }
6317 
6318 
6319 bool Value::IsString() const {
6320 #ifdef V8_ENABLE_CHECKS
6321  return FullIsString();
6322 #else
6323  return QuickIsString();
6324 #endif
6325 }
6326 
6327 bool Value::QuickIsString() const {
6328  typedef internal::Object O;
6329  typedef internal::Internals I;
6330  O* obj = *reinterpret_cast<O* const*>(this);
6331  if (!I::HasHeapObjectTag(obj)) return false;
6332  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
6333 }
6334 
6335 
6336 template <class T> Value* Value::Cast(T* value) {
6337  return static_cast<Value*>(value);
6338 }
6339 
6340 
6342 #ifdef V8_ENABLE_CHECKS
6343  CheckCast(value);
6344 #endif
6345  return static_cast<Symbol*>(value);
6346 }
6347 
6348 
6350 #ifdef V8_ENABLE_CHECKS
6351  CheckCast(value);
6352 #endif
6353  return static_cast<Number*>(value);
6354 }
6355 
6356 
6358 #ifdef V8_ENABLE_CHECKS
6359  CheckCast(value);
6360 #endif
6361  return static_cast<Integer*>(value);
6362 }
6363 
6364 
6366 #ifdef V8_ENABLE_CHECKS
6367  CheckCast(value);
6368 #endif
6369  return static_cast<Date*>(value);
6370 }
6371 
6372 
6374 #ifdef V8_ENABLE_CHECKS
6375  CheckCast(value);
6376 #endif
6377  return static_cast<StringObject*>(value);
6378 }
6379 
6380 
6382 #ifdef V8_ENABLE_CHECKS
6383  CheckCast(value);
6384 #endif
6385  return static_cast<SymbolObject*>(value);
6386 }
6387 
6388 
6390 #ifdef V8_ENABLE_CHECKS
6391  CheckCast(value);
6392 #endif
6393  return static_cast<NumberObject*>(value);
6394 }
6395 
6396 
6398 #ifdef V8_ENABLE_CHECKS
6399  CheckCast(value);
6400 #endif
6401  return static_cast<BooleanObject*>(value);
6402 }
6403 
6404 
6406 #ifdef V8_ENABLE_CHECKS
6407  CheckCast(value);
6408 #endif
6409  return static_cast<RegExp*>(value);
6410 }
6411 
6412 
6414 #ifdef V8_ENABLE_CHECKS
6415  CheckCast(value);
6416 #endif
6417  return static_cast<Object*>(value);
6418 }
6419 
6420 
6422 #ifdef V8_ENABLE_CHECKS
6423  CheckCast(value);
6424 #endif
6425  return static_cast<Array*>(value);
6426 }
6427 
6428 
6430 #ifdef V8_ENABLE_CHECKS
6431  CheckCast(value);
6432 #endif
6433  return static_cast<Promise*>(value);
6434 }
6435 
6436 
6438 #ifdef V8_ENABLE_CHECKS
6439  CheckCast(value);
6440 #endif
6441  return static_cast<Promise::Resolver*>(value);
6442 }
6443 
6444 
6446 #ifdef V8_ENABLE_CHECKS
6447  CheckCast(value);
6448 #endif
6449  return static_cast<ArrayBuffer*>(value);
6450 }
6451 
6452 
6454 #ifdef V8_ENABLE_CHECKS
6455  CheckCast(value);
6456 #endif
6457  return static_cast<ArrayBufferView*>(value);
6458 }
6459 
6460 
6462 #ifdef V8_ENABLE_CHECKS
6463  CheckCast(value);
6464 #endif
6465  return static_cast<TypedArray*>(value);
6466 }
6467 
6468 
6470 #ifdef V8_ENABLE_CHECKS
6471  CheckCast(value);
6472 #endif
6473  return static_cast<Uint8Array*>(value);
6474 }
6475 
6476 
6478 #ifdef V8_ENABLE_CHECKS
6479  CheckCast(value);
6480 #endif
6481  return static_cast<Int8Array*>(value);
6482 }
6483 
6484 
6486 #ifdef V8_ENABLE_CHECKS
6487  CheckCast(value);
6488 #endif
6489  return static_cast<Uint16Array*>(value);
6490 }
6491 
6492 
6494 #ifdef V8_ENABLE_CHECKS
6495  CheckCast(value);
6496 #endif
6497  return static_cast<Int16Array*>(value);
6498 }
6499 
6500 
6502 #ifdef V8_ENABLE_CHECKS
6503  CheckCast(value);
6504 #endif
6505  return static_cast<Uint32Array*>(value);
6506 }
6507 
6508 
6510 #ifdef V8_ENABLE_CHECKS
6511  CheckCast(value);
6512 #endif
6513  return static_cast<Int32Array*>(value);
6514 }
6515 
6516 
6518 #ifdef V8_ENABLE_CHECKS
6519  CheckCast(value);
6520 #endif
6521  return static_cast<Float32Array*>(value);
6522 }
6523 
6524 
6526 #ifdef V8_ENABLE_CHECKS
6527  CheckCast(value);
6528 #endif
6529  return static_cast<Float64Array*>(value);
6530 }
6531 
6532 
6534 #ifdef V8_ENABLE_CHECKS
6535  CheckCast(value);
6536 #endif
6537  return static_cast<Uint8ClampedArray*>(value);
6538 }
6539 
6540 
6542 #ifdef V8_ENABLE_CHECKS
6543  CheckCast(value);
6544 #endif
6545  return static_cast<DataView*>(value);
6546 }
6547 
6548 
6550 #ifdef V8_ENABLE_CHECKS
6551  CheckCast(value);
6552 #endif
6553  return static_cast<Function*>(value);
6554 }
6555 
6556 
6558 #ifdef V8_ENABLE_CHECKS
6559  CheckCast(value);
6560 #endif
6561  return static_cast<External*>(value);
6562 }
6563 
6564 
6565 template<typename T>
6567  return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
6568 }
6569 
6570 
6571 template<typename T>
6573  return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
6574 }
6575 
6576 
6577 template<typename T>
6579  return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
6580 }
6581 
6582 
6583 template<typename T>
6585  return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
6586 }
6587 
6588 
6589 template<typename T>
6591  return ReturnValue<T>(&args_[kReturnValueIndex]);
6592 }
6593 
6594 
6596  typedef internal::Object* S;
6597  typedef internal::Internals I;
6598  I::CheckInitialized(isolate);
6599  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
6600  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
6601 }
6602 
6603 
6605  typedef internal::Object* S;
6606  typedef internal::Internals I;
6607  I::CheckInitialized(isolate);
6608  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
6609  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
6610 }
6611 
6612 
6614  typedef internal::Object* S;
6615  typedef internal::Internals I;
6616  I::CheckInitialized(isolate);
6617  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
6618  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
6619 }
6620 
6621 
6623  typedef internal::Object* S;
6624  typedef internal::Internals I;
6625  I::CheckInitialized(isolate);
6626  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
6627  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
6628 }
6629 
6630 
6631 void Isolate::SetData(uint32_t slot, void* data) {
6632  typedef internal::Internals I;
6633  I::SetEmbedderData(this, slot, data);
6634 }
6635 
6636 
6637 void* Isolate::GetData(uint32_t slot) {
6638  typedef internal::Internals I;
6639  return I::GetEmbedderData(this, slot);
6640 }
6641 
6642 
6644  typedef internal::Internals I;
6645  return I::kNumIsolateDataSlots;
6646 }
6647 
6648 
6650  int64_t change_in_bytes) {
6651  typedef internal::Internals I;
6652  int64_t* amount_of_external_allocated_memory =
6653  reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
6654  I::kAmountOfExternalAllocatedMemoryOffset);
6655  int64_t* amount_of_external_allocated_memory_at_last_global_gc =
6656  reinterpret_cast<int64_t*>(
6657  reinterpret_cast<uint8_t*>(this) +
6658  I::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset);
6659  int64_t amount = *amount_of_external_allocated_memory + change_in_bytes;
6660  if (change_in_bytes > 0 &&
6661  amount - *amount_of_external_allocated_memory_at_last_global_gc >
6662  I::kExternalAllocationLimit) {
6663  CollectAllGarbage("external memory allocation limit reached.");
6664  } else {
6665  *amount_of_external_allocated_memory = amount;
6666  }
6667  return *amount_of_external_allocated_memory;
6668 }
6669 
6670 
6671 template<typename T>
6673  UniqueId id) {
6674  TYPE_CHECK(Value, T);
6675  SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id);
6676 }
6677 
6678 
6679 template<typename T>
6681  const Persistent<T>& object) {
6682  TYPE_CHECK(Value, T);
6683  SetReferenceFromGroup(id,
6684  reinterpret_cast<v8::internal::Object**>(object.val_));
6685 }
6686 
6687 
6688 template<typename T, typename S>
6690  const Persistent<S>& child) {
6691  TYPE_CHECK(Object, T);
6692  TYPE_CHECK(Value, S);
6693  SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_),
6694  reinterpret_cast<v8::internal::Object**>(child.val_));
6695 }
6696 
6697 
6699 #ifndef V8_ENABLE_CHECKS
6700  typedef internal::Object O;
6701  typedef internal::HeapObject HO;
6702  typedef internal::Internals I;
6703  HO* context = *reinterpret_cast<HO**>(this);
6704  O** result =
6705  HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
6706  return Local<Value>(reinterpret_cast<Value*>(result));
6707 #else
6708  return SlowGetEmbedderData(index);
6709 #endif
6710 }
6711 
6712 
6714 #ifndef V8_ENABLE_CHECKS
6715  typedef internal::Internals I;
6716  return I::ReadEmbedderData<void*>(this, index);
6717 #else
6718  return SlowGetAlignedPointerFromEmbedderData(index);
6719 #endif
6720 }
6721 
6722 
6735 } // namespace v8
6736 
6737 
6738 #undef TYPE_CHECK
6739 
6740 
6741 #endif // V8_H_
static internal::Object ** CreateHandle(internal::Isolate *isolate, internal::Object *value)
static const int kAmountOfExternalAllocatedMemoryOffset
Definition: v8.h:5603
V8_INLINE Local< Value > GetEmbedderData(int index)
Definition: v8.h:6698
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
Definition: v8.h:5754
void(* MemoryAllocationCallback)(ObjectSpace space, AllocationAction action, int size)
Definition: v8.h:3982
GarbageCollectionType
Definition: v8.h:4155
static V8_INLINE Object * Cast(Value *obj)
Definition: v8.h:6413
static V8_INLINE Persistent< T > & Cast(Persistent< S > &that)
Definition: v8.h:683
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:3928
static V8_INLINE Uint8ClampedArray * Cast(Value *obj)
Definition: v8.h:6533
Persistent< T, CopyablePersistentTraits< T > > CopyablePersistent
Definition: v8.h:607
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:5937
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:5947
const intptr_t kSmiTagMask
Definition: v8.h:5513
static V8_INLINE void Uncompilable()
Definition: v8.h:595
static const int kExternalAsciiRepresentationTag
Definition: v8.h:5600
static V8_INLINE T ReadField(const internal::Object *ptr, int offset)
Definition: v8.h:5726
const char * data
Definition: v8.h:4514
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Definition: v8.h:4003
static V8_INLINE Int8Array * Cast(Value *obj)
Definition: v8.h:6477
Definition: v8.h:1326
static V8_INLINE Date * Cast(v8::Value *obj)
Definition: v8.h:6365
static V8_INLINE T ReadEmbedderData(const v8::Context *context, int index)
Definition: v8.h:5733
V8_INLINE Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8.h:668
static V8_INLINE ArrayBufferView * Cast(Value *obj)
Definition: v8.h:6453
V8_INLINE Eternal(Isolate *isolate, Local< S > handle)
Definition: v8.h:400
friend class ReturnValue
Definition: v8.h:2453
V8_INLINE void SetUndefined()
Definition: v8.h:6031
static V8_INLINE Float32Array * Cast(Value *obj)
Definition: v8.h:6517
T value
Definition: v8.h:894
V8_INLINE HandleScope()
Definition: v8.h:816
Definition: v8.h:4693
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
Definition: v8.h:2664
V8_INLINE UniquePersistent(RValue rvalue)
Definition: v8.h:755
Definition: v8.h:1345
void * user_data
Definition: v8.h:4620
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:6212
virtual ~PersistentHandleVisitor()
Definition: v8.h:4684
V8_INLINE bool operator!=(const Persistent< S > &that) const
Definition: v8.h:270
static V8_INLINE Uint32Array * Cast(Value *obj)
Definition: v8.h:6501
static const int kOddballKindOffset
Definition: v8.h:5591
friend class internal::PropertyCallbackArguments
Definition: v8.h:2524
static V8_INLINE int SmiToInt(const internal::Object *value)
Definition: v8.h:5529
void(* InterruptCallback)(Isolate *isolate, void *data)
Definition: v8.h:4030
virtual v8::Handle< v8::FunctionTemplate > GetNativeFunctionTemplate(v8::Isolate *isolate, v8::Handle< v8::String > name)
Definition: v8.h:3822
void SetObjectGroupId(const Persistent< T > &object, UniqueId id)
Definition: v8.h:6672
static V8_INLINE uint8_t GetNodeState(internal::Object **obj)
Definition: v8.h:5693
void(* NamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3278
StackTraceOptions
Definition: v8.h:1217
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:3960
size_t code_range_size() const
Definition: v8.h:3903
int max_old_space_size() const
Definition: v8.h:3891
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:419
V8_INLINE const CachedData * GetCachedData() const
Definition: v8.h:6177
static const int kArgsLength
Definition: v8.h:2483
friend class PersistentBase
Definition: v8.h:563
int max_semi_space_size() const
Definition: v8.h:3889
bool auto_enable()
Definition: v8.h:3834
static const int kFirstNonstringType
Definition: v8.h:5630
static const int kNullValueRootIndex
Definition: v8.h:5611
static const uint32_t kNumIsolateDataSlots
Definition: v8.h:5637
static V8_INLINE int SmiValue(const internal::Object *value)
Definition: v8.h:5651
friend class Utils
Definition: v8.h:702
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:6115
static V8_INLINE bool HasHeapObjectTag(const internal::Object *value)
Definition: v8.h:5646
static V8_INLINE Array * Cast(Value *obj)
Definition: v8.h:6421
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3324
const int kSmiValueSize
Definition: v8.h:5573
static const int kHolderIndex
Definition: v8.h:2488
V8_INLINE Persistent & operator=(const Persistent &that)
Definition: v8.h:663
void * new_code_start
Definition: v8.h:4647
V8_INLINE Local< Function > Callee() const
Definition: v8.h:6083
V8_INLINE void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:6713
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:3315
V8_INLINE Handle()
Definition: v8.h:201
V8_INLINE bool IsString() const
Definition: v8.h:6319
static V8_INLINE void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8.h:5712
size_t used_heap_size()
Definition: v8.h:4045
friend class internal::FunctionCallbackArguments
Definition: v8.h:2486
static V8_INLINE Float64Array * Cast(Value *obj)
Definition: v8.h:6525
static const bool kResetInDestructor
Definition: v8.h:588
const char * name() const
Definition: v8.h:3827
Definition: v8.h:911
V8_INLINE PropertyCallbackInfo(internal::Object **args)
Definition: v8.h:2533
WriteOptions
Definition: v8.h:1656
Encoding
Definition: v8.h:1601
static V8_INLINE internal::Object ** GetRoot(v8::Isolate *isolate, int index)
Definition: v8.h:5719
V8_INLINE P * GetParameter() const
Definition: v8.h:421
V8_INLINE Eternal()
Definition: v8.h:398
static V8_INLINE uint32_t GetNumberOfDataSlots()
Definition: v8.h:6643
friend Handle< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:6595
const char * data() const
Definition: v8.h:3801
V8_INLINE Handle< Integer > ScriptID() const
Definition: v8.h:6152
AllocationAction
Definition: v8.h:3976
V8_INLINE bool IsNearDeath() const
Definition: v8.h:5829
static V8_INLINE int SmiToInt(const internal::Object *value)
Definition: v8.h:5557
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:863
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3286
void(* LogEventCallback)(const char *name, int event)
Definition: v8.h:3935
static const int kLineOffsetNotFound
Definition: v8.h:2604
V8_INLINE void Set(const Persistent< S > &handle)
V8_INLINE ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:6245
V8_INLINE Persistent(const Persistent< S, M2 > &that)
Definition: v8.h:660
CompressionAlgorithm
Definition: v8.h:4509
static V8_INLINE Resolver * Cast(Value *obj)
Definition: v8.h:6437
Persistent< T, NonCopyablePersistentTraits< T > > NonCopyablePersistent
Definition: v8.h:587
V8_INLINE ~Persistent()
Definition: v8.h:677
static const bool kResetInDestructor
Definition: v8.h:608
ExternalArrayType
Definition: v8.h:2051
BufferPolicy buffer_policy
Definition: v8.h:1045
friend class Utils
Definition: v8.h:558
V8_INLINE bool IsUndefined() const
Definition: v8.h:6283
size_t heap_size_limit()
Definition: v8.h:4046
internal::Object ** args_
Definition: v8.h:2534
V8_INLINE ScriptOrigin(Handle< Value > resource_name, Handle< Integer > resource_line_offset=Handle< Integer >(), Handle< Integer > resource_column_offset=Handle< Integer >(), Handle< Boolean > resource_is_shared_cross_origin=Handle< Boolean >(), Handle< Integer > script_id=Handle< Integer >())
Definition: v8.h:922
V8_INLINE Local< Value > GetInternalField(int index)
Definition: v8.h:6193
static V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8.h:5659
V8_INLINE Local< Value > Data() const
Definition: v8.h:6572
internal::Object ** values_
Definition: v8.h:2501
static const int kStringResourceOffset
Definition: v8.h:5589
int max_executable_size() const
Definition: v8.h:3893
V8_INLINE ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:6263
static V8_INLINE void Copy(const Persistent< S, M > &source, CopyablePersistent *dest)
Definition: v8.h:610
UseCounterFeature
Definition: v8.h:4165
static V8_INLINE Handle< T > New(Isolate *isolate, Handle< T > that)
Definition: v8.h:288
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
static const int kJSObjectHeaderSize
Definition: v8.h:5593
V8_INLINE void Set(Isolate *isolate, Local< S > handle)
static V8_INLINE Function * Cast(Value *obj)
Definition: v8.h:6549
V8_INLINE Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:646
static V8_INLINE Symbol * Cast(v8::Value *obj)
Definition: v8.h:6341
V8_INLINE int Length() const
Definition: v8.h:6127
static const int kArgsLength
Definition: v8.h:2520
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
V8_INLINE Local< Object > This() const
Definition: v8.h:6090
const intptr_t kHeapObjectTagMask
Definition: v8.h:5508
int length() const
Definition: v8.h:1893
static const int kNodeStateIsNearDeathValue
Definition: v8.h:5625
V8_INLINE P * ClearWeak()
static V8_INLINE Number * Cast(v8::Value *obj)
Definition: v8.h:6349
V8_INLINE void MarkPartiallyDependent()
Definition: v8.h:5918
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8.h:5196
V8_INLINE ~EscapableHandleScope()
Definition: v8.h:856
static V8_INLINE SymbolObject * Cast(v8::Value *obj)
Definition: v8.h:6381
friend class Utils
Definition: v8.h:297
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:4565
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:6566
size_t total_physical_size()
Definition: v8.h:4044
V8_INLINE Handle< Boolean > ResourceIsSharedCrossOrigin() const
Definition: v8.h:6147
V8_INLINE Handle< Boolean > True(Isolate *isolate)
Definition: v8.h:6613
size_t ByteLength() const
Definition: v8.h:2717
V8_INLINE bool IsEmpty() const
Definition: v8.h:467
static V8_INLINE Int32Array * Cast(Value *obj)
Definition: v8.h:6509
static const int kDataIndex
Definition: v8.h:2492
V8_INLINE ~Source()
Definition: v8.h:6172
static const int kContextEmbedderDataIndex
Definition: v8.h:5596
V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:5518
static const int kNodeFlagsOffset
Definition: v8.h:5621
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:6590
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2079
static const int kFixedArrayHeaderSize
Definition: v8.h:5594
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:2256
V8_INLINE Persistent()
Definition: v8.h:630
Maybe(T t)
Definition: v8.h:890
void set_max_old_space_size(int value)
Definition: v8.h:3892
V8_INLINE ReturnValue(const ReturnValue< S > &that)
Definition: v8.h:2429
static const int kNodeStateIsPendingValue
Definition: v8.h:5624
V8_INLINE void SetNull()
Definition: v8.h:6024
static const int kReturnValueDefaultValueIndex
Definition: v8.h:2490
Definition: v8.h:888
static const int kNodeStateIsWeakValue
Definition: v8.h:5623
V8_INLINE T * operator *() const
Definition: v8.h:235
static V8_INLINE bool IsExternalTwoByteString(int instance_type)
Definition: v8.h:5676
V8_INLINE ~Scope()
Definition: v8.h:5353
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:470
friend Handle< Primitive > Null(Isolate *isolate)
Definition: v8.h:6604
static const int kReturnValueIndex
Definition: v8.h:2529
V8_INLINE Handle< Value > ResourceName() const
Definition: v8.h:6132
Definition: libplatform.h:10
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:3305
void * Data() const
Definition: v8.h:2716
void(* GCEpilogueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:4028
EventType type
Definition: v8.h:4609
friend Handle< Boolean > True(Isolate *isolate)
Definition: v8.h:6613
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:251
V8_INLINE Local< Object > This() const
Definition: v8.h:6578
V8_DEPRECATED("Use GetUnboundScript()->GetId()", int GetId())
Definition: v8.h:1007
int compressed_size
Definition: v8.h:4515
static V8_INLINE void CheckInitialized(v8::Isolate *isolate)
Definition: v8.h:5640
void(* Callback)(const WeakCallbackData< T, P > &data)
Definition: v8.h:417
bool operator<(const UniqueId &other) const
Definition: v8.h:155
static V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8.h:5565
static V8_INLINE Handle< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8.h:291
const int kHeapObjectTag
Definition: v8.h:5506
V8_INLINE ~UniquePersistent()
Definition: v8.h:759
V8_INLINE bool operator!=(const Handle< S > &that) const
Definition: v8.h:266
V8_INLINE UniquePersistent(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:748
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:4549
friend class internal::GlobalHandles
Definition: v8.h:424
bool(* NamedSecurityCallback)(Local< Object > host, Local< Value > key, AccessType type, Local< Value > data)
Definition: v8.h:3344
bool operator!=(const UniqueId &other) const
Definition: v8.h:151
V8_INLINE void SetData(uint32_t slot, void *data)
Definition: v8.h:6631
bool operator==(const UniqueId &other) const
Definition: v8.h:147
V8_INLINE bool operator!=(const Handle< S > &that) const
Definition: v8.h:491
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
V8_INLINE bool IsNull() const
Definition: v8.h:6301
V8_INLINE bool IsEmpty() const
Definition: v8.h:226
static V8_INLINE Handle< T > Cast(Handle< S > that)
Definition: v8.h:275
V8_INLINE UniquePersistent & operator=(UniquePersistent< S > rhs)
Definition: v8.h:764
friend Handle< Boolean > False(Isolate *isolate)
Definition: v8.h:6622
int raw_size
Definition: v8.h:4516
const char ** begin() const
Definition: v8.h:5199
V8_INLINE Unlocker(Isolate *isolate)
Definition: v8.h:5451
internal::Object ** implicit_args_
Definition: v8.h:2500
void set_max_semi_space_size(int value)
Definition: v8.h:3890
struct name_t name
Definition: v8.h:4641
static V8_INLINE RegExp * Cast(v8::Value *obj)
Definition: v8.h:6405
static Local< Number > New(Isolate *isolate, double value)
V8_INLINE Local< Object > Holder() const
Definition: v8.h:6584
void Enter()
static const int kReturnValueDefaultValueIndex
Definition: v8.h:2528
GCType
Definition: v8.h:4014
#define V8_UNLIKELY(condition)
Definition: v8config.h:347
void(* NamedPropertyGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3239
Handle< UnboundScript > script
Definition: v8.h:4615
void set_stack_limit(uint32_t *value)
Definition: v8.h:3897
int length() const
Definition: v8.h:1915
static const int kUndefinedValueRootIndex
Definition: v8.h:5610
AccessType
Definition: v8.h:3331
static V8_INLINE void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8.h:5704
static const int kOddballType
Definition: v8.h:5631
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:4666
static V8_INLINE String * Cast(v8::Value *obj)
Definition: v8.h:6228
const int kApiInt64Size
Definition: v8.h:5503
Definition: v8.h:100
bool(* IndexedSecurityCallback)(Local< Object > host, uint32_t index, AccessType type, Local< Value > data)
Definition: v8.h:3354
static V8_INLINE External * Cast(Value *obj)
Definition: v8.h:6557
V8_INLINE bool IsWeak() const
Definition: v8.h:5840
static V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8.h:5537
static V8_INLINE Integer * Cast(v8::Value *obj)
Definition: v8.h:6357
static const int kFalseValueRootIndex
Definition: v8.h:5613
V8_INLINE Handle< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:6595
static V8_INLINE ArrayBuffer * Cast(Value *obj)
Definition: v8.h:6445
static V8_INLINE Local< T > Cast(Local< S > that)
Definition: v8.h:346
Definition: v8.h:983
struct line_info_t line_info
Definition: v8.h:4644
V8_INLINE Local()
Definition: v8.h:5750
V8_INLINE Local(Local< S > that)
Definition: v8.h:335
Definition: v8.h:2403
void(* FunctionCallback)(const FunctionCallbackInfo< Value > &info)
Definition: v8.h:2538
static V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:5534
static const int kEmptyStringRootIndex
Definition: v8.h:5614
Definition: v8.h:2045
void SetReferenceFromGroup(UniqueId id, const Persistent< T > &child)
Definition: v8.h:6680
V8_INLINE Local< Object > Holder() const
Definition: v8.h:6096
static V8_INLINE int GetOddballKind(const internal::Object *obj)
Definition: v8.h:5671
static V8_INLINE void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8.h:590
int dependency_count()
Definition: v8.h:3831
static const int kNodeIsIndependentShift
Definition: v8.h:5626
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:6109
V8_INLINE bool operator==(const Handle< S > &that) const
Definition: v8.h:478
static const int kIsolateIndex
Definition: v8.h:2489
const int kApiIntSize
Definition: v8.h:5502
V8_INLINE Handle< Boolean > False(Isolate *isolate)
Definition: v8.h:6622
NewStringType
Definition: v8.h:1801
const int kApiPointerSize
Definition: v8.h:5501
void(* MessageCallback)(Handle< Message > message, Handle< Value > error)
Definition: v8.h:3931
static V8_INLINE uint8_t GetNodeFlag(internal::Object **obj, int shift)
Definition: v8.h:5681
static const int kNodeIsPartiallyDependentShift
Definition: v8.h:5627
V8_INLINE bool operator==(const Handle< S > &that) const
Definition: v8.h:243
virtual ~Extension()
Definition: v8.h:3821
V8_INLINE Local< S > As()
Definition: v8.h:359
void set_max_available_threads(int value)
Definition: v8.h:3900
size_t source_length() const
Definition: v8.h:3828
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
Definition: v8.h:6689
static const int kHeapObjectMapOffset
Definition: v8.h:5586
static V8_INLINE int GetInstanceType(const internal::Object *obj)
Definition: v8.h:5663
V8_INLINE bool IsIndependent() const
Definition: v8.h:5820
static const int kCalleeIndex
Definition: v8.h:2493
V8_INLINE Persistent< S > & As()
Definition: v8.h:693
V8_INLINE void ClearWeak()
Definition: v8.h:516
static Local< Integer > New(Isolate *isolate, int32_t value)
V8_INLINE UniquePersistent(Isolate *isolate, Handle< S > that)
Definition: v8.h:738
ExternalAsciiStringResourceImpl(const char *data, size_t length)
Definition: v8.h:3799
static V8_INLINE DataView * Cast(Value *obj)
Definition: v8.h:6541
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:811
static V8_INLINE internal::Object * IntToSmi(int value)
Definition: v8.h:5562
static V8_INLINE Promise * Cast(Value *obj)
Definition: v8.h:6429
const int kSmiShiftSize
Definition: v8.h:5572
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
Definition: v8.h:2786
static const int kIsolateIndex
Definition: v8.h:2527
const int kSmiTagSize
Definition: v8.h:5512
static V8_INLINE void UpdateNodeState(internal::Object **obj, uint8_t value)
Definition: v8.h:5698
V8_INLINE void Reset()
Definition: v8.h:5849
V8_INLINE Local(Handle< S > that)
Definition: v8.h:354
V8_INLINE void * GetData(uint32_t slot)
Definition: v8.h:6637
static const int kFullStringRepresentationMask
Definition: v8.h:5597
static const int kContextHeaderSize
Definition: v8.h:5595
void *(* CreateHistogramCallback)(const char *name,