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

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

Issue 227723002: VM: Implement closure calls as instance calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: adjust inlining of dispatchers 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
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | 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) 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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 Smi::RawValue(true_value) - Smi::RawValue(false_value); 198 Smi::RawValue(true_value) - Smi::RawValue(false_value);
199 __ AndImmediate(result, result, val); 199 __ AndImmediate(result, result, val);
200 if (false_value != 0) { 200 if (false_value != 0) {
201 __ AddImmediate(result, result, Smi::RawValue(false_value)); 201 __ AddImmediate(result, result, Smi::RawValue(false_value));
202 } 202 }
203 } 203 }
204 } 204 }
205 205
206 206
207 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { 207 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const {
208 const intptr_t kNumInputs = 0; 208 return MakeCallSummary();
209 const intptr_t kNumTemps = 1;
210 LocationSummary* result =
211 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
212 result->set_out(0, Location::RegisterLocation(V0));
213 result->set_temp(0, Location::RegisterLocation(S4)); // Arg. descriptor.
214 return result;
215 } 209 }
216 210
217 211
218 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 212 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
219 // The arguments to the stub include the closure, as does the arguments 213 // Load closure object (first argument) in T1.
220 // descriptor.
221 Register temp_reg = locs()->temp(0).reg();
222 int argument_count = ArgumentCount(); 214 int argument_count = ArgumentCount();
215 __ lw(T1, Address(SP, (argument_count - 1) * kWordSize));
216
217 // Load arguments descriptor in S4.
223 const Array& arguments_descriptor = 218 const Array& arguments_descriptor =
224 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, 219 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count,
225 argument_names())); 220 argument_names()));
226 ASSERT(temp_reg == S4); 221 __ LoadObject(S4, arguments_descriptor);
227 __ LoadObject(temp_reg, arguments_descriptor); 222
228 compiler->GenerateDartCall(deopt_id(), 223 // Load the closure function in T0.
229 token_pos(), 224 __ lw(T0, FieldAddress(T1, Closure::function_offset()));
230 &StubCode::CallClosureFunctionLabel(), 225
231 PcDescriptors::kClosureCall, 226 // Load closure context in CTX; note that CTX has already been preserved.
232 locs()); 227 __ lw(CTX, FieldAddress(T1, Closure::context_offset()));
228
229 // Load closure function code in T2.
230 // S4: arguments descriptor array.
231 // S5: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value).
232 __ LoadImmediate(S5, 0);
233 __ lw(T2, FieldAddress(T0, Function::code_offset()));
234 __ lw(T2, FieldAddress(T2, Code::instructions_offset()));
235 __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag);
236 __ jalr(T2);
237 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall,
238 deopt_id(),
239 token_pos());
240 compiler->RecordSafepoint(locs());
241 // Marks either the continuation point in unoptimized code or the
242 // deoptimization point in optimized code, after call.
243 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id());
244 if (compiler->is_optimizing()) {
245 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos());
246 } else {
247 // Add deoptimization continuation point after the call and before the
248 // arguments are removed.
249 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
250 deopt_id_after,
251 token_pos());
252 }
233 __ Drop(argument_count); 253 __ Drop(argument_count);
234 } 254 }
235 255
236 256
237 LocationSummary* LoadLocalInstr::MakeLocationSummary(bool opt) const { 257 LocationSummary* LoadLocalInstr::MakeLocationSummary(bool opt) const {
238 return LocationSummary::Make(0, 258 return LocationSummary::Make(0,
239 Location::RequiresRegister(), 259 Location::RequiresRegister(),
240 LocationSummary::kNoCall); 260 LocationSummary::kNoCall);
241 } 261 }
242 262
(...skipping 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4369 compiler->GenerateCall(token_pos(), 4389 compiler->GenerateCall(token_pos(),
4370 &label, 4390 &label,
4371 PcDescriptors::kOther, 4391 PcDescriptors::kOther,
4372 locs()); 4392 locs());
4373 __ Drop(ArgumentCount()); // Discard arguments. 4393 __ Drop(ArgumentCount()); // Discard arguments.
4374 } 4394 }
4375 4395
4376 } // namespace dart 4396 } // namespace dart
4377 4397
4378 #endif // defined TARGET_ARCH_MIPS 4398 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698