Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: include/v8.h

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « codereview.settings ('k') | include/v8-profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 private: 448 private:
449 friend class internal::GlobalHandles; 449 friend class internal::GlobalHandles;
450 WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter) 450 WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter)
451 : isolate_(isolate), handle_(handle), parameter_(parameter) { } 451 : isolate_(isolate), handle_(handle), parameter_(parameter) { }
452 Isolate* isolate_; 452 Isolate* isolate_;
453 Local<T> handle_; 453 Local<T> handle_;
454 P* parameter_; 454 P* parameter_;
455 }; 455 };
456 456
457 457
458 // TODO(dcarney): Remove this class.
459 template<typename T,
460 typename P,
461 typename M = NonCopyablePersistentTraits<T> >
462 class WeakReferenceCallbacks {
463 public:
464 typedef void (*Revivable)(Isolate* isolate,
465 Persistent<T, M>* object,
466 P* parameter);
467 };
468
469
470 /** 458 /**
471 * An object reference that is independent of any handle scope. Where 459 * An object reference that is independent of any handle scope. Where
472 * a Local handle only lives as long as the HandleScope in which it was 460 * a Local handle only lives as long as the HandleScope in which it was
473 * allocated, a PersistentBase handle remains valid until it is explicitly 461 * allocated, a PersistentBase handle remains valid until it is explicitly
474 * disposed. 462 * disposed.
475 * 463 *
476 * A persistent handle contains a reference to a storage cell within 464 * A persistent handle contains a reference to a storage cell within
477 * the v8 engine which holds an object value and which is updated by 465 * the v8 engine which holds an object value and which is updated by
478 * the garbage collector whenever the object is moved. A new storage 466 * the garbage collector whenever the object is moved. A new storage
479 * cell can be created using the constructor or PersistentBase::Reset and 467 * cell can be created using the constructor or PersistentBase::Reset and
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 682 }
695 /** 683 /**
696 * The destructor will dispose the Persistent based on the 684 * The destructor will dispose the Persistent based on the
697 * kResetInDestructor flags in the traits class. Since not calling dispose 685 * kResetInDestructor flags in the traits class. Since not calling dispose
698 * can result in a memory leak, it is recommended to always set this flag. 686 * can result in a memory leak, it is recommended to always set this flag.
699 */ 687 */
700 V8_INLINE ~Persistent() { 688 V8_INLINE ~Persistent() {
701 if (M::kResetInDestructor) this->Reset(); 689 if (M::kResetInDestructor) this->Reset();
702 } 690 }
703 691
704 V8_DEPRECATED("Use Reset instead",
705 V8_INLINE void Dispose()) { this->Reset(); }
706
707 // TODO(dcarney): this is pretty useless, fix or remove 692 // TODO(dcarney): this is pretty useless, fix or remove
708 template <class S> 693 template <class S>
709 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT 694 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
710 #ifdef V8_ENABLE_CHECKS 695 #ifdef V8_ENABLE_CHECKS
711 // If we're going to perform the type check then we have to check 696 // If we're going to perform the type check then we have to check
712 // that the handle isn't empty before doing the checked cast. 697 // that the handle isn't empty before doing the checked cast.
713 if (!that.IsEmpty()) T::Cast(*that); 698 if (!that.IsEmpty()) T::Cast(*that);
714 #endif 699 #endif
715 return reinterpret_cast<Persistent<T>&>(that); 700 return reinterpret_cast<Persistent<T>&>(that);
716 } 701 }
717 702
718 // TODO(dcarney): this is pretty useless, fix or remove 703 // TODO(dcarney): this is pretty useless, fix or remove
719 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT 704 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
720 return Persistent<S>::Cast(*this); 705 return Persistent<S>::Cast(*this);
721 } 706 }
722 707
723 template<typename S, typename P>
724 V8_DEPRECATED(
725 "Use SetWeak instead",
726 V8_INLINE void MakeWeak(
727 P* parameter,
728 typename WeakReferenceCallbacks<S, P>::Revivable callback));
729
730 template<typename P>
731 V8_DEPRECATED(
732 "Use SetWeak instead",
733 V8_INLINE void MakeWeak(
734 P* parameter,
735 typename WeakReferenceCallbacks<T, P>::Revivable callback));
736
737 // This will be removed. 708 // This will be removed.
738 V8_INLINE T* ClearAndLeak(); 709 V8_INLINE T* ClearAndLeak();
739 710
740 V8_DEPRECATED("This will be removed",
741 V8_INLINE void Clear()) { this->val_ = 0; }
742
743 // TODO(dcarney): remove 711 // TODO(dcarney): remove
744 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 712 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
745 713
746 private: 714 private:
747 #endif 715 #endif
748 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } 716 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
749 717
750 V8_INLINE T* operator*() const { return this->val_; } 718 V8_INLINE T* operator*() const { return this->val_; }
751 719
752 private: 720 private:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 * garbage collector will no longer track the object stored in the 813 * garbage collector will no longer track the object stored in the
846 * handle and may deallocate it. The behavior of accessing a handle 814 * handle and may deallocate it. The behavior of accessing a handle
847 * for which the handle scope has been deleted is undefined. 815 * for which the handle scope has been deleted is undefined.
848 */ 816 */
849 class V8_EXPORT HandleScope { 817 class V8_EXPORT HandleScope {
850 public: 818 public:
851 HandleScope(Isolate* isolate); 819 HandleScope(Isolate* isolate);
852 820
853 ~HandleScope(); 821 ~HandleScope();
854 822
855 template <class T>
856 V8_DEPRECATED("Use EscapableHandleScope::Escape instead",
857 Local<T> Close(Handle<T> value));
858
859 /** 823 /**
860 * Counts the number of allocated handles. 824 * Counts the number of allocated handles.
861 */ 825 */
862 static int NumberOfHandles(); 826 static int NumberOfHandles();
863 827
864 private: 828 private:
865 /** 829 /**
866 * Creates a new handle with the given value. 830 * Creates a new handle with the given value.
867 */ 831 */
868 static internal::Object** CreateHandle(internal::Isolate* isolate, 832 static internal::Object** CreateHandle(internal::Isolate* isolate,
(...skipping 18 matching lines...) Expand all
887 public: 851 public:
888 internal::Object** next; 852 internal::Object** next;
889 internal::Object** limit; 853 internal::Object** limit;
890 int level; 854 int level;
891 V8_INLINE void Initialize() { 855 V8_INLINE void Initialize() {
892 next = limit = NULL; 856 next = limit = NULL;
893 level = 0; 857 level = 0;
894 } 858 }
895 }; 859 };
896 860
897 void Leave();
898
899 internal::Isolate* isolate_; 861 internal::Isolate* isolate_;
900 internal::Object** prev_next_; 862 internal::Object** prev_next_;
901 internal::Object** prev_limit_; 863 internal::Object** prev_limit_;
902 864
903 // TODO(dcarney): remove this field
904 // Allow for the active closing of HandleScopes which allows to pass a handle
905 // from the HandleScope being closed to the next top most HandleScope.
906 bool is_closed_;
907 internal::Object** RawClose(internal::Object** value);
908
909 friend class ImplementationUtilities; 865 friend class ImplementationUtilities;
910 friend class EscapableHandleScope; 866 friend class EscapableHandleScope;
911 template<class F> friend class Handle; 867 template<class F> friend class Handle;
912 template<class F> friend class Local; 868 template<class F> friend class Local;
913 friend class Object; 869 friend class Object;
914 friend class Context; 870 friend class Context;
915 }; 871 };
916 872
917 873
918 /** 874 /**
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 /** 1094 /**
1139 * Runs the script returning the resulting value. If the script is 1095 * Runs the script returning the resulting value. If the script is
1140 * context independent (created using ::New) it will be run in the 1096 * context independent (created using ::New) it will be run in the
1141 * currently entered context. If it is context specific (created 1097 * currently entered context. If it is context specific (created
1142 * using ::Compile) it will be run in the context in which it was 1098 * using ::Compile) it will be run in the context in which it was
1143 * compiled. 1099 * compiled.
1144 */ 1100 */
1145 Local<Value> Run(); 1101 Local<Value> Run();
1146 1102
1147 /** 1103 /**
1148 * Returns the script id value.
1149 */
1150 V8_DEPRECATED("Use GetId instead", Local<Value> Id());
1151
1152 /**
1153 * Returns the script id. 1104 * Returns the script id.
1154 */ 1105 */
1155 int GetId(); 1106 int GetId();
1156 1107
1157 /** 1108 /**
1158 * Associate an additional data object with the script. This is mainly used 1109 * Associate an additional data object with the script. This is mainly used
1159 * with the debugger as this data object is only available through the 1110 * with the debugger as this data object is only available through the
1160 * debugger API. 1111 * debugger API.
1161 */ 1112 */
1162 void SetData(Handle<String> data); 1113 void SetData(Handle<String> data);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 int GetEndColumn() const; 1184 int GetEndColumn() const;
1234 1185
1235 /** 1186 /**
1236 * Passes on the value set by the embedder when it fed the script from which 1187 * Passes on the value set by the embedder when it fed the script from which
1237 * this Message was generated to V8. 1188 * this Message was generated to V8.
1238 */ 1189 */
1239 bool IsSharedCrossOrigin() const; 1190 bool IsSharedCrossOrigin() const;
1240 1191
1241 // TODO(1245381): Print to a string instead of on a FILE. 1192 // TODO(1245381): Print to a string instead of on a FILE.
1242 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); 1193 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1243 V8_DEPRECATED("Will be removed",
1244 static void PrintCurrentStackTrace(FILE* out));
1245 1194
1246 static const int kNoLineNumberInfo = 0; 1195 static const int kNoLineNumberInfo = 0;
1247 static const int kNoColumnInfo = 0; 1196 static const int kNoColumnInfo = 0;
1248 static const int kNoScriptIdInfo = 0; 1197 static const int kNoScriptIdInfo = 0;
1249 }; 1198 };
1250 1199
1251 1200
1252 /** 1201 /**
1253 * Representation of a JavaScript stack trace. The information collected is a 1202 * Representation of a JavaScript stack trace. The information collected is a
1254 * snapshot of the execution stack and the information remains valid after 1203 * snapshot of the execution stack and the information remains valid after
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 * Grab a snapshot of the current JavaScript execution stack. 1241 * Grab a snapshot of the current JavaScript execution stack.
1293 * 1242 *
1294 * \param frame_limit The maximum number of stack frames we want to capture. 1243 * \param frame_limit The maximum number of stack frames we want to capture.
1295 * \param options Enumerates the set of things we will capture for each 1244 * \param options Enumerates the set of things we will capture for each
1296 * StackFrame. 1245 * StackFrame.
1297 */ 1246 */
1298 static Local<StackTrace> CurrentStackTrace( 1247 static Local<StackTrace> CurrentStackTrace(
1299 Isolate* isolate, 1248 Isolate* isolate,
1300 int frame_limit, 1249 int frame_limit,
1301 StackTraceOptions options = kOverview); 1250 StackTraceOptions options = kOverview);
1302 V8_DEPRECATED("Will be removed",
1303 static Local<StackTrace> CurrentStackTrace(
1304 int frame_limit, StackTraceOptions options = kOverview));
1305 }; 1251 };
1306 1252
1307 1253
1308 /** 1254 /**
1309 * A single JavaScript stack frame. 1255 * A single JavaScript stack frame.
1310 */ 1256 */
1311 class V8_EXPORT StackFrame { 1257 class V8_EXPORT StackFrame {
1312 public: 1258 public:
1313 /** 1259 /**
1314 * Returns the number, 1-based, of the line for the associate function call. 1260 * Returns the number, 1-based, of the line for the associate function call.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1572
1627 1573
1628 /** 1574 /**
1629 * A primitive boolean value (ECMA-262, 4.3.14). Either the true 1575 * A primitive boolean value (ECMA-262, 4.3.14). Either the true
1630 * or false value. 1576 * or false value.
1631 */ 1577 */
1632 class V8_EXPORT Boolean : public Primitive { 1578 class V8_EXPORT Boolean : public Primitive {
1633 public: 1579 public:
1634 bool Value() const; 1580 bool Value() const;
1635 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); 1581 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
1636 V8_DEPRECATED("Will be removed",
1637 V8_INLINE static Handle<Boolean> New(bool value));
1638 }; 1582 };
1639 1583
1640 1584
1641 /** 1585 /**
1642 * A JavaScript string value (ECMA-262, 4.3.17). 1586 * A JavaScript string value (ECMA-262, 4.3.17).
1643 */ 1587 */
1644 class V8_EXPORT String : public Primitive { 1588 class V8_EXPORT String : public Primitive {
1645 public: 1589 public:
1646 enum Encoding { 1590 enum Encoding {
1647 UNKNOWN_ENCODING = 0x1, 1591 UNKNOWN_ENCODING = 0x1,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 V8_INLINE ExternalStringResource* GetExternalStringResource() const; 1777 V8_INLINE ExternalStringResource* GetExternalStringResource() const;
1834 1778
1835 /** 1779 /**
1836 * Get the ExternalAsciiStringResource for an external ASCII string. 1780 * Get the ExternalAsciiStringResource for an external ASCII string.
1837 * Returns NULL if IsExternalAscii() doesn't return true. 1781 * Returns NULL if IsExternalAscii() doesn't return true.
1838 */ 1782 */
1839 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; 1783 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
1840 1784
1841 V8_INLINE static String* Cast(v8::Value* obj); 1785 V8_INLINE static String* Cast(v8::Value* obj);
1842 1786
1843 /**
1844 * Allocates a new string from either UTF-8 encoded or ASCII data.
1845 * The second parameter 'length' gives the buffer length. If omitted,
1846 * the function calls 'strlen' to determine the buffer length.
1847 */
1848 V8_DEPRECATED(
1849 "Use NewFromUtf8 instead",
1850 V8_INLINE static Local<String> New(const char* data, int length = -1));
1851
1852 /** Allocates a new string from 16-bit character codes.*/
1853 V8_DEPRECATED(
1854 "Use NewFromTwoByte instead",
1855 V8_INLINE static Local<String> New(
1856 const uint16_t* data, int length = -1));
1857
1858 /**
1859 * Creates an internalized string (historically called a "symbol",
1860 * not to be confused with ES6 symbols). Returns one if it exists already.
1861 */
1862 V8_DEPRECATED(
1863 "Use NewFromUtf8 instead",
1864 V8_INLINE static Local<String> NewSymbol(
1865 const char* data, int length = -1));
1866
1867 enum NewStringType { 1787 enum NewStringType {
1868 kNormalString, kInternalizedString, kUndetectableString 1788 kNormalString, kInternalizedString, kUndetectableString
1869 }; 1789 };
1870 1790
1871 /** Allocates a new string from UTF-8 data.*/ 1791 /** Allocates a new string from UTF-8 data.*/
1872 static Local<String> NewFromUtf8(Isolate* isolate, 1792 static Local<String> NewFromUtf8(Isolate* isolate,
1873 const char* data, 1793 const char* data,
1874 NewStringType type = kNormalString, 1794 NewStringType type = kNormalString,
1875 int length = -1); 1795 int length = -1);
1876 1796
(...skipping 20 matching lines...) Expand all
1897 /** 1817 /**
1898 * Creates a new external string using the data defined in the given 1818 * Creates a new external string using the data defined in the given
1899 * resource. When the external string is no longer live on V8's heap the 1819 * resource. When the external string is no longer live on V8's heap the
1900 * resource will be disposed by calling its Dispose method. The caller of 1820 * resource will be disposed by calling its Dispose method. The caller of
1901 * this function should not otherwise delete or modify the resource. Neither 1821 * this function should not otherwise delete or modify the resource. Neither
1902 * should the underlying buffer be deallocated or modified except through the 1822 * should the underlying buffer be deallocated or modified except through the
1903 * destructor of the external string resource. 1823 * destructor of the external string resource.
1904 */ 1824 */
1905 static Local<String> NewExternal(Isolate* isolate, 1825 static Local<String> NewExternal(Isolate* isolate,
1906 ExternalStringResource* resource); 1826 ExternalStringResource* resource);
1907 V8_DEPRECATED("Will be removed", static Local<String> NewExternal(
1908 ExternalStringResource* resource));
1909 1827
1910 /** 1828 /**
1911 * Associate an external string resource with this string by transforming it 1829 * Associate an external string resource with this string by transforming it
1912 * in place so that existing references to this string in the JavaScript heap 1830 * in place so that existing references to this string in the JavaScript heap
1913 * will use the external string resource. The external string resource's 1831 * will use the external string resource. The external string resource's
1914 * character contents need to be equivalent to this string. 1832 * character contents need to be equivalent to this string.
1915 * Returns true if the string has been changed to be an external string. 1833 * Returns true if the string has been changed to be an external string.
1916 * The string is not modified if the operation fails. See NewExternal for 1834 * The string is not modified if the operation fails. See NewExternal for
1917 * information on the lifetime of the resource. 1835 * information on the lifetime of the resource.
1918 */ 1836 */
1919 bool MakeExternal(ExternalStringResource* resource); 1837 bool MakeExternal(ExternalStringResource* resource);
1920 1838
1921 /** 1839 /**
1922 * Creates a new external string using the ASCII data defined in the given 1840 * Creates a new external string using the ASCII data defined in the given
1923 * resource. When the external string is no longer live on V8's heap the 1841 * resource. When the external string is no longer live on V8's heap the
1924 * resource will be disposed by calling its Dispose method. The caller of 1842 * resource will be disposed by calling its Dispose method. The caller of
1925 * this function should not otherwise delete or modify the resource. Neither 1843 * this function should not otherwise delete or modify the resource. Neither
1926 * should the underlying buffer be deallocated or modified except through the 1844 * should the underlying buffer be deallocated or modified except through the
1927 * destructor of the external string resource. 1845 * destructor of the external string resource.
1928 */ 1846 */
1929 static Local<String> NewExternal(Isolate* isolate, 1847 static Local<String> NewExternal(Isolate* isolate,
1930 ExternalAsciiStringResource* resource); 1848 ExternalAsciiStringResource* resource);
1931 V8_DEPRECATED("Will be removed", static Local<String> NewExternal(
1932 ExternalAsciiStringResource* resource));
1933 1849
1934 /** 1850 /**
1935 * Associate an external string resource with this string by transforming it 1851 * Associate an external string resource with this string by transforming it
1936 * in place so that existing references to this string in the JavaScript heap 1852 * in place so that existing references to this string in the JavaScript heap
1937 * will use the external string resource. The external string resource's 1853 * will use the external string resource. The external string resource's
1938 * character contents need to be equivalent to this string. 1854 * character contents need to be equivalent to this string.
1939 * Returns true if the string has been changed to be an external string. 1855 * Returns true if the string has been changed to be an external string.
1940 * The string is not modified if the operation fails. See NewExternal for 1856 * The string is not modified if the operation fails. See NewExternal for
1941 * information on the lifetime of the resource. 1857 * information on the lifetime of the resource.
1942 */ 1858 */
1943 bool MakeExternal(ExternalAsciiStringResource* resource); 1859 bool MakeExternal(ExternalAsciiStringResource* resource);
1944 1860
1945 /** 1861 /**
1946 * Returns true if this string can be made external. 1862 * Returns true if this string can be made external.
1947 */ 1863 */
1948 bool CanMakeExternal(); 1864 bool CanMakeExternal();
1949 1865
1950 /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/
1951 V8_DEPRECATED(
1952 "Use NewFromUtf8 instead",
1953 V8_INLINE static Local<String> NewUndetectable(const char* data,
1954 int length = -1));
1955
1956 /** Creates an undetectable string from the supplied 16-bit character codes.*/
1957 V8_DEPRECATED(
1958 "Use NewFromTwoByte instead",
1959 V8_INLINE static Local<String> NewUndetectable(const uint16_t* data,
1960 int length = -1));
1961
1962 /** 1866 /**
1963 * Converts an object to a UTF-8-encoded character array. Useful if 1867 * Converts an object to a UTF-8-encoded character array. Useful if
1964 * you want to print the object. If conversion to a string fails 1868 * you want to print the object. If conversion to a string fails
1965 * (e.g. due to an exception in the toString() method of the object) 1869 * (e.g. due to an exception in the toString() method of the object)
1966 * then the length() method returns 0 and the * operator returns 1870 * then the length() method returns 0 and the * operator returns
1967 * NULL. 1871 * NULL.
1968 */ 1872 */
1969 class V8_EXPORT Utf8Value { 1873 class V8_EXPORT Utf8Value {
1970 public: 1874 public:
1971 explicit Utf8Value(Handle<v8::Value> obj); 1875 explicit Utf8Value(Handle<v8::Value> obj);
1972 ~Utf8Value(); 1876 ~Utf8Value();
1973 char* operator*() { return str_; } 1877 char* operator*() { return str_; }
1974 const char* operator*() const { return str_; } 1878 const char* operator*() const { return str_; }
1975 int length() const { return length_; } 1879 int length() const { return length_; }
1976 private: 1880 private:
1977 char* str_; 1881 char* str_;
1978 int length_; 1882 int length_;
1979 1883
1980 // Disallow copying and assigning. 1884 // Disallow copying and assigning.
1981 Utf8Value(const Utf8Value&); 1885 Utf8Value(const Utf8Value&);
1982 void operator=(const Utf8Value&); 1886 void operator=(const Utf8Value&);
1983 }; 1887 };
1984 1888
1985 /** 1889 /**
1986 * Converts an object to an ASCII string.
1987 * Useful if you want to print the object.
1988 * If conversion to a string fails (eg. due to an exception in the toString()
1989 * method of the object) then the length() method returns 0 and the * operator
1990 * returns NULL.
1991 */
1992 class V8_EXPORT AsciiValue {
1993 public:
1994 V8_DEPRECATED("Use Utf8Value instead",
1995 explicit AsciiValue(Handle<v8::Value> obj));
1996 ~AsciiValue();
1997 char* operator*() { return str_; }
1998 const char* operator*() const { return str_; }
1999 int length() const { return length_; }
2000 private:
2001 char* str_;
2002 int length_;
2003
2004 // Disallow copying and assigning.
2005 AsciiValue(const AsciiValue&);
2006 void operator=(const AsciiValue&);
2007 };
2008
2009 /**
2010 * Converts an object to a two-byte string. 1890 * Converts an object to a two-byte string.
2011 * If conversion to a string fails (eg. due to an exception in the toString() 1891 * If conversion to a string fails (eg. due to an exception in the toString()
2012 * method of the object) then the length() method returns 0 and the * operator 1892 * method of the object) then the length() method returns 0 and the * operator
2013 * returns NULL. 1893 * returns NULL.
2014 */ 1894 */
2015 class V8_EXPORT Value { 1895 class V8_EXPORT Value {
2016 public: 1896 public:
2017 explicit Value(Handle<v8::Value> obj); 1897 explicit Value(Handle<v8::Value> obj);
2018 ~Value(); 1898 ~Value();
2019 uint16_t* operator*() { return str_; } 1899 uint16_t* operator*() { return str_; }
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 * Clones an element at index |index|. Returns an empty 2360 * Clones an element at index |index|. Returns an empty
2481 * handle if cloning fails (for any reason). 2361 * handle if cloning fails (for any reason).
2482 */ 2362 */
2483 Local<Object> CloneElementAt(uint32_t index); 2363 Local<Object> CloneElementAt(uint32_t index);
2484 2364
2485 /** 2365 /**
2486 * Creates a JavaScript array with the given length. If the length 2366 * Creates a JavaScript array with the given length. If the length
2487 * is negative the returned array will have length 0. 2367 * is negative the returned array will have length 0.
2488 */ 2368 */
2489 static Local<Array> New(Isolate* isolate, int length = 0); 2369 static Local<Array> New(Isolate* isolate, int length = 0);
2490 V8_DEPRECATED("Will be removed", static Local<Array> New(int length = 0));
2491 2370
2492 V8_INLINE static Array* Cast(Value* obj); 2371 V8_INLINE static Array* Cast(Value* obj);
2493 private: 2372 private:
2494 Array(); 2373 Array();
2495 static void CheckCast(Value* obj); 2374 static void CheckCast(Value* obj);
2496 }; 2375 };
2497 2376
2498 2377
2499 template<typename T> 2378 template<typename T>
2500 class ReturnValue { 2379 class ReturnValue {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 * kLineOffsetNotFound if no information available. 2528 * kLineOffsetNotFound if no information available.
2650 */ 2529 */
2651 int GetScriptColumnNumber() const; 2530 int GetScriptColumnNumber() const;
2652 2531
2653 /** 2532 /**
2654 * Tells whether this function is builtin. 2533 * Tells whether this function is builtin.
2655 */ 2534 */
2656 bool IsBuiltin() const; 2535 bool IsBuiltin() const;
2657 2536
2658 /** 2537 /**
2659 * Returns scriptId object.
2660 */
2661 V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId() const);
2662
2663 /**
2664 * Returns scriptId. 2538 * Returns scriptId.
2665 */ 2539 */
2666 int ScriptId() const; 2540 int ScriptId() const;
2667 2541
2542 /**
2543 * Returns the original function if this function is bound, else returns
2544 * v8::Undefined.
2545 */
2546 Local<Value> GetBoundFunction() const;
2547
2668 ScriptOrigin GetScriptOrigin() const; 2548 ScriptOrigin GetScriptOrigin() const;
2669 V8_INLINE static Function* Cast(Value* obj); 2549 V8_INLINE static Function* Cast(Value* obj);
2670 static const int kLineOffsetNotFound; 2550 static const int kLineOffsetNotFound;
2671 2551
2672 private: 2552 private:
2673 Function(); 2553 Function();
2674 static void CheckCast(Value* obj); 2554 static void CheckCast(Value* obj);
2675 }; 2555 };
2676 2556
2677 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2557 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 */ 2624 */
2745 size_t ByteLength() const; 2625 size_t ByteLength() const;
2746 2626
2747 /** 2627 /**
2748 * Create a new ArrayBuffer. Allocate |byte_length| bytes. 2628 * Create a new ArrayBuffer. Allocate |byte_length| bytes.
2749 * Allocated memory will be owned by a created ArrayBuffer and 2629 * Allocated memory will be owned by a created ArrayBuffer and
2750 * will be deallocated when it is garbage-collected, 2630 * will be deallocated when it is garbage-collected,
2751 * unless the object is externalized. 2631 * unless the object is externalized.
2752 */ 2632 */
2753 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); 2633 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
2754 V8_DEPRECATED("Will be removed",
2755 static Local<ArrayBuffer> New(size_t byte_length));
2756 2634
2757 /** 2635 /**
2758 * Create a new ArrayBuffer over an existing memory block. 2636 * Create a new ArrayBuffer over an existing memory block.
2759 * The created array buffer is immediately in externalized state. 2637 * The created array buffer is immediately in externalized state.
2760 * The memory block will not be reclaimed when a created ArrayBuffer 2638 * The memory block will not be reclaimed when a created ArrayBuffer
2761 * is garbage-collected. 2639 * is garbage-collected.
2762 */ 2640 */
2763 static Local<ArrayBuffer> New(Isolate* isolate, void* data, 2641 static Local<ArrayBuffer> New(Isolate* isolate, void* data,
2764 size_t byte_length); 2642 size_t byte_length);
2765 V8_DEPRECATED("Will be removed",
2766 static Local<ArrayBuffer> New(void* data, size_t byte_length));
2767 2643
2768 /** 2644 /**
2769 * Returns true if ArrayBuffer is extrenalized, that is, does not 2645 * Returns true if ArrayBuffer is extrenalized, that is, does not
2770 * own its memory block. 2646 * own its memory block.
2771 */ 2647 */
2772 bool IsExternal() const; 2648 bool IsExternal() const;
2773 2649
2774 /** 2650 /**
2775 * Neuters this ArrayBuffer and all its views (typed arrays). 2651 * Neuters this ArrayBuffer and all its views (typed arrays).
2776 * Neutering sets the byte length of the buffer and all typed arrays to zero, 2652 * Neutering sets the byte length of the buffer and all typed arrays to zero,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 static void CheckCast(Value* obj); 2893 static void CheckCast(Value* obj);
3018 }; 2894 };
3019 2895
3020 2896
3021 /** 2897 /**
3022 * An instance of the built-in Date constructor (ECMA-262, 15.9). 2898 * An instance of the built-in Date constructor (ECMA-262, 15.9).
3023 */ 2899 */
3024 class V8_EXPORT Date : public Object { 2900 class V8_EXPORT Date : public Object {
3025 public: 2901 public:
3026 static Local<Value> New(Isolate* isolate, double time); 2902 static Local<Value> New(Isolate* isolate, double time);
3027 V8_DEPRECATED("Will be removed", static Local<Value> New(double time));
3028
3029 V8_DEPRECATED(
3030 "Use ValueOf instead",
3031 double NumberValue() const) { return ValueOf(); }
3032 2903
3033 /** 2904 /**
3034 * A specialization of Value::NumberValue that is more efficient 2905 * A specialization of Value::NumberValue that is more efficient
3035 * because we know the structure of this object. 2906 * because we know the structure of this object.
3036 */ 2907 */
3037 double ValueOf() const; 2908 double ValueOf() const;
3038 2909
3039 V8_INLINE static Date* Cast(v8::Value* obj); 2910 V8_INLINE static Date* Cast(v8::Value* obj);
3040 2911
3041 /** 2912 /**
3042 * Notification that the embedder has changed the time zone, 2913 * Notification that the embedder has changed the time zone,
3043 * daylight savings time, or other date / time configuration 2914 * daylight savings time, or other date / time configuration
3044 * parameters. V8 keeps a cache of various values used for 2915 * parameters. V8 keeps a cache of various values used for
3045 * date / time computation. This notification will reset 2916 * date / time computation. This notification will reset
3046 * those cached values for the current context so that date / 2917 * those cached values for the current context so that date /
3047 * time configuration changes would be reflected in the Date 2918 * time configuration changes would be reflected in the Date
3048 * object. 2919 * object.
3049 * 2920 *
3050 * This API should not be called more than needed as it will 2921 * This API should not be called more than needed as it will
3051 * negatively impact the performance of date operations. 2922 * negatively impact the performance of date operations.
3052 */ 2923 */
3053 static void DateTimeConfigurationChangeNotification(Isolate* isolate); 2924 static void DateTimeConfigurationChangeNotification(Isolate* isolate);
3054 V8_DEPRECATED("Will be removed",
3055 static void DateTimeConfigurationChangeNotification());
3056 2925
3057 private: 2926 private:
3058 static void CheckCast(v8::Value* obj); 2927 static void CheckCast(v8::Value* obj);
3059 }; 2928 };
3060 2929
3061 2930
3062 /** 2931 /**
3063 * A Number object (ECMA-262, 4.3.21). 2932 * A Number object (ECMA-262, 4.3.21).
3064 */ 2933 */
3065 class V8_EXPORT NumberObject : public Object { 2934 class V8_EXPORT NumberObject : public Object {
3066 public: 2935 public:
3067 static Local<Value> New(Isolate* isolate, double value); 2936 static Local<Value> New(Isolate* isolate, double value);
3068 V8_DEPRECATED("Will be removed", static Local<Value> New(double value));
3069 2937
3070 V8_DEPRECATED(
3071 "Use ValueOf instead",
3072 double NumberValue() const) { return ValueOf(); }
3073
3074 /**
3075 * Returns the Number held by the object.
3076 */
3077 double ValueOf() const; 2938 double ValueOf() const;
3078 2939
3079 V8_INLINE static NumberObject* Cast(v8::Value* obj); 2940 V8_INLINE static NumberObject* Cast(v8::Value* obj);
3080 2941
3081 private: 2942 private:
3082 static void CheckCast(v8::Value* obj); 2943 static void CheckCast(v8::Value* obj);
3083 }; 2944 };
3084 2945
3085 2946
3086 /** 2947 /**
3087 * A Boolean object (ECMA-262, 4.3.15). 2948 * A Boolean object (ECMA-262, 4.3.15).
3088 */ 2949 */
3089 class V8_EXPORT BooleanObject : public Object { 2950 class V8_EXPORT BooleanObject : public Object {
3090 public: 2951 public:
3091 static Local<Value> New(bool value); 2952 static Local<Value> New(bool value);
3092 2953
3093 V8_DEPRECATED(
3094 "Use ValueOf instead",
3095 bool BooleanValue() const) { return ValueOf(); }
3096
3097 /**
3098 * Returns the Boolean held by the object.
3099 */
3100 bool ValueOf() const; 2954 bool ValueOf() const;
3101 2955
3102 V8_INLINE static BooleanObject* Cast(v8::Value* obj); 2956 V8_INLINE static BooleanObject* Cast(v8::Value* obj);
3103 2957
3104 private: 2958 private:
3105 static void CheckCast(v8::Value* obj); 2959 static void CheckCast(v8::Value* obj);
3106 }; 2960 };
3107 2961
3108 2962
3109 /** 2963 /**
3110 * A String object (ECMA-262, 4.3.18). 2964 * A String object (ECMA-262, 4.3.18).
3111 */ 2965 */
3112 class V8_EXPORT StringObject : public Object { 2966 class V8_EXPORT StringObject : public Object {
3113 public: 2967 public:
3114 static Local<Value> New(Handle<String> value); 2968 static Local<Value> New(Handle<String> value);
3115 2969
3116 V8_DEPRECATED(
3117 "Use ValueOf instead",
3118 Local<String> StringValue() const) { return ValueOf(); }
3119
3120 /**
3121 * Returns the String held by the object.
3122 */
3123 Local<String> ValueOf() const; 2970 Local<String> ValueOf() const;
3124 2971
3125 V8_INLINE static StringObject* Cast(v8::Value* obj); 2972 V8_INLINE static StringObject* Cast(v8::Value* obj);
3126 2973
3127 private: 2974 private:
3128 static void CheckCast(v8::Value* obj); 2975 static void CheckCast(v8::Value* obj);
3129 }; 2976 };
3130 2977
3131 2978
3132 /** 2979 /**
3133 * A Symbol object (ECMA-262 edition 6). 2980 * A Symbol object (ECMA-262 edition 6).
3134 * 2981 *
3135 * This is an experimental feature. Use at your own risk. 2982 * This is an experimental feature. Use at your own risk.
3136 */ 2983 */
3137 class V8_EXPORT SymbolObject : public Object { 2984 class V8_EXPORT SymbolObject : public Object {
3138 public: 2985 public:
3139 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); 2986 static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
3140 2987
3141 V8_DEPRECATED(
3142 "Use ValueOf instead",
3143 Local<Symbol> SymbolValue() const) { return ValueOf(); }
3144
3145 /**
3146 * Returns the Symbol held by the object.
3147 */
3148 Local<Symbol> ValueOf() const; 2988 Local<Symbol> ValueOf() const;
3149 2989
3150 V8_INLINE static SymbolObject* Cast(v8::Value* obj); 2990 V8_INLINE static SymbolObject* Cast(v8::Value* obj);
3151 2991
3152 private: 2992 private:
3153 static void CheckCast(v8::Value* obj); 2993 static void CheckCast(v8::Value* obj);
3154 }; 2994 };
3155 2995
3156 2996
3157 /** 2997 /**
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 }; 3040 };
3201 3041
3202 3042
3203 /** 3043 /**
3204 * A JavaScript value that wraps a C++ void*. This type of value is mainly used 3044 * A JavaScript value that wraps a C++ void*. This type of value is mainly used
3205 * to associate C++ data structures with JavaScript objects. 3045 * to associate C++ data structures with JavaScript objects.
3206 */ 3046 */
3207 class V8_EXPORT External : public Value { 3047 class V8_EXPORT External : public Value {
3208 public: 3048 public:
3209 static Local<External> New(Isolate* isolate, void* value); 3049 static Local<External> New(Isolate* isolate, void* value);
3210 V8_DEPRECATED("Will be removed", static Local<External> New(void *value));
3211 V8_INLINE static External* Cast(Value* obj); 3050 V8_INLINE static External* Cast(Value* obj);
3212 void* Value() const; 3051 void* Value() const;
3213 private: 3052 private:
3214 static void CheckCast(v8::Value* obj); 3053 static void CheckCast(v8::Value* obj);
3215 }; 3054 };
3216 3055
3217 3056
3218 // --- Templates --- 3057 // --- Templates ---
3219 3058
3220 3059
3221 /** 3060 /**
3222 * The superclass of object and function templates. 3061 * The superclass of object and function templates.
3223 */ 3062 */
3224 class V8_EXPORT Template : public Data { 3063 class V8_EXPORT Template : public Data {
3225 public: 3064 public:
3226 /** Adds a property to each instance created by this template.*/ 3065 /** Adds a property to each instance created by this template.*/
3227 void Set(Handle<String> name, Handle<Data> value, 3066 void Set(Handle<String> name, Handle<Data> value,
3228 PropertyAttribute attributes = None); 3067 PropertyAttribute attributes = None);
3229 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); 3068 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
3230 V8_DEPRECATED("Will be removed",
3231 V8_INLINE void Set(const char* name, Handle<Data> value));
3232 3069
3233 void SetAccessorProperty( 3070 void SetAccessorProperty(
3234 Local<String> name, 3071 Local<String> name,
3235 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), 3072 Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
3236 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), 3073 Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
3237 PropertyAttribute attribute = None, 3074 PropertyAttribute attribute = None,
3238 AccessControl settings = DEFAULT); 3075 AccessControl settings = DEFAULT);
3239 3076
3240 /** 3077 /**
3241 * Whenever the property with the given name is accessed on objects 3078 * Whenever the property with the given name is accessed on objects
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 * A Signature specifies which receivers and arguments are valid 3594 * A Signature specifies which receivers and arguments are valid
3758 * parameters to a function. 3595 * parameters to a function.
3759 */ 3596 */
3760 class V8_EXPORT Signature : public Data { 3597 class V8_EXPORT Signature : public Data {
3761 public: 3598 public:
3762 static Local<Signature> New(Isolate* isolate, 3599 static Local<Signature> New(Isolate* isolate,
3763 Handle<FunctionTemplate> receiver = 3600 Handle<FunctionTemplate> receiver =
3764 Handle<FunctionTemplate>(), 3601 Handle<FunctionTemplate>(),
3765 int argc = 0, 3602 int argc = 0,
3766 Handle<FunctionTemplate> argv[] = 0); 3603 Handle<FunctionTemplate> argv[] = 0);
3767 V8_DEPRECATED("Will be removed",
3768 static Local<Signature> New(Handle<FunctionTemplate> receiver =
3769 Handle<FunctionTemplate>(),
3770 int argc = 0,
3771 Handle<FunctionTemplate> argv[] =
3772 0));
3773 3604
3774 private: 3605 private:
3775 Signature(); 3606 Signature();
3776 }; 3607 };
3777 3608
3778 3609
3779 /** 3610 /**
3780 * An AccessorSignature specifies which receivers are valid parameters 3611 * An AccessorSignature specifies which receivers are valid parameters
3781 * to an accessor callback. 3612 * to an accessor callback.
3782 */ 3613 */
3783 class V8_EXPORT AccessorSignature : public Data { 3614 class V8_EXPORT AccessorSignature : public Data {
3784 public: 3615 public:
3785 static Local<AccessorSignature> New(Isolate* isolate, 3616 static Local<AccessorSignature> New(Isolate* isolate,
3786 Handle<FunctionTemplate> receiver = 3617 Handle<FunctionTemplate> receiver =
3787 Handle<FunctionTemplate>()); 3618 Handle<FunctionTemplate>());
3788 V8_DEPRECATED("Will be removed", static Local<AccessorSignature> New(
3789 Handle<FunctionTemplate> receiver =
3790 Handle<FunctionTemplate>()));
3791 3619
3792 private: 3620 private:
3793 AccessorSignature(); 3621 AccessorSignature();
3794 }; 3622 };
3795 3623
3796 3624
3797 class V8_EXPORT DeclaredAccessorDescriptor : public Data { 3625 class V8_EXPORT DeclaredAccessorDescriptor : public Data {
3798 private: 3626 private:
3799 DeclaredAccessorDescriptor(); 3627 DeclaredAccessorDescriptor();
3800 }; 3628 };
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3887 // Note that the strings passed into this constructor must live as long 3715 // Note that the strings passed into this constructor must live as long
3888 // as the Extension itself. 3716 // as the Extension itself.
3889 Extension(const char* name, 3717 Extension(const char* name,
3890 const char* source = 0, 3718 const char* source = 0,
3891 int dep_count = 0, 3719 int dep_count = 0,
3892 const char** deps = 0, 3720 const char** deps = 0,
3893 int source_length = -1); 3721 int source_length = -1);
3894 virtual ~Extension() { } 3722 virtual ~Extension() { }
3895 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( 3723 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
3896 v8::Isolate* isolate, v8::Handle<v8::String> name) { 3724 v8::Isolate* isolate, v8::Handle<v8::String> name) {
3897 #if defined(V8_DEPRECATION_WARNINGS)
3898 return v8::Handle<v8::FunctionTemplate>();
3899 #else
3900 return GetNativeFunction(name);
3901 #endif
3902 }
3903
3904 V8_DEPRECATED("Will be removed",
3905 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
3906 v8::Handle<v8::String> name)) {
3907 return v8::Handle<v8::FunctionTemplate>(); 3725 return v8::Handle<v8::FunctionTemplate>();
3908 } 3726 }
3909 3727
3910 const char* name() const { return name_; } 3728 const char* name() const { return name_; }
3911 size_t source_length() const { return source_length_; } 3729 size_t source_length() const { return source_length_; }
3912 const String::ExternalAsciiStringResource* source() const { 3730 const String::ExternalAsciiStringResource* source() const {
3913 return &source_; } 3731 return &source_; }
3914 int dependency_count() { return dep_count_; } 3732 int dependency_count() { return dep_count_; }
3915 const char** dependencies() { return deps_; } 3733 const char** dependencies() { return deps_; }
3916 void set_auto_enable(bool value) { auto_enable_ = value; } 3734 void set_auto_enable(bool value) { auto_enable_ = value; }
(...skipping 27 matching lines...) Expand all
3944 }; 3762 };
3945 3763
3946 3764
3947 // --- Statics --- 3765 // --- Statics ---
3948 3766
3949 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); 3767 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
3950 V8_INLINE Handle<Primitive> Null(Isolate* isolate); 3768 V8_INLINE Handle<Primitive> Null(Isolate* isolate);
3951 V8_INLINE Handle<Boolean> True(Isolate* isolate); 3769 V8_INLINE Handle<Boolean> True(Isolate* isolate);
3952 V8_INLINE Handle<Boolean> False(Isolate* isolate); 3770 V8_INLINE Handle<Boolean> False(Isolate* isolate);
3953 3771
3954 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Undefined());
3955 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Null());
3956 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT True());
3957 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT False());
3958
3959 3772
3960 /** 3773 /**
3961 * A set of constraints that specifies the limits of the runtime's memory use. 3774 * A set of constraints that specifies the limits of the runtime's memory use.
3962 * You must set the heap size before initializing the VM - the size cannot be 3775 * You must set the heap size before initializing the VM - the size cannot be
3963 * adjusted after the VM is initialized. 3776 * adjusted after the VM is initialized.
3964 * 3777 *
3965 * If you are using threads then you should hold the V8::Locker lock while 3778 * If you are using threads then you should hold the V8::Locker lock while
3966 * setting the stack limit and you must set a non-default stack limit separately 3779 * setting the stack limit and you must set a non-default stack limit separately
3967 * for each thread. 3780 * for each thread.
3968 */ 3781 */
3969 class V8_EXPORT ResourceConstraints { 3782 class V8_EXPORT ResourceConstraints {
3970 public: 3783 public:
3971 ResourceConstraints(); 3784 ResourceConstraints();
3972 3785
3973 /** 3786 /**
3974 * Configures the constraints with reasonable default values based on the 3787 * Configures the constraints with reasonable default values based on the
3975 * capabilities of the current device the VM is running on. 3788 * capabilities of the current device the VM is running on.
3976 * 3789 *
3977 * \param physical_memory The total amount of physical memory on the current 3790 * \param physical_memory The total amount of physical memory on the current
3978 * device, in bytes. 3791 * device, in bytes.
3979 * \param number_of_processors The number of CPUs available on the current 3792 * \param number_of_processors The number of CPUs available on the current
3980 * device. 3793 * device.
3981 */ 3794 */
3982 void ConfigureDefaults(uint64_t physical_memory, 3795 void ConfigureDefaults(uint64_t physical_memory,
3983 uint32_t number_of_processors); 3796 uint32_t number_of_processors);
3984 V8_DEPRECATED("Will be removed",
3985 void ConfigureDefaults(uint64_t physical_memory));
3986 3797
3987 int max_young_space_size() const { return max_young_space_size_; } 3798 int max_young_space_size() const { return max_young_space_size_; }
3988 void set_max_young_space_size(int value) { max_young_space_size_ = value; } 3799 void set_max_young_space_size(int value) { max_young_space_size_ = value; }
3989 int max_old_space_size() const { return max_old_space_size_; } 3800 int max_old_space_size() const { return max_old_space_size_; }
3990 void set_max_old_space_size(int value) { max_old_space_size_ = value; } 3801 void set_max_old_space_size(int value) { max_old_space_size_ = value; }
3991 int max_executable_size() const { return max_executable_size_; } 3802 int max_executable_size() const { return max_executable_size_; }
3992 void set_max_executable_size(int value) { max_executable_size_ = value; } 3803 void set_max_executable_size(int value) { max_executable_size_ = value; }
3993 uint32_t* stack_limit() const { return stack_limit_; } 3804 uint32_t* stack_limit() const { return stack_limit_; }
3994 // Sets an address beyond which the VM's stack may not grow. 3805 // Sets an address beyond which the VM's stack may not grow.
3995 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } 3806 void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
(...skipping 21 matching lines...) Expand all
4017 3828
4018 // --- Exceptions --- 3829 // --- Exceptions ---
4019 3830
4020 3831
4021 typedef void (*FatalErrorCallback)(const char* location, const char* message); 3832 typedef void (*FatalErrorCallback)(const char* location, const char* message);
4022 3833
4023 3834
4024 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error); 3835 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
4025 3836
4026 3837
4027 V8_DEPRECATED(
4028 "Use Isolate::ThrowException instead",
4029 Handle<Value> V8_EXPORT ThrowException(Handle<Value> exception));
4030
4031 /** 3838 /**
4032 * Create new error objects by calling the corresponding error object 3839 * Create new error objects by calling the corresponding error object
4033 * constructor with the message. 3840 * constructor with the message.
4034 */ 3841 */
4035 class V8_EXPORT Exception { 3842 class V8_EXPORT Exception {
4036 public: 3843 public:
4037 static Local<Value> RangeError(Handle<String> message); 3844 static Local<Value> RangeError(Handle<String> message);
4038 static Local<Value> ReferenceError(Handle<String> message); 3845 static Local<Value> ReferenceError(Handle<String> message);
4039 static Local<Value> SyntaxError(Handle<String> message); 3846 static Local<Value> SyntaxError(Handle<String> message);
4040 static Local<Value> TypeError(Handle<String> message); 3847 static Local<Value> TypeError(Handle<String> message);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 3917
4111 enum GCCallbackFlags { 3918 enum GCCallbackFlags {
4112 kNoGCCallbackFlags = 0, 3919 kNoGCCallbackFlags = 0,
4113 kGCCallbackFlagCompacted = 1 << 0, 3920 kGCCallbackFlagCompacted = 1 << 0,
4114 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1 3921 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1
4115 }; 3922 };
4116 3923
4117 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); 3924 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
4118 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); 3925 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
4119 3926
3927 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
3928
4120 3929
4121 /** 3930 /**
4122 * Collection of V8 heap information. 3931 * Collection of V8 heap information.
4123 * 3932 *
4124 * Instances of this class can be passed to v8::V8::HeapStatistics to 3933 * Instances of this class can be passed to v8::V8::HeapStatistics to
4125 * get heap statistics from V8. 3934 * get heap statistics from V8.
4126 */ 3935 */
4127 class V8_EXPORT HeapStatistics { 3936 class V8_EXPORT HeapStatistics {
4128 public: 3937 public:
4129 HeapStatistics(); 3938 HeapStatistics();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 * Requires: this == Isolate::GetCurrent(). 4022 * Requires: this == Isolate::GetCurrent().
4214 */ 4023 */
4215 void Exit(); 4024 void Exit();
4216 4025
4217 /** 4026 /**
4218 * Disposes the isolate. The isolate must not be entered by any 4027 * Disposes the isolate. The isolate must not be entered by any
4219 * thread to be disposable. 4028 * thread to be disposable.
4220 */ 4029 */
4221 void Dispose(); 4030 void Dispose();
4222 4031
4223 V8_DEPRECATED("Use SetData(0, data) instead.",
4224 V8_INLINE void SetData(void* data));
4225 V8_DEPRECATED("Use GetData(0) instead.", V8_INLINE void* GetData());
4226
4227 /** 4032 /**
4228 * Associate embedder-specific data with the isolate. |slot| has to be 4033 * Associate embedder-specific data with the isolate. |slot| has to be
4229 * between 0 and GetNumberOfDataSlots() - 1. 4034 * between 0 and GetNumberOfDataSlots() - 1.
4230 */ 4035 */
4231 V8_INLINE void SetData(uint32_t slot, void* data); 4036 V8_INLINE void SetData(uint32_t slot, void* data);
4232 4037
4233 /** 4038 /**
4234 * Retrieve embedder-specific data from the isolate. 4039 * Retrieve embedder-specific data from the isolate.
4235 * Returns NULL if SetData has never been called for the given |slot|. 4040 * Returns NULL if SetData has never been called for the given |slot|.
4236 */ 4041 */
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4370 */ 4175 */
4371 void AddGCEpilogueCallback( 4176 void AddGCEpilogueCallback(
4372 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); 4177 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
4373 4178
4374 /** 4179 /**
4375 * This function removes callback which was installed by 4180 * This function removes callback which was installed by
4376 * AddGCEpilogueCallback function. 4181 * AddGCEpilogueCallback function.
4377 */ 4182 */
4378 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); 4183 void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
4379 4184
4185 /**
4186 * Request V8 to interrupt long running JavaScript code and invoke
4187 * the given |callback| passing the given |data| to it. After |callback|
4188 * returns control will be returned to the JavaScript code.
4189 * At any given moment V8 can remember only a single callback for the very
4190 * last interrupt request.
4191 * Can be called from another thread without acquiring a |Locker|.
4192 * Registered |callback| must not reenter interrupted Isolate.
4193 */
4194 void RequestInterrupt(InterruptCallback callback, void* data);
4195
4196 /**
4197 * Clear interrupt request created by |RequestInterrupt|.
4198 * Can be called from another thread without acquiring a |Locker|.
4199 */
4200 void ClearInterrupt();
4201
4380 private: 4202 private:
4381 Isolate(); 4203 Isolate();
4382 Isolate(const Isolate&); 4204 Isolate(const Isolate&);
4383 ~Isolate(); 4205 ~Isolate();
4384 Isolate& operator=(const Isolate&); 4206 Isolate& operator=(const Isolate&);
4385 void* operator new(size_t size); 4207 void* operator new(size_t size);
4386 void operator delete(void*, size_t); 4208 void operator delete(void*, size_t);
4387 4209
4388 void SetObjectGroupId(internal::Object** object, UniqueId id); 4210 void SetObjectGroupId(internal::Object** object, UniqueId id);
4389 void SetReferenceFromGroup(UniqueId id, internal::Object** object); 4211 void SetReferenceFromGroup(UniqueId id, internal::Object** object);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
4834 * are not guaranteed to live past each call. The \p event_handler must 4656 * are not guaranteed to live past each call. The \p event_handler must
4835 * copy strings and other parameters it needs to keep around. 4657 * copy strings and other parameters it needs to keep around.
4836 * \note the set of events declared in JitCodeEvent::EventType is expected to 4658 * \note the set of events declared in JitCodeEvent::EventType is expected to
4837 * grow over time, and the JitCodeEvent structure is expected to accrue 4659 * grow over time, and the JitCodeEvent structure is expected to accrue
4838 * new members. The \p event_handler function must ignore event codes 4660 * new members. The \p event_handler function must ignore event codes
4839 * it does not recognize to maintain future compatibility. 4661 * it does not recognize to maintain future compatibility.
4840 */ 4662 */
4841 static void SetJitCodeEventHandler(JitCodeEventOptions options, 4663 static void SetJitCodeEventHandler(JitCodeEventOptions options,
4842 JitCodeEventHandler event_handler); 4664 JitCodeEventHandler event_handler);
4843 4665
4844 V8_DEPRECATED(
4845 "Use Isolate::AdjustAmountOfExternalAllocatedMemory instead",
4846 static int64_t AdjustAmountOfExternalAllocatedMemory(
4847 int64_t change_in_bytes));
4848
4849 /** 4666 /**
4850 * Forcefully terminate the current thread of JavaScript execution 4667 * Forcefully terminate the current thread of JavaScript execution
4851 * in the given isolate. If no isolate is provided, the default 4668 * in the given isolate. If no isolate is provided, the default
4852 * isolate is used. 4669 * isolate is used.
4853 * 4670 *
4854 * This method can be used by any thread even if that thread has not 4671 * This method can be used by any thread even if that thread has not
4855 * acquired the V8 lock with a Locker object. 4672 * acquired the V8 lock with a Locker object.
4856 * 4673 *
4857 * \param isolate The isolate in which to terminate the current JS execution. 4674 * \param isolate The isolate in which to terminate the current JS execution.
4858 */ 4675 */
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 */ 4785 */
4969 static void ShutdownPlatform(); 4786 static void ShutdownPlatform();
4970 4787
4971 private: 4788 private:
4972 V8(); 4789 V8();
4973 4790
4974 static internal::Object** GlobalizeReference(internal::Isolate* isolate, 4791 static internal::Object** GlobalizeReference(internal::Isolate* isolate,
4975 internal::Object** handle); 4792 internal::Object** handle);
4976 static internal::Object** CopyPersistent(internal::Object** handle); 4793 static internal::Object** CopyPersistent(internal::Object** handle);
4977 static void DisposeGlobal(internal::Object** global_handle); 4794 static void DisposeGlobal(internal::Object** global_handle);
4978 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
4979 typedef WeakCallbackData<Value, void>::Callback WeakCallback; 4795 typedef WeakCallbackData<Value, void>::Callback WeakCallback;
4980 static void MakeWeak(internal::Object** global_handle, 4796 static void MakeWeak(internal::Object** global_handle,
4981 void* data, 4797 void* data,
4982 WeakCallback weak_callback, 4798 WeakCallback weak_callback);
4983 RevivableCallback weak_reference_callback);
4984 static void ClearWeak(internal::Object** global_handle); 4799 static void ClearWeak(internal::Object** global_handle);
4985 static void Eternalize(Isolate* isolate, 4800 static void Eternalize(Isolate* isolate,
4986 Value* handle, 4801 Value* handle,
4987 int* index); 4802 int* index);
4988 static Local<Value> GetEternal(Isolate* isolate, int index); 4803 static Local<Value> GetEternal(Isolate* isolate, int index);
4989 4804
4990 template <class T> friend class Handle; 4805 template <class T> friend class Handle;
4991 template <class T> friend class Local; 4806 template <class T> friend class Local;
4992 template <class T> friend class Eternal; 4807 template <class T> friend class Eternal;
4993 template <class T> friend class PersistentBase; 4808 template <class T> friend class PersistentBase;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
5143 }; 4958 };
5144 4959
5145 4960
5146 /** 4961 /**
5147 * A sandboxed execution context with its own set of built-in objects 4962 * A sandboxed execution context with its own set of built-in objects
5148 * and functions. 4963 * and functions.
5149 */ 4964 */
5150 class V8_EXPORT Context { 4965 class V8_EXPORT Context {
5151 public: 4966 public:
5152 /** 4967 /**
5153 * Returns the global proxy object or global object itself for 4968 * Returns the global proxy object.
5154 * detached contexts.
5155 * 4969 *
5156 * Global proxy object is a thin wrapper whose prototype points to 4970 * Global proxy object is a thin wrapper whose prototype points to actual
5157 * actual context's global object with the properties like Object, etc. 4971 * context's global object with the properties like Object, etc. This is done
5158 * This is done that way for security reasons (for more details see 4972 * that way for security reasons (for more details see
5159 * https://wiki.mozilla.org/Gecko:SplitWindow). 4973 * https://wiki.mozilla.org/Gecko:SplitWindow).
5160 * 4974 *
5161 * Please note that changes to global proxy object prototype most probably 4975 * Please note that changes to global proxy object prototype most probably
5162 * would break VM---v8 expects only global object as a prototype of 4976 * would break VM---v8 expects only global object as a prototype of global
5163 * global proxy object. 4977 * proxy object.
5164 *
5165 * If DetachGlobal() has been invoked, Global() would return actual global
5166 * object until global is reattached with ReattachGlobal().
5167 */ 4978 */
5168 Local<Object> Global(); 4979 Local<Object> Global();
5169 4980
5170 /** 4981 /**
5171 * Detaches the global object from its context before 4982 * Detaches the global object from its context before
5172 * the global object can be reused to create a new context. 4983 * the global object can be reused to create a new context.
5173 */ 4984 */
5174 void DetachGlobal(); 4985 void DetachGlobal();
5175 4986
5176 /** 4987 /**
5177 * Reattaches a global object to a context. This can be used to
5178 * restore the connection between a global object and a context
5179 * after DetachGlobal has been called.
5180 *
5181 * \param global_object The global object to reattach to the
5182 * context. For this to work, the global object must be the global
5183 * object that was associated with this context before a call to
5184 * DetachGlobal.
5185 */
5186 void ReattachGlobal(Handle<Object> global_object);
5187
5188 /**
5189 * Creates a new context and returns a handle to the newly allocated 4988 * Creates a new context and returns a handle to the newly allocated
5190 * context. 4989 * context.
5191 * 4990 *
5192 * \param isolate The isolate in which to create the context. 4991 * \param isolate The isolate in which to create the context.
5193 * 4992 *
5194 * \param extensions An optional extension configuration containing 4993 * \param extensions An optional extension configuration containing
5195 * the extensions to be installed in the newly created context. 4994 * the extensions to be installed in the newly created context.
5196 * 4995 *
5197 * \param global_template An optional object template from which the 4996 * \param global_template An optional object template from which the
5198 * global object for the newly created context will be created. 4997 * global object for the newly created context will be created.
5199 * 4998 *
5200 * \param global_object An optional global object to be reused for 4999 * \param global_object An optional global object to be reused for
5201 * the newly created context. This global object must have been 5000 * the newly created context. This global object must have been
5202 * created by a previous call to Context::New with the same global 5001 * created by a previous call to Context::New with the same global
5203 * template. The state of the global object will be completely reset 5002 * template. The state of the global object will be completely reset
5204 * and only object identify will remain. 5003 * and only object identify will remain.
5205 */ 5004 */
5206 static Local<Context> New( 5005 static Local<Context> New(
5207 Isolate* isolate, 5006 Isolate* isolate,
5208 ExtensionConfiguration* extensions = NULL, 5007 ExtensionConfiguration* extensions = NULL,
5209 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), 5008 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
5210 Handle<Value> global_object = Handle<Value>()); 5009 Handle<Value> global_object = Handle<Value>());
5211 5010
5212 V8_DEPRECATED("Use Isolate::GetEnteredContext instead",
5213 static Local<Context> GetEntered());
5214
5215 V8_DEPRECATED("Use Isolate::GetCurrentContext instead",
5216 static Local<Context> GetCurrent());
5217
5218 V8_DEPRECATED("Use Isolate::GetCallingContext instead",
5219 static Local<Context> GetCalling());
5220
5221 /** 5011 /**
5222 * Sets the security token for the context. To access an object in 5012 * Sets the security token for the context. To access an object in
5223 * another context, the security tokens must match. 5013 * another context, the security tokens must match.
5224 */ 5014 */
5225 void SetSecurityToken(Handle<Value> token); 5015 void SetSecurityToken(Handle<Value> token);
5226 5016
5227 /** Restores the security token to the default value. */ 5017 /** Restores the security token to the default value. */
5228 void UseDefaultSecurityToken(); 5018 void UseDefaultSecurityToken();
5229 5019
5230 /** Returns the security token of this context.*/ 5020 /** Returns the security token of this context.*/
5231 Handle<Value> GetSecurityToken(); 5021 Handle<Value> GetSecurityToken();
5232 5022
5233 /** 5023 /**
5234 * Enter this context. After entering a context, all code compiled 5024 * Enter this context. After entering a context, all code compiled
5235 * and run is compiled and run in this context. If another context 5025 * and run is compiled and run in this context. If another context
5236 * is already entered, this old context is saved so it can be 5026 * is already entered, this old context is saved so it can be
5237 * restored when the new context is exited. 5027 * restored when the new context is exited.
5238 */ 5028 */
5239 void Enter(); 5029 void Enter();
5240 5030
5241 /** 5031 /**
5242 * Exit this context. Exiting the current context restores the 5032 * Exit this context. Exiting the current context restores the
5243 * context that was in place when entering the current context. 5033 * context that was in place when entering the current context.
5244 */ 5034 */
5245 void Exit(); 5035 void Exit();
5246 5036
5247 /** Returns true if the context has experienced an out of memory situation. */ 5037 /** Returns true if the context has experienced an out of memory situation. */
5248 bool HasOutOfMemoryException(); 5038 bool HasOutOfMemoryException();
5249 5039
5250 V8_DEPRECATED("Use Isolate::InContext instead",
5251 static bool InContext());
5252
5253 /** Returns an isolate associated with a current context. */ 5040 /** Returns an isolate associated with a current context. */
5254 v8::Isolate* GetIsolate(); 5041 v8::Isolate* GetIsolate();
5255 5042
5256 /** 5043 /**
5257 * Gets the embedder data with the given index, which must have been set by a 5044 * Gets the embedder data with the given index, which must have been set by a
5258 * previous call to SetEmbedderData with the same index. Note that index 0 5045 * previous call to SetEmbedderData with the same index. Note that index 0
5259 * currently has a special meaning for Chrome's debugger. 5046 * currently has a special meaning for Chrome's debugger.
5260 */ 5047 */
5261 V8_INLINE Local<Value> GetEmbedderData(int index); 5048 V8_INLINE Local<Value> GetEmbedderData(int index);
5262 5049
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5312 5099
5313 /** 5100 /**
5314 * Stack-allocated class which sets the execution context for all 5101 * Stack-allocated class which sets the execution context for all
5315 * operations executed within a local scope. 5102 * operations executed within a local scope.
5316 */ 5103 */
5317 class Scope { 5104 class Scope {
5318 public: 5105 public:
5319 explicit V8_INLINE Scope(Handle<Context> context) : context_(context) { 5106 explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
5320 context_->Enter(); 5107 context_->Enter();
5321 } 5108 }
5322 V8_DEPRECATED(
5323 "Use Handle version instead",
5324 V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context)) // NOLI NT
5325 : context_(Handle<Context>::New(isolate, context)) {
5326 context_->Enter();
5327 }
5328 V8_INLINE ~Scope() { context_->Exit(); } 5109 V8_INLINE ~Scope() { context_->Exit(); }
5329 5110
5330 private: 5111 private:
5331 Handle<Context> context_; 5112 Handle<Context> context_;
5332 }; 5113 };
5333 5114
5334 private: 5115 private:
5335 friend class Value; 5116 friend class Value;
5336 friend class Script; 5117 friend class Script;
5337 friend class Object; 5118 friend class Object;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5632 static const int kStringEncodingMask = 0x4; 5413 static const int kStringEncodingMask = 0x4;
5633 static const int kExternalTwoByteRepresentationTag = 0x02; 5414 static const int kExternalTwoByteRepresentationTag = 0x02;
5634 static const int kExternalAsciiRepresentationTag = 0x06; 5415 static const int kExternalAsciiRepresentationTag = 0x06;
5635 5416
5636 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; 5417 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
5637 static const int kIsolateRootsOffset = 5 * kApiPointerSize; 5418 static const int kIsolateRootsOffset = 5 * kApiPointerSize;
5638 static const int kUndefinedValueRootIndex = 5; 5419 static const int kUndefinedValueRootIndex = 5;
5639 static const int kNullValueRootIndex = 7; 5420 static const int kNullValueRootIndex = 7;
5640 static const int kTrueValueRootIndex = 8; 5421 static const int kTrueValueRootIndex = 8;
5641 static const int kFalseValueRootIndex = 9; 5422 static const int kFalseValueRootIndex = 9;
5642 static const int kEmptyStringRootIndex = 134; 5423 static const int kEmptyStringRootIndex = 135;
5643 5424
5644 static const int kNodeClassIdOffset = 1 * kApiPointerSize; 5425 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
5645 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; 5426 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
5646 static const int kNodeStateMask = 0xf; 5427 static const int kNodeStateMask = 0xf;
5647 static const int kNodeStateIsWeakValue = 2; 5428 static const int kNodeStateIsWeakValue = 2;
5648 static const int kNodeStateIsPendingValue = 3; 5429 static const int kNodeStateIsPendingValue = 3;
5649 static const int kNodeStateIsNearDeathValue = 4; 5430 static const int kNodeStateIsNearDeathValue = 4;
5650 static const int kNodeIsIndependentShift = 4; 5431 static const int kNodeIsIndependentShift = 4;
5651 static const int kNodeIsPartiallyDependentShift = 5; 5432 static const int kNodeIsPartiallyDependentShift = 5;
5652 5433
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5903 5684
5904 template <class T> 5685 template <class T>
5905 template <typename S, typename P> 5686 template <typename S, typename P>
5906 void PersistentBase<T>::SetWeak( 5687 void PersistentBase<T>::SetWeak(
5907 P* parameter, 5688 P* parameter,
5908 typename WeakCallbackData<S, P>::Callback callback) { 5689 typename WeakCallbackData<S, P>::Callback callback) {
5909 TYPE_CHECK(S, T); 5690 TYPE_CHECK(S, T);
5910 typedef typename WeakCallbackData<Value, void>::Callback Callback; 5691 typedef typename WeakCallbackData<Value, void>::Callback Callback;
5911 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), 5692 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
5912 parameter, 5693 parameter,
5913 reinterpret_cast<Callback>(callback), 5694 reinterpret_cast<Callback>(callback));
5914 NULL);
5915 } 5695 }
5916 5696
5917 5697
5918 template <class T> 5698 template <class T>
5919 template <typename P> 5699 template <typename P>
5920 void PersistentBase<T>::SetWeak( 5700 void PersistentBase<T>::SetWeak(
5921 P* parameter, 5701 P* parameter,
5922 typename WeakCallbackData<T, P>::Callback callback) { 5702 typename WeakCallbackData<T, P>::Callback callback) {
5923 SetWeak<T, P>(parameter, callback); 5703 SetWeak<T, P>(parameter, callback);
5924 } 5704 }
5925 5705
5926 5706
5927 template <class T, class M>
5928 template <typename S, typename P>
5929 void Persistent<T, M>::MakeWeak(
5930 P* parameters,
5931 typename WeakReferenceCallbacks<S, P>::Revivable callback) {
5932 TYPE_CHECK(S, T);
5933 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable;
5934 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
5935 parameters,
5936 NULL,
5937 reinterpret_cast<Revivable>(callback));
5938 }
5939
5940
5941 template <class T, class M>
5942 template <typename P>
5943 void Persistent<T, M>::MakeWeak(
5944 P* parameters,
5945 typename WeakReferenceCallbacks<T, P>::Revivable callback) {
5946 MakeWeak<T, P>(parameters, callback);
5947 }
5948
5949
5950 template <class T> 5707 template <class T>
5951 void PersistentBase<T>::ClearWeak() { 5708 void PersistentBase<T>::ClearWeak() {
5952 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); 5709 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
5953 } 5710 }
5954 5711
5955 5712
5956 template <class T> 5713 template <class T>
5957 void PersistentBase<T>::MarkIndependent() { 5714 void PersistentBase<T>::MarkIndependent() {
5958 typedef internal::Internals I; 5715 typedef internal::Internals I;
5959 if (this->IsEmpty()) return; 5716 if (this->IsEmpty()) return;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
6164 return is_construct_call_; 5921 return is_construct_call_;
6165 } 5922 }
6166 5923
6167 5924
6168 template<typename T> 5925 template<typename T>
6169 int FunctionCallbackInfo<T>::Length() const { 5926 int FunctionCallbackInfo<T>::Length() const {
6170 return length_; 5927 return length_;
6171 } 5928 }
6172 5929
6173 5930
6174 template <class T>
6175 Local<T> HandleScope::Close(Handle<T> value) {
6176 internal::Object** before = reinterpret_cast<internal::Object**>(*value);
6177 internal::Object** after = RawClose(before);
6178 return Local<T>(reinterpret_cast<T*>(after));
6179 }
6180
6181 Handle<Value> ScriptOrigin::ResourceName() const { 5931 Handle<Value> ScriptOrigin::ResourceName() const {
6182 return resource_name_; 5932 return resource_name_;
6183 } 5933 }
6184 5934
6185 5935
6186 Handle<Integer> ScriptOrigin::ResourceLineOffset() const { 5936 Handle<Integer> ScriptOrigin::ResourceLineOffset() const {
6187 return resource_line_offset_; 5937 return resource_line_offset_;
6188 } 5938 }
6189 5939
6190 5940
6191 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { 5941 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
6192 return resource_column_offset_; 5942 return resource_column_offset_;
6193 } 5943 }
6194 5944
6195 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { 5945 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const {
6196 return resource_is_shared_cross_origin_; 5946 return resource_is_shared_cross_origin_;
6197 } 5947 }
6198 5948
6199 5949
6200 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) { 5950 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) {
6201 return value ? True(isolate) : False(isolate); 5951 return value ? True(isolate) : False(isolate);
6202 } 5952 }
6203 5953
6204 5954
6205 Handle<Boolean> Boolean::New(bool value) {
6206 return Boolean::New(Isolate::GetCurrent(), value);
6207 }
6208
6209
6210 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) { 5955 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) {
6211 Set(v8::String::NewFromUtf8(isolate, name), value); 5956 Set(v8::String::NewFromUtf8(isolate, name), value);
6212 } 5957 }
6213 5958
6214 5959
6215 void Template::Set(const char* name, v8::Handle<Data> value) {
6216 Set(Isolate::GetCurrent(), name, value);
6217 }
6218
6219
6220 Local<Value> Object::GetInternalField(int index) { 5960 Local<Value> Object::GetInternalField(int index) {
6221 #ifndef V8_ENABLE_CHECKS 5961 #ifndef V8_ENABLE_CHECKS
6222 typedef internal::Object O; 5962 typedef internal::Object O;
6223 typedef internal::HeapObject HO; 5963 typedef internal::HeapObject HO;
6224 typedef internal::Internals I; 5964 typedef internal::Internals I;
6225 O* obj = *reinterpret_cast<O**>(this); 5965 O* obj = *reinterpret_cast<O**>(this);
6226 // Fast path: If the object is a plain JSObject, which is the common case, we 5966 // Fast path: If the object is a plain JSObject, which is the common case, we
6227 // know where to find the internal fields and can return the value directly. 5967 // know where to find the internal fields and can return the value directly.
6228 if (I::GetInstanceType(obj) == I::kJSObjectType) { 5968 if (I::GetInstanceType(obj) == I::kJSObjectType) {
6229 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); 5969 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6262 6002
6263 Local<String> String::Empty(Isolate* isolate) { 6003 Local<String> String::Empty(Isolate* isolate) {
6264 typedef internal::Object* S; 6004 typedef internal::Object* S;
6265 typedef internal::Internals I; 6005 typedef internal::Internals I;
6266 I::CheckInitialized(isolate); 6006 I::CheckInitialized(isolate);
6267 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); 6007 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
6268 return Local<String>(reinterpret_cast<String*>(slot)); 6008 return Local<String>(reinterpret_cast<String*>(slot));
6269 } 6009 }
6270 6010
6271 6011
6272 Local<String> String::New(const char* data, int length) {
6273 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length);
6274 }
6275
6276
6277 Local<String> String::New(const uint16_t* data, int length) {
6278 return NewFromTwoByte(Isolate::GetCurrent(), data, kNormalString, length);
6279 }
6280
6281
6282 Local<String> String::NewSymbol(const char* data, int length) {
6283 return NewFromUtf8(Isolate::GetCurrent(), data, kInternalizedString, length);
6284 }
6285
6286
6287 Local<String> String::NewUndetectable(const char* data, int length) {
6288 return NewFromUtf8(Isolate::GetCurrent(), data, kUndetectableString, length);
6289 }
6290
6291
6292 Local<String> String::NewUndetectable(const uint16_t* data, int length) {
6293 return NewFromTwoByte(
6294 Isolate::GetCurrent(), data, kUndetectableString, length);
6295 }
6296
6297
6298 String::ExternalStringResource* String::GetExternalStringResource() const { 6012 String::ExternalStringResource* String::GetExternalStringResource() const {
6299 typedef internal::Object O; 6013 typedef internal::Object O;
6300 typedef internal::Internals I; 6014 typedef internal::Internals I;
6301 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); 6015 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
6302 String::ExternalStringResource* result; 6016 String::ExternalStringResource* result;
6303 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { 6017 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
6304 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); 6018 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
6305 result = reinterpret_cast<String::ExternalStringResource*>(value); 6019 result = reinterpret_cast<String::ExternalStringResource*>(value);
6306 } else { 6020 } else {
6307 result = NULL; 6021 result = NULL;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
6658 6372
6659 Handle<Boolean> False(Isolate* isolate) { 6373 Handle<Boolean> False(Isolate* isolate) {
6660 typedef internal::Object* S; 6374 typedef internal::Object* S;
6661 typedef internal::Internals I; 6375 typedef internal::Internals I;
6662 I::CheckInitialized(isolate); 6376 I::CheckInitialized(isolate);
6663 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); 6377 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
6664 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); 6378 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
6665 } 6379 }
6666 6380
6667 6381
6668 void Isolate::SetData(void* data) {
6669 typedef internal::Internals I;
6670 I::SetEmbedderData(this, 0, data);
6671 }
6672
6673
6674 void* Isolate::GetData() {
6675 typedef internal::Internals I;
6676 return I::GetEmbedderData(this, 0);
6677 }
6678
6679
6680 void Isolate::SetData(uint32_t slot, void* data) { 6382 void Isolate::SetData(uint32_t slot, void* data) {
6681 typedef internal::Internals I; 6383 typedef internal::Internals I;
6682 I::SetEmbedderData(this, slot, data); 6384 I::SetEmbedderData(this, slot, data);
6683 } 6385 }
6684 6386
6685 6387
6686 void* Isolate::GetData(uint32_t slot) { 6388 void* Isolate::GetData(uint32_t slot) {
6687 typedef internal::Internals I; 6389 typedef internal::Internals I;
6688 return I::GetEmbedderData(this, slot); 6390 return I::GetEmbedderData(this, slot);
6689 } 6391 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
6759 */ 6461 */
6760 6462
6761 6463
6762 } // namespace v8 6464 } // namespace v8
6763 6465
6764 6466
6765 #undef TYPE_CHECK 6467 #undef TYPE_CHECK
6766 6468
6767 6469
6768 #endif // V8_H_ 6470 #endif // V8_H_
OLDNEW
« no previous file with comments | « codereview.settings ('k') | include/v8-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698