Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 PropertyAttributes writable = | 1183 PropertyAttributes writable = |
| 1184 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 1184 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 1185 DataDescriptor field(factory->last_index_string(), | 1185 DataDescriptor field(factory->last_index_string(), |
| 1186 JSRegExp::kLastIndexFieldIndex, writable, | 1186 JSRegExp::kLastIndexFieldIndex, writable, |
| 1187 Representation::Tagged()); | 1187 Representation::Tagged()); |
| 1188 initial_map->AppendDescriptor(&field); | 1188 initial_map->AppendDescriptor(&field); |
| 1189 } | 1189 } |
| 1190 | 1190 |
| 1191 static const int num_fields = JSRegExp::kInObjectFieldCount; | 1191 static const int num_fields = JSRegExp::kInObjectFieldCount; |
| 1192 initial_map->set_inobject_properties(num_fields); | 1192 initial_map->set_inobject_properties(num_fields); |
| 1193 initial_map->set_pre_allocated_property_fields(num_fields); | |
| 1194 initial_map->set_unused_property_fields(0); | 1193 initial_map->set_unused_property_fields(0); |
| 1195 initial_map->set_instance_size(initial_map->instance_size() + | 1194 initial_map->set_instance_size(initial_map->instance_size() + |
| 1196 num_fields * kPointerSize); | 1195 num_fields * kPointerSize); |
| 1197 | 1196 |
| 1198 // RegExp prototype object is itself a RegExp. | 1197 // RegExp prototype object is itself a RegExp. |
| 1199 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype"); | 1198 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype"); |
| 1200 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype()); | 1199 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype()); |
| 1201 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); | 1200 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); |
| 1202 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, | 1201 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, |
| 1203 heap->query_colon_string()); | 1202 heap->query_colon_string()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 JSGeneratorObject::kResultValuePropertyIndex, | 1292 JSGeneratorObject::kResultValuePropertyIndex, |
| 1294 NONE, Representation::Tagged()); | 1293 NONE, Representation::Tagged()); |
| 1295 iterator_result_map->AppendDescriptor(&value_descr); | 1294 iterator_result_map->AppendDescriptor(&value_descr); |
| 1296 | 1295 |
| 1297 DataDescriptor done_descr(factory->done_string(), | 1296 DataDescriptor done_descr(factory->done_string(), |
| 1298 JSGeneratorObject::kResultDonePropertyIndex, NONE, | 1297 JSGeneratorObject::kResultDonePropertyIndex, NONE, |
| 1299 Representation::Tagged()); | 1298 Representation::Tagged()); |
| 1300 iterator_result_map->AppendDescriptor(&done_descr); | 1299 iterator_result_map->AppendDescriptor(&done_descr); |
| 1301 | 1300 |
| 1302 iterator_result_map->set_unused_property_fields(0); | 1301 iterator_result_map->set_unused_property_fields(0); |
| 1303 iterator_result_map->set_pre_allocated_property_fields( | 1302 iterator_result_map->set_inobject_properties( |
|
Toon Verwaest
2015/07/10 16:15:17
You probably don't need this since it's assured ri
Michael Starzinger
2015/07/10 16:21:19
Done.
| |
| 1304 JSGeneratorObject::kResultPropertyCount); | 1303 JSGeneratorObject::kResultPropertyCount); |
| 1305 DCHECK_EQ(JSGeneratorObject::kResultSize, | 1304 DCHECK_EQ(JSGeneratorObject::kResultSize, |
| 1306 iterator_result_map->instance_size()); | 1305 iterator_result_map->instance_size()); |
| 1307 native_context()->set_iterator_result_map(*iterator_result_map); | 1306 native_context()->set_iterator_result_map(*iterator_result_map); |
| 1308 } | 1307 } |
| 1309 | 1308 |
| 1310 // -- W e a k M a p | 1309 // -- W e a k M a p |
| 1311 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, | 1310 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
| 1312 isolate->initial_object_prototype(), Builtins::kIllegal); | 1311 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1313 // -- W e a k S e t | 1312 // -- W e a k S e t |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1335 map->AppendDescriptor(&d); | 1334 map->AppendDescriptor(&d); |
| 1336 } | 1335 } |
| 1337 { // callee | 1336 { // callee |
| 1338 DataDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex, | 1337 DataDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex, |
| 1339 DONT_ENUM, Representation::Tagged()); | 1338 DONT_ENUM, Representation::Tagged()); |
| 1340 map->AppendDescriptor(&d); | 1339 map->AppendDescriptor(&d); |
| 1341 } | 1340 } |
| 1342 // @@iterator method is added later. | 1341 // @@iterator method is added later. |
| 1343 | 1342 |
| 1344 map->set_function_with_prototype(true); | 1343 map->set_function_with_prototype(true); |
| 1345 map->set_pre_allocated_property_fields(2); | |
| 1346 map->set_inobject_properties(2); | 1344 map->set_inobject_properties(2); |
| 1347 native_context()->set_sloppy_arguments_map(*map); | 1345 native_context()->set_sloppy_arguments_map(*map); |
| 1348 | 1346 |
| 1349 DCHECK(!function->has_initial_map()); | 1347 DCHECK(!function->has_initial_map()); |
| 1350 JSFunction::SetInitialMap(function, map, | 1348 JSFunction::SetInitialMap(function, map, |
| 1351 isolate->initial_object_prototype()); | 1349 isolate->initial_object_prototype()); |
| 1352 | 1350 |
| 1353 DCHECK(map->inobject_properties() > Heap::kArgumentsCalleeIndex); | 1351 DCHECK(map->inobject_properties() > Heap::kArgumentsCalleeIndex); |
| 1354 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); | 1352 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1355 DCHECK(!map->is_dictionary_map()); | 1353 DCHECK(!map->is_dictionary_map()); |
| 1356 DCHECK(IsFastObjectElementsKind(map->elements_kind())); | 1354 DCHECK(IsFastObjectElementsKind(map->elements_kind())); |
| 1357 } | 1355 } |
| 1358 | 1356 |
| 1359 { // --- fast and slow aliased arguments map | 1357 { // --- fast and slow aliased arguments map |
| 1360 Handle<Map> map = isolate->sloppy_arguments_map(); | 1358 Handle<Map> map = isolate->sloppy_arguments_map(); |
| 1361 map = Map::Copy(map, "FastAliasedArguments"); | 1359 map = Map::Copy(map, "FastAliasedArguments"); |
| 1362 map->set_elements_kind(FAST_SLOPPY_ARGUMENTS_ELEMENTS); | 1360 map->set_elements_kind(FAST_SLOPPY_ARGUMENTS_ELEMENTS); |
| 1363 DCHECK_EQ(2, map->pre_allocated_property_fields()); | 1361 DCHECK_EQ(2, map->inobject_properties()); |
| 1364 native_context()->set_fast_aliased_arguments_map(*map); | 1362 native_context()->set_fast_aliased_arguments_map(*map); |
| 1365 | 1363 |
| 1366 map = Map::Copy(map, "SlowAliasedArguments"); | 1364 map = Map::Copy(map, "SlowAliasedArguments"); |
| 1367 map->set_elements_kind(SLOW_SLOPPY_ARGUMENTS_ELEMENTS); | 1365 map->set_elements_kind(SLOW_SLOPPY_ARGUMENTS_ELEMENTS); |
| 1368 DCHECK_EQ(2, map->pre_allocated_property_fields()); | 1366 DCHECK_EQ(2, map->inobject_properties()); |
| 1369 native_context()->set_slow_aliased_arguments_map(*map); | 1367 native_context()->set_slow_aliased_arguments_map(*map); |
| 1370 } | 1368 } |
| 1371 | 1369 |
| 1372 { // --- strict mode arguments map | 1370 { // --- strict mode arguments map |
| 1373 const PropertyAttributes attributes = | 1371 const PropertyAttributes attributes = |
| 1374 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1372 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 1375 | 1373 |
| 1376 // Create the ThrowTypeError functions. | 1374 // Create the ThrowTypeError functions. |
| 1377 Handle<AccessorPair> callee = factory->NewAccessorPair(); | 1375 Handle<AccessorPair> callee = factory->NewAccessorPair(); |
| 1378 Handle<AccessorPair> caller = factory->NewAccessorPair(); | 1376 Handle<AccessorPair> caller = factory->NewAccessorPair(); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1405 AccessorConstantDescriptor d(factory->caller_string(), caller, | 1403 AccessorConstantDescriptor d(factory->caller_string(), caller, |
| 1406 attributes); | 1404 attributes); |
| 1407 map->AppendDescriptor(&d); | 1405 map->AppendDescriptor(&d); |
| 1408 } | 1406 } |
| 1409 // @@iterator method is added later. | 1407 // @@iterator method is added later. |
| 1410 | 1408 |
| 1411 map->set_function_with_prototype(true); | 1409 map->set_function_with_prototype(true); |
| 1412 DCHECK_EQ(native_context()->object_function()->prototype(), | 1410 DCHECK_EQ(native_context()->object_function()->prototype(), |
| 1413 *isolate->initial_object_prototype()); | 1411 *isolate->initial_object_prototype()); |
| 1414 Map::SetPrototype(map, isolate->initial_object_prototype()); | 1412 Map::SetPrototype(map, isolate->initial_object_prototype()); |
| 1415 map->set_pre_allocated_property_fields(1); | |
| 1416 map->set_inobject_properties(1); | 1413 map->set_inobject_properties(1); |
| 1417 | 1414 |
| 1418 // Copy constructor from the sloppy arguments boilerplate. | 1415 // Copy constructor from the sloppy arguments boilerplate. |
| 1419 map->SetConstructor( | 1416 map->SetConstructor( |
| 1420 native_context()->sloppy_arguments_map()->GetConstructor()); | 1417 native_context()->sloppy_arguments_map()->GetConstructor()); |
| 1421 | 1418 |
| 1422 native_context()->set_strict_arguments_map(*map); | 1419 native_context()->set_strict_arguments_map(*map); |
| 1423 | 1420 |
| 1424 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); | 1421 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1425 DCHECK(!map->is_dictionary_map()); | 1422 DCHECK(!map->is_dictionary_map()); |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2416 } | 2413 } |
| 2417 | 2414 |
| 2418 { | 2415 { |
| 2419 DataDescriptor input_field(factory()->input_string(), | 2416 DataDescriptor input_field(factory()->input_string(), |
| 2420 JSRegExpResult::kInputIndex, NONE, | 2417 JSRegExpResult::kInputIndex, NONE, |
| 2421 Representation::Tagged()); | 2418 Representation::Tagged()); |
| 2422 initial_map->AppendDescriptor(&input_field); | 2419 initial_map->AppendDescriptor(&input_field); |
| 2423 } | 2420 } |
| 2424 | 2421 |
| 2425 initial_map->set_inobject_properties(2); | 2422 initial_map->set_inobject_properties(2); |
| 2426 initial_map->set_pre_allocated_property_fields(2); | |
| 2427 initial_map->set_unused_property_fields(0); | 2423 initial_map->set_unused_property_fields(0); |
| 2428 | 2424 |
| 2429 native_context()->set_regexp_result_map(*initial_map); | 2425 native_context()->set_regexp_result_map(*initial_map); |
| 2430 } | 2426 } |
| 2431 | 2427 |
| 2432 // Add @@iterator method to the arguments object maps. | 2428 // Add @@iterator method to the arguments object maps. |
| 2433 { | 2429 { |
| 2434 PropertyAttributes attribs = DONT_ENUM; | 2430 PropertyAttributes attribs = DONT_ENUM; |
| 2435 Handle<AccessorInfo> arguments_iterator = | 2431 Handle<AccessorInfo> arguments_iterator = |
| 2436 Accessors::ArgumentsIteratorInfo(isolate(), attribs); | 2432 Accessors::ArgumentsIteratorInfo(isolate(), attribs); |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3202 } | 3198 } |
| 3203 | 3199 |
| 3204 | 3200 |
| 3205 // Called when the top-level V8 mutex is destroyed. | 3201 // Called when the top-level V8 mutex is destroyed. |
| 3206 void Bootstrapper::FreeThreadResources() { | 3202 void Bootstrapper::FreeThreadResources() { |
| 3207 DCHECK(!IsActive()); | 3203 DCHECK(!IsActive()); |
| 3208 } | 3204 } |
| 3209 | 3205 |
| 3210 } // namespace internal | 3206 } // namespace internal |
| 3211 } // namespace v8 | 3207 } // namespace v8 |
| OLD | NEW |