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

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

Issue 227723002: VM: Implement closure calls as instance calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: minimal inlining tweaks Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 5792 matching lines...) Expand 10 before | Expand all | Expand 10 after
5803 __ andl(EDX, Immediate( 5803 __ andl(EDX, Immediate(
5804 Smi::RawValue(true_value) - Smi::RawValue(false_value))); 5804 Smi::RawValue(true_value) - Smi::RawValue(false_value)));
5805 if (false_value != 0) { 5805 if (false_value != 0) {
5806 __ addl(EDX, Immediate(Smi::RawValue(false_value))); 5806 __ addl(EDX, Immediate(Smi::RawValue(false_value)));
5807 } 5807 }
5808 } 5808 }
5809 } 5809 }
5810 5810
5811 5811
5812 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { 5812 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const {
5813 const intptr_t kNumInputs = 0; 5813 return MakeCallSummary();
5814 const intptr_t kNumTemps = 1;
5815 LocationSummary* result =
5816 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
5817 result->set_out(0, Location::RegisterLocation(EAX));
5818 result->set_temp(0, Location::RegisterLocation(EDX)); // Arg. descriptor.
5819 return result;
5820 } 5814 }
5821 5815
5822 5816
5823 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5817 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5824 // The arguments to the stub include the closure, as does the arguments 5818 // Load closure object (first argument) in EDI.
5825 // descriptor. 5819 intptr_t argument_count = ArgumentCount();
5826 Register temp_reg = locs()->temp(0).reg(); 5820 __ movl(EDI, Address(ESP, (argument_count - 1) * kWordSize));
5827 int argument_count = ArgumentCount(); 5821
5822 // Load arguments descriptors.
5828 const Array& arguments_descriptor = 5823 const Array& arguments_descriptor =
5829 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, 5824 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count,
5830 argument_names())); 5825 argument_names()));
5831 __ LoadObject(temp_reg, arguments_descriptor); 5826 __ LoadObject(EDX, arguments_descriptor);
5832 ASSERT(temp_reg == EDX); 5827
5833 compiler->GenerateDartCall(deopt_id(), 5828 // Load the closure function into EAX.
5834 token_pos(), 5829 __ movl(EAX, FieldAddress(EDI, Closure::function_offset()));
5835 &StubCode::CallClosureFunctionLabel(), 5830
5836 PcDescriptors::kClosureCall, 5831 // Load closure context in CTX; note that CTX has already been preserved.
5837 locs()); 5832 __ movl(CTX, FieldAddress(EDI, Closure::context_offset()));
5833
5834 // EBX: Code (compiled code or lazy compile stub).
5835 __ movl(EBX, FieldAddress(EAX, Function::code_offset()));
5836
5837 // EAX: Function.
5838 // EDX: Arguments descriptor array.
5839 // ECX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value).
5840 __ xorl(ECX, ECX);
5841 __ movl(EBX, FieldAddress(EBX, Code::instructions_offset()));
5842 __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
5843 __ call(EBX);
5844 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall,
5845 deopt_id(),
5846 token_pos());
5847 compiler->RecordSafepoint(locs());
5848 // Marks either the continuation point in unoptimized code or the
5849 // deoptimization point in optimized code, after call.
5850 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id());
5851 if (compiler->is_optimizing()) {
5852 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos());
5853 } else {
5854 // Add deoptimization continuation point after the call and before the
5855 // arguments are removed.
5856 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
5857 deopt_id_after,
5858 token_pos());
5859 }
5838 __ Drop(argument_count); 5860 __ Drop(argument_count);
5839 } 5861 }
5840 5862
5841 5863
5842 LocationSummary* BooleanNegateInstr::MakeLocationSummary(bool opt) const { 5864 LocationSummary* BooleanNegateInstr::MakeLocationSummary(bool opt) const {
5843 return LocationSummary::Make(1, 5865 return LocationSummary::Make(1,
5844 Location::RequiresRegister(), 5866 Location::RequiresRegister(),
5845 LocationSummary::kNoCall); 5867 LocationSummary::kNoCall);
5846 } 5868 }
5847 5869
(...skipping 24 matching lines...) Expand all
5872 PcDescriptors::kOther, 5894 PcDescriptors::kOther,
5873 locs()); 5895 locs());
5874 __ Drop(ArgumentCount()); // Discard arguments. 5896 __ Drop(ArgumentCount()); // Discard arguments.
5875 } 5897 }
5876 5898
5877 } // namespace dart 5899 } // namespace dart
5878 5900
5879 #undef __ 5901 #undef __
5880 5902
5881 #endif // defined TARGET_ARCH_IA32 5903 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698