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 = 0; |
| 585 const intptr_t kNumTemps = 2; | |
| 586 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | |
| 587 locs->set_temp(0, Location::RegisterLocation(R10)); | |
| 588 locs->set_temp(1, Location::RegisterLocation(RBX)); | |
| 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()->temp(0).reg() == R10); |
| 596 ASSERT(locs()->temp(1).reg() == RBX); | |
| 597 | |
| 598 // 1. Allocate the array. R10 = length, RBX = element type. | |
| 599 __ movq(R10, Immediate(Smi::RawValue(ElementCount()))); | |
| 600 compiler->LoadValue(RBX, element_type()); | |
|
Vyacheslav Egorov (Google)
2012/05/30 10:44:11
New templates should not use LoadValue directly. I
Vyacheslav Egorov (Google)
2012/05/30 11:13:41
Actually I misread the code in BuildInstantiatedTy
| |
| 601 compiler->GenerateCall(token_index(), | |
| 602 try_index(), | |
| 603 &StubCode::AllocateArrayLabel(), | |
| 604 PcDescriptors::kOther); | |
| 605 | |
| 606 // 2. Initialize the array in RAX with the element values. | |
| 607 __ leaq(R10, FieldAddress(RAX, Array::data_offset())); | |
| 608 for (int i = ElementCount() - 1; i >= 0; --i) { | |
| 609 if (ElementAt(i)->IsUse()) { | |
| 610 __ popq(Address(R10, i * kWordSize)); | |
| 611 } else { | |
| 612 compiler->LoadValue(RBX, ElementAt(i)); | |
| 613 __ movq(Address(R10, i * kWordSize), RBX); | |
| 614 } | |
| 615 } | |
| 590 } | 616 } |
| 591 | 617 |
| 592 | 618 |
| 593 LocationSummary* CreateClosureComp::MakeLocationSummary() const { | 619 LocationSummary* CreateClosureComp::MakeLocationSummary() const { |
| 594 return NULL; | 620 return MakeCallSummary(); |
| 595 } | 621 } |
| 596 | 622 |
| 597 | 623 |
| 598 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 624 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 599 UNIMPLEMENTED(); | 625 const Function& closure_function = function(); |
| 626 const Code& stub = Code::Handle( | |
| 627 StubCode::GetAllocationStubForClosure(closure_function)); | |
| 628 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | |
| 629 compiler->GenerateCall(token_index(), try_index(), &label, | |
| 630 PcDescriptors::kOther); | |
| 631 | |
| 632 const Class& cls = Class::Handle(closure_function.signature_class()); | |
| 633 if (cls.HasTypeArguments()) { | |
| 634 __ Drop(1); // Discard type arguments. | |
| 635 } | |
| 636 if (closure_function.IsImplicitInstanceClosureFunction()) { | |
| 637 __ Drop(1); // Discard receiver. | |
| 638 } | |
| 600 } | 639 } |
| 601 | 640 |
| 602 | 641 |
| 603 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { | 642 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { |
| 604 return MakeCallSummary(); | 643 return MakeCallSummary(); |
| 605 } | 644 } |
| 606 | 645 |
| 607 | 646 |
| 608 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 647 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 609 const Class& cls = Class::ZoneHandle(constructor().owner()); | 648 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) { | 1004 if (locs()->out().reg() != RAX) { |
| 966 __ movq(locs()->out().reg(), RAX); | 1005 __ movq(locs()->out().reg(), RAX); |
| 967 } | 1006 } |
| 968 } | 1007 } |
| 969 | 1008 |
| 970 } // namespace dart | 1009 } // namespace dart |
| 971 | 1010 |
| 972 #undef __ | 1011 #undef __ |
| 973 | 1012 |
| 974 #endif // defined TARGET_ARCH_X64 | 1013 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |