| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (compiler->is_optimizing()) { | 232 if (compiler->is_optimizing()) { |
| 233 __ Drop1(); | 233 __ Drop1(); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 | 237 |
| 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 ASSERT(ic_data().NumArgsTested() == 1); |
| 242 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New( | 243 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New( |
| 243 instance_call()->ArgumentCount(), instance_call()->argument_names())); | 244 instance_call()->ArgumentCount(), instance_call()->argument_names())); |
| 244 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); | 245 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); |
| 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 if (with_checks()) { |
| 249 const intptr_t length = ic_data.length(); | 249 const intptr_t may_be_smi = |
| 250 if (!Utils::IsUint(8, length)) { | 250 (ic_data().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; |
| 251 GrowableArray<CidRangeTarget> sorted_ic_data; |
| 252 FlowGraphCompiler::SortICDataByCount(ic_data(), &sorted_ic_data, |
| 253 /* drop_smi = */ true); |
| 254 const intptr_t sorted_length = sorted_ic_data.length(); |
| 255 if (!Utils::IsUint(8, sorted_length)) { |
| 251 Unsupported(compiler); | 256 Unsupported(compiler); |
| 252 UNREACHABLE(); | 257 UNREACHABLE(); |
| 253 } | 258 } |
| 254 bool using_ranges = false; | 259 bool using_ranges = false; |
| 255 for (intptr_t i = 0; i < length; i++) { | 260 for (intptr_t i = 0; i < sorted_length; i++) { |
| 256 if (ic_data[i].cid_start != ic_data[i].cid_end) { | 261 if (sorted_ic_data[i].cid_start != sorted_ic_data[i].cid_end) { |
| 257 using_ranges = true; | 262 using_ranges = true; |
| 258 break; | 263 break; |
| 259 } | 264 } |
| 260 } | 265 } |
| 261 | 266 |
| 262 if (using_ranges) { | 267 if (using_ranges) { |
| 263 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), | 268 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), |
| 264 length); | 269 sorted_length + may_be_smi); |
| 265 } else { | 270 } else { |
| 266 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length); | 271 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), |
| 272 sorted_length + may_be_smi); |
| 267 } | 273 } |
| 268 for (intptr_t i = 0; i < length; i++) { | 274 if (may_be_smi == 1) { |
| 269 const Function& target = *ic_data[i].target; | 275 const Function& target = |
| 270 intptr_t cid_start = ic_data[i].cid_start; | 276 Function::ZoneHandle(compiler->zone(), ic_data().GetTargetAt(0)); |
| 271 intptr_t cid_end = ic_data[i].cid_end; | 277 __ Nop(compiler->ToEmbeddableCid(kSmiCid, this)); |
| 278 if (using_ranges) { |
| 279 __ Nop(compiler->ToEmbeddableCid(1, this)); |
| 280 } |
| 281 __ Nop(__ AddConstant(target)); |
| 282 } |
| 283 for (intptr_t i = 0; i < sorted_length; i++) { |
| 284 const Function& target = *sorted_ic_data[i].target; |
| 285 intptr_t cid_start = sorted_ic_data[i].cid_start; |
| 286 intptr_t cid_end = sorted_ic_data[i].cid_end; |
| 272 | 287 |
| 273 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); | 288 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); |
| 274 if (using_ranges) { | 289 if (using_ranges) { |
| 275 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); | 290 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); |
| 276 } | 291 } |
| 277 __ Nop(__ AddConstant(target)); | 292 __ Nop(__ AddConstant(target)); |
| 278 } | 293 } |
| 279 compiler->EmitDeopt(deopt_id(), | 294 compiler->EmitDeopt(deopt_id(), |
| 280 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); | 295 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); |
| 281 } else { | 296 } else { |
| 282 ASSERT(targets().HasSingleRecognizedTarget()); | 297 ASSERT(ic_data().HasOneTarget()); |
| 283 const Function& target = targets().FirstTarget(); | 298 const Function& target = Function::ZoneHandle(ic_data().GetTargetAt(0)); |
| 284 __ PushConstant(target); | 299 __ PushConstant(target); |
| 285 } | 300 } |
| 286 | 301 |
| 287 // Call the function. | 302 // Call the function. |
| 288 __ StaticCall(instance_call()->ArgumentCount(), argdesc_kidx); | 303 __ StaticCall(instance_call()->ArgumentCount(), argdesc_kidx); |
| 289 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), | 304 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), |
| 290 instance_call()->token_pos()); | 305 instance_call()->token_pos()); |
| 291 compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult); | 306 compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult); |
| 292 __ PopLocal(locs()->out(0).reg()); | 307 __ PopLocal(locs()->out(0).reg()); |
| 293 } | 308 } |
| (...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 } | 2098 } |
| 2084 __ IfULe(length, index); | 2099 __ IfULe(length, index); |
| 2085 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2100 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
| 2086 (generalized_ ? ICData::kGeneralized : 0) | | 2101 (generalized_ ? ICData::kGeneralized : 0) | |
| 2087 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2102 (licm_hoisted_ ? ICData::kHoisted : 0)); |
| 2088 } | 2103 } |
| 2089 | 2104 |
| 2090 } // namespace dart | 2105 } // namespace dart |
| 2091 | 2106 |
| 2092 #endif // defined TARGET_ARCH_DBC | 2107 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |