| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 5494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5505 Object::null_object(), PP); | 5505 Object::null_object(), PP); |
| 5506 __ j(EQUAL, deopt); | 5506 __ j(EQUAL, deopt); |
| 5507 return; | 5507 return; |
| 5508 } | 5508 } |
| 5509 | 5509 |
| 5510 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || | 5510 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || |
| 5511 (unary_checks().NumberOfChecks() > 1)); | 5511 (unary_checks().NumberOfChecks() > 1)); |
| 5512 Register value = locs()->in(0).reg(); | 5512 Register value = locs()->in(0).reg(); |
| 5513 Register temp = locs()->temp(0).reg(); | 5513 Register temp = locs()->temp(0).reg(); |
| 5514 Label is_ok; | 5514 Label is_ok; |
| 5515 intptr_t cix = 0; | 5515 if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) { |
| 5516 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { | |
| 5517 __ testq(value, Immediate(kSmiTagMask)); | 5516 __ testq(value, Immediate(kSmiTagMask)); |
| 5518 __ j(ZERO, &is_ok); | 5517 __ j(ZERO, &is_ok); |
| 5519 cix++; // Skip first check. | |
| 5520 } else { | 5518 } else { |
| 5521 __ testq(value, Immediate(kSmiTagMask)); | 5519 __ testq(value, Immediate(kSmiTagMask)); |
| 5522 __ j(ZERO, deopt); | 5520 __ j(ZERO, deopt); |
| 5523 } | 5521 } |
| 5524 __ LoadClassId(temp, value); | 5522 __ LoadClassId(temp, value); |
| 5525 | 5523 |
| 5526 if (IsDenseSwitch()) { | 5524 if (IsDenseSwitch()) { |
| 5527 ASSERT(cids_[0] < cids_[cids_.length() - 1]); | 5525 ASSERT(cids_[0] < cids_[cids_.length() - 1]); |
| 5528 __ subq(temp, Immediate(cids_[0])); | 5526 __ subq(temp, Immediate(cids_[0])); |
| 5529 __ cmpq(temp, Immediate(cids_[cids_.length() - 1] - cids_[0])); | 5527 __ cmpq(temp, Immediate(cids_[cids_.length() - 1] - cids_[0])); |
| 5530 __ j(ABOVE, deopt); | 5528 __ j(ABOVE, deopt); |
| 5531 | 5529 |
| 5532 intptr_t mask = ComputeCidMask(); | 5530 intptr_t mask = ComputeCidMask(); |
| 5533 if (!IsDenseMask(mask)) { | 5531 if (!IsDenseMask(mask)) { |
| 5534 // Only need mask if there are missing numbers in the range. | 5532 // Only need mask if there are missing numbers in the range. |
| 5535 ASSERT(cids_.length() > 2); | 5533 ASSERT(cids_.length() > 2); |
| 5536 Register mask_reg = locs()->temp(1).reg(); | 5534 Register mask_reg = locs()->temp(1).reg(); |
| 5537 __ movq(mask_reg, Immediate(mask)); | 5535 __ movq(mask_reg, Immediate(mask)); |
| 5538 __ btq(mask_reg, temp); | 5536 __ btq(mask_reg, temp); |
| 5539 __ j(NOT_CARRY, deopt); | 5537 __ j(NOT_CARRY, deopt); |
| 5540 } | 5538 } |
| 5541 } else { | 5539 } else { |
| 5542 const intptr_t num_checks = unary_checks().NumberOfChecks(); | 5540 GrowableArray<CidTarget> sorted_ic_data; |
| 5541 FlowGraphCompiler::SortICDataByCount(unary_checks(), |
| 5542 &sorted_ic_data, |
| 5543 /* drop_smi = */ true); |
| 5544 const intptr_t num_checks = sorted_ic_data.length(); |
| 5543 const bool use_near_jump = num_checks < 5; | 5545 const bool use_near_jump = num_checks < 5; |
| 5544 for (intptr_t i = cix; i < num_checks; i++) { | 5546 for (intptr_t i = 0; i < num_checks; i++) { |
| 5545 ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid); | 5547 const intptr_t cid = sorted_ic_data[i].cid; |
| 5546 __ cmpl(temp, Immediate(unary_checks().GetReceiverClassIdAt(i))); | 5548 __ cmpl(temp, Immediate(cid)); |
| 5547 if (i == (num_checks - 1)) { | 5549 if (i == (num_checks - 1)) { |
| 5548 __ j(NOT_EQUAL, deopt); | 5550 __ j(NOT_EQUAL, deopt); |
| 5549 } else { | 5551 } else { |
| 5550 if (use_near_jump) { | 5552 if (use_near_jump) { |
| 5551 __ j(EQUAL, &is_ok, Assembler::kNearJump); | 5553 __ j(EQUAL, &is_ok, Assembler::kNearJump); |
| 5552 } else { | 5554 } else { |
| 5553 __ j(EQUAL, &is_ok); | 5555 __ j(EQUAL, &is_ok); |
| 5554 } | 5556 } |
| 5555 } | 5557 } |
| 5556 } | 5558 } |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6440 __ Drop(1); | 6442 __ Drop(1); |
| 6441 __ popq(result); | 6443 __ popq(result); |
| 6442 } | 6444 } |
| 6443 | 6445 |
| 6444 | 6446 |
| 6445 } // namespace dart | 6447 } // namespace dart |
| 6446 | 6448 |
| 6447 #undef __ | 6449 #undef __ |
| 6448 | 6450 |
| 6449 #endif // defined TARGET_ARCH_X64 | 6451 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |