Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 ASSERT(call->is_compiled()); | 1230 ASSERT(call->is_compiled()); |
| 1231 | 1231 |
| 1232 // Set the expected parameters for apply to 2; required by builtin. | 1232 // Set the expected parameters for apply to 2; required by builtin. |
| 1233 apply->shared()->set_formal_parameter_count(2); | 1233 apply->shared()->set_formal_parameter_count(2); |
| 1234 | 1234 |
| 1235 // Set the lengths for the functions to satisfy ECMA-262. | 1235 // Set the lengths for the functions to satisfy ECMA-262. |
| 1236 call->shared()->set_length(1); | 1236 call->shared()->set_length(1); |
| 1237 apply->shared()->set_length(2); | 1237 apply->shared()->set_length(2); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 // Create a constructor for RegExp results (a variant of Array that | |
| 1241 // predefines the two properties index and match). | |
| 1242 { | |
| 1243 // RegExpResult initial map. | |
| 1244 | |
| 1245 // Find global.Array.prototype to inherit from. | |
| 1246 Handle<JSFunction> array_constructor(global_context()->array_function()); | |
| 1247 Handle<JSObject> array_prototype( | |
| 1248 JSObject::cast(array_constructor->instance_prototype())); | |
| 1249 | |
| 1250 // Add initial map. | |
| 1251 Handle<Map> initial_map = | |
| 1252 Factory::NewMap(JS_ARRAY_TYPE, JSArray::kRegExpResultSize); | |
| 1253 initial_map->set_constructor(*array_constructor); | |
| 1254 | |
| 1255 // Set prototype on map. | |
| 1256 initial_map->set_non_instance_prototype(false); | |
| 1257 initial_map->set_prototype(*array_prototype); | |
| 1258 | |
| 1259 // Update map with length accessor from Array and add "index" and "input". | |
| 1260 Handle<Map> array_map(global_context()->js_array_map()); | |
| 1261 Handle<DescriptorArray> array_descriptors( | |
| 1262 array_map->instance_descriptors()); | |
| 1263 ASSERT_EQ(1, array_descriptors->number_of_descriptors()); | |
| 1264 | |
| 1265 Handle<DescriptorArray> reresult_descriptors = | |
| 1266 Factory::NewDescriptorArray(3); | |
| 1267 | |
| 1268 reresult_descriptors->CopyFrom(0, *array_descriptors, 0); | |
| 1269 | |
| 1270 int enum_index = 0; | |
| 1271 { | |
| 1272 FieldDescriptor index_field(Heap::index_symbol(), | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Move the constant to JSRegExpResult (see comment i
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
| 1273 JSArray::kIndexIndex, | |
| 1274 NONE, | |
| 1275 enum_index++); | |
| 1276 reresult_descriptors->Set(1, &index_field); | |
| 1277 } | |
| 1278 | |
| 1279 { | |
| 1280 FieldDescriptor input_field(Heap::input_symbol(), | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Ditto.
Lasse Reichstein
2010/04/13 09:50:56
Done too.
| |
| 1281 JSArray::kInputIndex, | |
| 1282 NONE, | |
| 1283 enum_index++); | |
| 1284 reresult_descriptors->Set(2, &input_field); | |
| 1285 } | |
| 1286 reresult_descriptors->Sort(); | |
| 1287 | |
| 1288 initial_map->set_inobject_properties(2); | |
| 1289 initial_map->set_pre_allocated_property_fields(2); | |
| 1290 initial_map->set_unused_property_fields(0); | |
| 1291 initial_map->set_instance_descriptors(*reresult_descriptors); | |
| 1292 | |
| 1293 global_context()->set_regexp_result_map(*initial_map); | |
| 1294 } | |
| 1295 | |
| 1240 #ifdef DEBUG | 1296 #ifdef DEBUG |
| 1241 builtins->Verify(); | 1297 builtins->Verify(); |
| 1242 #endif | 1298 #endif |
| 1243 | 1299 |
| 1244 return true; | 1300 return true; |
| 1245 } | 1301 } |
| 1246 | 1302 |
| 1247 | 1303 |
| 1248 int BootstrapperActive::nesting_ = 0; | 1304 int BootstrapperActive::nesting_ = 0; |
| 1249 | 1305 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1659 } | 1715 } |
| 1660 | 1716 |
| 1661 | 1717 |
| 1662 // Restore statics that are thread local. | 1718 // Restore statics that are thread local. |
| 1663 char* BootstrapperActive::RestoreState(char* from) { | 1719 char* BootstrapperActive::RestoreState(char* from) { |
| 1664 nesting_ = *reinterpret_cast<int*>(from); | 1720 nesting_ = *reinterpret_cast<int*>(from); |
| 1665 return from + sizeof(nesting_); | 1721 return from + sizeof(nesting_); |
| 1666 } | 1722 } |
| 1667 | 1723 |
| 1668 } } // namespace v8::internal | 1724 } } // namespace v8::internal |
| OLD | NEW |