Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: src/bootstrapper.cc

Issue 1276533003: [runtime] Store constructor function index on primitive maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm failures Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 Handle<String> object_name = factory->Object_string(); 526 Handle<String> object_name = factory->Object_string();
527 527
528 Handle<JSObject> object_function_prototype; 528 Handle<JSObject> object_function_prototype;
529 529
530 { // --- O b j e c t --- 530 { // --- O b j e c t ---
531 Handle<JSFunction> object_fun = factory->NewFunction(object_name); 531 Handle<JSFunction> object_fun = factory->NewFunction(object_name);
532 int unused = JSObject::kInitialGlobalObjectUnusedPropertiesCount; 532 int unused = JSObject::kInitialGlobalObjectUnusedPropertiesCount;
533 int instance_size = JSObject::kHeaderSize + kPointerSize * unused; 533 int instance_size = JSObject::kHeaderSize + kPointerSize * unused;
534 Handle<Map> object_function_map = 534 Handle<Map> object_function_map =
535 factory->NewMap(JS_OBJECT_TYPE, instance_size); 535 factory->NewMap(JS_OBJECT_TYPE, instance_size);
536 object_function_map->set_inobject_properties(unused); 536 object_function_map->SetInObjectProperties(unused);
537 JSFunction::SetInitialMap(object_fun, object_function_map, 537 JSFunction::SetInitialMap(object_fun, object_function_map,
538 isolate->factory()->null_value()); 538 isolate->factory()->null_value());
539 object_function_map->set_unused_property_fields(unused); 539 object_function_map->set_unused_property_fields(unused);
540 540
541 native_context()->set_object_function(*object_fun); 541 native_context()->set_object_function(*object_fun);
542 542
543 // Allocate a new prototype for the object function. 543 // Allocate a new prototype for the object function.
544 object_function_prototype = 544 object_function_prototype =
545 factory->NewJSObject(isolate->object_function(), TENURED); 545 factory->NewJSObject(isolate->object_function(), TENURED);
546 Handle<Map> map = Map::Copy(handle(object_function_prototype->map()), 546 Handle<Map> map = Map::Copy(handle(object_function_prototype->map()),
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 // Builtin functions for RegExp.prototype. 1165 // Builtin functions for RegExp.prototype.
1166 Handle<JSFunction> regexp_fun = 1166 Handle<JSFunction> regexp_fun =
1167 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 1167 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
1168 isolate->initial_object_prototype(), 1168 isolate->initial_object_prototype(),
1169 Builtins::kIllegal); 1169 Builtins::kIllegal);
1170 native_context()->set_regexp_function(*regexp_fun); 1170 native_context()->set_regexp_function(*regexp_fun);
1171 1171
1172 DCHECK(regexp_fun->has_initial_map()); 1172 DCHECK(regexp_fun->has_initial_map());
1173 Handle<Map> initial_map(regexp_fun->initial_map()); 1173 Handle<Map> initial_map(regexp_fun->initial_map());
1174 1174
1175 DCHECK_EQ(0, initial_map->inobject_properties()); 1175 DCHECK_EQ(0, initial_map->GetInObjectProperties());
1176 1176
1177 PropertyAttributes final = 1177 PropertyAttributes final =
1178 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1178 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1179 Map::EnsureDescriptorSlack(initial_map, 5); 1179 Map::EnsureDescriptorSlack(initial_map, 5);
1180 1180
1181 { 1181 {
1182 // ECMA-262, section 15.10.7.1. 1182 // ECMA-262, section 15.10.7.1.
1183 DataDescriptor field(factory->source_string(), 1183 DataDescriptor field(factory->source_string(),
1184 JSRegExp::kSourceFieldIndex, final, 1184 JSRegExp::kSourceFieldIndex, final,
1185 Representation::Tagged()); 1185 Representation::Tagged());
(...skipping 24 matching lines...) Expand all
1210 // ECMA-262, section 15.10.7.5. 1210 // ECMA-262, section 15.10.7.5.
1211 PropertyAttributes writable = 1211 PropertyAttributes writable =
1212 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 1212 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1213 DataDescriptor field(factory->last_index_string(), 1213 DataDescriptor field(factory->last_index_string(),
1214 JSRegExp::kLastIndexFieldIndex, writable, 1214 JSRegExp::kLastIndexFieldIndex, writable,
1215 Representation::Tagged()); 1215 Representation::Tagged());
1216 initial_map->AppendDescriptor(&field); 1216 initial_map->AppendDescriptor(&field);
1217 } 1217 }
1218 1218
1219 static const int num_fields = JSRegExp::kInObjectFieldCount; 1219 static const int num_fields = JSRegExp::kInObjectFieldCount;
1220 initial_map->set_inobject_properties(num_fields); 1220 initial_map->SetInObjectProperties(num_fields);
1221 initial_map->set_unused_property_fields(0); 1221 initial_map->set_unused_property_fields(0);
1222 initial_map->set_instance_size(initial_map->instance_size() + 1222 initial_map->set_instance_size(initial_map->instance_size() +
1223 num_fields * kPointerSize); 1223 num_fields * kPointerSize);
1224 1224
1225 // RegExp prototype object is itself a RegExp. 1225 // RegExp prototype object is itself a RegExp.
1226 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype"); 1226 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype");
1227 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype()); 1227 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype());
1228 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); 1228 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1229 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, 1229 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1230 heap->query_colon_string()); 1230 heap->query_colon_string());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 } 1306 }
1307 1307
1308 { // Set up the iterator result object 1308 { // Set up the iterator result object
1309 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); 1309 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
1310 Handle<JSFunction> object_function(native_context()->object_function()); 1310 Handle<JSFunction> object_function(native_context()->object_function());
1311 Handle<Map> iterator_result_map = 1311 Handle<Map> iterator_result_map =
1312 Map::Create(isolate, JSGeneratorObject::kResultPropertyCount); 1312 Map::Create(isolate, JSGeneratorObject::kResultPropertyCount);
1313 DCHECK_EQ(JSGeneratorObject::kResultSize, 1313 DCHECK_EQ(JSGeneratorObject::kResultSize,
1314 iterator_result_map->instance_size()); 1314 iterator_result_map->instance_size());
1315 DCHECK_EQ(JSGeneratorObject::kResultPropertyCount, 1315 DCHECK_EQ(JSGeneratorObject::kResultPropertyCount,
1316 iterator_result_map->inobject_properties()); 1316 iterator_result_map->GetInObjectProperties());
1317 Map::EnsureDescriptorSlack(iterator_result_map, 1317 Map::EnsureDescriptorSlack(iterator_result_map,
1318 JSGeneratorObject::kResultPropertyCount); 1318 JSGeneratorObject::kResultPropertyCount);
1319 1319
1320 DataDescriptor value_descr(factory->value_string(), 1320 DataDescriptor value_descr(factory->value_string(),
1321 JSGeneratorObject::kResultValuePropertyIndex, 1321 JSGeneratorObject::kResultValuePropertyIndex,
1322 NONE, Representation::Tagged()); 1322 NONE, Representation::Tagged());
1323 iterator_result_map->AppendDescriptor(&value_descr); 1323 iterator_result_map->AppendDescriptor(&value_descr);
1324 1324
1325 DataDescriptor done_descr(factory->done_string(), 1325 DataDescriptor done_descr(factory->done_string(),
1326 JSGeneratorObject::kResultDonePropertyIndex, NONE, 1326 JSGeneratorObject::kResultDonePropertyIndex, NONE,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 map->AppendDescriptor(&d); 1361 map->AppendDescriptor(&d);
1362 } 1362 }
1363 { // callee 1363 { // callee
1364 DataDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex, 1364 DataDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex,
1365 DONT_ENUM, Representation::Tagged()); 1365 DONT_ENUM, Representation::Tagged());
1366 map->AppendDescriptor(&d); 1366 map->AppendDescriptor(&d);
1367 } 1367 }
1368 // @@iterator method is added later. 1368 // @@iterator method is added later.
1369 1369
1370 map->set_function_with_prototype(true); 1370 map->set_function_with_prototype(true);
1371 map->set_inobject_properties(2); 1371 map->SetInObjectProperties(2);
1372 native_context()->set_sloppy_arguments_map(*map); 1372 native_context()->set_sloppy_arguments_map(*map);
1373 1373
1374 DCHECK(!function->has_initial_map()); 1374 DCHECK(!function->has_initial_map());
1375 JSFunction::SetInitialMap(function, map, 1375 JSFunction::SetInitialMap(function, map,
1376 isolate->initial_object_prototype()); 1376 isolate->initial_object_prototype());
1377 1377
1378 DCHECK(map->inobject_properties() > Heap::kArgumentsCalleeIndex); 1378 DCHECK(map->GetInObjectProperties() > Heap::kArgumentsCalleeIndex);
1379 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); 1379 DCHECK(map->GetInObjectProperties() > Heap::kArgumentsLengthIndex);
1380 DCHECK(!map->is_dictionary_map()); 1380 DCHECK(!map->is_dictionary_map());
1381 DCHECK(IsFastObjectElementsKind(map->elements_kind())); 1381 DCHECK(IsFastObjectElementsKind(map->elements_kind()));
1382 } 1382 }
1383 1383
1384 { // --- fast and slow aliased arguments map 1384 { // --- fast and slow aliased arguments map
1385 Handle<Map> map = isolate->sloppy_arguments_map(); 1385 Handle<Map> map = isolate->sloppy_arguments_map();
1386 map = Map::Copy(map, "FastAliasedArguments"); 1386 map = Map::Copy(map, "FastAliasedArguments");
1387 map->set_elements_kind(FAST_SLOPPY_ARGUMENTS_ELEMENTS); 1387 map->set_elements_kind(FAST_SLOPPY_ARGUMENTS_ELEMENTS);
1388 DCHECK_EQ(2, map->inobject_properties()); 1388 DCHECK_EQ(2, map->GetInObjectProperties());
1389 native_context()->set_fast_aliased_arguments_map(*map); 1389 native_context()->set_fast_aliased_arguments_map(*map);
1390 1390
1391 map = Map::Copy(map, "SlowAliasedArguments"); 1391 map = Map::Copy(map, "SlowAliasedArguments");
1392 map->set_elements_kind(SLOW_SLOPPY_ARGUMENTS_ELEMENTS); 1392 map->set_elements_kind(SLOW_SLOPPY_ARGUMENTS_ELEMENTS);
1393 DCHECK_EQ(2, map->inobject_properties()); 1393 DCHECK_EQ(2, map->GetInObjectProperties());
1394 native_context()->set_slow_aliased_arguments_map(*map); 1394 native_context()->set_slow_aliased_arguments_map(*map);
1395 } 1395 }
1396 1396
1397 { // --- strict mode arguments map 1397 { // --- strict mode arguments map
1398 const PropertyAttributes attributes = 1398 const PropertyAttributes attributes =
1399 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1399 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1400 1400
1401 // Create the ThrowTypeError functions. 1401 // Create the ThrowTypeError functions.
1402 Handle<AccessorPair> callee = factory->NewAccessorPair(); 1402 Handle<AccessorPair> callee = factory->NewAccessorPair();
1403 Handle<AccessorPair> caller = factory->NewAccessorPair(); 1403 Handle<AccessorPair> caller = factory->NewAccessorPair();
(...skipping 26 matching lines...) Expand all
1430 AccessorConstantDescriptor d(factory->caller_string(), caller, 1430 AccessorConstantDescriptor d(factory->caller_string(), caller,
1431 attributes); 1431 attributes);
1432 map->AppendDescriptor(&d); 1432 map->AppendDescriptor(&d);
1433 } 1433 }
1434 // @@iterator method is added later. 1434 // @@iterator method is added later.
1435 1435
1436 map->set_function_with_prototype(true); 1436 map->set_function_with_prototype(true);
1437 DCHECK_EQ(native_context()->object_function()->prototype(), 1437 DCHECK_EQ(native_context()->object_function()->prototype(),
1438 *isolate->initial_object_prototype()); 1438 *isolate->initial_object_prototype());
1439 Map::SetPrototype(map, isolate->initial_object_prototype()); 1439 Map::SetPrototype(map, isolate->initial_object_prototype());
1440 map->set_inobject_properties(1); 1440 map->SetInObjectProperties(1);
1441 1441
1442 // Copy constructor from the sloppy arguments boilerplate. 1442 // Copy constructor from the sloppy arguments boilerplate.
1443 map->SetConstructor( 1443 map->SetConstructor(
1444 native_context()->sloppy_arguments_map()->GetConstructor()); 1444 native_context()->sloppy_arguments_map()->GetConstructor());
1445 1445
1446 native_context()->set_strict_arguments_map(*map); 1446 native_context()->set_strict_arguments_map(*map);
1447 1447
1448 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); 1448 DCHECK(map->GetInObjectProperties() > Heap::kArgumentsLengthIndex);
1449 DCHECK(!map->is_dictionary_map()); 1449 DCHECK(!map->is_dictionary_map());
1450 DCHECK(IsFastObjectElementsKind(map->elements_kind())); 1450 DCHECK(IsFastObjectElementsKind(map->elements_kind()));
1451 } 1451 }
1452 1452
1453 { // --- context extension 1453 { // --- context extension
1454 // Create a function for the context extension objects. 1454 // Create a function for the context extension objects.
1455 Handle<Code> code = Handle<Code>( 1455 Handle<Code> code = Handle<Code>(
1456 isolate->builtins()->builtin(Builtins::kIllegal)); 1456 isolate->builtins()->builtin(Builtins::kIllegal));
1457 Handle<JSFunction> context_extension_fun = factory->NewFunction( 1457 Handle<JSFunction> context_extension_fun = factory->NewFunction(
1458 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, 1458 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE,
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 initial_map->AppendDescriptor(&index_field); 2489 initial_map->AppendDescriptor(&index_field);
2490 } 2490 }
2491 2491
2492 { 2492 {
2493 DataDescriptor input_field(factory()->input_string(), 2493 DataDescriptor input_field(factory()->input_string(),
2494 JSRegExpResult::kInputIndex, NONE, 2494 JSRegExpResult::kInputIndex, NONE,
2495 Representation::Tagged()); 2495 Representation::Tagged());
2496 initial_map->AppendDescriptor(&input_field); 2496 initial_map->AppendDescriptor(&input_field);
2497 } 2497 }
2498 2498
2499 initial_map->set_inobject_properties(2); 2499 initial_map->SetInObjectProperties(2);
2500 initial_map->set_unused_property_fields(0); 2500 initial_map->set_unused_property_fields(0);
2501 2501
2502 native_context()->set_regexp_result_map(*initial_map); 2502 native_context()->set_regexp_result_map(*initial_map);
2503 } 2503 }
2504 2504
2505 // Add @@iterator method to the arguments object maps. 2505 // Add @@iterator method to the arguments object maps.
2506 { 2506 {
2507 PropertyAttributes attribs = DONT_ENUM; 2507 PropertyAttributes attribs = DONT_ENUM;
2508 Handle<AccessorInfo> arguments_iterator = 2508 Handle<AccessorInfo> arguments_iterator =
2509 Accessors::ArgumentsIteratorInfo(isolate(), attribs); 2509 Accessors::ArgumentsIteratorInfo(isolate(), attribs);
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 } 3260 }
3261 3261
3262 3262
3263 // Called when the top-level V8 mutex is destroyed. 3263 // Called when the top-level V8 mutex is destroyed.
3264 void Bootstrapper::FreeThreadResources() { 3264 void Bootstrapper::FreeThreadResources() {
3265 DCHECK(!IsActive()); 3265 DCHECK(!IsActive());
3266 } 3266 }
3267 3267
3268 } // namespace internal 3268 } // namespace internal
3269 } // namespace v8 3269 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698