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

Side by Side Diff: include/v8.h

Issue 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 4 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 | « build/all.gyp ('k') | preparser/preparser-process.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 #endif // _WIN32 74 #endif // _WIN32
75 75
76 /** 76 /**
77 * The v8 JavaScript engine. 77 * The v8 JavaScript engine.
78 */ 78 */
79 namespace v8 { 79 namespace v8 {
80 80
81 class Context; 81 class Context;
82 class String; 82 class String;
83 class StringObject;
83 class Value; 84 class Value;
84 class Utils; 85 class Utils;
85 class Number; 86 class Number;
87 class NumberObject;
86 class Object; 88 class Object;
87 class Array; 89 class Array;
88 class Int32; 90 class Int32;
89 class Uint32; 91 class Uint32;
90 class External; 92 class External;
91 class Primitive; 93 class Primitive;
92 class Boolean; 94 class Boolean;
95 class BooleanObject;
93 class Integer; 96 class Integer;
94 class Function; 97 class Function;
95 class Date; 98 class Date;
96 class ImplementationUtilities; 99 class ImplementationUtilities;
97 class Signature; 100 class Signature;
98 template <class T> class Handle; 101 template <class T> class Handle;
99 template <class T> class Local; 102 template <class T> class Local;
100 template <class T> class Persistent; 103 template <class T> class Persistent;
101 class FunctionTemplate; 104 class FunctionTemplate;
102 class ObjectTemplate; 105 class ObjectTemplate;
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 * Returns true if this value is a 32-bit unsigned integer. 925 * Returns true if this value is a 32-bit unsigned integer.
923 */ 926 */
924 V8EXPORT bool IsUint32() const; 927 V8EXPORT bool IsUint32() const;
925 928
926 /** 929 /**
927 * Returns true if this value is a Date. 930 * Returns true if this value is a Date.
928 */ 931 */
929 V8EXPORT bool IsDate() const; 932 V8EXPORT bool IsDate() const;
930 933
931 /** 934 /**
935 * Returns true if this value is a Boolean object.
936 */
937 V8EXPORT bool IsBooleanObject() const;
938
939 /**
940 * Returns true if this value is a Number object.
941 */
942 V8EXPORT bool IsNumberObject() const;
943
944 /**
945 * Returns true if this value is a String object.
946 */
947 V8EXPORT bool IsStringObject() const;
948
949 /**
950 * Returns true if this value is a NativeError.
951 */
952 V8EXPORT bool IsNativeError() const;
953
954 /**
932 * Returns true if this value is a RegExp. 955 * Returns true if this value is a RegExp.
933 */ 956 */
934 V8EXPORT bool IsRegExp() const; 957 V8EXPORT bool IsRegExp() const;
935 958
936 V8EXPORT Local<Boolean> ToBoolean() const; 959 V8EXPORT Local<Boolean> ToBoolean() const;
937 V8EXPORT Local<Number> ToNumber() const; 960 V8EXPORT Local<Number> ToNumber() const;
938 V8EXPORT Local<String> ToString() const; 961 V8EXPORT Local<String> ToString() const;
939 V8EXPORT Local<String> ToDetailString() const; 962 V8EXPORT Local<String> ToDetailString() const;
940 V8EXPORT Local<Object> ToObject() const; 963 V8EXPORT Local<Object> ToObject() const;
941 V8EXPORT Local<Integer> ToInteger() const; 964 V8EXPORT Local<Integer> ToInteger() const;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 // 1451 //
1429 // Note also that this only works for named properties. 1452 // Note also that this only works for named properties.
1430 V8EXPORT bool ForceSet(Handle<Value> key, 1453 V8EXPORT bool ForceSet(Handle<Value> key,
1431 Handle<Value> value, 1454 Handle<Value> value,
1432 PropertyAttribute attribs = None); 1455 PropertyAttribute attribs = None);
1433 1456
1434 V8EXPORT Local<Value> Get(Handle<Value> key); 1457 V8EXPORT Local<Value> Get(Handle<Value> key);
1435 1458
1436 V8EXPORT Local<Value> Get(uint32_t index); 1459 V8EXPORT Local<Value> Get(uint32_t index);
1437 1460
1461 /**
1462 * Gets the property attributes of a property which can be None or
1463 * any combination of ReadOnly, DontEnum and DontDelete. Returns
1464 * None when the property doesn't exist.
1465 */
1466 V8EXPORT PropertyAttribute GetPropertyAttributes(Handle<Value> key);
1467
1438 // TODO(1245389): Replace the type-specific versions of these 1468 // TODO(1245389): Replace the type-specific versions of these
1439 // functions with generic ones that accept a Handle<Value> key. 1469 // functions with generic ones that accept a Handle<Value> key.
1440 V8EXPORT bool Has(Handle<String> key); 1470 V8EXPORT bool Has(Handle<String> key);
1441 1471
1442 V8EXPORT bool Delete(Handle<String> key); 1472 V8EXPORT bool Delete(Handle<String> key);
1443 1473
1444 // Delete a property on this object bypassing interceptors and 1474 // Delete a property on this object bypassing interceptors and
1445 // ignoring dont-delete attributes. 1475 // ignoring dont-delete attributes.
1446 V8EXPORT bool ForceDelete(Handle<Value> key); 1476 V8EXPORT bool ForceDelete(Handle<Value> key);
1447 1477
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 * negatively impact the performance of date operations. 1768 * negatively impact the performance of date operations.
1739 */ 1769 */
1740 V8EXPORT static void DateTimeConfigurationChangeNotification(); 1770 V8EXPORT static void DateTimeConfigurationChangeNotification();
1741 1771
1742 private: 1772 private:
1743 V8EXPORT static void CheckCast(v8::Value* obj); 1773 V8EXPORT static void CheckCast(v8::Value* obj);
1744 }; 1774 };
1745 1775
1746 1776
1747 /** 1777 /**
1778 * A Number object (ECMA-262, 4.3.21).
1779 */
1780 class NumberObject : public Object {
1781 public:
1782 V8EXPORT static Local<Value> New(double value);
1783
1784 /**
1785 * Returns the Number held by the object.
1786 */
1787 V8EXPORT double NumberValue() const;
1788
1789 static inline NumberObject* Cast(v8::Value* obj);
1790
1791 private:
1792 V8EXPORT static void CheckCast(v8::Value* obj);
1793 };
1794
1795
1796 /**
1797 * A Boolean object (ECMA-262, 4.3.15).
1798 */
1799 class BooleanObject : public Object {
1800 public:
1801 V8EXPORT static Local<Value> New(bool value);
1802
1803 /**
1804 * Returns the Boolean held by the object.
1805 */
1806 V8EXPORT bool BooleanValue() const;
1807
1808 static inline BooleanObject* Cast(v8::Value* obj);
1809
1810 private:
1811 V8EXPORT static void CheckCast(v8::Value* obj);
1812 };
1813
1814
1815 /**
1816 * A String object (ECMA-262, 4.3.18).
1817 */
1818 class StringObject : public Object {
1819 public:
1820 V8EXPORT static Local<Value> New(Handle<String> value);
1821
1822 /**
1823 * Returns the String held by the object.
1824 */
1825 V8EXPORT Local<String> StringValue() const;
1826
1827 static inline StringObject* Cast(v8::Value* obj);
1828
1829 private:
1830 V8EXPORT static void CheckCast(v8::Value* obj);
1831 };
1832
1833
1834 /**
1748 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). 1835 * An instance of the built-in RegExp constructor (ECMA-262, 15.10).
1749 */ 1836 */
1750 class RegExp : public Object { 1837 class RegExp : public Object {
1751 public: 1838 public:
1752 /** 1839 /**
1753 * Regular expression flag bits. They can be or'ed to enable a set 1840 * Regular expression flag bits. They can be or'ed to enable a set
1754 * of flags. 1841 * of flags.
1755 */ 1842 */
1756 enum Flags { 1843 enum Flags {
1757 kNone = 0, 1844 kNone = 0,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 * 2224 *
2138 * Call with a value of true to make the __proto__ accessor ignore 2225 * Call with a value of true to make the __proto__ accessor ignore
2139 * instances of the function template. Call with a value of false 2226 * instances of the function template. Call with a value of false
2140 * to make the __proto__ accessor not ignore instances of the 2227 * to make the __proto__ accessor not ignore instances of the
2141 * function template. By default, instances of a function template 2228 * function template. By default, instances of a function template
2142 * are not ignored. 2229 * are not ignored.
2143 */ 2230 */
2144 void SetHiddenPrototype(bool value); 2231 void SetHiddenPrototype(bool value);
2145 2232
2146 /** 2233 /**
2147 * Sets the property attributes of the 'prototype' property of functions 2234 * Sets the ReadOnly flag in the attributes of the 'prototype' property
2148 * created from this FunctionTemplate. Can be any combination of ReadOnly, 2235 * of functions created from this FunctionTemplate to true.
2149 * DontEnum and DontDelete.
2150 */ 2236 */
2151 void SetPrototypeAttributes(int attributes); 2237 void ReadOnlyPrototype();
2152 2238
2153 /** 2239 /**
2154 * Returns true if the given object is an instance of this function 2240 * Returns true if the given object is an instance of this function
2155 * template. 2241 * template.
2156 */ 2242 */
2157 bool HasInstance(Handle<Value> object); 2243 bool HasInstance(Handle<Value> object);
2158 2244
2159 private: 2245 private:
2160 FunctionTemplate(); 2246 FunctionTemplate();
2161 void AddInstancePropertyAccessor(Handle<String> name, 2247 void AddInstancePropertyAccessor(Handle<String> name,
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 protected: 2800 protected:
2715 virtual int DecompressData(char* raw_data, 2801 virtual int DecompressData(char* raw_data,
2716 int* raw_data_size, 2802 int* raw_data_size,
2717 const char* compressed_data, 2803 const char* compressed_data,
2718 int compressed_data_size) = 0; 2804 int compressed_data_size) = 0;
2719 2805
2720 private: 2806 private:
2721 char** raw_data; 2807 char** raw_data;
2722 }; 2808 };
2723 2809
2810
2811 /**
2812 * EntropySource is used as a callback function when v8 needs a source
2813 * of entropy.
2814 */
2815 typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
2816
2724 /** 2817 /**
2725 * Container class for static utility functions. 2818 * Container class for static utility functions.
2726 */ 2819 */
2727 class V8EXPORT V8 { 2820 class V8EXPORT V8 {
2728 public: 2821 public:
2729 /** Set the callback to invoke in case of fatal errors. */ 2822 /** Set the callback to invoke in case of fatal errors. */
2730 static void SetFatalErrorHandler(FatalErrorCallback that); 2823 static void SetFatalErrorHandler(FatalErrorCallback that);
2731 2824
2732 /** 2825 /**
2733 * Set the callback to invoke to check if code generation from 2826 * Set the callback to invoke to check if code generation from
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2939 size_t length); 3032 size_t length);
2940 3033
2941 /** 3034 /**
2942 * Initializes from snapshot if possible. Otherwise, attempts to 3035 * Initializes from snapshot if possible. Otherwise, attempts to
2943 * initialize from scratch. This function is called implicitly if 3036 * initialize from scratch. This function is called implicitly if
2944 * you use the API without calling it first. 3037 * you use the API without calling it first.
2945 */ 3038 */
2946 static bool Initialize(); 3039 static bool Initialize();
2947 3040
2948 /** 3041 /**
3042 * Allows the host application to provide a callback which can be used
3043 * as a source of entropy for random number generators.
3044 */
3045 static void SetEntropySource(EntropySource source);
3046
3047 /**
2949 * Adjusts the amount of registered external memory. Used to give 3048 * Adjusts the amount of registered external memory. Used to give
2950 * V8 an indication of the amount of externally allocated memory 3049 * V8 an indication of the amount of externally allocated memory
2951 * that is kept alive by JavaScript objects. V8 uses this to decide 3050 * that is kept alive by JavaScript objects. V8 uses this to decide
2952 * when to perform global garbage collections. Registering 3051 * when to perform global garbage collections. Registering
2953 * externally allocated memory will trigger global garbage 3052 * externally allocated memory will trigger global garbage
2954 * collections more often than otherwise in an attempt to garbage 3053 * collections more often than otherwise in an attempt to garbage
2955 * collect the JavaScript objects keeping the externally allocated 3054 * collect the JavaScript objects keeping the externally allocated
2956 * memory alive. 3055 * memory alive.
2957 * 3056 *
2958 * \param change_in_bytes the change in externally allocated memory 3057 * \param change_in_bytes the change in externally allocated memory
(...skipping 18 matching lines...) Expand all
2977 * See also PauseProfiler(). 3076 * See also PauseProfiler().
2978 */ 3077 */
2979 static void ResumeProfiler(); 3078 static void ResumeProfiler();
2980 3079
2981 /** 3080 /**
2982 * Return whether profiler is currently paused. 3081 * Return whether profiler is currently paused.
2983 */ 3082 */
2984 static bool IsProfilerPaused(); 3083 static bool IsProfilerPaused();
2985 3084
2986 /** 3085 /**
2987 * If logging is performed into a memory buffer (via --logfile=*), allows to
2988 * retrieve previously written messages. This can be used for retrieving
2989 * profiler log data in the application. This function is thread-safe.
2990 *
2991 * Caller provides a destination buffer that must exist during GetLogLines
2992 * call. Only whole log lines are copied into the buffer.
2993 *
2994 * \param from_pos specified a point in a buffer to read from, 0 is the
2995 * beginning of a buffer. It is assumed that caller updates its current
2996 * position using returned size value from the previous call.
2997 * \param dest_buf destination buffer for log data.
2998 * \param max_size size of the destination buffer.
2999 * \returns actual size of log data copied into buffer.
3000 */
3001 static int GetLogLines(int from_pos, char* dest_buf, int max_size);
3002
3003 /**
3004 * The minimum allowed size for a log lines buffer. If the size of
3005 * the buffer given will not be enough to hold a line of the maximum
3006 * length, an attempt to find a log line end in GetLogLines will
3007 * fail, and an empty result will be returned.
3008 */
3009 static const int kMinimumSizeForLogLinesBuffer = 2048;
3010
3011 /**
3012 * Retrieve the V8 thread id of the calling thread. 3086 * Retrieve the V8 thread id of the calling thread.
3013 * 3087 *
3014 * The thread id for a thread should only be retrieved after the V8 3088 * The thread id for a thread should only be retrieved after the V8
3015 * lock has been acquired with a Locker object with that thread. 3089 * lock has been acquired with a Locker object with that thread.
3016 */ 3090 */
3017 static int GetCurrentThreadId(); 3091 static int GetCurrentThreadId();
3018 3092
3019 /** 3093 /**
3020 * Forcefully terminate execution of a JavaScript thread. This can 3094 * Forcefully terminate execution of a JavaScript thread. This can
3021 * be used to terminate long-running scripts. 3095 * be used to terminate long-running scripts.
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 4102
4029 4103
4030 Date* Date::Cast(v8::Value* value) { 4104 Date* Date::Cast(v8::Value* value) {
4031 #ifdef V8_ENABLE_CHECKS 4105 #ifdef V8_ENABLE_CHECKS
4032 CheckCast(value); 4106 CheckCast(value);
4033 #endif 4107 #endif
4034 return static_cast<Date*>(value); 4108 return static_cast<Date*>(value);
4035 } 4109 }
4036 4110
4037 4111
4112 StringObject* StringObject::Cast(v8::Value* value) {
4113 #ifdef V8_ENABLE_CHECKS
4114 CheckCast(value);
4115 #endif
4116 return static_cast<StringObject*>(value);
4117 }
4118
4119
4120 NumberObject* NumberObject::Cast(v8::Value* value) {
4121 #ifdef V8_ENABLE_CHECKS
4122 CheckCast(value);
4123 #endif
4124 return static_cast<NumberObject*>(value);
4125 }
4126
4127
4128 BooleanObject* BooleanObject::Cast(v8::Value* value) {
4129 #ifdef V8_ENABLE_CHECKS
4130 CheckCast(value);
4131 #endif
4132 return static_cast<BooleanObject*>(value);
4133 }
4134
4135
4038 RegExp* RegExp::Cast(v8::Value* value) { 4136 RegExp* RegExp::Cast(v8::Value* value) {
4039 #ifdef V8_ENABLE_CHECKS 4137 #ifdef V8_ENABLE_CHECKS
4040 CheckCast(value); 4138 CheckCast(value);
4041 #endif 4139 #endif
4042 return static_cast<RegExp*>(value); 4140 return static_cast<RegExp*>(value);
4043 } 4141 }
4044 4142
4045 4143
4046 Object* Object::Cast(v8::Value* value) { 4144 Object* Object::Cast(v8::Value* value) {
4047 #ifdef V8_ENABLE_CHECKS 4145 #ifdef V8_ENABLE_CHECKS
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4103 4201
4104 4202
4105 } // namespace v8 4203 } // namespace v8
4106 4204
4107 4205
4108 #undef V8EXPORT 4206 #undef V8EXPORT
4109 #undef TYPE_CHECK 4207 #undef TYPE_CHECK
4110 4208
4111 4209
4112 #endif // V8_H_ 4210 #endif // V8_H_
OLDNEW
« no previous file with comments | « build/all.gyp ('k') | preparser/preparser-process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698