Chromium Code Reviews| Index: runtime/vm/intermediate_language_x64.cc |
| =================================================================== |
| --- runtime/vm/intermediate_language_x64.cc (revision 8091) |
| +++ runtime/vm/intermediate_language_x64.cc (working copy) |
| @@ -581,22 +581,60 @@ |
| LocationSummary* CreateArrayComp::MakeLocationSummary() const { |
| - return NULL; |
| + const intptr_t kNumInputs = 1; |
| + 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.
|
| + 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()))); |
| + 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())); |
| + for (int i = ElementCount() - 1; i >= 0; --i) { |
| + if (ElementAt(i)->IsUse()) { |
| + __ popq(Address(R10, i * kWordSize)); |
| + } else { |
| + compiler->LoadValue(RBX, ElementAt(i)); |
| + __ movq(Address(R10, i * kWordSize), RBX); |
| + } |
| + } |
|
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.
|
| } |
| 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. |
| + } |
| + if (closure_function.IsImplicitInstanceClosureFunction()) { |
| + __ Drop(1); // Discard receiver. |
| + } |
| } |