Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 a->WordEqual( | 498 a->WordEqual( |
| 499 a->BitFieldDecodeWord<Map::NumberOfOwnDescriptorsBits>(bit_field3), | 499 a->BitFieldDecodeWord<Map::NumberOfOwnDescriptorsBits>(bit_field3), |
| 500 a->IntPtrConstant(0)), | 500 a->IntPtrConstant(0)), |
| 501 &no_properties, &call_runtime); | 501 &no_properties, &call_runtime); |
| 502 } | 502 } |
| 503 | 503 |
| 504 // Create a new object with the given prototype. | 504 // Create a new object with the given prototype. |
| 505 a->Bind(&no_properties); | 505 a->Bind(&no_properties); |
| 506 { | 506 { |
| 507 Variable map(a, MachineRepresentation::kTagged); | 507 Variable map(a, MachineRepresentation::kTagged); |
| 508 Variable properties(a, MachineRepresentation::kTagged); | |
| 508 Label non_null_proto(a), instantiate_map(a), good(a); | 509 Label non_null_proto(a), instantiate_map(a), good(a); |
| 509 | 510 |
| 510 a->Branch(a->WordEqual(prototype, a->NullConstant()), &good, | 511 a->Branch(a->WordEqual(prototype, a->NullConstant()), &good, |
| 511 &non_null_proto); | 512 &non_null_proto); |
| 512 | 513 |
| 513 a->Bind(&good); | 514 a->Bind(&good); |
| 514 { | 515 { |
| 515 map.Bind(a->LoadContextElement(context, | 516 map.Bind(a->LoadContextElement( |
| 516 Context::OBJECT_WITH_NULL_PROTOTYPE_MAP)); | 517 context, Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP)); |
| 518 properties.Bind( | |
| 519 a->AllocateNameDictionary(NameDictionary::kInitialCapacity)); | |
|
Camillo Bruni
2016/10/21 13:37:15
How can I make sure the GC updates the properties
Igor Sheludko
2016/10/21 15:01:09
You marked the variable as kTagged, so the compile
| |
| 517 a->Goto(&instantiate_map); | 520 a->Goto(&instantiate_map); |
| 518 } | 521 } |
| 519 | 522 |
| 520 a->Bind(&non_null_proto); | 523 a->Bind(&non_null_proto); |
| 521 { | 524 { |
| 525 properties.Bind(a->EmptyFixedArrayConstant()); | |
| 522 Node* object_function = | 526 Node* object_function = |
| 523 a->LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX); | 527 a->LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX); |
| 524 Node* object_function_map = a->LoadObjectField( | 528 Node* object_function_map = a->LoadObjectField( |
| 525 object_function, JSFunction::kPrototypeOrInitialMapOffset); | 529 object_function, JSFunction::kPrototypeOrInitialMapOffset); |
| 526 map.Bind(object_function_map); | 530 map.Bind(object_function_map); |
| 527 a->GotoIf(a->WordEqual(prototype, a->LoadMapPrototype(map.value())), | 531 a->GotoIf(a->WordEqual(prototype, a->LoadMapPrototype(map.value())), |
| 528 &instantiate_map); | 532 &instantiate_map); |
| 529 // Try loading the prototype info. | 533 // Try loading the prototype info. |
| 530 Node* prototype_info = | 534 Node* prototype_info = |
| 531 a->LoadMapPrototypeInfo(a->LoadMap(prototype), &call_runtime); | 535 a->LoadMapPrototypeInfo(a->LoadMap(prototype), &call_runtime); |
| 532 a->Comment("Load ObjectCreateMap from PrototypeInfo"); | 536 a->Comment("Load ObjectCreateMap from PrototypeInfo"); |
| 533 Node* weak_cell = | 537 Node* weak_cell = |
| 534 a->LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap); | 538 a->LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap); |
| 535 a->GotoIf(a->WordEqual(weak_cell, a->UndefinedConstant()), &call_runtime); | 539 a->GotoIf(a->WordEqual(weak_cell, a->UndefinedConstant()), &call_runtime); |
| 536 map.Bind(a->LoadWeakCellValue(weak_cell, &call_runtime)); | 540 map.Bind(a->LoadWeakCellValue(weak_cell, &call_runtime)); |
| 537 a->Goto(&instantiate_map); | 541 a->Goto(&instantiate_map); |
| 538 } | 542 } |
| 539 | 543 |
| 540 a->Bind(&instantiate_map); | 544 a->Bind(&instantiate_map); |
| 541 { | 545 { |
| 542 Node* instance = a->AllocateJSObjectFromMap(map.value()); | 546 Node* instance = |
| 547 a->AllocateJSObjectFromMap(map.value(), properties.value()); | |
| 543 a->Return(instance); | 548 a->Return(instance); |
| 544 } | 549 } |
| 545 } | 550 } |
| 546 | 551 |
| 547 a->Bind(&call_runtime); | 552 a->Bind(&call_runtime); |
| 548 { | 553 { |
| 549 a->Return( | 554 a->Return( |
| 550 a->CallRuntime(Runtime::kObjectCreate, context, prototype, properties)); | 555 a->CallRuntime(Runtime::kObjectCreate, context, prototype, properties)); |
| 551 } | 556 } |
| 552 } | 557 } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 typedef CompareDescriptor Descriptor; | 1057 typedef CompareDescriptor Descriptor; |
| 1053 Node* object = assembler->Parameter(Descriptor::kLeft); | 1058 Node* object = assembler->Parameter(Descriptor::kLeft); |
| 1054 Node* callable = assembler->Parameter(Descriptor::kRight); | 1059 Node* callable = assembler->Parameter(Descriptor::kRight); |
| 1055 Node* context = assembler->Parameter(Descriptor::kContext); | 1060 Node* context = assembler->Parameter(Descriptor::kContext); |
| 1056 | 1061 |
| 1057 assembler->Return(assembler->InstanceOf(object, callable, context)); | 1062 assembler->Return(assembler->InstanceOf(object, callable, context)); |
| 1058 } | 1063 } |
| 1059 | 1064 |
| 1060 } // namespace internal | 1065 } // namespace internal |
| 1061 } // namespace v8 | 1066 } // namespace v8 |
| OLD | NEW |