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