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

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

Issue 265443002: VM: Explicitly load function and context before calling a closure. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 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 return MakeCallSummary(); 208 const intptr_t kNumInputs = 1;
209 const intptr_t kNumTemps = 0;
210 LocationSummary* summary =
211 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
212 summary->set_in(0, Location::RegisterLocation(T0)); // Function.
213 summary->set_out(0, Location::RegisterLocation(V0));
214 return summary;
209 } 215 }
210 216
211 217
212 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 218 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
213 // Load closure object (first argument) in T1. 219 // Load arguments descriptor in S4.
214 int argument_count = ArgumentCount(); 220 int argument_count = ArgumentCount();
215 __ lw(T1, Address(SP, (argument_count - 1) * kWordSize));
216
217 // Load arguments descriptor in S4.
218 const Array& arguments_descriptor = 221 const Array& arguments_descriptor =
219 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, 222 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count,
220 argument_names())); 223 argument_names()));
221 __ LoadObject(S4, arguments_descriptor); 224 __ LoadObject(S4, arguments_descriptor);
222 225
223 // Load the closure function in T0.
224 __ lw(T0, FieldAddress(T1, Closure::function_offset()));
225
226 // Load closure context in CTX; note that CTX has already been preserved.
227 __ lw(CTX, FieldAddress(T1, Closure::context_offset()));
228
229 // Load closure function code in T2. 226 // Load closure function code in T2.
230 // S4: arguments descriptor array. 227 // S4: arguments descriptor array.
231 // S5: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value). 228 // S5: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value).
229 ASSERT(locs()->in(0).reg() == T0);
232 __ LoadImmediate(S5, 0); 230 __ LoadImmediate(S5, 0);
233 __ lw(T2, FieldAddress(T0, Function::code_offset())); 231 __ lw(T2, FieldAddress(T0, Function::code_offset()));
234 __ lw(T2, FieldAddress(T2, Code::instructions_offset())); 232 __ lw(T2, FieldAddress(T2, Code::instructions_offset()));
235 __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag); 233 __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag);
236 __ jalr(T2); 234 __ jalr(T2);
237 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, 235 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall,
238 deopt_id(), 236 deopt_id(),
239 token_pos()); 237 token_pos());
240 compiler->RecordSafepoint(locs()); 238 compiler->RecordSafepoint(locs());
241 // Marks either the continuation point in unoptimized code or the 239 // Marks either the continuation point in unoptimized code or the
242 // deoptimization point in optimized code, after call. 240 // deoptimization point in optimized code, after call.
243 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); 241 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id());
244 if (compiler->is_optimizing()) { 242 if (compiler->is_optimizing()) {
245 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); 243 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos(), InputCount());
246 } else { 244 } else {
247 // Add deoptimization continuation point after the call and before the 245 // Add deoptimization continuation point after the call and before the
248 // arguments are removed. 246 // arguments are removed.
249 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 247 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
250 deopt_id_after, 248 deopt_id_after,
251 token_pos()); 249 token_pos());
252 } 250 }
253 __ Drop(argument_count); 251 __ Drop(argument_count);
254 } 252 }
255 253
(...skipping 4209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4465 compiler->GenerateCall(token_pos(), 4463 compiler->GenerateCall(token_pos(),
4466 &label, 4464 &label,
4467 PcDescriptors::kOther, 4465 PcDescriptors::kOther,
4468 locs()); 4466 locs());
4469 __ Drop(ArgumentCount()); // Discard arguments. 4467 __ Drop(ArgumentCount()); // Discard arguments.
4470 } 4468 }
4471 4469
4472 } // namespace dart 4470 } // namespace dart
4473 4471
4474 #endif // defined TARGET_ARCH_MIPS 4472 #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