| 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/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 6054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6065 | 6065 |
| 6066 Label* deopt = NULL; | 6066 Label* deopt = NULL; |
| 6067 if (CanDeoptimize()) { | 6067 if (CanDeoptimize()) { |
| 6068 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryMintOp); | 6068 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryMintOp); |
| 6069 } | 6069 } |
| 6070 if (locs()->in(1).IsConstant()) { | 6070 if (locs()->in(1).IsConstant()) { |
| 6071 // Code for a constant shift amount. | 6071 // Code for a constant shift amount. |
| 6072 ASSERT(locs()->in(1).constant().IsSmi()); | 6072 ASSERT(locs()->in(1).constant().IsSmi()); |
| 6073 const int64_t shift = | 6073 const int64_t shift = |
| 6074 reinterpret_cast<int64_t>(locs()->in(1).constant().raw()) >> 1; | 6074 reinterpret_cast<int64_t>(locs()->in(1).constant().raw()) >> 1; |
| 6075 // TODO(alexmarkov): revise and uncomment the following assertions | 6075 ASSERT(shift >= 0); |
| 6076 // ASSERT(!has_shift_count_check()); | |
| 6077 // ASSERT((0 <= shift) && (shift < 64)); | |
| 6078 switch (op_kind()) { | 6076 switch (op_kind()) { |
| 6079 case Token::kSHR: | 6077 case Token::kSHR: |
| 6080 __ sarq(left, Immediate(shift)); | 6078 __ sarq(left, |
| 6079 Immediate(Utils::Minimum<int64_t>(shift, kBitsPerWord - 1))); |
| 6081 break; | 6080 break; |
| 6082 case Token::kSHL: { | 6081 case Token::kSHL: { |
| 6082 ASSERT(shift < 64); |
| 6083 if (can_overflow()) { | 6083 if (can_overflow()) { |
| 6084 // Check for overflow. | 6084 // Check for overflow. |
| 6085 Register temp = locs()->temp(0).reg(); | 6085 Register temp = locs()->temp(0).reg(); |
| 6086 __ movq(temp, left); | 6086 __ movq(temp, left); |
| 6087 __ shlq(left, Immediate(shift)); | 6087 __ shlq(left, Immediate(shift)); |
| 6088 __ sarq(left, Immediate(shift)); | 6088 __ sarq(left, Immediate(shift)); |
| 6089 __ cmpq(left, temp); | 6089 __ cmpq(left, temp); |
| 6090 __ j(NOT_EQUAL, deopt); // Overflow. | 6090 __ j(NOT_EQUAL, deopt); // Overflow. |
| 6091 } | 6091 } |
| 6092 // Shift for result now we know there is no overflow. | 6092 // Shift for result now we know there is no overflow. |
| 6093 __ shlq(left, Immediate(shift)); | 6093 __ shlq(left, Immediate(shift)); |
| 6094 break; | 6094 break; |
| 6095 } | 6095 } |
| 6096 default: | 6096 default: |
| 6097 UNREACHABLE(); | 6097 UNREACHABLE(); |
| 6098 } | 6098 } |
| 6099 } else { | 6099 } else { |
| 6100 // Code for a variable shift amount. | 6100 // Code for a variable shift amount. |
| 6101 // Deoptimize if shift count is > 63. | 6101 // Deoptimize if shift count is > 63 or negative. |
| 6102 // sarl operation masks the count to 5 bits and | 6102 // Sarq and shlq instructions mask the count to 6 bits. |
| 6103 // shrd is undefined with count > operand size (32) | |
| 6104 __ SmiUntag(RCX); | 6103 __ SmiUntag(RCX); |
| 6105 if (has_shift_count_check()) { | 6104 if (!IsShiftCountInRange()) { |
| 6106 __ cmpq(RCX, Immediate(kMintShiftCountLimit)); | 6105 __ cmpq(RCX, Immediate(kMintShiftCountLimit)); |
| 6107 __ j(ABOVE, deopt); | 6106 __ j(ABOVE, deopt); |
| 6108 } | 6107 } |
| 6109 Label done, large_shift; | 6108 Label done, large_shift; |
| 6110 switch (op_kind()) { | 6109 switch (op_kind()) { |
| 6111 case Token::kSHR: { | 6110 case Token::kSHR: { |
| 6112 __ sarq(left, RCX); | 6111 __ sarq(left, RCX); |
| 6113 break; | 6112 break; |
| 6114 } | 6113 } |
| 6115 case Token::kSHL: { | 6114 case Token::kSHL: { |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6649 compiler->AddCurrentDescriptor(stub_kind_, deopt_id_, token_pos()); | 6648 compiler->AddCurrentDescriptor(stub_kind_, deopt_id_, token_pos()); |
| 6650 compiler->RecordSafepoint(locs()); | 6649 compiler->RecordSafepoint(locs()); |
| 6651 } | 6650 } |
| 6652 | 6651 |
| 6653 | 6652 |
| 6654 } // namespace dart | 6653 } // namespace dart |
| 6655 | 6654 |
| 6656 #undef __ | 6655 #undef __ |
| 6657 | 6656 |
| 6658 #endif // defined TARGET_ARCH_X64 | 6657 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |