v8  3.14.5(node0.10.28)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
v8.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
38 #ifndef V8_H_
39 #define V8_H_
40 
41 #include "v8stdint.h"
42 
43 #ifdef _WIN32
44 
45 // Setup for Windows DLL export/import. When building the V8 DLL the
46 // BUILDING_V8_SHARED needs to be defined. When building a program which uses
47 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
48 // static library or building a program which uses the V8 static library neither
49 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
50 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
51 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
52  build configuration to ensure that at most one of these is set
53 #endif
54 
55 #ifdef BUILDING_V8_SHARED
56 #define V8EXPORT __declspec(dllexport)
57 #elif USING_V8_SHARED
58 #define V8EXPORT __declspec(dllimport)
59 #else
60 #define V8EXPORT
61 #endif // BUILDING_V8_SHARED
62 
63 #else // _WIN32
64 
65 // Setup for Linux shared library export.
66 #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
67  (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
68 #ifdef BUILDING_V8_SHARED
69 #define V8EXPORT __attribute__ ((visibility("default")))
70 #else
71 #define V8EXPORT
72 #endif
73 #else
74 #define V8EXPORT
75 #endif
76 
77 #endif // _WIN32
78 
82 namespace v8 {
83 
84 class Context;
85 class String;
86 class StringObject;
87 class Value;
88 class Utils;
89 class Number;
90 class NumberObject;
91 class Object;
92 class Array;
93 class Int32;
94 class Uint32;
95 class External;
96 class Primitive;
97 class Boolean;
98 class BooleanObject;
99 class Integer;
100 class Function;
101 class Date;
102 class ImplementationUtilities;
103 class Signature;
104 class AccessorSignature;
105 template <class T> class Handle;
106 template <class T> class Local;
107 template <class T> class Persistent;
108 class FunctionTemplate;
109 class ObjectTemplate;
110 class Data;
111 class AccessorInfo;
112 class StackTrace;
113 class StackFrame;
114 class Isolate;
115 
116 namespace internal {
117 
118 class Arguments;
119 class Object;
120 class Heap;
121 class HeapObject;
122 class Isolate;
123 }
124 
125 
126 // --- Weak Handles ---
127 
128 
139  void* parameter);
140 
141 
142 // --- Handles ---
143 
144 #define TYPE_CHECK(T, S) \
145  while (false) { \
146  *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
147  }
148 
174 template <class T> class Handle {
175  public:
179  inline Handle() : val_(0) {}
180 
184  inline explicit Handle(T* val) : val_(val) {}
185 
196  template <class S> inline Handle(Handle<S> that)
197  : val_(reinterpret_cast<T*>(*that)) {
203  TYPE_CHECK(T, S);
204  }
205 
209  inline bool IsEmpty() const { return val_ == 0; }
210 
214  inline void Clear() { val_ = 0; }
215 
216  inline T* operator->() const { return val_; }
217 
218  inline T* operator*() const { return val_; }
219 
226  template <class S> inline bool operator==(Handle<S> that) const {
227  internal::Object** a = reinterpret_cast<internal::Object**>(**this);
228  internal::Object** b = reinterpret_cast<internal::Object**>(*that);
229  if (a == 0) return b == 0;
230  if (b == 0) return false;
231  return *a == *b;
232  }
233 
240  template <class S> inline bool operator!=(Handle<S> that) const {
241  return !operator==(that);
242  }
243 
244  template <class S> static inline Handle<T> Cast(Handle<S> that) {
245 #ifdef V8_ENABLE_CHECKS
246  // If we're going to perform the type check then we have to check
247  // that the handle isn't empty before doing the checked cast.
248  if (that.IsEmpty()) return Handle<T>();
249 #endif
250  return Handle<T>(T::Cast(*that));
251  }
252 
253  template <class S> inline Handle<S> As() {
254  return Handle<S>::Cast(*this);
255  }
256 
257  private:
258  T* val_;
259 };
260 
261 
269 template <class T> class Local : public Handle<T> {
270  public:
271  inline Local();
272  template <class S> inline Local(Local<S> that)
273  : Handle<T>(reinterpret_cast<T*>(*that)) {
279  TYPE_CHECK(T, S);
280  }
281  template <class S> inline Local(S* that) : Handle<T>(that) { }
282  template <class S> static inline Local<T> Cast(Local<S> that) {
283 #ifdef V8_ENABLE_CHECKS
284  // If we're going to perform the type check then we have to check
285  // that the handle isn't empty before doing the checked cast.
286  if (that.IsEmpty()) return Local<T>();
287 #endif
288  return Local<T>(T::Cast(*that));
289  }
290 
291  template <class S> inline Local<S> As() {
292  return Local<S>::Cast(*this);
293  }
294 
299  inline static Local<T> New(Handle<T> that);
300 };
301 
302 
320 template <class T> class Persistent : public Handle<T> {
321  public:
326  inline Persistent();
327 
339  template <class S> inline Persistent(Persistent<S> that)
340  : Handle<T>(reinterpret_cast<T*>(*that)) {
346  TYPE_CHECK(T, S);
347  }
348 
349  template <class S> inline Persistent(S* that) : Handle<T>(that) { }
350 
355  template <class S> explicit inline Persistent(Handle<S> that)
356  : Handle<T>(*that) { }
357 
358  template <class S> static inline Persistent<T> Cast(Persistent<S> that) {
359 #ifdef V8_ENABLE_CHECKS
360  // If we're going to perform the type check then we have to check
361  // that the handle isn't empty before doing the checked cast.
362  if (that.IsEmpty()) return Persistent<T>();
363 #endif
364  return Persistent<T>(T::Cast(*that));
365  }
366 
367  template <class S> inline Persistent<S> As() {
368  return Persistent<S>::Cast(*this);
369  }
370 
375  inline static Persistent<T> New(Handle<T> that);
376 
383  inline void Dispose();
384 
391  inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
392 
394  inline void ClearWeak();
395 
403  inline void MarkIndependent();
404 
406  inline bool IsIndependent() const;
407 
409  inline bool IsNearDeath() const;
410 
412  inline bool IsWeak() const;
413 
418  inline void SetWrapperClassId(uint16_t class_id);
419 
424  inline uint16_t WrapperClassId() const;
425 
426  private:
428  friend class ObjectTemplate;
429 };
430 
431 
447  public:
448  HandleScope();
449 
450  ~HandleScope();
451 
456  template <class T> Local<T> Close(Handle<T> value);
457 
461  static int NumberOfHandles();
462 
466  static internal::Object** CreateHandle(internal::Object* value);
467  // Faster version, uses HeapObject to obtain the current Isolate.
468  static internal::Object** CreateHandle(internal::HeapObject* value);
469 
470  private:
471  // Make it impossible to create heap-allocated or illegal handle
472  // scopes by disallowing certain operations.
473  HandleScope(const HandleScope&);
474  void operator=(const HandleScope&);
475  void* operator new(size_t size);
476  void operator delete(void*, size_t);
477 
478  // This Data class is accessible internally as HandleScopeData through a
479  // typedef in the ImplementationUtilities class.
480  class V8EXPORT Data {
481  public:
482  internal::Object** next;
483  internal::Object** limit;
484  int level;
485  inline void Initialize() {
486  next = limit = NULL;
487  level = 0;
488  }
489  };
490 
491  void Leave();
492 
493  internal::Isolate* isolate_;
494  internal::Object** prev_next_;
495  internal::Object** prev_limit_;
496 
497  // Allow for the active closing of HandleScopes which allows to pass a handle
498  // from the HandleScope being closed to the next top most HandleScope.
499  bool is_closed_;
500  internal::Object** RawClose(internal::Object** value);
501 
503 };
504 
505 
506 // --- Special objects ---
507 
508 
512 class V8EXPORT Data {
513  private:
514  Data();
515 };
516 
517 
524 class V8EXPORT ScriptData { // NOLINT
525  public:
526  virtual ~ScriptData() { }
527 
534  static ScriptData* PreCompile(const char* input, int length);
535 
544  static ScriptData* PreCompile(Handle<String> source);
545 
553  static ScriptData* New(const char* data, int length);
554 
558  virtual int Length() = 0;
559 
564  virtual const char* Data() = 0;
565 
569  virtual bool HasError() = 0;
570 };
571 
572 
577  public:
578  inline ScriptOrigin(
579  Handle<Value> resource_name,
580  Handle<Integer> resource_line_offset = Handle<Integer>(),
581  Handle<Integer> resource_column_offset = Handle<Integer>())
582  : resource_name_(resource_name),
583  resource_line_offset_(resource_line_offset),
584  resource_column_offset_(resource_column_offset) { }
585  inline Handle<Value> ResourceName() const;
586  inline Handle<Integer> ResourceLineOffset() const;
587  inline Handle<Integer> ResourceColumnOffset() const;
588  private:
589  Handle<Value> resource_name_;
590  Handle<Integer> resource_line_offset_;
591  Handle<Integer> resource_column_offset_;
592 };
593 
594 
599  public:
615  static Local<Script> New(Handle<String> source,
616  ScriptOrigin* origin = NULL,
617  ScriptData* pre_data = NULL,
618  Handle<String> script_data = Handle<String>());
619 
630  static Local<Script> New(Handle<String> source,
631  Handle<Value> file_name);
632 
649  static Local<Script> Compile(Handle<String> source,
650  ScriptOrigin* origin = NULL,
651  ScriptData* pre_data = NULL,
652  Handle<String> script_data = Handle<String>());
653 
667  static Local<Script> Compile(Handle<String> source,
668  Handle<Value> file_name,
669  Handle<String> script_data = Handle<String>());
670 
678  Local<Value> Run();
679 
683  Local<Value> Id();
684 
690  void SetData(Handle<String> data);
691 };
692 
693 
698  public:
699  Local<String> Get() const;
700  Local<String> GetSourceLine() const;
701 
706  Handle<Value> GetScriptResourceName() const;
707 
712  Handle<Value> GetScriptData() const;
713 
719  Handle<StackTrace> GetStackTrace() const;
720 
724  int GetLineNumber() const;
725 
730  int GetStartPosition() const;
731 
736  int GetEndPosition() const;
737 
742  int GetStartColumn() const;
743 
748  int GetEndColumn() const;
749 
750  // TODO(1245381): Print to a string instead of on a FILE.
751  static void PrintCurrentStackTrace(FILE* out);
752 
753  static const int kNoLineNumberInfo = 0;
754  static const int kNoColumnInfo = 0;
755 };
756 
757 
764  public:
770  kLineNumber = 1,
771  kColumnOffset = 1 << 1 | kLineNumber,
772  kScriptName = 1 << 2,
773  kFunctionName = 1 << 3,
774  kIsEval = 1 << 4,
775  kIsConstructor = 1 << 5,
776  kScriptNameOrSourceURL = 1 << 6,
777  kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
778  kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
779  };
780 
784  Local<StackFrame> GetFrame(uint32_t index) const;
785 
789  int GetFrameCount() const;
790 
794  Local<Array> AsArray();
795 
803  static Local<StackTrace> CurrentStackTrace(
804  int frame_limit,
805  StackTraceOptions options = kOverview);
806 };
807 
808 
813  public:
820  int GetLineNumber() const;
821 
829  int GetColumn() const;
830 
835  Local<String> GetScriptName() const;
836 
842  Local<String> GetScriptNameOrSourceURL() const;
843 
847  Local<String> GetFunctionName() const;
848 
853  bool IsEval() const;
854 
859  bool IsConstructor() const;
860 };
861 
862 
863 // --- Value ---
864 
865 
869 class Value : public Data {
870  public:
875  inline bool IsUndefined() const;
876 
881  inline bool IsNull() const;
882 
886  V8EXPORT bool IsTrue() const;
887 
891  V8EXPORT bool IsFalse() const;
892 
897  inline bool IsString() const;
898 
902  V8EXPORT bool IsFunction() const;
903 
907  V8EXPORT bool IsArray() const;
908 
912  V8EXPORT bool IsObject() const;
913 
917  V8EXPORT bool IsBoolean() const;
918 
922  V8EXPORT bool IsNumber() const;
923 
927  V8EXPORT bool IsExternal() const;
928 
932  V8EXPORT bool IsInt32() const;
933 
937  V8EXPORT bool IsUint32() const;
938 
942  V8EXPORT bool IsDate() const;
943 
947  V8EXPORT bool IsBooleanObject() const;
948 
952  V8EXPORT bool IsNumberObject() const;
953 
957  V8EXPORT bool IsStringObject() const;
958 
962  V8EXPORT bool IsNativeError() const;
963 
967  V8EXPORT bool IsRegExp() const;
968 
976  V8EXPORT Local<Int32> ToInt32() const;
977 
983 
984  V8EXPORT bool BooleanValue() const;
985  V8EXPORT double NumberValue() const;
986  V8EXPORT int64_t IntegerValue() const;
987  V8EXPORT uint32_t Uint32Value() const;
988  V8EXPORT int32_t Int32Value() const;
989 
991  V8EXPORT bool Equals(Handle<Value> that) const;
992  V8EXPORT bool StrictEquals(Handle<Value> that) const;
993 
994  private:
995  inline bool QuickIsUndefined() const;
996  inline bool QuickIsNull() const;
997  inline bool QuickIsString() const;
998  V8EXPORT bool FullIsUndefined() const;
999  V8EXPORT bool FullIsNull() const;
1000  V8EXPORT bool FullIsString() const;
1001 };
1002 
1003 
1007 class Primitive : public Value { };
1008 
1009 
1014 class Boolean : public Primitive {
1015  public:
1016  V8EXPORT bool Value() const;
1017  static inline Handle<Boolean> New(bool value);
1018 };
1019 
1020 
1024 class String : public Primitive {
1025  public:
1026  enum Encoding {
1030  };
1034  V8EXPORT int Length() const;
1035 
1040  V8EXPORT int Utf8Length() const;
1041 
1048  V8EXPORT bool MayContainNonAscii() const;
1049 
1080  };
1081 
1082  // 16-bit character codes.
1083  V8EXPORT int Write(uint16_t* buffer,
1084  int start = 0,
1085  int length = -1,
1086  int options = NO_OPTIONS) const;
1087  // ASCII characters.
1088  V8EXPORT int WriteAscii(char* buffer,
1089  int start = 0,
1090  int length = -1,
1091  int options = NO_OPTIONS) const;
1092  // UTF-8 encoded characters.
1093  V8EXPORT int WriteUtf8(char* buffer,
1094  int length = -1,
1095  int* nchars_ref = NULL,
1096  int options = NO_OPTIONS) const;
1097 
1102  inline static v8::Local<v8::String> Empty(Isolate* isolate);
1103 
1107  V8EXPORT bool IsExternal() const;
1108 
1112  V8EXPORT bool IsExternalAscii() const;
1113 
1115  public:
1117 
1118  protected:
1120 
1127  virtual void Dispose() { delete this; }
1128 
1129  private:
1130  // Disallow copying and assigning.
1132  void operator=(const ExternalStringResourceBase&);
1133 
1134  friend class v8::internal::Heap;
1135  };
1136 
1144  : public ExternalStringResourceBase {
1145  public:
1151 
1155  virtual const uint16_t* data() const = 0;
1156 
1160  virtual size_t length() const = 0;
1161 
1162  protected:
1164  };
1165 
1178  : public ExternalStringResourceBase {
1179  public:
1186  virtual const char* data() const = 0;
1188  virtual size_t length() const = 0;
1189  protected:
1191  };
1192 
1198  inline ExternalStringResourceBase* GetExternalStringResourceBase(
1199  Encoding* encoding_out) const;
1200 
1205  inline ExternalStringResource* GetExternalStringResource() const;
1206 
1211  V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource()
1212  const;
1213 
1214  static inline String* Cast(v8::Value* obj);
1215 
1225  V8EXPORT static Local<String> New(const char* data, int length = -1);
1226 
1228  V8EXPORT static Local<String> New(const uint16_t* data, int length = -1);
1229 
1231  V8EXPORT static Local<String> NewSymbol(const char* data, int length = -1);
1232 
1238  Handle<String> right);
1239 
1248  V8EXPORT static Local<String> NewExternal(ExternalStringResource* resource);
1249 
1259  V8EXPORT bool MakeExternal(ExternalStringResource* resource);
1269  ExternalAsciiStringResource* resource);
1270 
1280  V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource);
1281 
1285  V8EXPORT bool CanMakeExternal();
1286 
1288  V8EXPORT static Local<String> NewUndetectable(const char* data,
1289  int length = -1);
1290 
1292  V8EXPORT static Local<String> NewUndetectable(const uint16_t* data,
1293  int length = -1);
1294 
1303  public:
1304  explicit Utf8Value(Handle<v8::Value> obj);
1305  ~Utf8Value();
1306  char* operator*() { return str_; }
1307  const char* operator*() const { return str_; }
1308  int length() const { return length_; }
1309  private:
1310  char* str_;
1311  int length_;
1312 
1313  // Disallow copying and assigning.
1314  Utf8Value(const Utf8Value&);
1315  void operator=(const Utf8Value&);
1316  };
1317 
1326  public:
1327  explicit AsciiValue(Handle<v8::Value> obj);
1328  ~AsciiValue();
1329  char* operator*() { return str_; }
1330  const char* operator*() const { return str_; }
1331  int length() const { return length_; }
1332  private:
1333  char* str_;
1334  int length_;
1335 
1336  // Disallow copying and assigning.
1337  AsciiValue(const AsciiValue&);
1338  void operator=(const AsciiValue&);
1339  };
1340 
1347  class V8EXPORT Value {
1348  public:
1349  explicit Value(Handle<v8::Value> obj);
1350  ~Value();
1351  uint16_t* operator*() { return str_; }
1352  const uint16_t* operator*() const { return str_; }
1353  int length() const { return length_; }
1354  private:
1355  uint16_t* str_;
1356  int length_;
1357 
1358  // Disallow copying and assigning.
1359  Value(const Value&);
1360  void operator=(const Value&);
1361  };
1362 
1363  private:
1364  V8EXPORT void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
1365  Encoding encoding) const;
1366  V8EXPORT void VerifyExternalStringResource(ExternalStringResource* val) const;
1367  V8EXPORT static void CheckCast(v8::Value* obj);
1368 };
1369 
1370 
1374 class Number : public Primitive {
1375  public:
1376  V8EXPORT double Value() const;
1377  V8EXPORT static Local<Number> New(double value);
1378  static inline Number* Cast(v8::Value* obj);
1379  private:
1380  V8EXPORT Number();
1381  V8EXPORT static void CheckCast(v8::Value* obj);
1382 };
1383 
1384 
1388 class Integer : public Number {
1389  public:
1390  V8EXPORT static Local<Integer> New(int32_t value);
1391  V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value);
1392  V8EXPORT static Local<Integer> New(int32_t value, Isolate*);
1393  V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
1394  V8EXPORT int64_t Value() const;
1395  static inline Integer* Cast(v8::Value* obj);
1396  private:
1397  V8EXPORT Integer();
1398  V8EXPORT static void CheckCast(v8::Value* obj);
1399 };
1400 
1401 
1405 class Int32 : public Integer {
1406  public:
1407  V8EXPORT int32_t Value() const;
1408  private:
1409  V8EXPORT Int32();
1410 };
1411 
1412 
1416 class Uint32 : public Integer {
1417  public:
1418  V8EXPORT uint32_t Value() const;
1419  private:
1420  V8EXPORT Uint32();
1421 };
1422 
1423 
1425  None = 0,
1426  ReadOnly = 1 << 0,
1427  DontEnum = 1 << 1,
1428  DontDelete = 1 << 2
1429 };
1430 
1441 };
1442 
1448 typedef Handle<Value> (*AccessorGetter)(Local<String> property,
1449  const AccessorInfo& info);
1450 
1451 
1452 typedef void (*AccessorSetter)(Local<String> property,
1453  Local<Value> value,
1454  const AccessorInfo& info);
1455 
1456 
1471  DEFAULT = 0,
1473  ALL_CAN_WRITE = 1 << 1,
1475 };
1476 
1477 
1481 class Object : public Value {
1482  public:
1483  V8EXPORT bool Set(Handle<Value> key,
1484  Handle<Value> value,
1485  PropertyAttribute attribs = None);
1486 
1487  V8EXPORT bool Set(uint32_t index,
1488  Handle<Value> value);
1489 
1490  // Sets a local property on this object bypassing interceptors and
1491  // overriding accessors or read-only properties.
1492  //
1493  // Note that if the object has an interceptor the property will be set
1494  // locally, but since the interceptor takes precedence the local property
1495  // will only be returned if the interceptor doesn't return a value.
1496  //
1497  // Note also that this only works for named properties.
1498  V8EXPORT bool ForceSet(Handle<Value> key,
1499  Handle<Value> value,
1500  PropertyAttribute attribs = None);
1501 
1503 
1504  V8EXPORT Local<Value> Get(uint32_t index);
1505 
1512 
1513  // TODO(1245389): Replace the type-specific versions of these
1514  // functions with generic ones that accept a Handle<Value> key.
1515  V8EXPORT bool Has(Handle<String> key);
1516 
1517  V8EXPORT bool Delete(Handle<String> key);
1518 
1519  // Delete a property on this object bypassing interceptors and
1520  // ignoring dont-delete attributes.
1522 
1523  V8EXPORT bool Has(uint32_t index);
1524 
1525  V8EXPORT bool Delete(uint32_t index);
1526 
1528  AccessorGetter getter,
1529  AccessorSetter setter = 0,
1530  Handle<Value> data = Handle<Value>(),
1531  AccessControl settings = DEFAULT,
1532  PropertyAttribute attribute = None);
1533 
1541 
1548 
1555 
1561  V8EXPORT bool SetPrototype(Handle<Value> prototype);
1562 
1569 
1576 
1582 
1587 
1591  inline Local<Value> GetInternalField(int index);
1593  V8EXPORT void SetInternalField(int index, Handle<Value> value);
1594 
1596  inline void* GetPointerFromInternalField(int index);
1597 
1599  V8EXPORT void SetPointerInInternalField(int index, void* value);
1600 
1601  // Testers for local properties.
1604  V8EXPORT bool HasRealIndexedProperty(uint32_t index);
1606 
1612  Handle<String> key);
1613 
1620 
1623 
1626 
1632  V8EXPORT void TurnOnAccessCheck();
1633 
1641  V8EXPORT int GetIdentityHash();
1642 
1652 
1660  V8EXPORT bool IsDirty();
1661 
1667 
1672 
1680  V8EXPORT void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
1684 
1693  void* data,
1694  ExternalArrayType array_type,
1695  int number_of_elements);
1700 
1706  V8EXPORT bool IsCallable();
1707 
1713  int argc,
1714  Handle<Value> argv[]);
1715 
1722  Handle<Value> argv[]);
1723 
1724  V8EXPORT static Local<Object> New();
1725  static inline Object* Cast(Value* obj);
1726 
1727  private:
1728  V8EXPORT Object();
1729  V8EXPORT static void CheckCast(Value* obj);
1730  V8EXPORT Local<Value> CheckedGetInternalField(int index);
1731  V8EXPORT void* SlowGetPointerFromInternalField(int index);
1732 
1737  inline Local<Value> UncheckedGetInternalField(int index);
1738 };
1739 
1740 
1744 class Array : public Object {
1745  public:
1746  V8EXPORT uint32_t Length() const;
1747 
1752  V8EXPORT Local<Object> CloneElementAt(uint32_t index);
1753 
1758  V8EXPORT static Local<Array> New(int length = 0);
1759 
1760  static inline Array* Cast(Value* obj);
1761  private:
1762  V8EXPORT Array();
1763  V8EXPORT static void CheckCast(Value* obj);
1764 };
1765 
1766 
1770 class Function : public Object {
1771  public:
1773  V8EXPORT Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
1775  int argc,
1776  Handle<Value> argv[]);
1777  V8EXPORT void SetName(Handle<String> name);
1778  V8EXPORT Handle<Value> GetName() const;
1779 
1787 
1792  V8EXPORT int GetScriptLineNumber() const;
1797  V8EXPORT int GetScriptColumnNumber() const;
1800  static inline Function* Cast(Value* obj);
1801  V8EXPORT static const int kLineOffsetNotFound;
1802 
1803  private:
1804  V8EXPORT Function();
1805  V8EXPORT static void CheckCast(Value* obj);
1806 };
1807 
1808 
1812 class Date : public Object {
1813  public:
1814  V8EXPORT static Local<Value> New(double time);
1815 
1820  V8EXPORT double NumberValue() const;
1821 
1822  static inline Date* Cast(v8::Value* obj);
1823 
1837 
1838  private:
1839  V8EXPORT static void CheckCast(v8::Value* obj);
1840 };
1841 
1842 
1846 class NumberObject : public Object {
1847  public:
1848  V8EXPORT static Local<Value> New(double value);
1849 
1853  V8EXPORT double NumberValue() const;
1854 
1855  static inline NumberObject* Cast(v8::Value* obj);
1856 
1857  private:
1858  V8EXPORT static void CheckCast(v8::Value* obj);
1859 };
1860 
1861 
1865 class BooleanObject : public Object {
1866  public:
1867  V8EXPORT static Local<Value> New(bool value);
1868 
1872  V8EXPORT bool BooleanValue() const;
1873 
1874  static inline BooleanObject* Cast(v8::Value* obj);
1875 
1876  private:
1877  V8EXPORT static void CheckCast(v8::Value* obj);
1878 };
1879 
1880 
1884 class StringObject : public Object {
1885  public:
1886  V8EXPORT static Local<Value> New(Handle<String> value);
1887 
1892 
1893  static inline StringObject* Cast(v8::Value* obj);
1894 
1895  private:
1896  V8EXPORT static void CheckCast(v8::Value* obj);
1897 };
1898 
1899 
1903 class RegExp : public Object {
1904  public:
1909  enum Flags {
1910  kNone = 0,
1911  kGlobal = 1,
1914  };
1915 
1926  V8EXPORT static Local<RegExp> New(Handle<String> pattern,
1927  Flags flags);
1928 
1934 
1938  V8EXPORT Flags GetFlags() const;
1939 
1940  static inline RegExp* Cast(v8::Value* obj);
1941 
1942  private:
1943  V8EXPORT static void CheckCast(v8::Value* obj);
1944 };
1945 
1946 
1958 class External : public Value {
1959  public:
1960  V8EXPORT static Local<Value> Wrap(void* data);
1961  static inline void* Unwrap(Handle<Value> obj);
1962 
1963  V8EXPORT static Local<External> New(void* value);
1964  static inline External* Cast(Value* obj);
1965  V8EXPORT void* Value() const;
1966  private:
1967  V8EXPORT External();
1968  V8EXPORT static void CheckCast(v8::Value* obj);
1969  static inline void* QuickUnwrap(Handle<v8::Value> obj);
1970  V8EXPORT static void* FullUnwrap(Handle<v8::Value> obj);
1971 };
1972 
1973 
1974 // --- Templates ---
1975 
1976 
1980 class V8EXPORT Template : public Data {
1981  public:
1983  void Set(Handle<String> name, Handle<Data> value,
1984  PropertyAttribute attributes = None);
1985  inline void Set(const char* name, Handle<Data> value);
1986  private:
1987  Template();
1988 
1989  friend class ObjectTemplate;
1990  friend class FunctionTemplate;
1991 };
1992 
1993 
2000 class Arguments {
2001  public:
2002  inline int Length() const;
2003  inline Local<Value> operator[](int i) const;
2004  inline Local<Function> Callee() const;
2005  inline Local<Object> This() const;
2006  inline Local<Object> Holder() const;
2007  inline bool IsConstructCall() const;
2008  inline Local<Value> Data() const;
2009  inline Isolate* GetIsolate() const;
2010 
2011  private:
2012  static const int kIsolateIndex = 0;
2013  static const int kDataIndex = -1;
2014  static const int kCalleeIndex = -2;
2015  static const int kHolderIndex = -3;
2016 
2018  inline Arguments(internal::Object** implicit_args,
2019  internal::Object** values,
2020  int length,
2021  bool is_construct_call);
2022  internal::Object** implicit_args_;
2023  internal::Object** values_;
2024  int length_;
2025  bool is_construct_call_;
2026 };
2027 
2028 
2034  public:
2036  : args_(args) { }
2037  inline Isolate* GetIsolate() const;
2038  inline Local<Value> Data() const;
2039  inline Local<Object> This() const;
2040  inline Local<Object> Holder() const;
2041 
2042  private:
2043  internal::Object** args_;
2044 };
2045 
2046 
2047 typedef Handle<Value> (*InvocationCallback)(const Arguments& args);
2048 
2053 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property,
2054  const AccessorInfo& info);
2055 
2056 
2061 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property,
2062  Local<Value> value,
2063  const AccessorInfo& info);
2064 
2070 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property,
2071  const AccessorInfo& info);
2072 
2073 
2079 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property,
2080  const AccessorInfo& info);
2081 
2086 typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info);
2087 
2088 
2093 typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index,
2094  const AccessorInfo& info);
2095 
2096 
2101 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index,
2102  Local<Value> value,
2103  const AccessorInfo& info);
2104 
2105 
2110 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index,
2111  const AccessorInfo& info);
2112 
2118 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index,
2119  const AccessorInfo& info);
2120 
2125 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info);
2126 
2127 
2137 };
2138 
2139 
2145  Local<Value> key,
2146  AccessType type,
2147  Local<Value> data);
2148 
2149 
2155  uint32_t index,
2156  AccessType type,
2157  Local<Value> data);
2158 
2159 
2253  public:
2255  static Local<FunctionTemplate> New(
2256  InvocationCallback callback = 0,
2257  Handle<Value> data = Handle<Value>(),
2258  Handle<Signature> signature = Handle<Signature>());
2260  Local<Function> GetFunction();
2261 
2267  void SetCallHandler(InvocationCallback callback,
2268  Handle<Value> data = Handle<Value>());
2269 
2271  Local<ObjectTemplate> InstanceTemplate();
2272 
2274  void Inherit(Handle<FunctionTemplate> parent);
2275 
2280  Local<ObjectTemplate> PrototypeTemplate();
2281 
2282 
2288  void SetClassName(Handle<String> name);
2289 
2302  void SetHiddenPrototype(bool value);
2303 
2308  void ReadOnlyPrototype();
2309 
2314  bool HasInstance(Handle<Value> object);
2315 
2316  private:
2317  FunctionTemplate();
2318  void AddInstancePropertyAccessor(Handle<String> name,
2319  AccessorGetter getter,
2320  AccessorSetter setter,
2321  Handle<Value> data,
2322  AccessControl settings,
2323  PropertyAttribute attributes,
2324  Handle<AccessorSignature> signature);
2325  void SetNamedInstancePropertyHandler(NamedPropertyGetter getter,
2326  NamedPropertySetter setter,
2327  NamedPropertyQuery query,
2328  NamedPropertyDeleter remover,
2329  NamedPropertyEnumerator enumerator,
2330  Handle<Value> data);
2331  void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter,
2332  IndexedPropertySetter setter,
2333  IndexedPropertyQuery query,
2334  IndexedPropertyDeleter remover,
2335  IndexedPropertyEnumerator enumerator,
2336  Handle<Value> data);
2337  void SetInstanceCallAsFunctionHandler(InvocationCallback callback,
2338  Handle<Value> data);
2339 
2340  friend class Context;
2341  friend class ObjectTemplate;
2342 };
2343 
2344 
2352  public:
2354  static Local<ObjectTemplate> New();
2355 
2357  Local<Object> NewInstance();
2358 
2388  void SetAccessor(Handle<String> name,
2389  AccessorGetter getter,
2390  AccessorSetter setter = 0,
2391  Handle<Value> data = Handle<Value>(),
2392  AccessControl settings = DEFAULT,
2393  PropertyAttribute attribute = None,
2394  Handle<AccessorSignature> signature =
2396 
2414  void SetNamedPropertyHandler(NamedPropertyGetter getter,
2415  NamedPropertySetter setter = 0,
2416  NamedPropertyQuery query = 0,
2417  NamedPropertyDeleter deleter = 0,
2418  NamedPropertyEnumerator enumerator = 0,
2419  Handle<Value> data = Handle<Value>());
2420 
2437  void SetIndexedPropertyHandler(IndexedPropertyGetter getter,
2438  IndexedPropertySetter setter = 0,
2439  IndexedPropertyQuery query = 0,
2440  IndexedPropertyDeleter deleter = 0,
2441  IndexedPropertyEnumerator enumerator = 0,
2442  Handle<Value> data = Handle<Value>());
2443 
2450  void SetCallAsFunctionHandler(InvocationCallback callback,
2451  Handle<Value> data = Handle<Value>());
2452 
2461  void MarkAsUndetectable();
2462 
2474  void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
2475  IndexedSecurityCallback indexed_handler,
2476  Handle<Value> data = Handle<Value>(),
2477  bool turned_on_by_default = true);
2478 
2483  int InternalFieldCount();
2484 
2489  void SetInternalFieldCount(int value);
2490 
2491  private:
2492  ObjectTemplate();
2493  static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor);
2494  friend class FunctionTemplate;
2495 };
2496 
2497 
2502 class V8EXPORT Signature : public Data {
2503  public:
2504  static Local<Signature> New(Handle<FunctionTemplate> receiver =
2506  int argc = 0,
2507  Handle<FunctionTemplate> argv[] = 0);
2508  private:
2509  Signature();
2510 };
2511 
2512 
2518  public:
2521  private:
2523 };
2524 
2525 
2530 class V8EXPORT TypeSwitch : public Data {
2531  public:
2533  static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
2534  int match(Handle<Value> value);
2535  private:
2536  TypeSwitch();
2537 };
2538 
2539 
2540 // --- Extensions ---
2541 
2544  public:
2545  ExternalAsciiStringResourceImpl() : data_(0), length_(0) {}
2546  ExternalAsciiStringResourceImpl(const char* data, size_t length)
2547  : data_(data), length_(length) {}
2548  const char* data() const { return data_; }
2549  size_t length() const { return length_; }
2550 
2551  private:
2552  const char* data_;
2553  size_t length_;
2554 };
2555 
2559 class V8EXPORT Extension { // NOLINT
2560  public:
2561  // Note that the strings passed into this constructor must live as long
2562  // as the Extension itself.
2563  Extension(const char* name,
2564  const char* source = 0,
2565  int dep_count = 0,
2566  const char** deps = 0,
2567  int source_length = -1);
2568  virtual ~Extension() { }
2572  }
2573 
2574  const char* name() const { return name_; }
2575  size_t source_length() const { return source_length_; }
2577  return &source_; }
2578  int dependency_count() { return dep_count_; }
2579  const char** dependencies() { return deps_; }
2580  void set_auto_enable(bool value) { auto_enable_ = value; }
2581  bool auto_enable() { return auto_enable_; }
2582 
2583  private:
2584  const char* name_;
2585  size_t source_length_; // expected to initialize before source_
2587  int dep_count_;
2588  const char** deps_;
2589  bool auto_enable_;
2590 
2591  // Disallow copying and assigning.
2592  Extension(const Extension&);
2593  void operator=(const Extension&);
2594 };
2595 
2596 
2597 void V8EXPORT RegisterExtension(Extension* extension);
2598 
2599 
2604  public:
2605  inline DeclareExtension(Extension* extension) {
2606  RegisterExtension(extension);
2607  }
2608 };
2609 
2610 
2611 // --- Statics ---
2612 
2613 
2614 Handle<Primitive> V8EXPORT Undefined();
2615 Handle<Primitive> V8EXPORT Null();
2616 Handle<Boolean> V8EXPORT True();
2617 Handle<Boolean> V8EXPORT False();
2618 
2619 inline Handle<Primitive> Undefined(Isolate* isolate);
2620 inline Handle<Primitive> Null(Isolate* isolate);
2621 inline Handle<Boolean> True(Isolate* isolate);
2622 inline Handle<Boolean> False(Isolate* isolate);
2623 
2624 
2635  public:
2637  int max_young_space_size() const { return max_young_space_size_; }
2638  void set_max_young_space_size(int value) { max_young_space_size_ = value; }
2639  int max_old_space_size() const { return max_old_space_size_; }
2640  void set_max_old_space_size(int value) { max_old_space_size_ = value; }
2641  int max_executable_size() { return max_executable_size_; }
2642  void set_max_executable_size(int value) { max_executable_size_ = value; }
2643  uint32_t* stack_limit() const { return stack_limit_; }
2644  // Sets an address beyond which the VM's stack may not grow.
2645  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
2646  private:
2647  int max_young_space_size_;
2648  int max_old_space_size_;
2649  int max_executable_size_;
2650  uint32_t* stack_limit_;
2651 };
2652 
2653 
2654 bool V8EXPORT SetResourceConstraints(ResourceConstraints* constraints);
2655 
2656 
2657 // --- Exceptions ---
2658 
2659 
2660 typedef void (*FatalErrorCallback)(const char* location, const char* message);
2661 
2662 
2664 
2665 
2673 
2679  public:
2680  static Local<Value> RangeError(Handle<String> message);
2681  static Local<Value> ReferenceError(Handle<String> message);
2682  static Local<Value> SyntaxError(Handle<String> message);
2683  static Local<Value> TypeError(Handle<String> message);
2684  static Local<Value> Error(Handle<String> message);
2685 };
2686 
2687 
2688 // --- Counters Callbacks ---
2689 
2690 typedef int* (*CounterLookupCallback)(const char* name);
2691 
2692 typedef void* (*CreateHistogramCallback)(const char* name,
2693  int min,
2694  int max,
2695  size_t buckets);
2696 
2697 typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
2698 
2699 // --- Memory Allocation Callback ---
2707 
2711  };
2712 
2717  };
2718 
2720  AllocationAction action,
2721  int size);
2722 
2723 // --- Leave Script Callback ---
2724 typedef void (*CallCompletedCallback)();
2725 
2726 // --- Failed Access Check Callback ---
2728  AccessType type,
2729  Local<Value> data);
2730 
2731 // --- AllowCodeGenerationFromStrings callbacks ---
2732 
2738 
2739 // --- Garbage Collection Callbacks ---
2740 
2748 enum GCType {
2752 };
2753 
2757 };
2758 
2761 
2762 typedef void (*GCCallback)();
2763 
2764 
2772  public:
2773  HeapStatistics();
2774  size_t total_heap_size() { return total_heap_size_; }
2775  size_t total_heap_size_executable() { return total_heap_size_executable_; }
2776  size_t used_heap_size() { return used_heap_size_; }
2777  size_t heap_size_limit() { return heap_size_limit_; }
2778 
2779  private:
2780  void set_total_heap_size(size_t size) { total_heap_size_ = size; }
2781  void set_total_heap_size_executable(size_t size) {
2782  total_heap_size_executable_ = size;
2783  }
2784  void set_used_heap_size(size_t size) { used_heap_size_ = size; }
2785  void set_heap_size_limit(size_t size) { heap_size_limit_ = size; }
2786 
2787  size_t total_heap_size_;
2788  size_t total_heap_size_executable_;
2789  size_t used_heap_size_;
2790  size_t heap_size_limit_;
2791 
2792  friend class V8;
2793 };
2794 
2795 
2796 class RetainedObjectInfo;
2797 
2808  public:
2813  class V8EXPORT Scope {
2814  public:
2815  explicit Scope(Isolate* isolate) : isolate_(isolate) {
2816  isolate->Enter();
2817  }
2818 
2819  ~Scope() { isolate_->Exit(); }
2820 
2821  private:
2822  Isolate* const isolate_;
2823 
2824  // Prevent copying of Scope objects.
2825  Scope(const Scope&);
2826  Scope& operator=(const Scope&);
2827  };
2828 
2836  static Isolate* New();
2837 
2842  static Isolate* GetCurrent();
2843 
2854  void Enter();
2855 
2863  void Exit();
2864 
2869  void Dispose();
2870 
2874  inline void SetData(void* data);
2875 
2880  inline void* GetData();
2881 
2882  private:
2883  Isolate();
2884  Isolate(const Isolate&);
2885  ~Isolate();
2886  Isolate& operator=(const Isolate&);
2887  void* operator new(size_t size);
2888  void operator delete(void*, size_t);
2889 };
2890 
2891 
2893  public:
2897  };
2898 
2899  const char* data;
2902 };
2903 
2904 
2914  public:
2916  virtual ~StartupDataDecompressor();
2917  int Decompress();
2918 
2919  protected:
2920  virtual int DecompressData(char* raw_data,
2921  int* raw_data_size,
2922  const char* compressed_data,
2923  int compressed_data_size) = 0;
2924 
2925  private:
2926  char** raw_data;
2927 };
2928 
2929 
2934 typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
2935 
2936 
2950 typedef uintptr_t (*ReturnAddressLocationResolver)(
2951  uintptr_t return_addr_location);
2952 
2953 
2965 typedef void (*FunctionEntryHook)(uintptr_t function,
2966  uintptr_t return_addr_location);
2967 
2968 
2975  enum EventType {
2979  };
2980 
2981  // Type of event.
2983  // Start of the instructions.
2984  void* code_start;
2985  // Size of the instructions.
2986  size_t code_len;
2987 
2988  union {
2989  // Only valid for CODE_ADDED.
2990  struct {
2991  // Name of the object associated with the code, note that the string is
2992  // not zero-terminated.
2993  const char* str;
2994  // Number of chars in str.
2995  size_t len;
2996  } name;
2997  // New location of instructions. Only valid for CODE_MOVED.
2999  };
3000 };
3001 
3007  // Generate callbacks for already existent code.
3009 };
3010 
3011 
3017 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
3018 
3019 
3024  public:
3026  virtual void VisitExternalString(Handle<String> string) {}
3027 };
3028 
3029 
3034  public:
3037  uint16_t class_id) {}
3038 };
3039 
3040 
3044 class V8EXPORT V8 {
3045  public:
3047  static void SetFatalErrorHandler(FatalErrorCallback that);
3048 
3053  static void SetAllowCodeGenerationFromStringsCallback(
3055 
3068  static void IgnoreOutOfMemoryException();
3069 
3074  static bool IsDead();
3075 
3095  static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm();
3096  static int GetCompressedStartupDataCount();
3097  static void GetCompressedStartupData(StartupData* compressed_data);
3098  static void SetDecompressedStartupData(StartupData* decompressed_data);
3099 
3106  static bool AddMessageListener(MessageCallback that);
3107 
3111  static void RemoveMessageListeners(MessageCallback that);
3112 
3117  static void SetCaptureStackTraceForUncaughtExceptions(
3118  bool capture,
3119  int frame_limit = 10,
3121 
3125  static void SetFlagsFromString(const char* str, int length);
3126 
3130  static void SetFlagsFromCommandLine(int* argc,
3131  char** argv,
3132  bool remove_flags);
3133 
3135  static const char* GetVersion();
3136 
3141  static void SetCounterFunction(CounterLookupCallback);
3142 
3149  static void SetCreateHistogramFunction(CreateHistogramCallback);
3150  static void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
3151 
3156  static void EnableSlidingStateWindow();
3157 
3159  static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
3160 
3171  static void AddGCPrologueCallback(
3172  GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
3173 
3178  static void RemoveGCPrologueCallback(GCPrologueCallback callback);
3179 
3188  static void SetGlobalGCPrologueCallback(GCCallback);
3189 
3200  static void AddGCEpilogueCallback(
3201  GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
3202 
3207  static void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
3208 
3217  static void SetGlobalGCEpilogueCallback(GCCallback);
3218 
3223  static void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
3224  ObjectSpace space,
3225  AllocationAction action);
3226 
3230  static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
3231 
3239  static void AddCallCompletedCallback(CallCompletedCallback callback);
3240 
3244  static void RemoveCallCompletedCallback(CallCompletedCallback callback);
3245 
3255  static void AddObjectGroup(Persistent<Value>* objects,
3256  size_t length,
3257  RetainedObjectInfo* info = NULL);
3258 
3266  static void AddImplicitReferences(Persistent<Object> parent,
3267  Persistent<Value>* children,
3268  size_t length);
3269 
3275  static bool Initialize();
3276 
3281  static void SetEntropySource(EntropySource source);
3282 
3287  static void SetReturnAddressLocationResolver(
3288  ReturnAddressLocationResolver return_address_resolver);
3289 
3302  static bool SetFunctionEntryHook(FunctionEntryHook entry_hook);
3303 
3324  static void SetJitCodeEventHandler(JitCodeEventOptions options,
3325  JitCodeEventHandler event_handler);
3326 
3341  static intptr_t AdjustAmountOfExternalAllocatedMemory(
3342  intptr_t change_in_bytes);
3343 
3353  static void PauseProfiler();
3354 
3359  static void ResumeProfiler();
3360 
3364  static bool IsProfilerPaused();
3365 
3372  static int GetCurrentThreadId();
3373 
3398  static void TerminateExecution(int thread_id);
3399 
3410  static void TerminateExecution(Isolate* isolate = NULL);
3411 
3422  static bool IsExecutionTerminating(Isolate* isolate = NULL);
3423 
3433  static bool Dispose();
3434 
3438  static void GetHeapStatistics(HeapStatistics* heap_statistics);
3439 
3445  static void VisitExternalResources(ExternalResourceVisitor* visitor);
3446 
3451  static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
3452 
3465  static bool IdleNotification(int hint = 1000);
3466 
3471  static void LowMemoryNotification();
3472 
3479  static int ContextDisposedNotification();
3480 
3481  private:
3482  V8();
3483 
3484  static internal::Object** GlobalizeReference(internal::Object** handle);
3485  static void DisposeGlobal(internal::Object** global_handle);
3486  static void MakeWeak(internal::Object** global_handle,
3487  void* data,
3489  static void ClearWeak(internal::Object** global_handle);
3490  static void MarkIndependent(internal::Object** global_handle);
3491  static bool IsGlobalIndependent(internal::Object** global_handle);
3492  static bool IsGlobalNearDeath(internal::Object** global_handle);
3493  static bool IsGlobalWeak(internal::Object** global_handle);
3494  static void SetWrapperClassId(internal::Object** global_handle,
3495  uint16_t class_id);
3496  static uint16_t GetWrapperClassId(internal::Object** global_handle);
3497 
3498  template <class T> friend class Handle;
3499  template <class T> friend class Local;
3500  template <class T> friend class Persistent;
3501  friend class Context;
3502 };
3503 
3504 
3509  public:
3513  TryCatch();
3514 
3518  ~TryCatch();
3519 
3523  bool HasCaught() const;
3524 
3538  bool CanContinue() const;
3539 
3547  Handle<Value> ReThrow();
3548 
3555  Local<Value> Exception() const;
3556 
3561  Local<Value> StackTrace() const;
3562 
3570  Local<v8::Message> Message() const;
3571 
3581  void Reset();
3582 
3591  void SetVerbose(bool value);
3592 
3598  void SetCaptureMessage(bool value);
3599 
3600  private:
3601  v8::internal::Isolate* isolate_;
3602  void* next_;
3603  void* exception_;
3604  void* message_;
3605  bool is_verbose_ : 1;
3606  bool can_continue_ : 1;
3607  bool capture_message_ : 1;
3608  bool rethrow_ : 1;
3609 
3611 };
3612 
3613 
3614 // --- Context ---
3615 
3616 
3621  public:
3622  ExtensionConfiguration(int name_count, const char* names[])
3623  : name_count_(name_count), names_(names) { }
3624  private:
3626  int name_count_;
3627  const char** names_;
3628 };
3629 
3630 
3636  public:
3653  Local<Object> Global();
3654 
3659  void DetachGlobal();
3660 
3671  void ReattachGlobal(Handle<Object> global_object);
3672 
3691  static Persistent<Context> New(
3692  ExtensionConfiguration* extensions = NULL,
3693  Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
3694  Handle<Value> global_object = Handle<Value>());
3695 
3697  static Local<Context> GetEntered();
3698 
3700  static Local<Context> GetCurrent();
3701 
3707  static Local<Context> GetCalling();
3708 
3713  void SetSecurityToken(Handle<Value> token);
3714 
3716  void UseDefaultSecurityToken();
3717 
3719  Handle<Value> GetSecurityToken();
3720 
3727  void Enter();
3728 
3733  void Exit();
3734 
3736  bool HasOutOfMemoryException();
3737 
3739  static bool InContext();
3740 
3746  void SetData(Handle<Value> data);
3747  Local<Value> GetData();
3748 
3762  void AllowCodeGenerationFromStrings(bool allow);
3763 
3768  bool IsCodeGenerationFromStringsAllowed();
3769 
3775  void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
3776 
3781  class Scope {
3782  public:
3783  explicit inline Scope(Handle<Context> context) : context_(context) {
3784  context_->Enter();
3785  }
3786  inline ~Scope() { context_->Exit(); }
3787  private:
3788  Handle<Context> context_;
3789  };
3790 
3791  private:
3792  friend class Value;
3793  friend class Script;
3794  friend class Object;
3795  friend class Function;
3796 };
3797 
3798 
3882  public:
3886  explicit Unlocker(Isolate* isolate = NULL);
3887  ~Unlocker();
3888  private:
3889  internal::Isolate* isolate_;
3890 };
3891 
3892 
3894  public:
3898  explicit Locker(Isolate* isolate = NULL);
3899  ~Locker();
3900 
3908  static void StartPreemption(int every_n_ms);
3909 
3913  static void StopPreemption();
3914 
3919  static bool IsLocked(Isolate* isolate = NULL);
3920 
3924  static bool IsActive();
3925 
3926  private:
3927  bool has_lock_;
3928  bool top_level_;
3929  internal::Isolate* isolate_;
3930 
3931  static bool active_;
3932 
3933  // Disallow copying and assigning.
3934  Locker(const Locker&);
3935  void operator=(const Locker&);
3936 };
3937 
3938 
3942 struct HeapStatsUpdate;
3943 
3944 
3948 class V8EXPORT OutputStream { // NOLINT
3949  public:
3951  kAscii = 0 // 7-bit ASCII.
3952  };
3954  kContinue = 0,
3955  kAbort = 1
3956  };
3957  virtual ~OutputStream() {}
3959  virtual void EndOfStream() = 0;
3961  virtual int GetChunkSize() { return 1024; }
3963  virtual OutputEncoding GetOutputEncoding() { return kAscii; }
3969  virtual WriteResult WriteAsciiChunk(char* data, int size) = 0;
3976  return kAbort;
3977  };
3978 };
3979 
3980 
3985 class V8EXPORT ActivityControl { // NOLINT
3986  public:
3988  kContinue = 0,
3989  kAbort = 1
3990  };
3991  virtual ~ActivityControl() {}
3996  virtual ControlOption ReportProgressValue(int done, int total) = 0;
3997 };
3998 
3999 
4000 // --- Implementation ---
4001 
4002 
4003 namespace internal {
4004 
4005 const int kApiPointerSize = sizeof(void*); // NOLINT
4006 const int kApiIntSize = sizeof(int); // NOLINT
4007 
4008 // Tag information for HeapObject.
4009 const int kHeapObjectTag = 1;
4010 const int kHeapObjectTagSize = 2;
4011 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
4012 
4013 // Tag information for Smi.
4014 const int kSmiTag = 0;
4015 const int kSmiTagSize = 1;
4016 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
4017 
4018 template <size_t ptr_size> struct SmiTagging;
4019 
4020 // Smi constants for 32-bit systems.
4021 template <> struct SmiTagging<4> {
4022  static const int kSmiShiftSize = 0;
4023  static const int kSmiValueSize = 31;
4024  static inline int SmiToInt(internal::Object* value) {
4025  int shift_bits = kSmiTagSize + kSmiShiftSize;
4026  // Throw away top 32 bits and shift down (requires >> to be sign extending).
4027  return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
4028  }
4029 
4030  // For 32-bit systems any 2 bytes aligned pointer can be encoded as smi
4031  // with a plain reinterpret_cast.
4032  static const uintptr_t kEncodablePointerMask = 0x1;
4033  static const int kPointerToSmiShift = 0;
4034 };
4035 
4036 // Smi constants for 64-bit systems.
4037 template <> struct SmiTagging<8> {
4038  static const int kSmiShiftSize = 31;
4039  static const int kSmiValueSize = 32;
4040  static inline int SmiToInt(internal::Object* value) {
4041  int shift_bits = kSmiTagSize + kSmiShiftSize;
4042  // Shift down and throw away top 32 bits.
4043  return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
4044  }
4045 
4046  // To maximize the range of pointers that can be encoded
4047  // in the available 32 bits, we require them to be 8 bytes aligned.
4048  // This gives 2 ^ (32 + 3) = 32G address space covered.
4049  // It might be not enough to cover stack allocated objects on some platforms.
4050  static const int kPointerAlignment = 3;
4051 
4052  static const uintptr_t kEncodablePointerMask =
4053  ~(uintptr_t(0xffffffff) << kPointerAlignment);
4054 
4055  static const int kPointerToSmiShift =
4057 };
4058 
4062 const uintptr_t kEncodablePointerMask =
4065 
4071 class Internals {
4072  public:
4073  // These values match non-compiler-dependent values defined within
4074  // the implementation of v8.
4075  static const int kHeapObjectMapOffset = 0;
4077  static const int kStringResourceOffset = 3 * kApiPointerSize;
4078 
4079  static const int kOddballKindOffset = 3 * kApiPointerSize;
4081  static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
4082  static const int kFullStringRepresentationMask = 0x07;
4083  static const int kStringEncodingMask = 0x4;
4084  static const int kExternalTwoByteRepresentationTag = 0x02;
4085  static const int kExternalAsciiRepresentationTag = 0x06;
4086 
4087  static const int kIsolateStateOffset = 0;
4089  static const int kIsolateRootsOffset = 3 * kApiPointerSize;
4090  static const int kUndefinedValueRootIndex = 5;
4091  static const int kNullValueRootIndex = 7;
4092  static const int kTrueValueRootIndex = 8;
4093  static const int kFalseValueRootIndex = 9;
4094  static const int kEmptySymbolRootIndex = 117;
4095 
4096  static const int kJSObjectType = 0xaa;
4097  static const int kFirstNonstringType = 0x80;
4098  static const int kOddballType = 0x82;
4099  static const int kForeignType = 0x85;
4100 
4101  static const int kUndefinedOddballKind = 5;
4102  static const int kNullOddballKind = 3;
4103 
4104  static inline bool HasHeapObjectTag(internal::Object* value) {
4105  return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
4106  kHeapObjectTag);
4107  }
4108 
4109  static inline bool HasSmiTag(internal::Object* value) {
4110  return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
4111  }
4112 
4113  static inline int SmiValue(internal::Object* value) {
4114  return PlatformSmiTagging::SmiToInt(value);
4115  }
4116 
4117  static inline int GetInstanceType(internal::Object* obj) {
4118  typedef internal::Object O;
4119  O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
4120  return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
4121  }
4122 
4123  static inline int GetOddballKind(internal::Object* obj) {
4124  typedef internal::Object O;
4125  return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
4126  }
4127 
4128  static inline void* GetExternalPointerFromSmi(internal::Object* value) {
4129  const uintptr_t address = reinterpret_cast<uintptr_t>(value);
4130  return reinterpret_cast<void*>(address >> kPointerToSmiShift);
4131  }
4132 
4133  static inline void* GetExternalPointer(internal::Object* obj) {
4134  if (HasSmiTag(obj)) {
4135  return GetExternalPointerFromSmi(obj);
4136  } else if (GetInstanceType(obj) == kForeignType) {
4137  return ReadField<void*>(obj, kForeignAddressOffset);
4138  } else {
4139  return NULL;
4140  }
4141  }
4142 
4143  static inline bool IsExternalTwoByteString(int instance_type) {
4144  int representation = (instance_type & kFullStringRepresentationMask);
4145  return representation == kExternalTwoByteRepresentationTag;
4146  }
4147 
4148  static inline bool IsInitialized(v8::Isolate* isolate) {
4149  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset;
4150  return *reinterpret_cast<int*>(addr) == 1;
4151  }
4152 
4153  static inline void SetEmbedderData(v8::Isolate* isolate, void* data) {
4154  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
4156  *reinterpret_cast<void**>(addr) = data;
4157  }
4158 
4159  static inline void* GetEmbedderData(v8::Isolate* isolate) {
4160  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
4162  return *reinterpret_cast<void**>(addr);
4163  }
4164 
4165  static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) {
4166  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
4167  return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
4168  }
4169 
4170  template <typename T>
4171  static inline T ReadField(Object* ptr, int offset) {
4172  uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
4173  return *reinterpret_cast<T*>(addr);
4174  }
4175 
4176  static inline bool CanCastToHeapObject(void* o) { return false; }
4177  static inline bool CanCastToHeapObject(Context* o) { return true; }
4178  static inline bool CanCastToHeapObject(String* o) { return true; }
4179  static inline bool CanCastToHeapObject(Object* o) { return true; }
4180  static inline bool CanCastToHeapObject(Message* o) { return true; }
4181  static inline bool CanCastToHeapObject(StackTrace* o) { return true; }
4182  static inline bool CanCastToHeapObject(StackFrame* o) { return true; }
4183 };
4184 
4185 } // namespace internal
4186 
4187 
4188 template <class T>
4190 
4191 
4192 template <class T>
4194  if (that.IsEmpty()) return Local<T>();
4195  T* that_ptr = *that;
4196  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
4198  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
4199  reinterpret_cast<internal::HeapObject*>(*p))));
4200  }
4201  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
4202 }
4203 
4204 
4205 template <class T>
4207  if (that.IsEmpty()) return Persistent<T>();
4208  internal::Object** p = reinterpret_cast<internal::Object**>(*that);
4209  return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p)));
4210 }
4211 
4212 
4213 template <class T>
4215  if (this->IsEmpty()) return false;
4216  return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this));
4217 }
4218 
4219 
4220 template <class T>
4222  if (this->IsEmpty()) return false;
4223  return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this));
4224 }
4225 
4226 
4227 template <class T>
4229  if (this->IsEmpty()) return false;
4230  return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this));
4231 }
4232 
4233 
4234 template <class T>
4236  if (this->IsEmpty()) return;
4237  V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this));
4238 }
4239 
4240 
4241 template <class T>
4243 
4244 template <class T>
4245 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
4246  V8::MakeWeak(reinterpret_cast<internal::Object**>(**this),
4247  parameters,
4248  callback);
4249 }
4250 
4251 template <class T>
4253  V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
4254 }
4255 
4256 template <class T>
4258  V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this));
4259 }
4260 
4261 template <class T>
4263  V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id);
4264 }
4265 
4266 template <class T>
4268  return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this));
4269 }
4270 
4271 Arguments::Arguments(internal::Object** implicit_args,
4272  internal::Object** values, int length,
4273  bool is_construct_call)
4274  : implicit_args_(implicit_args),
4275  values_(values),
4276  length_(length),
4277  is_construct_call_(is_construct_call) { }
4278 
4279 
4281  if (i < 0 || length_ <= i) return Local<Value>(*Undefined());
4282  return Local<Value>(reinterpret_cast<Value*>(values_ - i));
4283 }
4284 
4285 
4287  return Local<Function>(reinterpret_cast<Function*>(
4288  &implicit_args_[kCalleeIndex]));
4289 }
4290 
4291 
4293  return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
4294 }
4295 
4296 
4298  return Local<Object>(reinterpret_cast<Object*>(
4299  &implicit_args_[kHolderIndex]));
4300 }
4301 
4302 
4304  return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
4305 }
4306 
4307 
4309  return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
4310 }
4311 
4312 
4314  return is_construct_call_;
4315 }
4316 
4317 
4318 int Arguments::Length() const {
4319  return length_;
4320 }
4321 
4322 
4323 template <class T>
4325  internal::Object** before = reinterpret_cast<internal::Object**>(*value);
4326  internal::Object** after = RawClose(before);
4327  return Local<T>(reinterpret_cast<T*>(after));
4328 }
4329 
4331  return resource_name_;
4332 }
4333 
4334 
4336  return resource_line_offset_;
4337 }
4338 
4339 
4341  return resource_column_offset_;
4342 }
4343 
4344 
4346  return value ? True() : False();
4347 }
4348 
4349 
4350 void Template::Set(const char* name, v8::Handle<Data> value) {
4351  Set(v8::String::New(name), value);
4352 }
4353 
4354 
4356 #ifndef V8_ENABLE_CHECKS
4357  Local<Value> quick_result = UncheckedGetInternalField(index);
4358  if (!quick_result.IsEmpty()) return quick_result;
4359 #endif
4360  return CheckedGetInternalField(index);
4361 }
4362 
4363 
4364 Local<Value> Object::UncheckedGetInternalField(int index) {
4365  typedef internal::Object O;
4366  typedef internal::Internals I;
4367  O* obj = *reinterpret_cast<O**>(this);
4368  if (I::GetInstanceType(obj) == I::kJSObjectType) {
4369  // If the object is a plain JSObject, which is the common case,
4370  // we know where to find the internal fields and can return the
4371  // value directly.
4372  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
4373  O* value = I::ReadField<O*>(obj, offset);
4374  O** result = HandleScope::CreateHandle(value);
4375  return Local<Value>(reinterpret_cast<Value*>(result));
4376  } else {
4377  return Local<Value>();
4378  }
4379 }
4380 
4381 
4383 #ifdef V8_ENABLE_CHECKS
4384  return FullUnwrap(obj);
4385 #else
4386  return QuickUnwrap(obj);
4387 #endif
4388 }
4389 
4390 
4391 void* External::QuickUnwrap(Handle<v8::Value> wrapper) {
4392  typedef internal::Object O;
4393  O* obj = *reinterpret_cast<O**>(const_cast<v8::Value*>(*wrapper));
4395 }
4396 
4397 
4399  typedef internal::Object O;
4400  typedef internal::Internals I;
4401 
4402  O* obj = *reinterpret_cast<O**>(this);
4403 
4404  if (I::GetInstanceType(obj) == I::kJSObjectType) {
4405  // If the object is a plain JSObject, which is the common case,
4406  // we know where to find the internal fields and can return the
4407  // value directly.
4408  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
4409  O* value = I::ReadField<O*>(obj, offset);
4410  return I::GetExternalPointer(value);
4411  }
4412 
4413  return SlowGetPointerFromInternalField(index);
4414 }
4415 
4416 
4418 #ifdef V8_ENABLE_CHECKS
4419  CheckCast(value);
4420 #endif
4421  return static_cast<String*>(value);
4422 }
4423 
4424 
4426  typedef internal::Object* S;
4427  typedef internal::Internals I;
4428  if (!I::IsInitialized(isolate)) return Empty();
4429  S* slot = I::GetRoot(isolate, I::kEmptySymbolRootIndex);
4430  return Local<String>(reinterpret_cast<String*>(slot));
4431 }
4432 
4433 
4435  typedef internal::Object O;
4436  typedef internal::Internals I;
4437  O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
4439  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
4440  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
4441  result = reinterpret_cast<String::ExternalStringResource*>(value);
4442  } else {
4443  result = NULL;
4444  }
4445 #ifdef V8_ENABLE_CHECKS
4446  VerifyExternalStringResource(result);
4447 #endif
4448  return result;
4449 }
4450 
4451 
4453  String::Encoding* encoding_out) const {
4454  typedef internal::Object O;
4455  typedef internal::Internals I;
4456  O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
4457  int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
4458  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
4459  ExternalStringResourceBase* resource = NULL;
4460  if (type == I::kExternalAsciiRepresentationTag ||
4461  type == I::kExternalTwoByteRepresentationTag) {
4462  void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
4463  resource = static_cast<ExternalStringResourceBase*>(value);
4464  }
4465 #ifdef V8_ENABLE_CHECKS
4466  VerifyExternalStringResourceBase(resource, *encoding_out);
4467 #endif
4468  return resource;
4469 }
4470 
4471 
4472 bool Value::IsUndefined() const {
4473 #ifdef V8_ENABLE_CHECKS
4474  return FullIsUndefined();
4475 #else
4476  return QuickIsUndefined();
4477 #endif
4478 }
4479 
4480 bool Value::QuickIsUndefined() const {
4481  typedef internal::Object O;
4482  typedef internal::Internals I;
4483  O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this));
4484  if (!I::HasHeapObjectTag(obj)) return false;
4485  if (I::GetInstanceType(obj) != I::kOddballType) return false;
4486  return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
4487 }
4488 
4489 
4490 bool Value::IsNull() const {
4491 #ifdef V8_ENABLE_CHECKS
4492  return FullIsNull();
4493 #else
4494  return QuickIsNull();
4495 #endif
4496 }
4497 
4498 bool Value::QuickIsNull() const {
4499  typedef internal::Object O;
4500  typedef internal::Internals I;
4501  O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this));
4502  if (!I::HasHeapObjectTag(obj)) return false;
4503  if (I::GetInstanceType(obj) != I::kOddballType) return false;
4504  return (I::GetOddballKind(obj) == I::kNullOddballKind);
4505 }
4506 
4507 
4508 bool Value::IsString() const {
4509 #ifdef V8_ENABLE_CHECKS
4510  return FullIsString();
4511 #else
4512  return QuickIsString();
4513 #endif
4514 }
4515 
4516 bool Value::QuickIsString() const {
4517  typedef internal::Object O;
4518  typedef internal::Internals I;
4519  O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this));
4520  if (!I::HasHeapObjectTag(obj)) return false;
4521  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
4522 }
4523 
4524 
4526 #ifdef V8_ENABLE_CHECKS
4527  CheckCast(value);
4528 #endif
4529  return static_cast<Number*>(value);
4530 }
4531 
4532 
4534 #ifdef V8_ENABLE_CHECKS
4535  CheckCast(value);
4536 #endif
4537  return static_cast<Integer*>(value);
4538 }
4539 
4540 
4542 #ifdef V8_ENABLE_CHECKS
4543  CheckCast(value);
4544 #endif
4545  return static_cast<Date*>(value);
4546 }
4547 
4548 
4550 #ifdef V8_ENABLE_CHECKS
4551  CheckCast(value);
4552 #endif
4553  return static_cast<StringObject*>(value);
4554 }
4555 
4556 
4558 #ifdef V8_ENABLE_CHECKS
4559  CheckCast(value);
4560 #endif
4561  return static_cast<NumberObject*>(value);
4562 }
4563 
4564 
4566 #ifdef V8_ENABLE_CHECKS
4567  CheckCast(value);
4568 #endif
4569  return static_cast<BooleanObject*>(value);
4570 }
4571 
4572 
4574 #ifdef V8_ENABLE_CHECKS
4575  CheckCast(value);
4576 #endif
4577  return static_cast<RegExp*>(value);
4578 }
4579 
4580 
4582 #ifdef V8_ENABLE_CHECKS
4583  CheckCast(value);
4584 #endif
4585  return static_cast<Object*>(value);
4586 }
4587 
4588 
4590 #ifdef V8_ENABLE_CHECKS
4591  CheckCast(value);
4592 #endif
4593  return static_cast<Array*>(value);
4594 }
4595 
4596 
4598 #ifdef V8_ENABLE_CHECKS
4599  CheckCast(value);
4600 #endif
4601  return static_cast<Function*>(value);
4602 }
4603 
4604 
4606 #ifdef V8_ENABLE_CHECKS
4607  CheckCast(value);
4608 #endif
4609  return static_cast<External*>(value);
4610 }
4611 
4612 
4614  return *reinterpret_cast<Isolate**>(&args_[-3]);
4615 }
4616 
4617 
4619  return Local<Value>(reinterpret_cast<Value*>(&args_[-2]));
4620 }
4621 
4622 
4624  return Local<Object>(reinterpret_cast<Object*>(&args_[0]));
4625 }
4626 
4627 
4629  return Local<Object>(reinterpret_cast<Object*>(&args_[-1]));
4630 }
4631 
4632 
4634  typedef internal::Object* S;
4635  typedef internal::Internals I;
4636  if (!I::IsInitialized(isolate)) return Undefined();
4637  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
4638  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
4639 }
4640 
4641 
4643  typedef internal::Object* S;
4644  typedef internal::Internals I;
4645  if (!I::IsInitialized(isolate)) return Null();
4646  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
4647  return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
4648 }
4649 
4650 
4652  typedef internal::Object* S;
4653  typedef internal::Internals I;
4654  if (!I::IsInitialized(isolate)) return True();
4655  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
4656  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
4657 }
4658 
4659 
4661  typedef internal::Object* S;
4662  typedef internal::Internals I;
4663  if (!I::IsInitialized(isolate)) return False();
4664  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
4665  return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
4666 }
4667 
4668 
4669 void Isolate::SetData(void* data) {
4670  typedef internal::Internals I;
4671  I::SetEmbedderData(this, data);
4672 }
4673 
4674 
4676  typedef internal::Internals I;
4677  return I::GetEmbedderData(this);
4678 }
4679 
4680 
4693 } // namespace v8
4694 
4695 
4696 #undef V8EXPORT
4697 #undef TYPE_CHECK
4698 
4699 
4700 #endif // V8_H_
Handle< S > As()
Definition: v8.h:253
void MakeWeak(void *parameters, WeakReferenceCallback callback)
Definition: v8.h:4245
virtual v8::Handle< v8::FunctionTemplate > GetNativeFunction(v8::Handle< v8::String > name)
Definition: v8.h:2570
Local< S > As()
Definition: v8.h:291
Handle< Array >(* NamedPropertyEnumerator)(const AccessorInfo &info)
Definition: v8.h:2086
const char * operator*() const
Definition: v8.h:1330
V8EXPORT int Length() const
Definition: api.cc:3741
V8EXPORT double NumberValue() const
Definition: api.cc:2555
void(* GCCallback)()
Definition: v8.h:2762
static Object * Cast(Value *obj)
Definition: v8.h:4581
static bool IsExternalTwoByteString(int instance_type)
Definition: v8.h:4143
virtual void VisitPersistentHandle(Persistent< Value > value, uint16_t class_id)
Definition: v8.h:3036
V8EXPORT int WriteUtf8(char *buffer, int length=-1, int *nchars_ref=NULL, int options=NO_OPTIONS) const
Definition: api.cc:3852
const intptr_t kSmiTagMask
Definition: v8.h:4016
V8EXPORT bool HasRealIndexedProperty(uint32_t index)
Definition: api.cc:3144
void(* MemoryAllocationCallback)(ObjectSpace space, AllocationAction action, int size)
Definition: v8.h:2719
void set_max_young_space_size(int value)
Definition: v8.h:2638
static const int kExternalAsciiRepresentationTag
Definition: v8.h:4085
V8EXPORT bool BooleanValue() const
Definition: api.cc:5001
V8EXPORT bool IsTrue() const
Definition: api.cc:2143
V8EXPORT uint8_t * GetIndexedPropertiesPixelData()
Definition: api.cc:3435
const char * data
Definition: v8.h:2899
char * operator*()
Definition: v8.h:1306
V8EXPORT bool DeleteHiddenValue(Handle< String > key)
Definition: api.cc:3336
Handle< Boolean > V8EXPORT True()
Definition: api.cc:569
V8EXPORT Local< String > GetSource() const
Definition: api.cc:5125
V8EXPORT const ExternalAsciiStringResource * GetExternalAsciiStringResource() const
Definition: api.cc:4122
static Date * Cast(v8::Value *obj)
Definition: v8.h:4541
void(* CallCompletedCallback)()
Definition: v8.h:2724
Handle< Value >(* NamedPropertySetter)(Local< String > property, Local< Value > value, const AccessorInfo &info)
Definition: v8.h:2061
void Dispose()
Definition: v8.h:4235
#define I(name, number_of_args, result_size)
Definition: runtime.cc:13224
const int kPointerToSmiShift
Definition: v8.h:4064
ScriptOrigin(Handle< Value > resource_name, Handle< Integer > resource_line_offset=Handle< Integer >(), Handle< Integer > resource_column_offset=Handle< Integer >())
Definition: v8.h:578
Definition: v8.h:3044
void * GetData()
Definition: v8.h:4675
static bool IsInitialized(v8::Isolate *isolate)
Definition: v8.h:4148
V8EXPORT Local< Object > CloneElementAt(uint32_t index)
Definition: api.cc:5181
Definition: v8.h:869
V8EXPORT bool StrictEquals(Handle< Value > that) const
Definition: api.cc:2711
Local< Object > Holder() const
Definition: v8.h:4297
bool IsIndependent() const
Definition: v8.h:4214
V8EXPORT Local< Value > Get(Handle< Value > key)
Definition: api.cc:2853
virtual ~PersistentHandleVisitor()
Definition: v8.h:3035
bool operator!=(Handle< S > that) const
Definition: v8.h:240
static const int kOddballKindOffset
Definition: v8.h:4079
virtual ~OutputStream()
Definition: v8.h:3957
Handle< Integer > ResourceLineOffset() const
Definition: v8.h:4335
V8EXPORT bool IsNativeError() const
Definition: api.cc:2279
void V8EXPORT RegisterExtension(Extension *extension)
Definition: api.cc:526
V8EXPORT PropertyAttribute GetPropertyAttributes(Handle< Value > key)
Definition: api.cc:2880
V8EXPORT Local< Array > GetOwnPropertyNames()
Definition: api.cc:2967
StackTraceOptions
Definition: v8.h:769
V8EXPORT bool IsBooleanObject() const
Definition: api.cc:2298
ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:4452
bool auto_enable()
Definition: v8.h:2581
static const int kFirstNonstringType
Definition: v8.h:4097
static const int kNullValueRootIndex
Definition: v8.h:4091
static Array * Cast(Value *obj)
Definition: v8.h:4589
static V8EXPORT Local< String > New(const char *data, int length=-1)
Definition: api.cc:4779
Local< Function > Callee() const
Definition: v8.h:4286
const int kSmiValueSize
Definition: v8.h:4061
Local< Object > This() const
Definition: v8.h:4623
void * new_code_start
Definition: v8.h:2998
V8EXPORT bool IsExternal() const
Definition: api.cc:2197
bool(* IndexedSecurityCallback)(Local< Object > host, uint32_t index, AccessType type, Local< Value > data)
Definition: v8.h:2154
static V8EXPORT Local< String > NewSymbol(const char *data, int length=-1)
Definition: api.cc:5203
V8EXPORT Local< String > GetConstructorName()
Definition: api.cc:3053
V8EXPORT Local< Int32 > ToInt32() const
Definition: api.cc:2597
size_t used_heap_size()
Definition: v8.h:2776
static bool CanCastToHeapObject(String *o)
Definition: v8.h:4178
Handle< Primitive > V8EXPORT Null()
Definition: api.cc:559
Definition: v8.h:512
V8EXPORT Local< Context > CreationContext()
Definition: api.cc:3284
WriteOptions
Definition: v8.h:1075
Encoding
Definition: v8.h:1026
int int32_t
Definition: unicode.cc:47
void * GetPointerFromInternalField(int index)
Definition: v8.h:4398
void(* MessageCallback)(Handle< Message > message, Handle< Value > error)
Definition: v8.h:2663
V8EXPORT bool HasRealNamedCallbackProperty(Handle< String > key)
Definition: api.cc:3152
V8EXPORT Local< Value > GetHiddenValue(Handle< String > key)
Definition: api.cc:3322
static int SmiToInt(internal::Object *value)
Definition: v8.h:4040
static Handle< T > Cast(Handle< S > that)
Definition: v8.h:244
AllocationAction
Definition: v8.h:2713
int *(* CounterLookupCallback)(const char *name)
Definition: v8.h:2690
TickSample * sample
Handle< Object > SetAccessor(Handle< JSObject > obj, Handle< AccessorInfo > info)
Definition: handles.cc:342
#define S(x)
Definition: version.cc:55
V8EXPORT Local< Array > GetPropertyNames()
Definition: api.cc:2946
V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType()
Definition: api.cc:3505
V8EXPORT Local< Value > Call(Handle< Object > recv, int argc, Handle< Value > argv[])
Definition: api.cc:3652
V8EXPORT bool IsRegExp() const
Definition: api.cc:2306
static V8EXPORT const int kLineOffsetNotFound
Definition: v8.h:1801
void(* GCPrologueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:2759
V8EXPORT bool MayContainNonAscii() const
Definition: api.cc:3843
V8EXPORT Local< Number > ToNumber() const
Definition: api.cc:2390
CompressionAlgorithm
Definition: v8.h:2894
void Clear()
Definition: v8.h:214
ExternalArrayType
Definition: v8.h:1431
unsigned short uint16_t
Definition: unicode.cc:46
V8EXPORT void * GetIndexedPropertiesExternalArrayData()
Definition: api.cc:3492
size_t heap_size_limit()
Definition: v8.h:2777
V8EXPORT bool IsCallable()
Definition: api.cc:3548
Local< Value > Data() const
Definition: v8.h:4303
Handle< Value > ResourceName() const
Definition: v8.h:4330
static V8EXPORT Local< Value > Wrap(void *data)
Definition: api.cc:4707
Local< Value > GetInternalField(int index)
Definition: v8.h:4355
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:2660
bool IsNearDeath() const
Definition: v8.h:4221
V8EXPORT Local< String > ToString() const
Definition: api.cc:2313
char * operator*()
Definition: v8.h:1329
const uint16_t * operator*() const
Definition: v8.h:1352
Handle< Value >(* IndexedPropertySetter)(uint32_t index, Local< Value > value, const AccessorInfo &info)
Definition: v8.h:2101
static const int kStringResourceOffset
Definition: v8.h:4077
int length() const
Definition: v8.h:1353
V8EXPORT Local< Value > CallAsConstructor(int argc, Handle< Value > argv[])
Definition: api.cc:3591
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
V8EXPORT bool CanMakeExternal()
Definition: api.cc:4944
V8EXPORT bool IsDirty()
Definition: api.cc:3251
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
Definition: api.cc:902
Local(S *that)
Definition: v8.h:281
static const int kJSObjectHeaderSize
Definition: v8.h:4081
static Function * Cast(Value *obj)
Definition: v8.h:4597
V8EXPORT Handle< Value > GetName() const
Definition: api.cc:3685
static int SmiToInt(internal::Object *value)
Definition: v8.h:4024
static V8EXPORT Local< String > NewUndetectable(const char *data, int length=-1)
Definition: api.cc:4806
static void * Unwrap(Handle< Value > obj)
Definition: v8.h:4382
V8EXPORT void SetIndexedPropertiesToExternalArrayData(void *data, ExternalArrayType array_type, int number_of_elements)
Definition: api.cc:3460
const intptr_t kHeapObjectTagMask
Definition: v8.h:4011
V8EXPORT Local< Uint32 > ToUint32() const
Definition: api.cc:2615
V8EXPORT bool Equals(Handle< Value > that) const
Definition: api.cc:2684
V8EXPORT Handle< Value > GetScriptId() const
Definition: api.cc:3733
static Number * Cast(v8::Value *obj)
Definition: v8.h:4525
V8EXPORT Local< Value > GetConstructor()
Definition: api.cc:3042
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:2727
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8.h:3622
V8EXPORT bool IsExternal() const
Definition: api.cc:4064
V8EXPORT bool HasIndexedPropertiesInExternalArrayData()
Definition: api.cc:3483
static void * GetExternalPointer(internal::Object *obj)
Definition: v8.h:4133
V8EXPORT void SetInternalField(int index, Handle< Value > value)
Definition: api.cc:4214
V8EXPORT void SetPointerInInternalField(int index, void *value)
Definition: api.cc:4248
static V8EXPORT Local< Integer > NewFromUnsigned(uint32_t value)
Definition: api.cc:5235
Local< Object > Holder() const
Definition: v8.h:4628
Handle< Value >(* IndexedPropertyGetter)(uint32_t index, const AccessorInfo &info)
Definition: v8.h:2093
V8EXPORT Local< Value > GetRealNamedProperty(Handle< String > key)
Definition: api.cc:3217
V8EXPORT bool IsExternalAscii() const
Definition: api.cc:4074
T * operator*() const
Definition: v8.h:218
V8EXPORT bool IsStringObject() const
Definition: api.cc:2247
V8EXPORT bool MakeExternal(ExternalStringResource *resource)
Definition: api.cc:4884
V8EXPORT ScriptOrigin GetScriptOrigin() const
Definition: api.cc:3697
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
Definition: v8.h:2965
bool IsWeak() const
Definition: v8.h:4228
bool IsNull() const
Definition: v8.h:4490
V8EXPORT bool IsUint32() const
Definition: api.cc:2222
HANDLE HANDLE LPSTACKFRAME64 StackFrame
Persistent(S *that)
Definition: v8.h:349
V8EXPORT int InternalFieldCount()
Definition: api.cc:4185
static bool HasSmiTag(internal::Object *value)
Definition: v8.h:4109
Handle< Value >(* InvocationCallback)(const Arguments &args)
Definition: v8.h:2047
Handle< Value >(* NamedPropertyGetter)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:2053
int max_old_space_size() const
Definition: v8.h:2639
V8EXPORT void * Value() const
Definition: api.cc:4762
V8EXPORT Local< String > ObjectProtoToString()
Definition: api.cc:2988
static V8EXPORT void DateTimeConfigurationChangeNotification()
Definition: api.cc:5062
void *(* CreateHistogramCallback)(const char *name, int min, int max, size_t buckets)
Definition: v8.h:2692
void set_max_old_space_size(int value)
Definition: v8.h:2640
V8EXPORT bool HasIndexedPropertiesInPixelData()
Definition: api.cc:3427
int max_young_space_size() const
Definition: v8.h:2637
static const int kIsolateStateOffset
Definition: v8.h:4087
const char * operator*() const
Definition: v8.h:1307
Handle< Integer >(* NamedPropertyQuery)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:2070
static const int kMapInstanceTypeOffset
Definition: v8.h:4076
virtual int GetChunkSize()
Definition: v8.h:3961
V8EXPORT Local< Value > GetPrototype()
Definition: api.cc:2900
EventType type
Definition: v8.h:2982
V8EXPORT bool ForceDelete(Handle< Value > key)
Definition: api.cc:2829
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Definition: v8.h:2737
int compressed_size
Definition: v8.h:2900
V8EXPORT int Utf8Length() const
Definition: api.cc:3748
bool operator==(Handle< S > that) const
Definition: v8.h:226
Handle()
Definition: v8.h:179
uint16_t WrapperClassId() const
Definition: v8.h:4267
const int kHeapObjectTag
Definition: v8.h:4009
V8EXPORT bool HasIndexedLookupInterceptor()
Definition: api.cc:3171
Handle< Integer >(* IndexedPropertyQuery)(uint32_t index, const AccessorInfo &info)
Definition: v8.h:2110
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:2950
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
int Length() const
Definition: v8.h:4318
const char * name() const
Definition: v8.h:2574
V8EXPORT int32_t Int32Value() const
Definition: api.cc:2662
void(* AccessorSetter)(Local< String > property, Local< Value > value, const AccessorInfo &info)
Definition: v8.h:1452
V8EXPORT bool IsBoolean() const
Definition: api.cc:2189
V8EXPORT Local< Object > NewInstance() const
Definition: api.cc:3628
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
Definition: v8.h:3975
int raw_size
Definition: v8.h:2901
V8EXPORT void SetIndexedPropertiesToPixelData(uint8_t *data, int length)
Definition: api.cc:3407
V8EXPORT void TurnOnAccessCheck()
Definition: api.cc:3233
#define TYPE_CHECK(T, S)
Definition: v8.h:144
static RegExp * Cast(v8::Value *obj)
Definition: v8.h:4573
V8EXPORT int GetScriptColumnNumber() const
Definition: api.cc:3724
void Enter()
Definition: api.cc:5543
GCType
Definition: v8.h:2748
V8EXPORT bool Has(Handle< String > key)
Definition: api.cc:3075
void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:4262
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:2697
V8EXPORT bool SetHiddenValue(Handle< String > key, Handle< Value > value)
Definition: api.cc:3305
void set_stack_limit(uint32_t *value)
Definition: v8.h:2645
static Persistent< T > New(Handle< T > that)
Definition: v8.h:4206
static void * GetEmbedderData(v8::Isolate *isolate)
Definition: v8.h:4159
static int SmiValue(internal::Object *value)
Definition: v8.h:4113
V8EXPORT Local< String > ToDetailString() const
Definition: api.cc:2333
static const int kUndefinedValueRootIndex
Definition: v8.h:4090
AccessType
Definition: v8.h:2131
static const int kOddballType
Definition: v8.h:4098
int max_executable_size()
Definition: v8.h:2641
static Local< T > New(Handle< T > that)
Definition: v8.h:4193
static String * Cast(v8::Value *obj)
Definition: v8.h:4417
V8EXPORT bool HasNamedLookupInterceptor()
Definition: api.cc:3163
Definition: v8.h:105
V8EXPORT bool BooleanValue() const
Definition: api.cc:2540
static External * Cast(Value *obj)
Definition: v8.h:4605
uint32_t * stack_limit() const
Definition: v8.h:2643
virtual ~ActivityControl()
Definition: v8.h:3991
Persistent()
Definition: v8.h:4242
V8EXPORT bool SetPrototype(Handle< Value > prototype)
Definition: api.cc:2911
static Integer * Cast(v8::Value *obj)
Definition: v8.h:4533
static void SetEmbedderData(v8::Isolate *isolate, void *data)
Definition: v8.h:4153
bool IsUndefined() const
Definition: v8.h:4472
void(* WeakReferenceCallback)(Persistent< Value > object, void *parameter)
Definition: v8.h:138
V8EXPORT bool IsFunction() const
Definition: api.cc:2155
static const int kFalseValueRootIndex
Definition: v8.h:4093
Handle< Boolean > V8EXPORT False()
Definition: api.cc:579
Definition: v8.h:598
static bool CanCastToHeapObject(Context *o)
Definition: v8.h:4177
Local()
Definition: v8.h:4189
ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:4434
Local< Object > This() const
Definition: v8.h:4292
#define T(name, string, precedence)
Definition: token.cc:48
Definition: v8.h:1744
V8EXPORT int64_t IntegerValue() const
Definition: api.cc:2575
bool IsString() const
Definition: v8.h:4508
static Local< T > Cast(Local< S > that)
Definition: v8.h:282
V8EXPORT bool IsObject() const
Definition: api.cc:2177
void(* GCEpilogueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:2760
V8EXPORT void SetName(Handle< String > name)
Definition: api.cc:3676
Definition: v8.h:1425
V8EXPORT double Value() const
Definition: api.cc:4138
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:3017
static V8EXPORT v8::Local< v8::String > Empty()
Definition: api.cc:4769
int dependency_count()
Definition: v8.h:2578
V8EXPORT Local< Value > CallAsFunction(Handle< Object > recv, int argc, Handle< Value > argv[])
Definition: api.cc:3559
const int kApiIntSize
Definition: v8.h:4006
V8EXPORT bool IsDate() const
Definition: api.cc:2239
const int kApiPointerSize
Definition: v8.h:4005
Local(Local< S > that)
Definition: v8.h:272
Handle< Integer > ResourceColumnOffset() const
Definition: v8.h:4340
AccessorInfo(internal::Object **args)
Definition: v8.h:2035
static internal::Object ** CreateHandle(internal::Object *value)
Definition: api.cc:730
V8EXPORT int GetIndexedPropertiesExternalArrayDataLength()
Definition: api.cc:3535
V8EXPORT uint32_t Uint32Value() const
Definition: api.cc:2743
DeclareExtension(Extension *extension)
Definition: v8.h:2605
virtual ~Extension()
Definition: v8.h:2568
Local< Value > operator[](int i) const
Definition: v8.h:4280
uint16_t * operator*()
Definition: v8.h:1351
static void * GetExternalPointerFromSmi(internal::Object *value)
Definition: v8.h:4128
static const int kHeapObjectMapOffset
Definition: v8.h:4075
struct v8::JitCodeEvent::@0::@2 name
static const int kEmptySymbolRootIndex
Definition: v8.h:4094
V8EXPORT bool IsNumber() const
Definition: api.cc:2183
int length() const
Definition: v8.h:1308
Persistent(Persistent< S > that)
Definition: v8.h:339
const String::ExternalAsciiStringResource * source() const
Definition: v8.h:2576
static T ReadField(Object *ptr, int offset)
Definition: v8.h:4171
V8EXPORT Local< String > StringValue() const
Definition: api.cc:5022
V8EXPORT bool ForceSet(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:2807
V8EXPORT bool Delete(Handle< String > key)
Definition: api.cc:3064
static bool CanCastToHeapObject(StackTrace *o)
Definition: v8.h:4181
ExternalAsciiStringResourceImpl(const char *data, size_t length)
Definition: v8.h:2546
Persistent< S > As()
Definition: v8.h:367
const intptr_t kPointerAlignment
Definition: v8globals.h:48
V8EXPORT Local< Object > Clone()
Definition: api.cc:3256
const int kSmiShiftSize
Definition: v8.h:4060
const int kSmiTagSize
Definition: v8.h:4015
V8EXPORT bool SetAccessor(Handle< String > name, AccessorGetter getter, AccessorSetter setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None)
Definition: api.cc:3104
static const int kFullStringRepresentationMask
Definition: v8.h:4082
size_t len
Definition: v8.h:2995
virtual void VisitExternalString(Handle< String > string)
Definition: v8.h:3026
V8EXPORT int GetIndexedPropertiesPixelDataLength()
Definition: api.cc:3448
bool(* NamedSecurityCallback)(Local< Object > host, Local< Value > key, AccessType type, Local< Value > data)
Definition: v8.h:2144
V8EXPORT bool IsFalse() const
Definition: api.cc:2149
V8EXPORT Flags GetFlags() const
Definition: api.cc:5145
virtual ~ScriptData()
Definition: v8.h:526
static Persistent< T > Cast(Persistent< S > that)
Definition: v8.h:358
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:2934
static NumberObject * Cast(v8::Value *obj)
Definition: v8.h:4557
Definition: v8.h:1812
static V8EXPORT Local< Integer > New(int32_t value)
Definition: api.cc:5228
V8EXPORT int GetScriptLineNumber() const
Definition: api.cc:3714
void set_auto_enable(bool value)
Definition: v8.h:2580
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
const int kSmiTag
Definition: v8.h:4014
V8EXPORT int64_t Value() const
Definition: api.cc:4152
#define V8EXPORT
Definition: v8.h:74
Local< T > Close(Handle< T > value)
Definition: v8.h:4324
V8EXPORT bool IsNumberObject() const
Definition: api.cc:2255
static bool CanCastToHeapObject(void *o)
Definition: v8.h:4176
static const int kUndefinedOddballKind
Definition: v8.h:4101
V8EXPORT int WriteAscii(char *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
Definition: api.cc:3984
static int GetOddballKind(internal::Object *obj)
Definition: v8.h:4123
Persistent(Handle< S > that)
Definition: v8.h:355
const int kHeapObjectTagSize
Definition: v8.h:4010
Handle< Primitive > V8EXPORT Undefined()
Definition: api.cc:549
V8EXPORT Local< Value > GetRealNamedPropertyInPrototypeChain(Handle< String > key)
Definition: api.cc:3202
static V8EXPORT Local< Number > New(double value)
Definition: api.cc:5215
static bool CanCastToHeapObject(Message *o)
Definition: v8.h:4180
SmiTagging< kApiPointerSize > PlatformSmiTagging
Definition: v8.h:4059
ObjectSpace
Definition: v8.h:2700
bool IsEmpty() const
Definition: v8.h:209
const char * str
Definition: v8.h:2993
static V8EXPORT Local< String > Concat(Handle< String > left, Handle< String > right)
Definition: api.cc:4793
V8EXPORT double NumberValue() const
Definition: api.cc:4979
int length() const
Definition: v8.h:1331
V8EXPORT bool HasOwnProperty(Handle< String > key)
Definition: api.cc:3126
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
Definition: flags.cc:301
static const int kStringEncodingMask
Definition: v8.h:4083
Definition: v8.h:1405
GCCallbackFlags
Definition: v8.h:2754
Isolate * GetIsolate() const
Definition: v8.h:4613
V8EXPORT Local< Object > ToObject() const
Definition: api.cc:2353
V8EXPORT bool IsArray() const
Definition: api.cc:2171
const uintptr_t kEncodablePointerMask
Definition: v8.h:4062
V8EXPORT uint32_t Length() const
Definition: api.cc:5168
static int GetInstanceType(internal::Object *obj)
Definition: v8.h:4117
V8EXPORT Local< Boolean > ToBoolean() const
Definition: api.cc:2373
V8EXPORT Local< Integer > ToInteger() const
Definition: api.cc:2410
static const int kExternalTwoByteRepresentationTag
Definition: v8.h:4084
static const int kTrueValueRootIndex
Definition: v8.h:4092
static V8EXPORT Local< External > New(void *value)
Definition: api.cc:4752
Local< Value > Data() const
Definition: v8.h:4618
Handle< Boolean >(* IndexedPropertyDeleter)(uint32_t index, const AccessorInfo &info)
Definition: v8.h:2118
Isolate * GetIsolate() const
Definition: v8.h:4308
static BooleanObject * Cast(v8::Value *obj)
Definition: v8.h:4565
V8EXPORT bool IsInt32() const
Definition: api.cc:2205
V8EXPORT bool HasRealNamedProperty(Handle< String > key)
Definition: api.cc:3135
static bool HasHeapObjectTag(internal::Object *value)
Definition: v8.h:4104
static const int kForeignType
Definition: v8.h:4099
Scope(Isolate *isolate)
Definition: v8.h:2815
Scope(Handle< Context > context)
Definition: v8.h:3783
static Handle< Boolean > New(bool value)
Definition: v8.h:4345
size_t total_heap_size()
Definition: v8.h:2774
static const int kIsolateRootsOffset
Definition: v8.h:4089
static V8EXPORT Local< String > NewExternal(ExternalStringResource *resource)
Definition: api.cc:4871
bool V8EXPORT SetResourceConstraints(ResourceConstraints *constraints)
Definition: api.cc:596
V8EXPORT Handle< Value > GetInferredName() const
Definition: api.cc:3691
Handle(Handle< S > that)
Definition: v8.h:196
V8EXPORT Local< Object > FindInstanceInPrototypeChain(Handle< FunctionTemplate > tmpl)
Definition: api.cc:2928
const char * data() const
Definition: v8.h:2548
void ClearWeak()
Definition: v8.h:4252
void MarkIndependent()
Definition: v8.h:4257
size_t source_length() const
Definition: v8.h:2575
static StringObject * Cast(v8::Value *obj)
Definition: v8.h:4549
T * operator->() const
Definition: v8.h:216
Handle< Value > V8EXPORT ThrowException(Handle< Value > exception)
Definition: api.cc:486
void SetData(void *data)
Definition: v8.h:4669
Handle(T *val)
Definition: v8.h:184
const char ** dependencies()
Definition: v8.h:2579
void * code_start
Definition: v8.h:2984
bool IsConstructCall() const
Definition: v8.h:4313
static const int kIsolateEmbedderDataOffset
Definition: v8.h:4088
Handle< Array >(* IndexedPropertyEnumerator)(const AccessorInfo &info)
Definition: v8.h:2125
static const int kNullOddballKind
Definition: v8.h:4102
V8EXPORT int32_t Value() const
Definition: api.cc:4163
Handle< Value >(* AccessorGetter)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:1448
Definition: v8.h:106
static bool CanCastToHeapObject(Object *o)
Definition: v8.h:4179
V8EXPORT int Write(uint16_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
Definition: api.cc:4035
static internal::Object ** GetRoot(v8::Isolate *isolate, int index)
Definition: v8.h:4165
AccessControl
Definition: v8.h:1470
PropertyAttribute
Definition: v8.h:1424
static bool CanCastToHeapObject(StackFrame *o)
Definition: v8.h:4182
virtual ~ExternalResourceVisitor()
Definition: v8.h:3025
size_t code_len
Definition: v8.h:2986
size_t total_heap_size_executable()
Definition: v8.h:2775
static V8EXPORT Local< Object > New()
Definition: api.cc:4957
V8EXPORT Local< Uint32 > ToArrayIndex() const
Definition: api.cc:2633
V8EXPORT uint32_t Value() const
Definition: api.cc:4174
const uint32_t kStringEncodingMask
Definition: objects.h:468
V8EXPORT int GetIdentityHash()
Definition: api.cc:3295
virtual OutputEncoding GetOutputEncoding()
Definition: v8.h:3963
static const int kJSObjectType
Definition: v8.h:4096
void set_max_executable_size(int value)
Definition: v8.h:2642
JitCodeEventOptions
Definition: v8.h:3005
Handle< Boolean >(* NamedPropertyDeleter)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:2079
V8EXPORT bool Value() const
Definition: api.cc:4145
V8EXPORT bool Set(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:2765
static const int kForeignAddressOffset
Definition: v8.h:4080
V8EXPORT double NumberValue() const
Definition: api.cc:5052