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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 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(); | |
246 | 245 |
247 // Push the target onto the stack. | 246 // Push the target onto the stack. |
248 if (with_checks()) { | 247 if (with_checks()) { |
249 const intptr_t length = ic_data.length(); | 248 const intptr_t length = targets_.length(); |
250 if (!Utils::IsUint(8, length)) { | 249 if (!Utils::IsUint(8, length)) { |
251 Unsupported(compiler); | 250 Unsupported(compiler); |
252 UNREACHABLE(); | 251 UNREACHABLE(); |
253 } | 252 } |
254 bool using_ranges = false; | 253 bool using_ranges = false; |
255 for (intptr_t i = 0; i < length; i++) { | 254 for (intptr_t i = 0; i < length; i++) { |
256 if (ic_data[i].cid_start != ic_data[i].cid_end) { | 255 if (targets_[i].cid_start != targets_[i].cid_end) { |
257 using_ranges = true; | 256 using_ranges = true; |
258 break; | 257 break; |
259 } | 258 } |
260 } | 259 } |
261 | 260 |
262 if (using_ranges) { | 261 if (using_ranges) { |
263 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), | 262 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), |
264 length); | 263 length); |
265 } else { | 264 } else { |
266 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length); | 265 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length); |
267 } | 266 } |
268 for (intptr_t i = 0; i < length; i++) { | 267 for (intptr_t i = 0; i < length; i++) { |
269 const Function& target = *ic_data[i].target; | 268 const Function& target = *targets_.TargetAt(i)->target; |
270 intptr_t cid_start = ic_data[i].cid_start; | 269 intptr_t cid_start = targets_[i].cid_start; |
271 intptr_t cid_end = ic_data[i].cid_end; | 270 intptr_t cid_end = targets_[i].cid_end; |
272 | 271 |
273 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); | 272 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); |
274 if (using_ranges) { | 273 if (using_ranges) { |
275 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); | 274 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); |
276 } | 275 } |
277 __ Nop(__ AddConstant(target)); | 276 __ Nop(__ AddConstant(target)); |
278 } | 277 } |
279 compiler->EmitDeopt(deopt_id(), | 278 compiler->EmitDeopt(deopt_id(), |
280 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); | 279 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); |
281 } else { | 280 } else { |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 | 1491 |
1493 EMIT_NATIVE_CODE(CheckClassId, 1) { | 1492 EMIT_NATIVE_CODE(CheckClassId, 1) { |
1494 __ CheckClassId(locs()->in(0).reg(), compiler->ToEmbeddableCid(cid_, this)); | 1493 __ CheckClassId(locs()->in(0).reg(), compiler->ToEmbeddableCid(cid_, this)); |
1495 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); | 1494 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); |
1496 } | 1495 } |
1497 | 1496 |
1498 | 1497 |
1499 EMIT_NATIVE_CODE(CheckClass, 1) { | 1498 EMIT_NATIVE_CODE(CheckClass, 1) { |
1500 const Register value = locs()->in(0).reg(); | 1499 const Register value = locs()->in(0).reg(); |
1501 if (IsNullCheck()) { | 1500 if (IsNullCheck()) { |
1502 ASSERT(DeoptIfNull() || DeoptIfNotNull()); | 1501 ASSERT(IsDeoptIfNull() || IsDeoptIfNotNull()); |
1503 if (DeoptIfNull()) { | 1502 if (IsDeoptIfNull()) { |
1504 __ IfEqNull(value); | 1503 __ IfEqNull(value); |
1505 } else { | 1504 } else { |
1506 __ IfNeNull(value); | 1505 __ IfNeNull(value); |
1507 } | 1506 } |
1508 } else { | 1507 } else { |
1509 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || | 1508 ASSERT(!cids_.IsMonomorphic() || !cids_.HasClassId(kSmiCid)); |
1510 (unary_checks().NumberOfChecks() > 1)); | 1509 const intptr_t may_be_smi = cids_.HasClassId(kSmiCid) ? 1 : 0; |
1511 const intptr_t may_be_smi = | 1510 bool is_bit_test = false; |
1512 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; | |
1513 bool is_dense_switch = false; | |
1514 intptr_t cid_mask = 0; | 1511 intptr_t cid_mask = 0; |
1515 if (IsDenseSwitch()) { | 1512 if (IsBitTest()) { |
1516 ASSERT(cids_[0] < cids_[cids_.length() - 1]); | |
1517 cid_mask = ComputeCidMask(); | 1513 cid_mask = ComputeCidMask(); |
1518 is_dense_switch = Smi::IsValid(cid_mask); | 1514 is_bit_test = Smi::IsValid(cid_mask); |
1519 } | 1515 } |
1520 if (is_dense_switch) { | 1516 if (is_bit_test) { |
1521 const intptr_t low_cid = cids_[0]; | 1517 intptr_t min = cids_.ComputeLowestCid(); |
1522 __ CheckDenseSwitch(value, may_be_smi); | 1518 __ CheckBitTest(value, may_be_smi); |
1523 __ Nop(compiler->ToEmbeddableCid(low_cid, this)); | 1519 __ Nop(compiler->ToEmbeddableCid(min, this)); |
1524 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); | 1520 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); |
1525 } else { | 1521 } else { |
1526 GrowableArray<CidRangeTarget> sorted_ic_data; | |
1527 FlowGraphCompiler::SortICDataByCount(unary_checks(), &sorted_ic_data, | |
1528 /* drop_smi = */ true); | |
1529 const intptr_t sorted_length = sorted_ic_data.length(); | |
1530 | |
1531 bool using_ranges = false; | 1522 bool using_ranges = false; |
1532 for (intptr_t i = 0; i < sorted_length; i++) { | 1523 int smi_adjustment = 0; |
1533 if (sorted_ic_data[i].cid_start != sorted_ic_data[i].cid_end) { | 1524 int length = cids_.length(); |
1525 for (intptr_t i = 0; i < length; i++) { | |
1526 if (cids_[i].cid_start != cids_[i].cid_end) { | |
1534 using_ranges = true; | 1527 using_ranges = true; |
1535 break; | 1528 } else if (cids_[i].cid_start == kSmiCid) { |
1529 ASSERT(cids_[i].cid_end == kSmiCid); | |
Vyacheslav Egorov (Google)
2017/05/09 21:07:27
it is not completely clear to me why we can assume
erikcorry
2017/05/10 08:47:43
Comment added: // We are in the else clause.
| |
1530 ASSERT(smi_adjustment == 0); | |
1531 smi_adjustment = 1; | |
1536 } | 1532 } |
1537 } | 1533 } |
1538 | 1534 |
1539 if (!Utils::IsUint(8, sorted_length)) { | 1535 if (!Utils::IsUint(8, length)) { |
1540 Unsupported(compiler); | 1536 Unsupported(compiler); |
1541 UNREACHABLE(); | 1537 UNREACHABLE(); |
1542 } | 1538 } |
1543 if (using_ranges) { | 1539 if (using_ranges) { |
1544 __ CheckCidsByRange(value, may_be_smi, sorted_length * 2); | 1540 __ CheckCidsByRange(value, may_be_smi, (length - smi_adjustment) * 2); |
1545 } else { | 1541 } else { |
1546 __ CheckCids(value, may_be_smi, sorted_length); | 1542 __ CheckCids(value, may_be_smi, length - smi_adjustment); |
1547 } | 1543 } |
1548 for (intptr_t i = 0; i < sorted_length; i++) { | 1544 for (intptr_t i = 0; i < length; i++) { |
1549 intptr_t cid_start = sorted_ic_data[i].cid_start; | 1545 intptr_t cid_start = cids_[i].cid_start; |
1550 intptr_t cid_end = sorted_ic_data[i].cid_end; | 1546 intptr_t cid_end = cids_[i].cid_end; |
1547 if (cid_start == kSmiCid && cid_end == kSmiCid) { | |
1548 ASSERT(smi_adjustment == 1); | |
1549 continue; | |
1550 } | |
1551 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); | 1551 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); |
1552 if (using_ranges) { | 1552 if (using_ranges) { |
1553 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); | 1553 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); |
1554 } | 1554 } |
1555 } | 1555 } |
1556 } | 1556 } |
1557 } | 1557 } |
1558 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass, | 1558 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass, |
1559 licm_hoisted_ ? ICData::kHoisted : 0); | 1559 licm_hoisted_ ? ICData::kHoisted : 0); |
1560 } | 1560 } |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2083 } | 2083 } |
2084 __ IfULe(length, index); | 2084 __ IfULe(length, index); |
2085 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2085 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
2086 (generalized_ ? ICData::kGeneralized : 0) | | 2086 (generalized_ ? ICData::kGeneralized : 0) | |
2087 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2087 (licm_hoisted_ ? ICData::kHoisted : 0)); |
2088 } | 2088 } |
2089 | 2089 |
2090 } // namespace dart | 2090 } // namespace dart |
2091 | 2091 |
2092 #endif // defined TARGET_ARCH_DBC | 2092 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |