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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 compiler->GenerateInstanceOf(cid(), | 574 compiler->GenerateInstanceOf(cid(), |
| 575 token_index(), | 575 token_index(), |
| 576 try_index(), | 576 try_index(), |
| 577 type(), | 577 type(), |
| 578 negate_result()); | 578 negate_result()); |
| 579 ASSERT(locs()->out().reg() == RAX); | 579 ASSERT(locs()->out().reg() == RAX); |
| 580 } | 580 } |
| 581 | 581 |
| 582 | 582 |
| 583 LocationSummary* CreateArrayComp::MakeLocationSummary() const { | 583 LocationSummary* CreateArrayComp::MakeLocationSummary() const { |
| 584 return NULL; | 584 const intptr_t kNumInputs = 1; |
| 585 const intptr_t kNumTemps = 2; | |
|
Vyacheslav Egorov (Google)
2012/05/30 11:42:17
should be 1
regis
2012/05/30 13:41:10
Done.
| |
| 586 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | |
| 587 locs->set_in(0, Location::RegisterLocation(RBX)); | |
| 588 locs->set_temp(0, Location::RegisterLocation(R10)); | |
| 589 locs->set_out(Location::RegisterLocation(RAX)); | |
| 590 return locs; | |
| 585 } | 591 } |
| 586 | 592 |
| 587 | 593 |
| 588 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 594 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 589 UNIMPLEMENTED(); | 595 ASSERT(locs()->in(0).reg() == RBX); |
| 596 ASSERT(locs()->temp(0).reg() == R10); | |
| 597 | |
| 598 // 1. Allocate the array. R10 = length, RBX = element type. | |
| 599 __ movq(R10, Immediate(Smi::RawValue(ElementCount()))); | |
| 600 compiler->GenerateCall(token_index(), | |
| 601 try_index(), | |
| 602 &StubCode::AllocateArrayLabel(), | |
| 603 PcDescriptors::kOther); | |
| 604 | |
| 605 // 2. Initialize the array in RAX with the element values. | |
| 606 __ leaq(R10, FieldAddress(RAX, Array::data_offset())); | |
| 607 for (int i = ElementCount() - 1; i >= 0; --i) { | |
| 608 if (ElementAt(i)->IsUse()) { | |
| 609 __ popq(Address(R10, i * kWordSize)); | |
| 610 } else { | |
| 611 compiler->LoadValue(RBX, ElementAt(i)); | |
| 612 __ movq(Address(R10, i * kWordSize), RBX); | |
| 613 } | |
| 614 } | |
|
Vyacheslav Egorov (Google)
2012/05/30 11:42:17
On the one hand: it has all arguments on the stack
regis
2012/05/30 13:41:10
Added comment.
| |
| 590 } | 615 } |
| 591 | 616 |
| 592 | 617 |
| 593 LocationSummary* CreateClosureComp::MakeLocationSummary() const { | 618 LocationSummary* CreateClosureComp::MakeLocationSummary() const { |
| 594 return NULL; | 619 return MakeCallSummary(); |
| 595 } | 620 } |
| 596 | 621 |
| 597 | 622 |
| 598 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 623 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 599 UNIMPLEMENTED(); | 624 const Function& closure_function = function(); |
| 625 const Code& stub = Code::Handle( | |
| 626 StubCode::GetAllocationStubForClosure(closure_function)); | |
| 627 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | |
| 628 compiler->GenerateCall(token_index(), try_index(), &label, | |
| 629 PcDescriptors::kOther); | |
| 630 | |
| 631 const Class& cls = Class::Handle(closure_function.signature_class()); | |
| 632 if (cls.HasTypeArguments()) { | |
| 633 __ Drop(1); // Discard type arguments. | |
| 634 } | |
| 635 if (closure_function.IsImplicitInstanceClosureFunction()) { | |
| 636 __ Drop(1); // Discard receiver. | |
| 637 } | |
| 600 } | 638 } |
| 601 | 639 |
| 602 | 640 |
| 603 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { | 641 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { |
| 604 return MakeCallSummary(); | 642 return MakeCallSummary(); |
| 605 } | 643 } |
| 606 | 644 |
| 607 | 645 |
| 608 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 646 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 609 const Class& cls = Class::ZoneHandle(constructor().owner()); | 647 const Class& cls = Class::ZoneHandle(constructor().owner()); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 965 if (locs()->out().reg() != RAX) { | 1003 if (locs()->out().reg() != RAX) { |
| 966 __ movq(locs()->out().reg(), RAX); | 1004 __ movq(locs()->out().reg(), RAX); |
| 967 } | 1005 } |
| 968 } | 1006 } |
| 969 | 1007 |
| 970 } // namespace dart | 1008 } // namespace dart |
| 971 | 1009 |
| 972 #undef __ | 1010 #undef __ |
| 973 | 1011 |
| 974 #endif // defined TARGET_ARCH_X64 | 1012 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |