svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1 | // Copyright 2011 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 | #include "v8.h" |
| 29 | |
| 30 | #include "api.h" |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 31 | #include "debug.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 32 | #include "execution.h" |
| 33 | #include "factory.h" |
| 34 | #include "macro-assembler.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 35 | #include "objects.h" |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 36 | #include "objects-visiting.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 38 | namespace v8 { |
| 39 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 40 | |
| 41 | |
| 42 | Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) { |
| 43 | ASSERT(0 <= size); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 44 | CALL_HEAP_FUNCTION( |
| 45 | isolate(), |
| 46 | isolate()->heap()->AllocateFixedArray(size, pretenure), |
| 47 | FixedArray); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 51 | Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, |
| 52 | PretenureFlag pretenure) { |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 53 | ASSERT(0 <= size); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 54 | CALL_HEAP_FUNCTION( |
| 55 | isolate(), |
| 56 | isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure), |
| 57 | FixedArray); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 61 | Handle<FixedArray> Factory::NewFixedDoubleArray(int size, |
| 62 | PretenureFlag pretenure) { |
| 63 | ASSERT(0 <= size); |
| 64 | CALL_HEAP_FUNCTION( |
| 65 | isolate(), |
| 66 | isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), |
| 67 | FixedArray); |
| 68 | } |
| 69 | |
| 70 | |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 71 | Handle<StringDictionary> Factory::NewStringDictionary(int at_least_space_for) { |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 72 | ASSERT(0 <= at_least_space_for); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 73 | CALL_HEAP_FUNCTION(isolate(), |
| 74 | StringDictionary::Allocate(at_least_space_for), |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 75 | StringDictionary); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | Handle<NumberDictionary> Factory::NewNumberDictionary(int at_least_space_for) { |
| 80 | ASSERT(0 <= at_least_space_for); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 81 | CALL_HEAP_FUNCTION(isolate(), |
| 82 | NumberDictionary::Allocate(at_least_space_for), |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 83 | NumberDictionary); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 87 | Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) { |
| 88 | ASSERT(0 <= at_least_space_for); |
| 89 | CALL_HEAP_FUNCTION(isolate(), |
| 90 | ObjectHashTable::Allocate(at_least_space_for), |
| 91 | ObjectHashTable); |
| 92 | } |
| 93 | |
| 94 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 95 | Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors) { |
| 96 | ASSERT(0 <= number_of_descriptors); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 97 | CALL_HEAP_FUNCTION(isolate(), |
| 98 | DescriptorArray::Allocate(number_of_descriptors), |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 99 | DescriptorArray); |
| 100 | } |
| 101 | |
| 102 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 103 | Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( |
| 104 | int deopt_entry_count, |
| 105 | PretenureFlag pretenure) { |
| 106 | ASSERT(deopt_entry_count > 0); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 107 | CALL_HEAP_FUNCTION(isolate(), |
| 108 | DeoptimizationInputData::Allocate(deopt_entry_count, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 109 | pretenure), |
| 110 | DeoptimizationInputData); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | Handle<DeoptimizationOutputData> Factory::NewDeoptimizationOutputData( |
| 115 | int deopt_entry_count, |
| 116 | PretenureFlag pretenure) { |
| 117 | ASSERT(deopt_entry_count > 0); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 118 | CALL_HEAP_FUNCTION(isolate(), |
| 119 | DeoptimizationOutputData::Allocate(deopt_entry_count, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 120 | pretenure), |
| 121 | DeoptimizationOutputData); |
| 122 | } |
| 123 | |
| 124 | |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 125 | // Symbols are created in the old generation (data space). |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 126 | Handle<String> Factory::LookupSymbol(Vector<const char> string) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 127 | CALL_HEAP_FUNCTION(isolate(), |
| 128 | isolate()->heap()->LookupSymbol(string), |
| 129 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 130 | } |
| 131 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 132 | // Symbols are created in the old generation (data space). |
| 133 | Handle<String> Factory::LookupSymbol(Handle<String> string) { |
| 134 | CALL_HEAP_FUNCTION(isolate(), |
| 135 | isolate()->heap()->LookupSymbol(*string), |
| 136 | String); |
| 137 | } |
| 138 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 139 | Handle<String> Factory::LookupAsciiSymbol(Vector<const char> string) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 140 | CALL_HEAP_FUNCTION(isolate(), |
| 141 | isolate()->heap()->LookupAsciiSymbol(string), |
| 142 | String); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 143 | } |
| 144 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 145 | |
| 146 | Handle<String> Factory::LookupAsciiSymbol(Handle<SeqAsciiString> string, |
| 147 | int from, |
| 148 | int length) { |
| 149 | CALL_HEAP_FUNCTION(isolate(), |
| 150 | isolate()->heap()->LookupAsciiSymbol(string, |
| 151 | from, |
| 152 | length), |
| 153 | String); |
| 154 | } |
| 155 | |
| 156 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 157 | Handle<String> Factory::LookupTwoByteSymbol(Vector<const uc16> string) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 158 | CALL_HEAP_FUNCTION(isolate(), |
| 159 | isolate()->heap()->LookupTwoByteSymbol(string), |
| 160 | String); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 161 | } |
| 162 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 163 | |
| 164 | Handle<String> Factory::NewStringFromAscii(Vector<const char> string, |
| 165 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 166 | CALL_HEAP_FUNCTION( |
| 167 | isolate(), |
| 168 | isolate()->heap()->AllocateStringFromAscii(string, pretenure), |
| 169 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | Handle<String> Factory::NewStringFromUtf8(Vector<const char> string, |
| 173 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 174 | CALL_HEAP_FUNCTION( |
| 175 | isolate(), |
| 176 | isolate()->heap()->AllocateStringFromUtf8(string, pretenure), |
| 177 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 181 | Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, |
| 182 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 183 | CALL_HEAP_FUNCTION( |
| 184 | isolate(), |
| 185 | isolate()->heap()->AllocateStringFromTwoByte(string, pretenure), |
| 186 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 190 | Handle<SeqAsciiString> Factory::NewRawAsciiString(int length, |
| 191 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 192 | CALL_HEAP_FUNCTION( |
| 193 | isolate(), |
| 194 | isolate()->heap()->AllocateRawAsciiString(length, pretenure), |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 195 | SeqAsciiString); |
erik.corry@gmail.com | 4a2e25e | 2010-07-07 12:22:46 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 199 | Handle<SeqTwoByteString> Factory::NewRawTwoByteString(int length, |
| 200 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 201 | CALL_HEAP_FUNCTION( |
| 202 | isolate(), |
| 203 | isolate()->heap()->AllocateRawTwoByteString(length, pretenure), |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 204 | SeqTwoByteString); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | |
| 208 | Handle<String> Factory::NewConsString(Handle<String> first, |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 209 | Handle<String> second) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 210 | CALL_HEAP_FUNCTION(isolate(), |
| 211 | isolate()->heap()->AllocateConsString(*first, *second), |
| 212 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 216 | Handle<String> Factory::NewSubString(Handle<String> str, |
| 217 | int begin, |
| 218 | int end) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 219 | CALL_HEAP_FUNCTION(isolate(), |
| 220 | str->SubString(begin, end), |
| 221 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 225 | Handle<String> Factory::NewProperSubString(Handle<String> str, |
| 226 | int begin, |
| 227 | int end) { |
| 228 | ASSERT(begin > 0 || end < str->length()); |
| 229 | CALL_HEAP_FUNCTION(isolate(), |
| 230 | isolate()->heap()->AllocateSubString(*str, begin, end), |
| 231 | String); |
| 232 | } |
| 233 | |
| 234 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 235 | Handle<String> Factory::NewExternalStringFromAscii( |
| 236 | ExternalAsciiString::Resource* resource) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 237 | CALL_HEAP_FUNCTION( |
| 238 | isolate(), |
| 239 | isolate()->heap()->AllocateExternalStringFromAscii(resource), |
| 240 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | |
| 244 | Handle<String> Factory::NewExternalStringFromTwoByte( |
| 245 | ExternalTwoByteString::Resource* resource) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 246 | CALL_HEAP_FUNCTION( |
| 247 | isolate(), |
| 248 | isolate()->heap()->AllocateExternalStringFromTwoByte(resource), |
| 249 | String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | |
| 253 | Handle<Context> Factory::NewGlobalContext() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 254 | CALL_HEAP_FUNCTION( |
| 255 | isolate(), |
| 256 | isolate()->heap()->AllocateGlobalContext(), |
| 257 | Context); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | |
| 261 | Handle<Context> Factory::NewFunctionContext(int length, |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 262 | Handle<JSFunction> function) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 263 | CALL_HEAP_FUNCTION( |
| 264 | isolate(), |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 265 | isolate()->heap()->AllocateFunctionContext(length, *function), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 266 | Context); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 270 | Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, |
| 271 | Handle<Context> previous, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 272 | Handle<String> name, |
| 273 | Handle<Object> thrown_object) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 274 | CALL_HEAP_FUNCTION( |
| 275 | isolate(), |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 276 | isolate()->heap()->AllocateCatchContext(*function, |
| 277 | *previous, |
| 278 | *name, |
| 279 | *thrown_object), |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 280 | Context); |
| 281 | } |
| 282 | |
| 283 | |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 284 | Handle<Context> Factory::NewWithContext(Handle<JSFunction> function, |
| 285 | Handle<Context> previous, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 286 | Handle<JSObject> extension) { |
| 287 | CALL_HEAP_FUNCTION( |
| 288 | isolate(), |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 289 | isolate()->heap()->AllocateWithContext(*function, *previous, *extension), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 290 | Context); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | |
| 294 | Handle<Struct> Factory::NewStruct(InstanceType type) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 295 | CALL_HEAP_FUNCTION( |
| 296 | isolate(), |
| 297 | isolate()->heap()->AllocateStruct(type), |
| 298 | Struct); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | |
| 302 | Handle<AccessorInfo> Factory::NewAccessorInfo() { |
| 303 | Handle<AccessorInfo> info = |
| 304 | Handle<AccessorInfo>::cast(NewStruct(ACCESSOR_INFO_TYPE)); |
| 305 | info->set_flag(0); // Must clear the flag, it was initialized as undefined. |
| 306 | return info; |
| 307 | } |
| 308 | |
| 309 | |
| 310 | Handle<Script> Factory::NewScript(Handle<String> source) { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 311 | // Generate id for this script. |
| 312 | int id; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 313 | Heap* heap = isolate()->heap(); |
| 314 | if (heap->last_script_id()->IsUndefined()) { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 315 | // Script ids start from one. |
| 316 | id = 1; |
| 317 | } else { |
| 318 | // Increment id, wrap when positive smi is exhausted. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 319 | id = Smi::cast(heap->last_script_id())->value(); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 320 | id++; |
| 321 | if (!Smi::IsValid(id)) { |
| 322 | id = 0; |
| 323 | } |
| 324 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 325 | heap->SetLastScriptId(Smi::FromInt(id)); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 326 | |
| 327 | // Create and initialize script object. |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 328 | Handle<Foreign> wrapper = NewForeign(0, TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 329 | Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); |
| 330 | script->set_source(*source); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 331 | script->set_name(heap->undefined_value()); |
| 332 | script->set_id(heap->last_script_id()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 333 | script->set_line_offset(Smi::FromInt(0)); |
| 334 | script->set_column_offset(Smi::FromInt(0)); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 335 | script->set_data(heap->undefined_value()); |
| 336 | script->set_context_data(heap->undefined_value()); |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 337 | script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); |
| 338 | script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST)); |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 339 | script->set_wrapper(*wrapper); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 340 | script->set_line_ends(heap->undefined_value()); |
| 341 | script->set_eval_from_shared(heap->undefined_value()); |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 342 | script->set_eval_from_instructions_offset(Smi::FromInt(0)); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 343 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 344 | return script; |
| 345 | } |
| 346 | |
| 347 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 348 | Handle<Foreign> Factory::NewForeign(Address addr, PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 349 | CALL_HEAP_FUNCTION(isolate(), |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 350 | isolate()->heap()->AllocateForeign(addr, pretenure), |
| 351 | Foreign); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 355 | Handle<Foreign> Factory::NewForeign(const AccessorDescriptor* desc) { |
| 356 | return NewForeign((Address) desc, TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 360 | Handle<ByteArray> Factory::NewByteArray(int length, PretenureFlag pretenure) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 361 | ASSERT(0 <= length); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 362 | CALL_HEAP_FUNCTION( |
| 363 | isolate(), |
| 364 | isolate()->heap()->AllocateByteArray(length, pretenure), |
| 365 | ByteArray); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 369 | Handle<ExternalArray> Factory::NewExternalArray(int length, |
| 370 | ExternalArrayType array_type, |
| 371 | void* external_pointer, |
| 372 | PretenureFlag pretenure) { |
| 373 | ASSERT(0 <= length); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 374 | CALL_HEAP_FUNCTION( |
| 375 | isolate(), |
| 376 | isolate()->heap()->AllocateExternalArray(length, |
| 377 | array_type, |
| 378 | external_pointer, |
| 379 | pretenure), |
| 380 | ExternalArray); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 384 | Handle<JSGlobalPropertyCell> Factory::NewJSGlobalPropertyCell( |
| 385 | Handle<Object> value) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 386 | CALL_HEAP_FUNCTION( |
| 387 | isolate(), |
| 388 | isolate()->heap()->AllocateJSGlobalPropertyCell(*value), |
| 389 | JSGlobalPropertyCell); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 393 | Handle<Map> Factory::NewMap(InstanceType type, int instance_size) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 394 | CALL_HEAP_FUNCTION( |
| 395 | isolate(), |
| 396 | isolate()->heap()->AllocateMap(type, instance_size), |
| 397 | Map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | |
| 401 | Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 402 | CALL_HEAP_FUNCTION( |
| 403 | isolate(), |
| 404 | isolate()->heap()->AllocateFunctionPrototype(*function), |
| 405 | JSObject); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame] | 409 | Handle<Map> Factory::CopyMapDropDescriptors(Handle<Map> src) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 410 | CALL_HEAP_FUNCTION(isolate(), src->CopyDropDescriptors(), Map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 414 | Handle<Map> Factory::CopyMap(Handle<Map> src, |
| 415 | int extra_inobject_properties) { |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame] | 416 | Handle<Map> copy = CopyMapDropDescriptors(src); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 417 | // Check that we do not overflow the instance size when adding the |
| 418 | // extra inobject properties. |
| 419 | int instance_size_delta = extra_inobject_properties * kPointerSize; |
| 420 | int max_instance_size_delta = |
| 421 | JSObject::kMaxInstanceSize - copy->instance_size(); |
| 422 | if (instance_size_delta > max_instance_size_delta) { |
| 423 | // If the instance size overflows, we allocate as many properties |
| 424 | // as we can as inobject properties. |
| 425 | instance_size_delta = max_instance_size_delta; |
| 426 | extra_inobject_properties = max_instance_size_delta >> kPointerSizeLog2; |
| 427 | } |
| 428 | // Adjust the map with the extra inobject properties. |
| 429 | int inobject_properties = |
| 430 | copy->inobject_properties() + extra_inobject_properties; |
| 431 | copy->set_inobject_properties(inobject_properties); |
| 432 | copy->set_unused_property_fields(inobject_properties); |
| 433 | copy->set_instance_size(copy->instance_size() + instance_size_delta); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 434 | copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy)); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 435 | return copy; |
| 436 | } |
| 437 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 438 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 439 | Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 440 | CALL_HEAP_FUNCTION(isolate(), src->CopyDropTransitions(), Map); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 444 | Handle<Map> Factory::GetFastElementsMap(Handle<Map> src) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 445 | CALL_HEAP_FUNCTION(isolate(), src->GetFastElementsMap(), Map); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | |
| 449 | Handle<Map> Factory::GetSlowElementsMap(Handle<Map> src) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 450 | CALL_HEAP_FUNCTION(isolate(), src->GetSlowElementsMap(), Map); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 454 | Handle<Map> Factory::GetExternalArrayElementsMap( |
| 455 | Handle<Map> src, |
| 456 | ExternalArrayType array_type, |
| 457 | bool safe_to_add_transition) { |
| 458 | CALL_HEAP_FUNCTION(isolate(), |
| 459 | src->GetExternalArrayElementsMap(array_type, |
| 460 | safe_to_add_transition), |
| 461 | Map); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 465 | Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 466 | CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 470 | Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo( |
| 471 | Handle<SharedFunctionInfo> function_info, |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 472 | Handle<Map> function_map, |
| 473 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 474 | CALL_HEAP_FUNCTION( |
| 475 | isolate(), |
| 476 | isolate()->heap()->AllocateFunction(*function_map, |
| 477 | *function_info, |
| 478 | isolate()->heap()->the_hole_value(), |
| 479 | pretenure), |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 480 | JSFunction); |
| 481 | } |
| 482 | |
| 483 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 484 | Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
| 485 | Handle<SharedFunctionInfo> function_info, |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 486 | Handle<Context> context, |
| 487 | PretenureFlag pretenure) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 488 | Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 489 | function_info, |
| 490 | function_info->strict_mode() |
| 491 | ? isolate()->strict_mode_function_map() |
| 492 | : isolate()->function_map(), |
| 493 | pretenure); |
| 494 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 495 | result->set_context(*context); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 496 | int number_of_literals = function_info->num_literals(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 497 | Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 498 | if (number_of_literals > 0) { |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 499 | // Store the object, regexp and array functions in the literals |
| 500 | // array prefix. These functions will be used when creating |
| 501 | // object, regexp and array literals in this function. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 502 | literals->set(JSFunction::kLiteralGlobalContextIndex, |
| 503 | context->global_context()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 504 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 505 | result->set_literals(*literals); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 506 | result->set_next_function_link(isolate()->heap()->undefined_value()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 507 | |
| 508 | if (V8::UseCrankshaft() && |
| 509 | FLAG_always_opt && |
| 510 | result->is_compiled() && |
| 511 | !function_info->is_toplevel() && |
| 512 | function_info->allows_lazy_compilation()) { |
| 513 | result->MarkForLazyRecompilation(); |
| 514 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 515 | return result; |
| 516 | } |
| 517 | |
| 518 | |
| 519 | Handle<Object> Factory::NewNumber(double value, |
| 520 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 521 | CALL_HEAP_FUNCTION( |
| 522 | isolate(), |
| 523 | isolate()->heap()->NumberFromDouble(value, pretenure), Object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | |
| 527 | Handle<Object> Factory::NewNumberFromInt(int value) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 528 | CALL_HEAP_FUNCTION( |
| 529 | isolate(), |
| 530 | isolate()->heap()->NumberFromInt32(value), Object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 534 | Handle<Object> Factory::NewNumberFromUint(uint32_t value) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 535 | CALL_HEAP_FUNCTION( |
| 536 | isolate(), |
| 537 | isolate()->heap()->NumberFromUint32(value), Object); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 541 | Handle<JSObject> Factory::NewNeanderObject() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 542 | CALL_HEAP_FUNCTION( |
| 543 | isolate(), |
| 544 | isolate()->heap()->AllocateJSObjectFromMap( |
| 545 | isolate()->heap()->neander_map()), |
| 546 | JSObject); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | |
| 550 | Handle<Object> Factory::NewTypeError(const char* type, |
| 551 | Vector< Handle<Object> > args) { |
| 552 | return NewError("MakeTypeError", type, args); |
| 553 | } |
| 554 | |
| 555 | |
| 556 | Handle<Object> Factory::NewTypeError(Handle<String> message) { |
| 557 | return NewError("$TypeError", message); |
| 558 | } |
| 559 | |
| 560 | |
| 561 | Handle<Object> Factory::NewRangeError(const char* type, |
| 562 | Vector< Handle<Object> > args) { |
| 563 | return NewError("MakeRangeError", type, args); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | Handle<Object> Factory::NewRangeError(Handle<String> message) { |
| 568 | return NewError("$RangeError", message); |
| 569 | } |
| 570 | |
| 571 | |
| 572 | Handle<Object> Factory::NewSyntaxError(const char* type, Handle<JSArray> args) { |
| 573 | return NewError("MakeSyntaxError", type, args); |
| 574 | } |
| 575 | |
| 576 | |
| 577 | Handle<Object> Factory::NewSyntaxError(Handle<String> message) { |
| 578 | return NewError("$SyntaxError", message); |
| 579 | } |
| 580 | |
| 581 | |
| 582 | Handle<Object> Factory::NewReferenceError(const char* type, |
| 583 | Vector< Handle<Object> > args) { |
| 584 | return NewError("MakeReferenceError", type, args); |
| 585 | } |
| 586 | |
| 587 | |
| 588 | Handle<Object> Factory::NewReferenceError(Handle<String> message) { |
| 589 | return NewError("$ReferenceError", message); |
| 590 | } |
| 591 | |
| 592 | |
| 593 | Handle<Object> Factory::NewError(const char* maker, const char* type, |
| 594 | Vector< Handle<Object> > args) { |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 595 | v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 596 | Handle<FixedArray> array = NewFixedArray(args.length()); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 597 | for (int i = 0; i < args.length(); i++) { |
| 598 | array->set(i, *args[i]); |
| 599 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 600 | Handle<JSArray> object = NewJSArrayWithElements(array); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 601 | Handle<Object> result = NewError(maker, type, object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 602 | return result.EscapeFrom(&scope); |
| 603 | } |
| 604 | |
| 605 | |
| 606 | Handle<Object> Factory::NewEvalError(const char* type, |
| 607 | Vector< Handle<Object> > args) { |
| 608 | return NewError("MakeEvalError", type, args); |
| 609 | } |
| 610 | |
| 611 | |
| 612 | Handle<Object> Factory::NewError(const char* type, |
| 613 | Vector< Handle<Object> > args) { |
| 614 | return NewError("MakeError", type, args); |
| 615 | } |
| 616 | |
| 617 | |
| 618 | Handle<Object> Factory::NewError(const char* maker, |
| 619 | const char* type, |
| 620 | Handle<JSArray> args) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 621 | Handle<String> make_str = LookupAsciiSymbol(maker); |
| 622 | Handle<Object> fun_obj( |
| 623 | isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str)); |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 624 | // If the builtins haven't been properly configured yet this error |
| 625 | // constructor may not have been defined. Bail out. |
| 626 | if (!fun_obj->IsJSFunction()) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 627 | return undefined_value(); |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 628 | Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 629 | Handle<Object> type_obj = LookupAsciiSymbol(type); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 630 | Object** argv[2] = { type_obj.location(), |
| 631 | Handle<Object>::cast(args).location() }; |
| 632 | |
| 633 | // Invoke the JavaScript factory method. If an exception is thrown while |
| 634 | // running the factory method, use the exception as the result. |
| 635 | bool caught_exception; |
| 636 | Handle<Object> result = Execution::TryCall(fun, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 637 | isolate()->js_builtins_object(), 2, argv, &caught_exception); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 638 | return result; |
| 639 | } |
| 640 | |
| 641 | |
| 642 | Handle<Object> Factory::NewError(Handle<String> message) { |
| 643 | return NewError("$Error", message); |
| 644 | } |
| 645 | |
| 646 | |
| 647 | Handle<Object> Factory::NewError(const char* constructor, |
| 648 | Handle<String> message) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 649 | Handle<String> constr = LookupAsciiSymbol(constructor); |
| 650 | Handle<JSFunction> fun = Handle<JSFunction>( |
| 651 | JSFunction::cast(isolate()->js_builtins_object()-> |
| 652 | GetPropertyNoExceptionThrown(*constr))); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 653 | Object** argv[1] = { Handle<Object>::cast(message).location() }; |
| 654 | |
| 655 | // Invoke the JavaScript factory method. If an exception is thrown while |
| 656 | // running the factory method, use the exception as the result. |
| 657 | bool caught_exception; |
| 658 | Handle<Object> result = Execution::TryCall(fun, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 659 | isolate()->js_builtins_object(), 1, argv, &caught_exception); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 660 | return result; |
| 661 | } |
| 662 | |
| 663 | |
| 664 | Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| 665 | InstanceType type, |
| 666 | int instance_size, |
| 667 | Handle<Code> code, |
| 668 | bool force_initial_map) { |
| 669 | // Allocate the function |
| 670 | Handle<JSFunction> function = NewFunction(name, the_hole_value()); |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 671 | |
| 672 | // Setup the code pointer in both the shared function info and in |
| 673 | // the function itself. |
| 674 | function->shared()->set_code(*code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 675 | function->set_code(*code); |
| 676 | |
| 677 | if (force_initial_map || |
| 678 | type != JS_OBJECT_TYPE || |
| 679 | instance_size != JSObject::kHeaderSize) { |
| 680 | Handle<Map> initial_map = NewMap(type, instance_size); |
| 681 | Handle<JSObject> prototype = NewFunctionPrototype(function); |
| 682 | initial_map->set_prototype(*prototype); |
| 683 | function->set_initial_map(*initial_map); |
| 684 | initial_map->set_constructor(*function); |
| 685 | } else { |
| 686 | ASSERT(!function->has_initial_map()); |
| 687 | ASSERT(!function->has_prototype()); |
| 688 | } |
| 689 | |
| 690 | return function; |
| 691 | } |
| 692 | |
| 693 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 694 | Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, |
| 695 | InstanceType type, |
| 696 | int instance_size, |
| 697 | Handle<JSObject> prototype, |
| 698 | Handle<Code> code, |
| 699 | bool force_initial_map) { |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 700 | // Allocate the function. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 701 | Handle<JSFunction> function = NewFunction(name, prototype); |
| 702 | |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 703 | // Setup the code pointer in both the shared function info and in |
| 704 | // the function itself. |
| 705 | function->shared()->set_code(*code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 706 | function->set_code(*code); |
| 707 | |
| 708 | if (force_initial_map || |
| 709 | type != JS_OBJECT_TYPE || |
| 710 | instance_size != JSObject::kHeaderSize) { |
| 711 | Handle<Map> initial_map = NewMap(type, instance_size); |
| 712 | function->set_initial_map(*initial_map); |
| 713 | initial_map->set_constructor(*function); |
| 714 | } |
| 715 | |
| 716 | // Set function.prototype and give the prototype a constructor |
| 717 | // property that refers to the function. |
| 718 | SetPrototypeProperty(function, prototype); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 719 | // Currently safe because it is only invoked from Genesis. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 720 | SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 721 | return function; |
| 722 | } |
| 723 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 724 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 725 | Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, |
| 726 | Handle<Code> code) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 727 | Handle<JSFunction> function = NewFunctionWithoutPrototype(name, |
| 728 | kNonStrictMode); |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 729 | function->shared()->set_code(*code); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 730 | function->set_code(*code); |
| 731 | ASSERT(!function->has_initial_map()); |
| 732 | ASSERT(!function->has_prototype()); |
| 733 | return function; |
| 734 | } |
| 735 | |
| 736 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 737 | Handle<Code> Factory::NewCode(const CodeDesc& desc, |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 738 | Code::Flags flags, |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 739 | Handle<Object> self_ref, |
| 740 | bool immovable) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 741 | CALL_HEAP_FUNCTION(isolate(), |
| 742 | isolate()->heap()->CreateCode( |
| 743 | desc, flags, self_ref, immovable), |
| 744 | Code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | |
| 748 | Handle<Code> Factory::CopyCode(Handle<Code> code) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 749 | CALL_HEAP_FUNCTION(isolate(), |
| 750 | isolate()->heap()->CopyCode(*code), |
| 751 | Code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 755 | Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 756 | CALL_HEAP_FUNCTION(isolate(), |
| 757 | isolate()->heap()->CopyCode(*code, reloc_info), |
| 758 | Code); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 762 | MUST_USE_RESULT static inline MaybeObject* DoCopyInsert( |
| 763 | DescriptorArray* array, |
| 764 | String* key, |
| 765 | Object* value, |
| 766 | PropertyAttributes attributes) { |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 767 | CallbacksDescriptor desc(key, value, attributes); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 768 | MaybeObject* obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 769 | return obj; |
| 770 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 771 | |
| 772 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 773 | // Allocate the new array. |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 774 | Handle<DescriptorArray> Factory::CopyAppendForeignDescriptor( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 775 | Handle<DescriptorArray> array, |
| 776 | Handle<String> key, |
| 777 | Handle<Object> value, |
| 778 | PropertyAttributes attributes) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 779 | CALL_HEAP_FUNCTION(isolate(), |
| 780 | DoCopyInsert(*array, *key, *value, attributes), |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 781 | DescriptorArray); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 782 | } |
| 783 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 784 | |
| 785 | Handle<String> Factory::SymbolFromString(Handle<String> value) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 786 | CALL_HEAP_FUNCTION(isolate(), |
| 787 | isolate()->heap()->LookupSymbol(*value), String); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | |
| 791 | Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors( |
| 792 | Handle<DescriptorArray> array, |
| 793 | Handle<Object> descriptors) { |
| 794 | v8::NeanderArray callbacks(descriptors); |
| 795 | int nof_callbacks = callbacks.length(); |
| 796 | Handle<DescriptorArray> result = |
| 797 | NewDescriptorArray(array->number_of_descriptors() + nof_callbacks); |
| 798 | |
| 799 | // Number of descriptors added to the result so far. |
| 800 | int descriptor_count = 0; |
| 801 | |
| 802 | // Copy the descriptors from the array. |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 803 | for (int i = 0; i < array->number_of_descriptors(); i++) { |
| 804 | if (array->GetType(i) != NULL_DESCRIPTOR) { |
| 805 | result->CopyFrom(descriptor_count++, *array, i); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 806 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | // Number of duplicates detected. |
| 810 | int duplicates = 0; |
| 811 | |
| 812 | // Fill in new callback descriptors. Process the callbacks from |
| 813 | // back to front so that the last callback with a given name takes |
| 814 | // precedence over previously added callbacks with that name. |
| 815 | for (int i = nof_callbacks - 1; i >= 0; i--) { |
| 816 | Handle<AccessorInfo> entry = |
| 817 | Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i))); |
| 818 | // Ensure the key is a symbol before writing into the instance descriptor. |
| 819 | Handle<String> key = |
| 820 | SymbolFromString(Handle<String>(String::cast(entry->name()))); |
| 821 | // Check if a descriptor with this name already exists before writing. |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 822 | if (result->LinearSearch(*key, descriptor_count) == |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 823 | DescriptorArray::kNotFound) { |
| 824 | CallbacksDescriptor desc(*key, *entry, entry->property_attributes()); |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 825 | result->Set(descriptor_count, &desc); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 826 | descriptor_count++; |
| 827 | } else { |
| 828 | duplicates++; |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | // If duplicates were detected, allocate a result of the right size |
| 833 | // and transfer the elements. |
| 834 | if (duplicates > 0) { |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 835 | int number_of_descriptors = result->number_of_descriptors() - duplicates; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 836 | Handle<DescriptorArray> new_result = |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 837 | NewDescriptorArray(number_of_descriptors); |
| 838 | for (int i = 0; i < number_of_descriptors; i++) { |
| 839 | new_result->CopyFrom(i, *result, i); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 840 | } |
| 841 | result = new_result; |
| 842 | } |
| 843 | |
| 844 | // Sort the result before returning. |
| 845 | result->Sort(); |
| 846 | return result; |
| 847 | } |
| 848 | |
| 849 | |
| 850 | Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, |
| 851 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 852 | CALL_HEAP_FUNCTION( |
| 853 | isolate(), |
| 854 | isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 858 | Handle<GlobalObject> Factory::NewGlobalObject( |
| 859 | Handle<JSFunction> constructor) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 860 | CALL_HEAP_FUNCTION(isolate(), |
| 861 | isolate()->heap()->AllocateGlobalObject(*constructor), |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 862 | GlobalObject); |
| 863 | } |
| 864 | |
| 865 | |
| 866 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 867 | Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 868 | CALL_HEAP_FUNCTION( |
| 869 | isolate(), |
| 870 | isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED), |
| 871 | JSObject); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | |
ricow@chromium.org | badaffc | 2011-03-17 12:15:27 +0000 | [diff] [blame] | 875 | Handle<JSArray> Factory::NewJSArray(int capacity, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 876 | PretenureFlag pretenure) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 877 | Handle<JSObject> obj = NewJSObject(isolate()->array_function(), pretenure); |
| 878 | CALL_HEAP_FUNCTION(isolate(), |
| 879 | Handle<JSArray>::cast(obj)->Initialize(capacity), |
| 880 | JSArray); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | |
| 884 | Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements, |
| 885 | PretenureFlag pretenure) { |
| 886 | Handle<JSArray> result = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 887 | Handle<JSArray>::cast(NewJSObject(isolate()->array_function(), |
| 888 | pretenure)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 889 | result->SetContent(*elements); |
| 890 | return result; |
| 891 | } |
| 892 | |
| 893 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 894 | Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, |
| 895 | Handle<Object> prototype) { |
| 896 | CALL_HEAP_FUNCTION( |
| 897 | isolate(), |
| 898 | isolate()->heap()->AllocateJSProxy(*handler, *prototype), |
| 899 | JSProxy); |
| 900 | } |
| 901 | |
| 902 | |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 903 | void Factory::BecomeJSObject(Handle<JSProxy> object) { |
| 904 | CALL_HEAP_FUNCTION_VOID( |
| 905 | isolate(), |
| 906 | isolate()->heap()->ReinitializeJSProxyAsJSObject(*object)); |
| 907 | } |
| 908 | |
| 909 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 910 | Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 911 | Handle<String> name, |
| 912 | int number_of_literals, |
| 913 | Handle<Code> code, |
ager@chromium.org | b573749 | 2010-07-15 09:29:43 +0000 | [diff] [blame] | 914 | Handle<SerializedScopeInfo> scope_info) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 915 | Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); |
| 916 | shared->set_code(*code); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 917 | shared->set_scope_info(*scope_info); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 918 | int literals_array_size = number_of_literals; |
| 919 | // If the function contains object, regexp or array literals, |
| 920 | // allocate extra space for a literals array prefix containing the |
| 921 | // context. |
| 922 | if (number_of_literals > 0) { |
| 923 | literals_array_size += JSFunction::kLiteralsPrefixSize; |
| 924 | } |
| 925 | shared->set_num_literals(literals_array_size); |
| 926 | return shared; |
| 927 | } |
| 928 | |
| 929 | |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 930 | Handle<JSMessageObject> Factory::NewJSMessageObject( |
| 931 | Handle<String> type, |
| 932 | Handle<JSArray> arguments, |
| 933 | int start_position, |
| 934 | int end_position, |
| 935 | Handle<Object> script, |
| 936 | Handle<Object> stack_trace, |
| 937 | Handle<Object> stack_frames) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 938 | CALL_HEAP_FUNCTION(isolate(), |
| 939 | isolate()->heap()->AllocateJSMessageObject(*type, |
| 940 | *arguments, |
| 941 | start_position, |
| 942 | end_position, |
| 943 | *script, |
| 944 | *stack_trace, |
| 945 | *stack_frames), |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 946 | JSMessageObject); |
| 947 | } |
| 948 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 949 | Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(Handle<String> name) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 950 | CALL_HEAP_FUNCTION(isolate(), |
| 951 | isolate()->heap()->AllocateSharedFunctionInfo(*name), |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 952 | SharedFunctionInfo); |
| 953 | } |
| 954 | |
| 955 | |
sgjesse@chromium.org | c514574 | 2009-10-07 09:00:33 +0000 | [diff] [blame] | 956 | Handle<String> Factory::NumberToString(Handle<Object> number) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 957 | CALL_HEAP_FUNCTION(isolate(), |
| 958 | isolate()->heap()->NumberToString(*number), String); |
sgjesse@chromium.org | c514574 | 2009-10-07 09:00:33 +0000 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 962 | Handle<NumberDictionary> Factory::DictionaryAtNumberPut( |
| 963 | Handle<NumberDictionary> dictionary, |
| 964 | uint32_t key, |
| 965 | Handle<Object> value) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 966 | CALL_HEAP_FUNCTION(isolate(), |
| 967 | dictionary->AtNumberPut(key, *value), |
| 968 | NumberDictionary); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | |
| 972 | Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name, |
| 973 | Handle<Object> prototype) { |
| 974 | Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 975 | CALL_HEAP_FUNCTION( |
| 976 | isolate(), |
| 977 | isolate()->heap()->AllocateFunction(*isolate()->function_map(), |
| 978 | *function_share, |
| 979 | *prototype), |
| 980 | JSFunction); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | |
| 984 | Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| 985 | Handle<Object> prototype) { |
| 986 | Handle<JSFunction> fun = NewFunctionHelper(name, prototype); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 987 | fun->set_context(isolate()->context()->global_context()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 988 | return fun; |
| 989 | } |
| 990 | |
| 991 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 992 | Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 993 | Handle<String> name, |
| 994 | StrictModeFlag strict_mode) { |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 995 | Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 996 | Handle<Map> map = strict_mode == kStrictMode |
| 997 | ? isolate()->strict_mode_function_without_prototype_map() |
| 998 | : isolate()->function_without_prototype_map(); |
| 999 | CALL_HEAP_FUNCTION(isolate(), |
| 1000 | isolate()->heap()->AllocateFunction( |
| 1001 | *map, |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1002 | *function_share, |
| 1003 | *the_hole_value()), |
| 1004 | JSFunction); |
| 1005 | } |
| 1006 | |
| 1007 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1008 | Handle<JSFunction> Factory::NewFunctionWithoutPrototype( |
| 1009 | Handle<String> name, |
| 1010 | StrictModeFlag strict_mode) { |
| 1011 | Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name, strict_mode); |
| 1012 | fun->set_context(isolate()->context()->global_context()); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1013 | return fun; |
| 1014 | } |
| 1015 | |
| 1016 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1017 | Handle<Object> Factory::ToObject(Handle<Object> object) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1018 | CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1022 | Handle<Object> Factory::ToObject(Handle<Object> object, |
| 1023 | Handle<Context> global_context) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1024 | CALL_HEAP_FUNCTION(isolate(), object->ToObject(*global_context), Object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1028 | #ifdef ENABLE_DEBUGGER_SUPPORT |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 1029 | Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { |
| 1030 | // Get the original code of the function. |
| 1031 | Handle<Code> code(shared->code()); |
| 1032 | |
| 1033 | // Create a copy of the code before allocating the debug info object to avoid |
| 1034 | // allocation while setting up the debug info object. |
| 1035 | Handle<Code> original_code(*Factory::CopyCode(code)); |
| 1036 | |
| 1037 | // Allocate initial fixed array for active break points before allocating the |
| 1038 | // debug info object to avoid allocation while setting up the debug info |
| 1039 | // object. |
| 1040 | Handle<FixedArray> break_points( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1041 | NewFixedArray(Debug::kEstimatedNofBreakPointsInFunction)); |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 1042 | |
| 1043 | // Create and set up the debug info object. Debug info contains function, a |
| 1044 | // copy of the original code, the executing code and initial fixed array for |
| 1045 | // active break points. |
| 1046 | Handle<DebugInfo> debug_info = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1047 | Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 1048 | debug_info->set_shared(*shared); |
| 1049 | debug_info->set_original_code(*original_code); |
| 1050 | debug_info->set_code(*code); |
| 1051 | debug_info->set_break_points(*break_points); |
| 1052 | |
| 1053 | // Link debug info to function. |
| 1054 | shared->set_debug_info(*debug_info); |
| 1055 | |
| 1056 | return debug_info; |
| 1057 | } |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1058 | #endif |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 1059 | |
| 1060 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1061 | Handle<JSObject> Factory::NewArgumentsObject(Handle<Object> callee, |
| 1062 | int length) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1063 | CALL_HEAP_FUNCTION( |
| 1064 | isolate(), |
| 1065 | isolate()->heap()->AllocateArgumentsObject(*callee, length), JSObject); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | |
| 1069 | Handle<JSFunction> Factory::CreateApiFunction( |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1070 | Handle<FunctionTemplateInfo> obj, ApiInstanceType instance_type) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1071 | Handle<Code> code = isolate()->builtins()->HandleApiCall(); |
| 1072 | Handle<Code> construct_stub = isolate()->builtins()->JSConstructStubApi(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1073 | |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1074 | int internal_field_count = 0; |
| 1075 | if (!obj->instance_template()->IsUndefined()) { |
| 1076 | Handle<ObjectTemplateInfo> instance_template = |
| 1077 | Handle<ObjectTemplateInfo>( |
| 1078 | ObjectTemplateInfo::cast(obj->instance_template())); |
| 1079 | internal_field_count = |
| 1080 | Smi::cast(instance_template->internal_field_count())->value(); |
| 1081 | } |
| 1082 | |
| 1083 | int instance_size = kPointerSize * internal_field_count; |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1084 | InstanceType type = INVALID_TYPE; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1085 | switch (instance_type) { |
| 1086 | case JavaScriptObject: |
| 1087 | type = JS_OBJECT_TYPE; |
| 1088 | instance_size += JSObject::kHeaderSize; |
| 1089 | break; |
| 1090 | case InnerGlobalObject: |
| 1091 | type = JS_GLOBAL_OBJECT_TYPE; |
| 1092 | instance_size += JSGlobalObject::kSize; |
| 1093 | break; |
| 1094 | case OuterGlobalObject: |
| 1095 | type = JS_GLOBAL_PROXY_TYPE; |
| 1096 | instance_size += JSGlobalProxy::kSize; |
| 1097 | break; |
| 1098 | default: |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1099 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1100 | } |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1101 | ASSERT(type != INVALID_TYPE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1102 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1103 | Handle<JSFunction> result = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1104 | NewFunction(Factory::empty_symbol(), |
| 1105 | type, |
| 1106 | instance_size, |
| 1107 | code, |
| 1108 | true); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1109 | // Set class name. |
| 1110 | Handle<Object> class_name = Handle<Object>(obj->class_name()); |
| 1111 | if (class_name->IsString()) { |
| 1112 | result->shared()->set_instance_class_name(*class_name); |
| 1113 | result->shared()->set_name(*class_name); |
| 1114 | } |
| 1115 | |
| 1116 | Handle<Map> map = Handle<Map>(result->initial_map()); |
| 1117 | |
| 1118 | // Mark as undetectable if needed. |
| 1119 | if (obj->undetectable()) { |
| 1120 | map->set_is_undetectable(); |
| 1121 | } |
| 1122 | |
| 1123 | // Mark as hidden for the __proto__ accessor if needed. |
| 1124 | if (obj->hidden_prototype()) { |
| 1125 | map->set_is_hidden_prototype(); |
| 1126 | } |
| 1127 | |
| 1128 | // Mark as needs_access_check if needed. |
| 1129 | if (obj->needs_access_check()) { |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 1130 | map->set_is_access_check_needed(true); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1133 | // Set interceptor information in the map. |
| 1134 | if (!obj->named_property_handler()->IsUndefined()) { |
| 1135 | map->set_has_named_interceptor(); |
| 1136 | } |
| 1137 | if (!obj->indexed_property_handler()->IsUndefined()) { |
| 1138 | map->set_has_indexed_interceptor(); |
| 1139 | } |
| 1140 | |
| 1141 | // Set instance call-as-function information in the map. |
| 1142 | if (!obj->instance_call_handler()->IsUndefined()) { |
| 1143 | map->set_has_instance_call_handler(); |
| 1144 | } |
| 1145 | |
| 1146 | result->shared()->set_function_data(*obj); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1147 | result->shared()->set_construct_stub(*construct_stub); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 1148 | result->shared()->DontAdaptArguments(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1149 | |
| 1150 | // Recursively copy parent templates' accessors, 'data' may be modified. |
| 1151 | Handle<DescriptorArray> array = |
| 1152 | Handle<DescriptorArray>(map->instance_descriptors()); |
| 1153 | while (true) { |
| 1154 | Handle<Object> props = Handle<Object>(obj->property_accessors()); |
| 1155 | if (!props->IsUndefined()) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1156 | array = CopyAppendCallbackDescriptors(array, props); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1157 | } |
| 1158 | Handle<Object> parent = Handle<Object>(obj->parent_template()); |
| 1159 | if (parent->IsUndefined()) break; |
| 1160 | obj = Handle<FunctionTemplateInfo>::cast(parent); |
| 1161 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 1162 | if (!array->IsEmpty()) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1163 | map->set_instance_descriptors(*array); |
| 1164 | } |
| 1165 | |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1166 | ASSERT(result->shared()->IsApiFunction()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1167 | return result; |
| 1168 | } |
| 1169 | |
| 1170 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1171 | Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1172 | CALL_HEAP_FUNCTION(isolate(), |
| 1173 | MapCache::Allocate(at_least_space_for), MapCache); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 1177 | MUST_USE_RESULT static MaybeObject* UpdateMapCacheWith(Context* context, |
| 1178 | FixedArray* keys, |
| 1179 | Map* map) { |
| 1180 | Object* result; |
| 1181 | { MaybeObject* maybe_result = |
| 1182 | MapCache::cast(context->map_cache())->Put(keys, map); |
| 1183 | if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1184 | } |
| 1185 | context->set_map_cache(MapCache::cast(result)); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1186 | return result; |
| 1187 | } |
| 1188 | |
| 1189 | |
| 1190 | Handle<MapCache> Factory::AddToMapCache(Handle<Context> context, |
| 1191 | Handle<FixedArray> keys, |
| 1192 | Handle<Map> map) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1193 | CALL_HEAP_FUNCTION(isolate(), |
| 1194 | UpdateMapCacheWith(*context, *keys, *map), MapCache); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | |
| 1198 | Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, |
| 1199 | Handle<FixedArray> keys) { |
| 1200 | if (context->map_cache()->IsUndefined()) { |
| 1201 | // Allocate the new map cache for the global context. |
| 1202 | Handle<MapCache> new_cache = NewMapCache(24); |
| 1203 | context->set_map_cache(*new_cache); |
| 1204 | } |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 1205 | // Check to see whether there is a matching element in the cache. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1206 | Handle<MapCache> cache = |
| 1207 | Handle<MapCache>(MapCache::cast(context->map_cache())); |
| 1208 | Handle<Object> result = Handle<Object>(cache->Lookup(*keys)); |
| 1209 | if (result->IsMap()) return Handle<Map>::cast(result); |
| 1210 | // Create a new map and add it to the cache. |
| 1211 | Handle<Map> map = |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 1212 | CopyMap(Handle<Map>(context->object_function()->initial_map()), |
| 1213 | keys->length()); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1214 | AddToMapCache(context, keys, map); |
| 1215 | return Handle<Map>(map); |
| 1216 | } |
| 1217 | |
| 1218 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1219 | void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp, |
| 1220 | JSRegExp::Type type, |
| 1221 | Handle<String> source, |
| 1222 | JSRegExp::Flags flags, |
| 1223 | Handle<Object> data) { |
| 1224 | Handle<FixedArray> store = NewFixedArray(JSRegExp::kAtomDataSize); |
| 1225 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1226 | store->set(JSRegExp::kTagIndex, Smi::FromInt(type)); |
| 1227 | store->set(JSRegExp::kSourceIndex, *source); |
| 1228 | store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value())); |
| 1229 | store->set(JSRegExp::kAtomPatternIndex, *data); |
| 1230 | regexp->set_data(*store); |
| 1231 | } |
| 1232 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1233 | void Factory::SetRegExpIrregexpData(Handle<JSRegExp> regexp, |
| 1234 | JSRegExp::Type type, |
| 1235 | Handle<String> source, |
| 1236 | JSRegExp::Flags flags, |
| 1237 | int capture_count) { |
| 1238 | Handle<FixedArray> store = NewFixedArray(JSRegExp::kIrregexpDataSize); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1239 | Smi* uninitialized = Smi::FromInt(JSRegExp::kUninitializedValue); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1240 | store->set(JSRegExp::kTagIndex, Smi::FromInt(type)); |
| 1241 | store->set(JSRegExp::kSourceIndex, *source); |
| 1242 | store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value())); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1243 | store->set(JSRegExp::kIrregexpASCIICodeIndex, uninitialized); |
| 1244 | store->set(JSRegExp::kIrregexpUC16CodeIndex, uninitialized); |
| 1245 | store->set(JSRegExp::kIrregexpASCIICodeSavedIndex, uninitialized); |
| 1246 | store->set(JSRegExp::kIrregexpUC16CodeSavedIndex, uninitialized); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1247 | store->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(0)); |
| 1248 | store->set(JSRegExp::kIrregexpCaptureCountIndex, |
| 1249 | Smi::FromInt(capture_count)); |
| 1250 | regexp->set_data(*store); |
| 1251 | } |
| 1252 | |
| 1253 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1254 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1255 | void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc, |
| 1256 | Handle<JSObject> instance, |
| 1257 | bool* pending_exception) { |
| 1258 | // Configure the instance by adding the properties specified by the |
| 1259 | // instance template. |
| 1260 | Handle<Object> instance_template = Handle<Object>(desc->instance_template()); |
| 1261 | if (!instance_template->IsUndefined()) { |
| 1262 | Execution::ConfigureInstance(instance, |
| 1263 | instance_template, |
| 1264 | pending_exception); |
| 1265 | } else { |
| 1266 | *pending_exception = false; |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | |
| 1271 | } } // namespace v8::internal |