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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 Smi::RawValue(true_value) - Smi::RawValue(false_value); | 175 Smi::RawValue(true_value) - Smi::RawValue(false_value); |
176 __ AndImmediate(result, result, val); | 176 __ AndImmediate(result, result, val); |
177 if (false_value != 0) { | 177 if (false_value != 0) { |
178 __ AddImmediate(result, Smi::RawValue(false_value)); | 178 __ AddImmediate(result, Smi::RawValue(false_value)); |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 | 183 |
184 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { | 184 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { |
185 const intptr_t kNumInputs = 0; | 185 return MakeCallSummary(); |
186 const intptr_t kNumTemps = 1; | |
187 LocationSummary* result = | |
188 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
189 result->set_out(0, Location::RegisterLocation(R0)); | |
190 result->set_temp(0, Location::RegisterLocation(R4)); // Arg. descriptor. | |
191 return result; | |
192 } | 186 } |
193 | 187 |
194 | 188 |
195 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 189 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
196 // The arguments to the stub include the closure, as does the arguments | 190 // Load closure object (first argument) in R1. |
197 // descriptor. | |
198 Register temp_reg = locs()->temp(0).reg(); | |
199 int argument_count = ArgumentCount(); | 191 int argument_count = ArgumentCount(); |
| 192 __ ldr(R1, Address(SP, (argument_count - 1) * kWordSize)); |
| 193 |
| 194 // Load arguments descriptor in R4. |
200 const Array& arguments_descriptor = | 195 const Array& arguments_descriptor = |
201 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, | 196 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
202 argument_names())); | 197 argument_names())); |
203 __ LoadObject(temp_reg, arguments_descriptor); | 198 __ LoadObject(R4, arguments_descriptor); |
204 ASSERT(temp_reg == R4); | 199 |
205 compiler->GenerateDartCall(deopt_id(), | 200 // Load the closure function into R0. |
206 token_pos(), | 201 __ ldr(R0, FieldAddress(R1, Closure::function_offset())); |
207 &StubCode::CallClosureFunctionLabel(), | 202 |
208 PcDescriptors::kClosureCall, | 203 // Load closure context in CTX; note that CTX has already been preserved. |
209 locs()); | 204 __ ldr(CTX, FieldAddress(R1, Closure::context_offset())); |
| 205 |
| 206 // R4: Arguments descriptor. |
| 207 // R0: Function. |
| 208 __ ldr(R2, FieldAddress(R0, Function::code_offset())); |
| 209 |
| 210 // R2: code. |
| 211 // R5: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value). |
| 212 __ LoadImmediate(R5, 0); |
| 213 __ ldr(R2, FieldAddress(R2, Code::instructions_offset())); |
| 214 __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag); |
| 215 __ blx(R2); |
| 216 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, |
| 217 deopt_id(), |
| 218 token_pos()); |
| 219 compiler->RecordSafepoint(locs()); |
| 220 // Marks either the continuation point in unoptimized code or the |
| 221 // deoptimization point in optimized code, after call. |
| 222 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); |
| 223 if (compiler->is_optimizing()) { |
| 224 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); |
| 225 } else { |
| 226 // Add deoptimization continuation point after the call and before the |
| 227 // arguments are removed. |
| 228 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 229 deopt_id_after, |
| 230 token_pos()); |
| 231 } |
210 __ Drop(argument_count); | 232 __ Drop(argument_count); |
211 } | 233 } |
212 | 234 |
213 | 235 |
214 LocationSummary* LoadLocalInstr::MakeLocationSummary(bool opt) const { | 236 LocationSummary* LoadLocalInstr::MakeLocationSummary(bool opt) const { |
215 return LocationSummary::Make(0, | 237 return LocationSummary::Make(0, |
216 Location::RequiresRegister(), | 238 Location::RequiresRegister(), |
217 LocationSummary::kNoCall); | 239 LocationSummary::kNoCall); |
218 } | 240 } |
219 | 241 |
(...skipping 5702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5922 compiler->GenerateCall(token_pos(), | 5944 compiler->GenerateCall(token_pos(), |
5923 &label, | 5945 &label, |
5924 PcDescriptors::kOther, | 5946 PcDescriptors::kOther, |
5925 locs()); | 5947 locs()); |
5926 __ Drop(ArgumentCount()); // Discard arguments. | 5948 __ Drop(ArgumentCount()); // Discard arguments. |
5927 } | 5949 } |
5928 | 5950 |
5929 } // namespace dart | 5951 } // namespace dart |
5930 | 5952 |
5931 #endif // defined TARGET_ARCH_ARM | 5953 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |