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