| 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 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 | 1492 |
| 1493 EMIT_NATIVE_CODE(CheckClassId, 1) { | 1493 EMIT_NATIVE_CODE(CheckClassId, 1) { |
| 1494 __ CheckClassId(locs()->in(0).reg(), compiler->ToEmbeddableCid(cid_, this)); | 1494 __ CheckClassId(locs()->in(0).reg(), compiler->ToEmbeddableCid(cid_, this)); |
| 1495 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); | 1495 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 | 1498 |
| 1499 EMIT_NATIVE_CODE(CheckClass, 1) { | 1499 EMIT_NATIVE_CODE(CheckClass, 1) { |
| 1500 const Register value = locs()->in(0).reg(); | 1500 const Register value = locs()->in(0).reg(); |
| 1501 if (IsNullCheck()) { | 1501 if (IsNullCheck()) { |
| 1502 ASSERT(DeoptIfNull() || DeoptIfNotNull()); | 1502 ASSERT(IsDeoptIfNull() || IsDeoptIfNotNull()); |
| 1503 if (DeoptIfNull()) { | 1503 if (IsDeoptIfNull()) { |
| 1504 __ IfEqNull(value); | 1504 __ IfEqNull(value); |
| 1505 } else { | 1505 } else { |
| 1506 __ IfNeNull(value); | 1506 __ IfNeNull(value); |
| 1507 } | 1507 } |
| 1508 } else { | 1508 } else { |
| 1509 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || | 1509 ASSERT(!targets_.IsMonomorphic() || !targets_.HasReceiverClassId(kSmiCid)); |
| 1510 (unary_checks().NumberOfChecks() > 1)); | 1510 const intptr_t may_be_smi = targets_.HasReceiverClassId(kSmiCid) ? 1 : 0; |
| 1511 const intptr_t may_be_smi = | |
| 1512 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; | |
| 1513 bool is_dense_switch = false; | 1511 bool is_dense_switch = false; |
| 1514 intptr_t cid_mask = 0; | 1512 intptr_t cid_mask = 0; |
| 1515 if (IsDenseSwitch()) { | 1513 if (IsDenseSwitch()) { |
| 1516 ASSERT(cids_[0] < cids_[cids_.length() - 1]); | |
| 1517 cid_mask = ComputeCidMask(); | 1514 cid_mask = ComputeCidMask(); |
| 1518 is_dense_switch = Smi::IsValid(cid_mask); | 1515 is_dense_switch = Smi::IsValid(cid_mask); |
| 1519 } | 1516 } |
| 1520 if (is_dense_switch) { | 1517 if (is_dense_switch) { |
| 1521 const intptr_t low_cid = cids_[0]; | 1518 intptr_t min = targets_.ComputeLowestCid(); |
| 1522 __ CheckDenseSwitch(value, may_be_smi); | 1519 __ CheckDenseSwitch(value, may_be_smi); |
| 1523 __ Nop(compiler->ToEmbeddableCid(low_cid, this)); | 1520 __ Nop(compiler->ToEmbeddableCid(min, this)); |
| 1524 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); | 1521 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); |
| 1525 } else { | 1522 } 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; | 1523 bool using_ranges = false; |
| 1532 for (intptr_t i = 0; i < sorted_length; i++) { | 1524 int smi_adjustment = 0; |
| 1533 if (sorted_ic_data[i].cid_start != sorted_ic_data[i].cid_end) { | 1525 int length = targets_.length(); |
| 1526 for (intptr_t i = 0; i < length; i++) { |
| 1527 if (targets_[i].cid_start != targets_[i].cid_end) { |
| 1534 using_ranges = true; | 1528 using_ranges = true; |
| 1535 break; | 1529 } else if (targets_[i].cid_start == kSmiCid) { |
| 1530 ASSERT(targets_[i].cid_end == kSmiCid); |
| 1531 ASSERT(smi_adjustment == 0); |
| 1532 smi_adjustment = 1; |
| 1536 } | 1533 } |
| 1537 } | 1534 } |
| 1538 | 1535 |
| 1539 if (!Utils::IsUint(8, sorted_length)) { | 1536 if (!Utils::IsUint(8, length)) { |
| 1540 Unsupported(compiler); | 1537 Unsupported(compiler); |
| 1541 UNREACHABLE(); | 1538 UNREACHABLE(); |
| 1542 } | 1539 } |
| 1543 if (using_ranges) { | 1540 if (using_ranges) { |
| 1544 __ CheckCidsByRange(value, may_be_smi, sorted_length * 2); | 1541 __ CheckCidsByRange(value, may_be_smi, (length - smi_adjustment) * 2); |
| 1545 } else { | 1542 } else { |
| 1546 __ CheckCids(value, may_be_smi, sorted_length); | 1543 __ CheckCids(value, may_be_smi, length - smi_adjustment); |
| 1547 } | 1544 } |
| 1548 for (intptr_t i = 0; i < sorted_length; i++) { | 1545 for (intptr_t i = 0; i < length; i++) { |
| 1549 intptr_t cid_start = sorted_ic_data[i].cid_start; | 1546 intptr_t cid_start = targets_[i].cid_start; |
| 1550 intptr_t cid_end = sorted_ic_data[i].cid_end; | 1547 intptr_t cid_end = targets_[i].cid_end; |
| 1548 if (cid_start == kSmiCid && cid_end == kSmiCid) { |
| 1549 ASSERT(smi_adjustment == 1); |
| 1550 continue; |
| 1551 } |
| 1551 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); | 1552 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); |
| 1552 if (using_ranges) { | 1553 if (using_ranges) { |
| 1553 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); | 1554 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); |
| 1554 } | 1555 } |
| 1555 } | 1556 } |
| 1556 } | 1557 } |
| 1557 } | 1558 } |
| 1558 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass, | 1559 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass, |
| 1559 licm_hoisted_ ? ICData::kHoisted : 0); | 1560 licm_hoisted_ ? ICData::kHoisted : 0); |
| 1560 } | 1561 } |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 } | 2084 } |
| 2084 __ IfULe(length, index); | 2085 __ IfULe(length, index); |
| 2085 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2086 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
| 2086 (generalized_ ? ICData::kGeneralized : 0) | | 2087 (generalized_ ? ICData::kGeneralized : 0) | |
| 2087 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2088 (licm_hoisted_ ? ICData::kHoisted : 0)); |
| 2088 } | 2089 } |
| 2089 | 2090 |
| 2090 } // namespace dart | 2091 } // namespace dart |
| 2091 | 2092 |
| 2092 #endif // defined TARGET_ARCH_DBC | 2093 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |