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