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

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 10460002: Move CreateArray and CreateClosure to new location template. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // TODO(regis): The elements of the array could be considered as arguments to
585 // CreateArrayComp, thereby making CreateArrayComp a call.
586 // For VerifyCallComputation to work, CreateArrayComp would need an
587 // ArgumentCount getter and an ArgumentAt getter.
588 const intptr_t kNumInputs = 1;
589 const intptr_t kNumTemps = 1;
590 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps);
591 locs->set_in(0, Location::RegisterLocation(RBX));
592 locs->set_temp(0, Location::RegisterLocation(R10));
593 locs->set_out(Location::RegisterLocation(RAX));
594 return locs;
585 } 595 }
586 596
587 597
588 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) { 598 void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) {
589 UNIMPLEMENTED(); 599 ASSERT(locs()->in(0).reg() == RBX);
600 ASSERT(locs()->temp(0).reg() == R10);
601
602 // 1. Allocate the array. R10 = length, RBX = element type.
603 __ movq(R10, Immediate(Smi::RawValue(ElementCount())));
srdjan 2012/05/30 15:58:37 Use temp instead of R10, so that the knowledge of
regis 2012/05/30 16:59:08 Done.
604 compiler->GenerateCall(token_index(),
605 try_index(),
606 &StubCode::AllocateArrayLabel(),
607 PcDescriptors::kOther);
608
609 // 2. Initialize the array in RAX with the element values.
610 __ leaq(R10, FieldAddress(RAX, Array::data_offset()));
srdjan 2012/05/30 15:58:37 ditto here and below.
regis 2012/05/30 16:59:08 Done.
611 for (int i = ElementCount() - 1; i >= 0; --i) {
612 if (ElementAt(i)->IsUse()) {
613 __ popq(Address(R10, i * kWordSize));
614 } else {
615 compiler->LoadValue(RBX, ElementAt(i));
srdjan 2012/05/30 15:58:37 I think this should no happend, i.e., FlowGraphBui
regis 2012/05/30 16:59:08 Done.
616 __ movq(Address(R10, i * kWordSize), RBX);
617 }
618 }
590 } 619 }
591 620
592 621
593 LocationSummary* CreateClosureComp::MakeLocationSummary() const { 622 LocationSummary* CreateClosureComp::MakeLocationSummary() const {
594 return NULL; 623 return MakeCallSummary();
595 } 624 }
596 625
597 626
598 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { 627 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) {
599 UNIMPLEMENTED(); 628 const Function& closure_function = function();
629 const Code& stub = Code::Handle(
630 StubCode::GetAllocationStubForClosure(closure_function));
631 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint());
632 compiler->GenerateCall(token_index(), try_index(), &label,
633 PcDescriptors::kOther);
634
635 const Class& cls = Class::Handle(closure_function.signature_class());
636 if (cls.HasTypeArguments()) {
637 __ Drop(1); // Discard type arguments.
srdjan 2012/05/30 15:58:37 Could we normalize the closure creation to always
regis 2012/05/30 16:59:08 Done.
638 }
639 if (closure_function.IsImplicitInstanceClosureFunction()) {
640 __ Drop(1); // Discard receiver.
641 }
600 } 642 }
601 643
602 644
603 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { 645 LocationSummary* AllocateObjectComp::MakeLocationSummary() const {
604 return MakeCallSummary(); 646 return MakeCallSummary();
605 } 647 }
606 648
607 649
608 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { 650 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) {
609 const Class& cls = Class::ZoneHandle(constructor().owner()); 651 const Class& cls = Class::ZoneHandle(constructor().owner());
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 if (locs()->out().reg() != RAX) { 1007 if (locs()->out().reg() != RAX) {
966 __ movq(locs()->out().reg(), RAX); 1008 __ movq(locs()->out().reg(), RAX);
967 } 1009 }
968 } 1010 }
969 1011
970 } // namespace dart 1012 } // namespace dart
971 1013
972 #undef __ 1014 #undef __
973 1015
974 #endif // defined TARGET_ARCH_X64 1016 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698