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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 8103)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -581,22 +581,64 @@
LocationSummary* CreateArrayComp::MakeLocationSummary() const {
- return NULL;
+ // TODO(regis): The elements of the array could be considered as arguments to
+ // CreateArrayComp, thereby making CreateArrayComp a call.
+ // For VerifyCallComputation to work, CreateArrayComp would need an
+ // ArgumentCount getter and an ArgumentAt getter.
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps);
+ locs->set_in(0, Location::RegisterLocation(RBX));
+ locs->set_temp(0, Location::RegisterLocation(R10));
+ locs->set_out(Location::RegisterLocation(RAX));
+ return locs;
}
void CreateArrayComp::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ ASSERT(locs()->in(0).reg() == RBX);
+ ASSERT(locs()->temp(0).reg() == R10);
+
+ // 1. Allocate the array. R10 = length, RBX = element type.
+ __ 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.
+ compiler->GenerateCall(token_index(),
+ try_index(),
+ &StubCode::AllocateArrayLabel(),
+ PcDescriptors::kOther);
+
+ // 2. Initialize the array in RAX with the element values.
+ __ 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.
+ for (int i = ElementCount() - 1; i >= 0; --i) {
+ if (ElementAt(i)->IsUse()) {
+ __ popq(Address(R10, i * kWordSize));
+ } else {
+ 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.
+ __ movq(Address(R10, i * kWordSize), RBX);
+ }
+ }
}
LocationSummary* CreateClosureComp::MakeLocationSummary() const {
- return NULL;
+ return MakeCallSummary();
}
void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ const Function& closure_function = function();
+ const Code& stub = Code::Handle(
+ StubCode::GetAllocationStubForClosure(closure_function));
+ const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint());
+ compiler->GenerateCall(token_index(), try_index(), &label,
+ PcDescriptors::kOther);
+
+ const Class& cls = Class::Handle(closure_function.signature_class());
+ if (cls.HasTypeArguments()) {
+ __ 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.
+ }
+ if (closure_function.IsImplicitInstanceClosureFunction()) {
+ __ Drop(1); // Discard receiver.
+ }
}
« 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