OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |