Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: runtime/vm/intermediate_language_dbc.cc

Issue 2891713002: Cleanup: Make CheckClassId instruction more general so it (Closed)
Patch Set: Feedback from Martin Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 length = targets_.length(); 248 const intptr_t length = targets_.length();
249 if (!Utils::IsUint(8, length)) { 249 if (!Utils::IsUint(8, length)) {
250 Unsupported(compiler); 250 Unsupported(compiler);
251 UNREACHABLE(); 251 UNREACHABLE();
252 } 252 }
253 bool using_ranges = false; 253 bool using_ranges = false;
254 for (intptr_t i = 0; i < length; i++) { 254 for (intptr_t i = 0; i < length; i++) {
255 if (targets_[i].cid_start != targets_[i].cid_end) { 255 if (!targets_[i].IsSingleCid()) {
256 using_ranges = true; 256 using_ranges = true;
257 break; 257 break;
258 } 258 }
259 } 259 }
260 260
261 if (using_ranges) { 261 if (using_ranges) {
262 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(), 262 __ PushPolymorphicInstanceCallByRange(instance_call()->ArgumentCount(),
263 length); 263 length);
264 } else { 264 } else {
265 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length); 265 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), length);
266 } 266 }
267 for (intptr_t i = 0; i < length; i++) { 267 for (intptr_t i = 0; i < length; i++) {
268 const Function& target = *targets_.TargetAt(i)->target; 268 const Function& target = *targets_.TargetAt(i)->target;
269 intptr_t cid_start = targets_[i].cid_start;
270 intptr_t cid_end = targets_[i].cid_end;
271 269
272 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); 270 __ Nop(compiler->ToEmbeddableCid(targets_[i].cid_start, this));
273 if (using_ranges) { 271 if (using_ranges) {
274 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); 272 __ Nop(compiler->ToEmbeddableCid(1 + targets_[i].Extent(), this));
275 } 273 }
276 __ Nop(__ AddConstant(target)); 274 __ Nop(__ AddConstant(target));
277 } 275 }
278 compiler->EmitDeopt(deopt_id(), 276 compiler->EmitDeopt(deopt_id(),
279 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); 277 ICData::kDeoptPolymorphicInstanceCallTestFail, 0);
280 } else { 278 } else {
281 ASSERT(targets().HasSingleTarget()); 279 ASSERT(targets().HasSingleTarget());
282 const Function& target = targets().FirstTarget(); 280 const Function& target = targets().FirstTarget();
283 __ PushConstant(target); 281 __ PushConstant(target);
284 } 282 }
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 EMIT_NATIVE_CODE(CheckEitherNonSmi, 2) { 1481 EMIT_NATIVE_CODE(CheckEitherNonSmi, 2) {
1484 const Register left = locs()->in(0).reg(); 1482 const Register left = locs()->in(0).reg();
1485 const Register right = locs()->in(1).reg(); 1483 const Register right = locs()->in(1).reg();
1486 __ CheckEitherNonSmi(left, right); 1484 __ CheckEitherNonSmi(left, right);
1487 compiler->EmitDeopt(deopt_id(), ICData::kDeoptBinaryDoubleOp, 1485 compiler->EmitDeopt(deopt_id(), ICData::kDeoptBinaryDoubleOp,
1488 licm_hoisted_ ? ICData::kHoisted : 0); 1486 licm_hoisted_ ? ICData::kHoisted : 0);
1489 } 1487 }
1490 1488
1491 1489
1492 EMIT_NATIVE_CODE(CheckClassId, 1) { 1490 EMIT_NATIVE_CODE(CheckClassId, 1) {
1493 __ CheckClassId(locs()->in(0).reg(), compiler->ToEmbeddableCid(cid_, this)); 1491 if (cids_.IsSingleCid()) {
1492 __ CheckClassId(locs()->in(0).reg(),
1493 compiler->ToEmbeddableCid(cids_.cid_start, this));
1494 } else {
1495 __ CheckClassIdRange(locs()->in(0).reg(),
1496 compiler->ToEmbeddableCid(cids_.cid_start, this));
1497 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cids_.Extent()))));
1498 }
1494 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); 1499 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass);
1495 } 1500 }
1496 1501
1497 1502
1498 EMIT_NATIVE_CODE(CheckClass, 1) { 1503 EMIT_NATIVE_CODE(CheckClass, 1) {
1499 const Register value = locs()->in(0).reg(); 1504 const Register value = locs()->in(0).reg();
1500 if (IsNullCheck()) { 1505 if (IsNullCheck()) {
1501 ASSERT(IsDeoptIfNull() || IsDeoptIfNotNull()); 1506 ASSERT(IsDeoptIfNull() || IsDeoptIfNotNull());
1502 if (IsDeoptIfNull()) { 1507 if (IsDeoptIfNull()) {
1503 __ IfEqNull(value); 1508 __ IfEqNull(value);
(...skipping 12 matching lines...) Expand all
1516 if (is_bit_test) { 1521 if (is_bit_test) {
1517 intptr_t min = cids_.ComputeLowestCid(); 1522 intptr_t min = cids_.ComputeLowestCid();
1518 __ CheckBitTest(value, may_be_smi); 1523 __ CheckBitTest(value, may_be_smi);
1519 __ Nop(compiler->ToEmbeddableCid(min, this)); 1524 __ Nop(compiler->ToEmbeddableCid(min, this));
1520 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); 1525 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask))));
1521 } else { 1526 } else {
1522 bool using_ranges = false; 1527 bool using_ranges = false;
1523 int smi_adjustment = 0; 1528 int smi_adjustment = 0;
1524 int length = cids_.length(); 1529 int length = cids_.length();
1525 for (intptr_t i = 0; i < length; i++) { 1530 for (intptr_t i = 0; i < length; i++) {
1526 if (cids_[i].cid_start != cids_[i].cid_end) { 1531 if (!cids_[i].IsSingleCid()) {
1527 using_ranges = true; 1532 using_ranges = true;
1528 } else if (cids_[i].cid_start == kSmiCid) { 1533 } else if (cids_[i].cid_start == kSmiCid) {
1529 ASSERT(cids_[i].cid_end == kSmiCid); // We are in the else clause. 1534 ASSERT(cids_[i].cid_end == kSmiCid); // We are in the else clause.
1530 ASSERT(smi_adjustment == 0); 1535 ASSERT(smi_adjustment == 0);
1531 smi_adjustment = 1; 1536 smi_adjustment = 1;
1532 } 1537 }
1533 } 1538 }
1534 1539
1535 if (!Utils::IsUint(8, length)) { 1540 if (!Utils::IsUint(8, length)) {
1536 Unsupported(compiler); 1541 Unsupported(compiler);
1537 UNREACHABLE(); 1542 UNREACHABLE();
1538 } 1543 }
1539 if (using_ranges) { 1544 if (using_ranges) {
1540 __ CheckCidsByRange(value, may_be_smi, (length - smi_adjustment) * 2); 1545 __ CheckCidsByRange(value, may_be_smi, (length - smi_adjustment) * 2);
1541 } else { 1546 } else {
1542 __ CheckCids(value, may_be_smi, length - smi_adjustment); 1547 __ CheckCids(value, may_be_smi, length - smi_adjustment);
1543 } 1548 }
1544 for (intptr_t i = 0; i < length; i++) { 1549 for (intptr_t i = 0; i < length; i++) {
1545 intptr_t cid_start = cids_[i].cid_start; 1550 intptr_t cid_start = cids_[i].cid_start;
1546 intptr_t cid_end = cids_[i].cid_end; 1551 intptr_t cid_end = cids_[i].cid_end;
1547 if (cid_start == kSmiCid && cid_end == kSmiCid) { 1552 if (cid_start == kSmiCid && cid_end == kSmiCid) {
1548 ASSERT(smi_adjustment == 1); 1553 ASSERT(smi_adjustment == 1);
1549 continue; 1554 continue;
1550 } 1555 }
1551 __ Nop(compiler->ToEmbeddableCid(cid_start, this)); 1556 __ Nop(compiler->ToEmbeddableCid(cid_start, this));
1552 if (using_ranges) { 1557 if (using_ranges) {
1553 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this)); 1558 __ Nop(compiler->ToEmbeddableCid(1 + cids_[i].Extent(), this));
1554 } 1559 }
1555 } 1560 }
1556 } 1561 }
1557 } 1562 }
1558 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass, 1563 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass,
1559 licm_hoisted_ ? ICData::kHoisted : 0); 1564 licm_hoisted_ ? ICData::kHoisted : 0);
1560 } 1565 }
1561 1566
1562 1567
1563 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) { 1568 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) {
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 } 2088 }
2084 __ IfULe(length, index); 2089 __ IfULe(length, index);
2085 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, 2090 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound,
2086 (generalized_ ? ICData::kGeneralized : 0) | 2091 (generalized_ ? ICData::kGeneralized : 0) |
2087 (licm_hoisted_ ? ICData::kHoisted : 0)); 2092 (licm_hoisted_ ? ICData::kHoisted : 0));
2088 } 2093 }
2089 2094
2090 } // namespace dart 2095 } // namespace dart
2091 2096
2092 #endif // defined TARGET_ARCH_DBC 2097 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698