OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. |
6 #if defined(TARGET_ARCH_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 EMIT_NATIVE_CODE(PolymorphicInstanceCall, | 238 EMIT_NATIVE_CODE(PolymorphicInstanceCall, |
239 0, | 239 0, |
240 Location::RegisterLocation(0), | 240 Location::RegisterLocation(0), |
241 LocationSummary::kCall) { | 241 LocationSummary::kCall) { |
242 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New( | 242 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New( |
243 instance_call()->ArgumentCount(), instance_call()->argument_names())); | 243 instance_call()->ArgumentCount(), instance_call()->argument_names())); |
244 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); | 244 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); |
245 const CallTargets& ic_data = targets(); | 245 const CallTargets& ic_data = targets(); |
246 | 246 |
247 // Push the target onto the stack. | 247 // Push the target onto the stack. |
248 if (with_checks()) { | 248 const intptr_t length = ic_data.length(); |
249 const intptr_t length = ic_data.length(); | 249 if (!Utils::IsUint(8, length)) { |
250 if (!Utils::IsUint(8, length)) { | 250 Unsupported(compiler); |
251 Unsupported(compiler); | 251 UNREACHABLE(); |
252 UNREACHABLE(); | 252 } |
| 253 bool using_ranges = false; |
| 254 for (intptr_t i = 0; i < length; i++) { |
| 255 if (ic_data[i].cid_start != ic_data[i].cid_end) { |
| 256 using_ranges = true; |
| 257 break; |
253 } | 258 } |
254 bool using_ranges = false; | 259 } |
255 for (intptr_t i = 0; i < length; i++) { | 260 |
256 if (ic_data[i].cid_start != ic_data[i].cid_end) { | 261 if (using_ranges) { |
257 using_ranges = true; | 262 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), |
258 break; | 263 length); |
259 } | 264 } else { |
| 265 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length); |
| 266 } |
| 267 for (intptr_t i = 0; i < length; i++) { |
| 268 const Function& target = *ic_data[i].target; |
| 269 intptr_t cid_start = ic_data[i].cid_start; |
| 270 intptr_t cid_end = ic_data[i].cid_end; |
| 271 |
| 272 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); |
| 273 if (using_ranges) { |
| 274 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); |
260 } | 275 } |
261 | 276 __ Nop(__ AddConstant(target)); |
262 if (using_ranges) { | |
263 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), | |
264 length); | |
265 } else { | |
266 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length); | |
267 } | |
268 for (intptr_t i = 0; i < length; i++) { | |
269 const Function& target = *ic_data[i].target; | |
270 intptr_t cid_start = ic_data[i].cid_start; | |
271 intptr_t cid_end = ic_data[i].cid_end; | |
272 | |
273 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); | |
274 if (using_ranges) { | |
275 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); | |
276 } | |
277 __ Nop(__ AddConstant(target)); | |
278 } | |
279 compiler->EmitDeopt(deopt_id(), | |
280 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); | |
281 } else { | |
282 ASSERT(targets().HasSingleTarget()); | |
283 const Function& target = targets().FirstTarget(); | |
284 __ PushConstant(target); | |
285 } | 277 } |
| 278 compiler->EmitDeopt(deopt_id(), ICData::kDeoptPolymorphicInstanceCallTestFail, |
| 279 0); |
286 | 280 |
287 // Call the function. | 281 // Call the function. |
288 __ StaticCall(instance_call()->ArgumentCount(), argdesc_kidx); | 282 __ StaticCall(instance_call()->ArgumentCount(), argdesc_kidx); |
289 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), | 283 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), |
290 instance_call()->token_pos()); | 284 instance_call()->token_pos()); |
291 compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult); | 285 compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult); |
292 __ PopLocal(locs()->out(0).reg()); | 286 __ PopLocal(locs()->out(0).reg()); |
293 } | 287 } |
294 | 288 |
295 | 289 |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 } | 2077 } |
2084 __ IfULe(length, index); | 2078 __ IfULe(length, index); |
2085 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2079 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
2086 (generalized_ ? ICData::kGeneralized : 0) | | 2080 (generalized_ ? ICData::kGeneralized : 0) | |
2087 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2081 (licm_hoisted_ ? ICData::kHoisted : 0)); |
2088 } | 2082 } |
2089 | 2083 |
2090 } // namespace dart | 2084 } // namespace dart |
2091 | 2085 |
2092 #endif // defined TARGET_ARCH_DBC | 2086 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |