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

Side by Side Diff: src/builtins/builtins-object.cc

Issue 2430273007: [runtime] Object.create(null) creates a slow object (Closed)
Patch Set: fix GC mole issue Created 4 years, 1 month 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/bootstrapper.cc ('k') | src/code-stub-assembler.h » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins.h" 5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h" 6 #include "src/builtins/builtins-utils.h"
7 7
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/property-descriptor.h" 9 #include "src/property-descriptor.h"
10 10
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 Node* bit_field3 = a->LoadMapBitField3(properties_map); 487 Node* bit_field3 = a->LoadMapBitField3(properties_map);
488 a->GotoIf(a->IsSetWord32<Map::DictionaryMap>(bit_field3), &call_runtime); 488 a->GotoIf(a->IsSetWord32<Map::DictionaryMap>(bit_field3), &call_runtime);
489 a->Branch(a->IsSetWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3), 489 a->Branch(a->IsSetWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3),
490 &call_runtime, &no_properties); 490 &call_runtime, &no_properties);
491 } 491 }
492 492
493 // Create a new object with the given prototype. 493 // Create a new object with the given prototype.
494 a->Bind(&no_properties); 494 a->Bind(&no_properties);
495 { 495 {
496 Variable map(a, MachineRepresentation::kTagged); 496 Variable map(a, MachineRepresentation::kTagged);
497 Variable properties(a, MachineRepresentation::kTagged);
497 Label non_null_proto(a), instantiate_map(a), good(a); 498 Label non_null_proto(a), instantiate_map(a), good(a);
498 499
499 a->Branch(a->WordEqual(prototype, a->NullConstant()), &good, 500 a->Branch(a->WordEqual(prototype, a->NullConstant()), &good,
500 &non_null_proto); 501 &non_null_proto);
501 502
502 a->Bind(&good); 503 a->Bind(&good);
503 { 504 {
504 map.Bind(a->LoadContextElement(context, 505 map.Bind(a->LoadContextElement(
505 Context::OBJECT_WITH_NULL_PROTOTYPE_MAP)); 506 context, Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP));
507 properties.Bind(
508 a->AllocateNameDictionary(NameDictionary::kInitialCapacity));
506 a->Goto(&instantiate_map); 509 a->Goto(&instantiate_map);
507 } 510 }
508 511
509 a->Bind(&non_null_proto); 512 a->Bind(&non_null_proto);
510 { 513 {
514 properties.Bind(a->EmptyFixedArrayConstant());
511 Node* object_function = 515 Node* object_function =
512 a->LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX); 516 a->LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX);
513 Node* object_function_map = a->LoadObjectField( 517 Node* object_function_map = a->LoadObjectField(
514 object_function, JSFunction::kPrototypeOrInitialMapOffset); 518 object_function, JSFunction::kPrototypeOrInitialMapOffset);
515 map.Bind(object_function_map); 519 map.Bind(object_function_map);
516 a->GotoIf(a->WordEqual(prototype, a->LoadMapPrototype(map.value())), 520 a->GotoIf(a->WordEqual(prototype, a->LoadMapPrototype(map.value())),
517 &instantiate_map); 521 &instantiate_map);
518 // Try loading the prototype info. 522 // Try loading the prototype info.
519 Node* prototype_info = 523 Node* prototype_info =
520 a->LoadMapPrototypeInfo(a->LoadMap(prototype), &call_runtime); 524 a->LoadMapPrototypeInfo(a->LoadMap(prototype), &call_runtime);
521 a->Comment("Load ObjectCreateMap from PrototypeInfo"); 525 a->Comment("Load ObjectCreateMap from PrototypeInfo");
522 Node* weak_cell = 526 Node* weak_cell =
523 a->LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap); 527 a->LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap);
524 a->GotoIf(a->WordEqual(weak_cell, a->UndefinedConstant()), &call_runtime); 528 a->GotoIf(a->WordEqual(weak_cell, a->UndefinedConstant()), &call_runtime);
525 map.Bind(a->LoadWeakCellValue(weak_cell, &call_runtime)); 529 map.Bind(a->LoadWeakCellValue(weak_cell, &call_runtime));
526 a->Goto(&instantiate_map); 530 a->Goto(&instantiate_map);
527 } 531 }
528 532
529 a->Bind(&instantiate_map); 533 a->Bind(&instantiate_map);
530 { 534 {
531 Node* instance = a->AllocateJSObjectFromMap(map.value()); 535 Node* instance =
536 a->AllocateJSObjectFromMap(map.value(), properties.value());
532 a->Return(instance); 537 a->Return(instance);
533 } 538 }
534 } 539 }
535 540
536 a->Bind(&call_runtime); 541 a->Bind(&call_runtime);
537 { 542 {
538 a->Return( 543 a->Return(
539 a->CallRuntime(Runtime::kObjectCreate, context, prototype, properties)); 544 a->CallRuntime(Runtime::kObjectCreate, context, prototype, properties));
540 } 545 }
541 } 546 }
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 typedef CompareDescriptor Descriptor; 1046 typedef CompareDescriptor Descriptor;
1042 Node* object = assembler->Parameter(Descriptor::kLeft); 1047 Node* object = assembler->Parameter(Descriptor::kLeft);
1043 Node* callable = assembler->Parameter(Descriptor::kRight); 1048 Node* callable = assembler->Parameter(Descriptor::kRight);
1044 Node* context = assembler->Parameter(Descriptor::kContext); 1049 Node* context = assembler->Parameter(Descriptor::kContext);
1045 1050
1046 assembler->Return(assembler->InstanceOf(object, callable, context)); 1051 assembler->Return(assembler->InstanceOf(object, callable, context));
1047 } 1052 }
1048 1053
1049 } // namespace internal 1054 } // namespace internal
1050 } // namespace v8 1055 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698