Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "lib/error.h" | 8 #include "lib/error.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 const intptr_t kNumTemps = 1; | 584 const intptr_t kNumTemps = 1; |
| 585 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | 585 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); |
| 586 locs->set_in(0, Location::RegisterLocation(RBX)); | 586 locs->set_in(0, Location::RegisterLocation(RBX)); |
| 587 locs->set_temp(0, Location::RegisterLocation(R10)); | 587 locs->set_temp(0, Location::RegisterLocation(R10)); |
| 588 locs->set_out(Location::RegisterLocation(RAX)); | 588 locs->set_out(Location::RegisterLocation(RAX)); |
| 589 return locs; | 589 return locs; |
| 590 } | 590 } |
| 591 | 591 |
| 592 | 592 |
| 593 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 593 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 594 ASSERT(locs()->in(0).reg() == RBX); | 594 Register temp_reg = locs()->temp(0).reg(); |
| 595 ASSERT(locs()->temp(0).reg() == R10); | 595 Register result_reg = locs()->out().reg(); |
| 596 | 596 |
| 597 // 1. Allocate the array. R10 = length, RBX = element type. | 597 // 1. Allocate the array. R10 = length, RBX = element type. |
| 598 __ movq(R10, Immediate(Smi::RawValue(ElementCount()))); | 598 ASSERT(temp_reg == R10); |
| 599 ASSERT(locs()->in(0).reg() == RBX); | |
| 600 __ movq(temp_reg, Immediate(Smi::RawValue(ElementCount()))); | |
| 599 compiler->GenerateCall(token_index(), | 601 compiler->GenerateCall(token_index(), |
| 600 try_index(), | 602 try_index(), |
| 601 &StubCode::AllocateArrayLabel(), | 603 &StubCode::AllocateArrayLabel(), |
| 602 PcDescriptors::kOther); | 604 PcDescriptors::kOther); |
| 603 | 605 |
| 604 // 2. Initialize the array in RAX with the element values. | 606 // 2. Initialize the array in result_reg with the element values. |
| 605 __ leaq(R10, FieldAddress(RAX, Array::data_offset())); | 607 __ leaq(temp_reg, FieldAddress(result_reg, Array::data_offset())); |
| 606 for (int i = ElementCount() - 1; i >= 0; --i) { | 608 for (int i = ElementCount() - 1; i >= 0; --i) { |
| 607 if (ElementAt(i)->IsUse()) { | 609 ASSERT(ElementAt(i)->IsUse()); |
| 608 __ popq(Address(R10, i * kWordSize)); | 610 __ popq(Address(temp_reg, i * kWordSize)); |
| 609 } else { | |
| 610 compiler->LoadValue(RBX, ElementAt(i)); | |
| 611 __ movq(Address(R10, i * kWordSize), RBX); | |
| 612 } | |
| 613 } | 611 } |
| 614 } | 612 } |
| 615 | 613 |
| 616 | 614 |
| 617 LocationSummary* CreateClosureComp::MakeLocationSummary() const { | 615 LocationSummary* CreateClosureComp::MakeLocationSummary() const { |
| 618 return MakeCallSummary(); | 616 return MakeCallSummary(); |
| 619 } | 617 } |
| 620 | 618 |
| 621 | 619 |
| 622 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 620 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 623 const Function& closure_function = function(); | 621 const Function& closure_function = function(); |
| 624 const Code& stub = Code::Handle( | 622 const Code& stub = Code::Handle( |
| 625 StubCode::GetAllocationStubForClosure(closure_function)); | 623 StubCode::GetAllocationStubForClosure(closure_function)); |
| 626 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | 624 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); |
| 627 compiler->GenerateCall(token_index(), try_index(), &label, | 625 compiler->GenerateCall(token_index(), try_index(), &label, |
| 628 PcDescriptors::kOther); | 626 PcDescriptors::kOther); |
| 629 | 627 __ Drop(1); // Discard type arguments. |
| 630 const Class& cls = Class::Handle(closure_function.signature_class()); | |
| 631 if (cls.HasTypeArguments()) { | |
| 632 __ Drop(1); // Discard type arguments. | |
| 633 } | |
| 634 if (closure_function.IsImplicitInstanceClosureFunction()) { | 628 if (closure_function.IsImplicitInstanceClosureFunction()) { |
| 635 __ Drop(1); // Discard receiver. | 629 __ Drop(1); // Discard receiver. |
| 636 } | 630 } |
|
srdjan
2012/05/30 17:19:43
or you can say, Drop(2), else Drop(1) and removed
regis
2012/05/30 18:08:34
Done.
| |
| 637 } | 631 } |
| 638 | 632 |
| 639 | 633 |
| 640 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { | 634 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { |
| 641 return MakeCallSummary(); | 635 return MakeCallSummary(); |
| 642 } | 636 } |
| 643 | 637 |
| 644 | 638 |
| 645 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 639 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 646 const Class& cls = Class::ZoneHandle(constructor().owner()); | 640 const Class& cls = Class::ZoneHandle(constructor().owner()); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 if (locs()->out().reg() != RAX) { | 1057 if (locs()->out().reg() != RAX) { |
| 1064 __ movq(locs()->out().reg(), RAX); | 1058 __ movq(locs()->out().reg(), RAX); |
| 1065 } | 1059 } |
| 1066 } | 1060 } |
| 1067 | 1061 |
| 1068 } // namespace dart | 1062 } // namespace dart |
| 1069 | 1063 |
| 1070 #undef __ | 1064 #undef __ |
| 1071 | 1065 |
| 1072 #endif // defined TARGET_ARCH_X64 | 1066 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |