| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_FACTORY_H_ | 28 #ifndef V8_FACTORY_H_ |
| 29 #define V8_FACTORY_H_ | 29 #define V8_FACTORY_H_ |
| 30 | 30 |
| 31 #include "globals.h" | 31 #include "globals.h" |
| 32 #include "handles.h" |
| 32 #include "heap.h" | 33 #include "heap.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 // Interface for handle based allocation. | 38 // Interface for handle based allocation. |
| 38 | 39 |
| 39 class Factory : public AllStatic { | 40 class Factory { |
| 40 public: | 41 public: |
| 41 // Allocate a new fixed array with undefined entries. | 42 // Allocate a new fixed array with undefined entries. |
| 42 static Handle<FixedArray> NewFixedArray( | 43 Handle<FixedArray> NewFixedArray( |
| 43 int size, | 44 int size, |
| 44 PretenureFlag pretenure = NOT_TENURED); | 45 PretenureFlag pretenure = NOT_TENURED); |
| 45 | 46 |
| 46 // Allocate a new fixed array with non-existing entries (the hole). | 47 // Allocate a new fixed array with non-existing entries (the hole). |
| 47 static Handle<FixedArray> NewFixedArrayWithHoles( | 48 Handle<FixedArray> NewFixedArrayWithHoles( |
| 48 int size, | 49 int size, |
| 49 PretenureFlag pretenure = NOT_TENURED); | 50 PretenureFlag pretenure = NOT_TENURED); |
| 50 | 51 |
| 51 static Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for); | 52 Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for); |
| 52 | 53 |
| 53 static Handle<StringDictionary> NewStringDictionary(int at_least_space_for); | 54 Handle<StringDictionary> NewStringDictionary(int at_least_space_for); |
| 54 | 55 |
| 55 static Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors); | 56 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors); |
| 56 static Handle<DeoptimizationInputData> NewDeoptimizationInputData( | 57 Handle<DeoptimizationInputData> NewDeoptimizationInputData( |
| 57 int deopt_entry_count, | 58 int deopt_entry_count, |
| 58 PretenureFlag pretenure); | 59 PretenureFlag pretenure); |
| 59 static Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( | 60 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( |
| 60 int deopt_entry_count, | 61 int deopt_entry_count, |
| 61 PretenureFlag pretenure); | 62 PretenureFlag pretenure); |
| 62 | 63 |
| 63 static Handle<String> LookupSymbol(Vector<const char> str); | 64 Handle<String> LookupSymbol(Vector<const char> str); |
| 64 static Handle<String> LookupAsciiSymbol(Vector<const char> str); | 65 Handle<String> LookupAsciiSymbol(Vector<const char> str); |
| 65 static Handle<String> LookupTwoByteSymbol(Vector<const uc16> str); | 66 Handle<String> LookupTwoByteSymbol(Vector<const uc16> str); |
| 66 static Handle<String> LookupAsciiSymbol(const char* str) { | 67 Handle<String> LookupAsciiSymbol(const char* str) { |
| 67 return LookupSymbol(CStrVector(str)); | 68 return LookupSymbol(CStrVector(str)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 | 71 |
| 71 // String creation functions. Most of the string creation functions take | 72 // String creation functions. Most of the string creation functions take |
| 72 // a Heap::PretenureFlag argument to optionally request that they be | 73 // a Heap::PretenureFlag argument to optionally request that they be |
| 73 // allocated in the old generation. The pretenure flag defaults to | 74 // allocated in the old generation. The pretenure flag defaults to |
| 74 // DONT_TENURE. | 75 // DONT_TENURE. |
| 75 // | 76 // |
| 76 // Creates a new String object. There are two String encodings: ASCII and | 77 // Creates a new String object. There are two String encodings: ASCII and |
| 77 // two byte. One should choose between the three string factory functions | 78 // two byte. One should choose between the three string factory functions |
| 78 // based on the encoding of the string buffer that the string is | 79 // based on the encoding of the string buffer that the string is |
| 79 // initialized from. | 80 // initialized from. |
| 80 // - ...FromAscii initializes the string from a buffer that is ASCII | 81 // - ...FromAscii initializes the string from a buffer that is ASCII |
| 81 // encoded (it does not check that the buffer is ASCII encoded) and | 82 // encoded (it does not check that the buffer is ASCII encoded) and |
| 82 // the result will be ASCII encoded. | 83 // the result will be ASCII encoded. |
| 83 // - ...FromUtf8 initializes the string from a buffer that is UTF-8 | 84 // - ...FromUtf8 initializes the string from a buffer that is UTF-8 |
| 84 // encoded. If the characters are all single-byte characters, the | 85 // encoded. If the characters are all single-byte characters, the |
| 85 // result will be ASCII encoded, otherwise it will converted to two | 86 // result will be ASCII encoded, otherwise it will converted to two |
| 86 // byte. | 87 // byte. |
| 87 // - ...FromTwoByte initializes the string from a buffer that is two | 88 // - ...FromTwoByte initializes the string from a buffer that is two |
| 88 // byte encoded. If the characters are all single-byte characters, | 89 // byte encoded. If the characters are all single-byte characters, |
| 89 // the result will be converted to ASCII, otherwise it will be left as | 90 // the result will be converted to ASCII, otherwise it will be left as |
| 90 // two byte. | 91 // two byte. |
| 91 // | 92 // |
| 92 // ASCII strings are pretenured when used as keys in the SourceCodeCache. | 93 // ASCII strings are pretenured when used as keys in the SourceCodeCache. |
| 93 static Handle<String> NewStringFromAscii( | 94 Handle<String> NewStringFromAscii( |
| 94 Vector<const char> str, | 95 Vector<const char> str, |
| 95 PretenureFlag pretenure = NOT_TENURED); | 96 PretenureFlag pretenure = NOT_TENURED); |
| 96 | 97 |
| 97 // UTF8 strings are pretenured when used for regexp literal patterns and | 98 // UTF8 strings are pretenured when used for regexp literal patterns and |
| 98 // flags in the parser. | 99 // flags in the parser. |
| 99 static Handle<String> NewStringFromUtf8( | 100 Handle<String> NewStringFromUtf8( |
| 100 Vector<const char> str, | 101 Vector<const char> str, |
| 101 PretenureFlag pretenure = NOT_TENURED); | 102 PretenureFlag pretenure = NOT_TENURED); |
| 102 | 103 |
| 103 static Handle<String> NewStringFromTwoByte( | 104 Handle<String> NewStringFromTwoByte( |
| 104 Vector<const uc16> str, | 105 Vector<const uc16> str, |
| 105 PretenureFlag pretenure = NOT_TENURED); | 106 PretenureFlag pretenure = NOT_TENURED); |
| 106 | 107 |
| 107 // Allocates and partially initializes an ASCII or TwoByte String. The | 108 // Allocates and partially initializes an ASCII or TwoByte String. The |
| 108 // characters of the string are uninitialized. Currently used in regexp code | 109 // characters of the string are uninitialized. Currently used in regexp code |
| 109 // only, where they are pretenured. | 110 // only, where they are pretenured. |
| 110 static Handle<String> NewRawAsciiString( | 111 Handle<String> NewRawAsciiString( |
| 111 int length, | 112 int length, |
| 112 PretenureFlag pretenure = NOT_TENURED); | 113 PretenureFlag pretenure = NOT_TENURED); |
| 113 static Handle<String> NewRawTwoByteString( | 114 Handle<String> NewRawTwoByteString( |
| 114 int length, | 115 int length, |
| 115 PretenureFlag pretenure = NOT_TENURED); | 116 PretenureFlag pretenure = NOT_TENURED); |
| 116 | 117 |
| 117 // Create a new cons string object which consists of a pair of strings. | 118 // Create a new cons string object which consists of a pair of strings. |
| 118 static Handle<String> NewConsString(Handle<String> first, | 119 Handle<String> NewConsString(Handle<String> first, |
| 119 Handle<String> second); | 120 Handle<String> second); |
| 120 | 121 |
| 121 // Create a new string object which holds a substring of a string. | 122 // Create a new string object which holds a substring of a string. |
| 122 static Handle<String> NewSubString(Handle<String> str, | 123 Handle<String> NewSubString(Handle<String> str, |
| 123 int begin, | 124 int begin, |
| 124 int end); | 125 int end); |
| 125 | 126 |
| 126 // Creates a new external String object. There are two String encodings | 127 // Creates a new external String object. There are two String encodings |
| 127 // in the system: ASCII and two byte. Unlike other String types, it does | 128 // in the system: ASCII and two byte. Unlike other String types, it does |
| 128 // not make sense to have a UTF-8 factory function for external strings, | 129 // not make sense to have a UTF-8 factory function for external strings, |
| 129 // because we cannot change the underlying buffer. | 130 // because we cannot change the underlying buffer. |
| 130 static Handle<String> NewExternalStringFromAscii( | 131 Handle<String> NewExternalStringFromAscii( |
| 131 ExternalAsciiString::Resource* resource); | 132 ExternalAsciiString::Resource* resource); |
| 132 static Handle<String> NewExternalStringFromTwoByte( | 133 Handle<String> NewExternalStringFromTwoByte( |
| 133 ExternalTwoByteString::Resource* resource); | 134 ExternalTwoByteString::Resource* resource); |
| 134 | 135 |
| 135 // Create a global (but otherwise uninitialized) context. | 136 // Create a global (but otherwise uninitialized) context. |
| 136 static Handle<Context> NewGlobalContext(); | 137 Handle<Context> NewGlobalContext(); |
| 137 | 138 |
| 138 // Create a function context. | 139 // Create a function context. |
| 139 static Handle<Context> NewFunctionContext(int length, | 140 Handle<Context> NewFunctionContext(int length, |
| 140 Handle<JSFunction> closure); | 141 Handle<JSFunction> closure); |
| 141 | 142 |
| 142 // Create a 'with' context. | 143 // Create a 'with' context. |
| 143 static Handle<Context> NewWithContext(Handle<Context> previous, | 144 Handle<Context> NewWithContext(Handle<Context> previous, |
| 144 Handle<JSObject> extension, | 145 Handle<JSObject> extension, |
| 145 bool is_catch_context); | 146 bool is_catch_context); |
| 146 | 147 |
| 147 // Return the Symbol matching the passed in string. | 148 // Return the Symbol matching the passed in string. |
| 148 static Handle<String> SymbolFromString(Handle<String> value); | 149 Handle<String> SymbolFromString(Handle<String> value); |
| 149 | 150 |
| 150 // Allocate a new struct. The struct is pretenured (allocated directly in | 151 // Allocate a new struct. The struct is pretenured (allocated directly in |
| 151 // the old generation). | 152 // the old generation). |
| 152 static Handle<Struct> NewStruct(InstanceType type); | 153 Handle<Struct> NewStruct(InstanceType type); |
| 153 | 154 |
| 154 static Handle<AccessorInfo> NewAccessorInfo(); | 155 Handle<AccessorInfo> NewAccessorInfo(); |
| 155 | 156 |
| 156 static Handle<Script> NewScript(Handle<String> source); | 157 Handle<Script> NewScript(Handle<String> source); |
| 157 | 158 |
| 158 // Proxies are pretenured when allocated by the bootstrapper. | 159 // Proxies are pretenured when allocated by the bootstrapper. |
| 159 static Handle<Proxy> NewProxy(Address addr, | 160 Handle<Proxy> NewProxy(Address addr, |
| 160 PretenureFlag pretenure = NOT_TENURED); | 161 PretenureFlag pretenure = NOT_TENURED); |
| 161 | 162 |
| 162 // Allocate a new proxy. The proxy is pretenured (allocated directly in | 163 // Allocate a new proxy. The proxy is pretenured (allocated directly in |
| 163 // the old generation). | 164 // the old generation). |
| 164 static Handle<Proxy> NewProxy(const AccessorDescriptor* proxy); | 165 Handle<Proxy> NewProxy(const AccessorDescriptor* proxy); |
| 165 | 166 |
| 166 static Handle<ByteArray> NewByteArray(int length, | 167 Handle<ByteArray> NewByteArray(int length, |
| 167 PretenureFlag pretenure = NOT_TENURED); | 168 PretenureFlag pretenure = NOT_TENURED); |
| 168 | 169 |
| 169 static Handle<ExternalArray> NewExternalArray( | 170 Handle<ExternalArray> NewExternalArray( |
| 170 int length, | 171 int length, |
| 171 ExternalArrayType array_type, | 172 ExternalArrayType array_type, |
| 172 void* external_pointer, | 173 void* external_pointer, |
| 173 PretenureFlag pretenure = NOT_TENURED); | 174 PretenureFlag pretenure = NOT_TENURED); |
| 174 | 175 |
| 175 static Handle<JSGlobalPropertyCell> NewJSGlobalPropertyCell( | 176 Handle<JSGlobalPropertyCell> NewJSGlobalPropertyCell( |
| 176 Handle<Object> value); | 177 Handle<Object> value); |
| 177 | 178 |
| 178 static Handle<Map> NewMap(InstanceType type, int instance_size); | 179 Handle<Map> NewMap(InstanceType type, int instance_size); |
| 179 | 180 |
| 180 static Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function); | 181 Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function); |
| 181 | 182 |
| 182 static Handle<Map> CopyMapDropDescriptors(Handle<Map> map); | 183 Handle<Map> CopyMapDropDescriptors(Handle<Map> map); |
| 183 | 184 |
| 184 // Copy the map adding more inobject properties if possible without | 185 // Copy the map adding more inobject properties if possible without |
| 185 // overflowing the instance size. | 186 // overflowing the instance size. |
| 186 static Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props); | 187 Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props); |
| 187 | 188 |
| 188 static Handle<Map> CopyMapDropTransitions(Handle<Map> map); | 189 Handle<Map> CopyMapDropTransitions(Handle<Map> map); |
| 189 | 190 |
| 190 static Handle<Map> GetFastElementsMap(Handle<Map> map); | 191 Handle<Map> GetFastElementsMap(Handle<Map> map); |
| 191 | 192 |
| 192 static Handle<Map> GetSlowElementsMap(Handle<Map> map); | 193 Handle<Map> GetSlowElementsMap(Handle<Map> map); |
| 193 | 194 |
| 194 static Handle<Map> NewExternalArrayElementsMap(Handle<Map> map); | 195 Handle<Map> NewExternalArrayElementsMap(Handle<Map> map); |
| 195 | 196 |
| 196 static Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array); | 197 Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array); |
| 197 | 198 |
| 198 // Numbers (eg, literals) are pretenured by the parser. | 199 // Numbers (eg, literals) are pretenured by the parser. |
| 199 static Handle<Object> NewNumber(double value, | 200 Handle<Object> NewNumber(double value, |
| 200 PretenureFlag pretenure = NOT_TENURED); | 201 PretenureFlag pretenure = NOT_TENURED); |
| 201 | 202 |
| 202 static Handle<Object> NewNumberFromInt(int value); | 203 Handle<Object> NewNumberFromInt(int value); |
| 203 static Handle<Object> NewNumberFromUint(uint32_t value); | 204 Handle<Object> NewNumberFromUint(uint32_t value); |
| 204 | 205 |
| 205 // These objects are used by the api to create env-independent data | 206 // These objects are used by the api to create env-independent data |
| 206 // structures in the heap. | 207 // structures in the heap. |
| 207 static Handle<JSObject> NewNeanderObject(); | 208 Handle<JSObject> NewNeanderObject(); |
| 208 | 209 |
| 209 static Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length); | 210 Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length); |
| 210 | 211 |
| 211 // JS objects are pretenured when allocated by the bootstrapper and | 212 // JS objects are pretenured when allocated by the bootstrapper and |
| 212 // runtime. | 213 // runtime. |
| 213 static Handle<JSObject> NewJSObject(Handle<JSFunction> constructor, | 214 Handle<JSObject> NewJSObject(Handle<JSFunction> constructor, |
| 214 PretenureFlag pretenure = NOT_TENURED); | 215 PretenureFlag pretenure = NOT_TENURED); |
| 215 | 216 |
| 216 // Global objects are pretenured. | 217 // Global objects are pretenured. |
| 217 static Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor); | 218 Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor); |
| 218 | 219 |
| 219 // JS objects are pretenured when allocated by the bootstrapper and | 220 // JS objects are pretenured when allocated by the bootstrapper and |
| 220 // runtime. | 221 // runtime. |
| 221 static Handle<JSObject> NewJSObjectFromMap(Handle<Map> map); | 222 Handle<JSObject> NewJSObjectFromMap(Handle<Map> map); |
| 222 | 223 |
| 223 // JS arrays are pretenured when allocated by the parser. | 224 // JS arrays are pretenured when allocated by the parser. |
| 224 static Handle<JSArray> NewJSArray(int capacity, | 225 Handle<JSArray> NewJSArray(int capacity, |
| 225 PretenureFlag pretenure = NOT_TENURED); | 226 PretenureFlag pretenure = NOT_TENURED); |
| 226 | 227 |
| 227 static Handle<JSArray> NewJSArrayWithElements( | 228 Handle<JSArray> NewJSArrayWithElements( |
| 228 Handle<FixedArray> elements, | 229 Handle<FixedArray> elements, |
| 229 PretenureFlag pretenure = NOT_TENURED); | 230 PretenureFlag pretenure = NOT_TENURED); |
| 230 | 231 |
| 231 static Handle<JSFunction> NewFunction(Handle<String> name, | 232 Handle<JSFunction> NewFunction(Handle<String> name, |
| 232 Handle<Object> prototype); | 233 Handle<Object> prototype); |
| 233 | 234 |
| 234 static Handle<JSFunction> NewFunctionWithoutPrototype( | 235 Handle<JSFunction> NewFunctionWithoutPrototype( |
| 235 Handle<String> name, | 236 Handle<String> name, |
| 236 StrictModeFlag strict_mode); | 237 StrictModeFlag strict_mode); |
| 237 | 238 |
| 238 static Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global); | 239 Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global); |
| 239 | 240 |
| 240 static Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo( | 241 Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo( |
| 241 Handle<SharedFunctionInfo> function_info, | 242 Handle<SharedFunctionInfo> function_info, |
| 242 Handle<Map> function_map, | 243 Handle<Map> function_map, |
| 243 PretenureFlag pretenure); | 244 PretenureFlag pretenure); |
| 244 | 245 |
| 245 static Handle<JSFunction> NewFunctionFromSharedFunctionInfo( | 246 Handle<JSFunction> NewFunctionFromSharedFunctionInfo( |
| 246 Handle<SharedFunctionInfo> function_info, | 247 Handle<SharedFunctionInfo> function_info, |
| 247 Handle<Context> context, | 248 Handle<Context> context, |
| 248 PretenureFlag pretenure = TENURED); | 249 PretenureFlag pretenure = TENURED); |
| 249 | 250 |
| 250 static Handle<Code> NewCode(const CodeDesc& desc, | 251 Handle<Code> NewCode(const CodeDesc& desc, |
| 251 Code::Flags flags, | 252 Code::Flags flags, |
| 252 Handle<Object> self_reference, | 253 Handle<Object> self_reference, |
| 253 bool immovable = false); | 254 bool immovable = false); |
| 254 | 255 |
| 255 static Handle<Code> CopyCode(Handle<Code> code); | 256 Handle<Code> CopyCode(Handle<Code> code); |
| 256 | 257 |
| 257 static Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info); | 258 Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info); |
| 258 | 259 |
| 259 static Handle<Object> ToObject(Handle<Object> object); | 260 Handle<Object> ToObject(Handle<Object> object); |
| 260 static Handle<Object> ToObject(Handle<Object> object, | 261 Handle<Object> ToObject(Handle<Object> object, |
| 261 Handle<Context> global_context); | 262 Handle<Context> global_context); |
| 262 | 263 |
| 263 // Interface for creating error objects. | 264 // Interface for creating error objects. |
| 264 | 265 |
| 265 static Handle<Object> NewError(const char* maker, const char* type, | 266 Handle<Object> NewError(const char* maker, const char* type, |
| 266 Handle<JSArray> args); | 267 Handle<JSArray> args); |
| 267 static Handle<Object> NewError(const char* maker, const char* type, | 268 Handle<Object> NewError(const char* maker, const char* type, |
| 268 Vector< Handle<Object> > args); | 269 Vector< Handle<Object> > args); |
| 269 static Handle<Object> NewError(const char* type, | 270 Handle<Object> NewError(const char* type, |
| 270 Vector< Handle<Object> > args); | 271 Vector< Handle<Object> > args); |
| 271 static Handle<Object> NewError(Handle<String> message); | 272 Handle<Object> NewError(Handle<String> message); |
| 272 static Handle<Object> NewError(const char* constructor, | 273 Handle<Object> NewError(const char* constructor, |
| 273 Handle<String> message); | 274 Handle<String> message); |
| 274 | 275 |
| 275 static Handle<Object> NewTypeError(const char* type, | 276 Handle<Object> NewTypeError(const char* type, |
| 276 Vector< Handle<Object> > args); | 277 Vector< Handle<Object> > args); |
| 277 static Handle<Object> NewTypeError(Handle<String> message); | 278 Handle<Object> NewTypeError(Handle<String> message); |
| 278 | 279 |
| 279 static Handle<Object> NewRangeError(const char* type, | 280 Handle<Object> NewRangeError(const char* type, |
| 280 Vector< Handle<Object> > args); | 281 Vector< Handle<Object> > args); |
| 281 static Handle<Object> NewRangeError(Handle<String> message); | 282 Handle<Object> NewRangeError(Handle<String> message); |
| 282 | 283 |
| 283 static Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args); | 284 Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args); |
| 284 static Handle<Object> NewSyntaxError(Handle<String> message); | 285 Handle<Object> NewSyntaxError(Handle<String> message); |
| 285 | 286 |
| 286 static Handle<Object> NewReferenceError(const char* type, | 287 Handle<Object> NewReferenceError(const char* type, |
| 287 Vector< Handle<Object> > args); | 288 Vector< Handle<Object> > args); |
| 288 static Handle<Object> NewReferenceError(Handle<String> message); | 289 Handle<Object> NewReferenceError(Handle<String> message); |
| 289 | 290 |
| 290 static Handle<Object> NewEvalError(const char* type, | 291 Handle<Object> NewEvalError(const char* type, |
| 291 Vector< Handle<Object> > args); | 292 Vector< Handle<Object> > args); |
| 292 | 293 |
| 293 | 294 |
| 294 static Handle<JSFunction> NewFunction(Handle<String> name, | 295 Handle<JSFunction> NewFunction(Handle<String> name, |
| 295 InstanceType type, | 296 InstanceType type, |
| 296 int instance_size, | 297 int instance_size, |
| 297 Handle<Code> code, | 298 Handle<Code> code, |
| 298 bool force_initial_map); | 299 bool force_initial_map); |
| 299 | 300 |
| 300 static Handle<JSFunction> NewFunction(Handle<Map> function_map, | 301 Handle<JSFunction> NewFunction(Handle<Map> function_map, |
| 301 Handle<SharedFunctionInfo> shared, Handle<Object> prototype); | 302 Handle<SharedFunctionInfo> shared, Handle<Object> prototype); |
| 302 | 303 |
| 303 | 304 |
| 304 static Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, | 305 Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, |
| 305 InstanceType type, | 306 InstanceType type, |
| 306 int instance_size, | 307 int instance_size, |
| 307 Handle<JSObject> prototype, | 308 Handle<JSObject> prototype, |
| 308 Handle<Code> code, | 309 Handle<Code> code, |
| 309 bool force_initial_map); | 310 bool force_initial_map); |
| 310 | 311 |
| 311 static Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, | 312 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, |
| 312 Handle<Code> code); | 313 Handle<Code> code); |
| 313 | 314 |
| 314 static Handle<DescriptorArray> CopyAppendProxyDescriptor( | 315 Handle<DescriptorArray> CopyAppendProxyDescriptor( |
| 315 Handle<DescriptorArray> array, | 316 Handle<DescriptorArray> array, |
| 316 Handle<String> key, | 317 Handle<String> key, |
| 317 Handle<Object> value, | 318 Handle<Object> value, |
| 318 PropertyAttributes attributes); | 319 PropertyAttributes attributes); |
| 319 | 320 |
| 320 static Handle<String> NumberToString(Handle<Object> number); | 321 Handle<String> NumberToString(Handle<Object> number); |
| 321 | 322 |
| 322 enum ApiInstanceType { | 323 enum ApiInstanceType { |
| 323 JavaScriptObject, | 324 JavaScriptObject, |
| 324 InnerGlobalObject, | 325 InnerGlobalObject, |
| 325 OuterGlobalObject | 326 OuterGlobalObject |
| 326 }; | 327 }; |
| 327 | 328 |
| 328 static Handle<JSFunction> CreateApiFunction( | 329 Handle<JSFunction> CreateApiFunction( |
| 329 Handle<FunctionTemplateInfo> data, | 330 Handle<FunctionTemplateInfo> data, |
| 330 ApiInstanceType type = JavaScriptObject); | 331 ApiInstanceType type = JavaScriptObject); |
| 331 | 332 |
| 332 static Handle<JSFunction> InstallMembers(Handle<JSFunction> function); | 333 Handle<JSFunction> InstallMembers(Handle<JSFunction> function); |
| 333 | 334 |
| 334 // Installs interceptors on the instance. 'desc' is a function template, | 335 // Installs interceptors on the instance. 'desc' is a function template, |
| 335 // and instance is an object instance created by the function of this | 336 // and instance is an object instance created by the function of this |
| 336 // function template. | 337 // function template. |
| 337 static void ConfigureInstance(Handle<FunctionTemplateInfo> desc, | 338 void ConfigureInstance(Handle<FunctionTemplateInfo> desc, |
| 338 Handle<JSObject> instance, | 339 Handle<JSObject> instance, |
| 339 bool* pending_exception); | 340 bool* pending_exception); |
| 340 | 341 |
| 341 #define ROOT_ACCESSOR(type, name, camel_name) \ | 342 #define ROOT_ACCESSOR(type, name, camel_name) \ |
| 342 static inline Handle<type> name() { \ | 343 inline Handle<type> name() { \ |
| 343 return Handle<type>(BitCast<type**>( \ | 344 return Handle<type>(BitCast<type**>( \ |
| 344 &Heap::roots_[Heap::k##camel_name##RootIndex])); \ | 345 &isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \ |
| 345 } | 346 } |
| 346 ROOT_LIST(ROOT_ACCESSOR) | 347 ROOT_LIST(ROOT_ACCESSOR) |
| 347 #undef ROOT_ACCESSOR_ACCESSOR | 348 #undef ROOT_ACCESSOR_ACCESSOR |
| 348 | 349 |
| 349 #define SYMBOL_ACCESSOR(name, str) \ | 350 #define SYMBOL_ACCESSOR(name, str) \ |
| 350 static inline Handle<String> name() { \ | 351 inline Handle<String> name() { \ |
| 351 return Handle<String>(BitCast<String**>( \ | 352 return Handle<String>(BitCast<String**>( \ |
| 352 &Heap::roots_[Heap::k##name##RootIndex])); \ | 353 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \ |
| 353 } | 354 } |
| 354 SYMBOL_LIST(SYMBOL_ACCESSOR) | 355 SYMBOL_LIST(SYMBOL_ACCESSOR) |
| 355 #undef SYMBOL_ACCESSOR | 356 #undef SYMBOL_ACCESSOR |
| 356 | 357 |
| 357 static Handle<String> hidden_symbol() { | 358 Handle<String> hidden_symbol() { |
| 358 return Handle<String>(&Heap::hidden_symbol_); | 359 return Handle<String>(&isolate()->heap()->hidden_symbol_); |
| 359 } | 360 } |
| 360 | 361 |
| 361 static Handle<SharedFunctionInfo> NewSharedFunctionInfo( | 362 Handle<SharedFunctionInfo> NewSharedFunctionInfo( |
| 362 Handle<String> name, | 363 Handle<String> name, |
| 363 int number_of_literals, | 364 int number_of_literals, |
| 364 Handle<Code> code, | 365 Handle<Code> code, |
| 365 Handle<SerializedScopeInfo> scope_info); | 366 Handle<SerializedScopeInfo> scope_info); |
| 366 static Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name); | 367 Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name); |
| 367 | 368 |
| 368 static Handle<JSMessageObject> NewJSMessageObject( | 369 Handle<JSMessageObject> NewJSMessageObject( |
| 369 Handle<String> type, | 370 Handle<String> type, |
| 370 Handle<JSArray> arguments, | 371 Handle<JSArray> arguments, |
| 371 int start_position, | 372 int start_position, |
| 372 int end_position, | 373 int end_position, |
| 373 Handle<Object> script, | 374 Handle<Object> script, |
| 374 Handle<Object> stack_trace, | 375 Handle<Object> stack_trace, |
| 375 Handle<Object> stack_frames); | 376 Handle<Object> stack_frames); |
| 376 | 377 |
| 377 static Handle<NumberDictionary> DictionaryAtNumberPut( | 378 Handle<NumberDictionary> DictionaryAtNumberPut( |
| 378 Handle<NumberDictionary>, | 379 Handle<NumberDictionary>, |
| 379 uint32_t key, | 380 uint32_t key, |
| 380 Handle<Object> value); | 381 Handle<Object> value); |
| 381 | 382 |
| 382 #ifdef ENABLE_DEBUGGER_SUPPORT | 383 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 383 static Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); | 384 Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); |
| 384 #endif | 385 #endif |
| 385 | 386 |
| 386 // Return a map using the map cache in the global context. | 387 // Return a map using the map cache in the global context. |
| 387 // The key the an ordered set of property names. | 388 // The key the an ordered set of property names. |
| 388 static Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context, | 389 Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context, |
| 389 Handle<FixedArray> keys); | 390 Handle<FixedArray> keys); |
| 390 | 391 |
| 391 // Creates a new FixedArray that holds the data associated with the | 392 // Creates a new FixedArray that holds the data associated with the |
| 392 // atom regexp and stores it in the regexp. | 393 // atom regexp and stores it in the regexp. |
| 393 static void SetRegExpAtomData(Handle<JSRegExp> regexp, | 394 void SetRegExpAtomData(Handle<JSRegExp> regexp, |
| 394 JSRegExp::Type type, | 395 JSRegExp::Type type, |
| 395 Handle<String> source, | 396 Handle<String> source, |
| 396 JSRegExp::Flags flags, | 397 JSRegExp::Flags flags, |
| 397 Handle<Object> match_pattern); | 398 Handle<Object> match_pattern); |
| 398 | 399 |
| 399 // Creates a new FixedArray that holds the data associated with the | 400 // Creates a new FixedArray that holds the data associated with the |
| 400 // irregexp regexp and stores it in the regexp. | 401 // irregexp regexp and stores it in the regexp. |
| 401 static void SetRegExpIrregexpData(Handle<JSRegExp> regexp, | 402 void SetRegExpIrregexpData(Handle<JSRegExp> regexp, |
| 402 JSRegExp::Type type, | 403 JSRegExp::Type type, |
| 403 Handle<String> source, | 404 Handle<String> source, |
| 404 JSRegExp::Flags flags, | 405 JSRegExp::Flags flags, |
| 405 int capture_count); | 406 int capture_count); |
| 406 | 407 |
| 407 private: | 408 private: |
| 408 static Handle<JSFunction> NewFunctionHelper(Handle<String> name, | 409 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); } |
| 409 Handle<Object> prototype); | |
| 410 | 410 |
| 411 static Handle<JSFunction> NewFunctionWithoutPrototypeHelper( | 411 Handle<JSFunction> NewFunctionHelper(Handle<String> name, |
| 412 Handle<Object> prototype); |
| 413 |
| 414 Handle<JSFunction> NewFunctionWithoutPrototypeHelper( |
| 412 Handle<String> name, | 415 Handle<String> name, |
| 413 StrictModeFlag strict_mode); | 416 StrictModeFlag strict_mode); |
| 414 | 417 |
| 415 static Handle<DescriptorArray> CopyAppendCallbackDescriptors( | 418 Handle<DescriptorArray> CopyAppendCallbackDescriptors( |
| 416 Handle<DescriptorArray> array, | 419 Handle<DescriptorArray> array, |
| 417 Handle<Object> descriptors); | 420 Handle<Object> descriptors); |
| 418 | 421 |
| 419 // Create a new map cache. | 422 // Create a new map cache. |
| 420 static Handle<MapCache> NewMapCache(int at_least_space_for); | 423 Handle<MapCache> NewMapCache(int at_least_space_for); |
| 421 | 424 |
| 422 // Update the map cache in the global context with (keys, map) | 425 // Update the map cache in the global context with (keys, map) |
| 423 static Handle<MapCache> AddToMapCache(Handle<Context> context, | 426 Handle<MapCache> AddToMapCache(Handle<Context> context, |
| 424 Handle<FixedArray> keys, | 427 Handle<FixedArray> keys, |
| 425 Handle<Map> map); | 428 Handle<Map> map); |
| 426 }; | 429 }; |
| 427 | 430 |
| 428 | 431 |
| 429 } } // namespace v8::internal | 432 } } // namespace v8::internal |
| 430 | 433 |
| 431 #endif // V8_FACTORY_H_ | 434 #endif // V8_FACTORY_H_ |
| OLD | NEW |