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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 6070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6081 // Code for a constant shift amount. | 6081 // Code for a constant shift amount. |
6082 ASSERT(locs()->in(1).constant().IsSmi()); | 6082 ASSERT(locs()->in(1).constant().IsSmi()); |
6083 const int32_t shift = | 6083 const int32_t shift = |
6084 reinterpret_cast<int32_t>(locs()->in(1).constant().raw()) >> 1; | 6084 reinterpret_cast<int32_t>(locs()->in(1).constant().raw()) >> 1; |
6085 switch (op_kind()) { | 6085 switch (op_kind()) { |
6086 case Token::kSHR: { | 6086 case Token::kSHR: { |
6087 if (shift > 31) { | 6087 if (shift > 31) { |
6088 __ movl(left_lo, left_hi); // Shift by 32. | 6088 __ movl(left_lo, left_hi); // Shift by 32. |
6089 __ sarl(left_hi, Immediate(31)); // Sign extend left hi. | 6089 __ sarl(left_hi, Immediate(31)); // Sign extend left hi. |
6090 if (shift > 32) { | 6090 if (shift > 32) { |
6091 __ sarl(left_lo, Immediate(shift - 32)); | 6091 __ sarl(left_lo, Immediate(shift > 63 ? 31 : shift - 32)); |
6092 } | 6092 } |
6093 } else { | 6093 } else { |
6094 __ shrdl(left_lo, left_hi, Immediate(shift)); | 6094 __ shrdl(left_lo, left_hi, Immediate(shift)); |
6095 __ sarl(left_hi, Immediate(shift)); | 6095 __ sarl(left_hi, Immediate(shift)); |
6096 } | 6096 } |
6097 break; | 6097 break; |
6098 } | 6098 } |
6099 case Token::kSHL: { | 6099 case Token::kSHL: { |
6100 if (can_overflow()) { | 6100 if (can_overflow()) { |
6101 Register temp1 = locs()->temp(0).reg(); | 6101 Register temp1 = locs()->temp(0).reg(); |
6102 Register temp2 = locs()->temp(1).reg(); | 6102 Register temp2 = locs()->temp(1).reg(); |
6103 __ movl(temp1, left_hi); // Preserve high 32 bits. | 6103 __ movl(temp1, left_hi); // Preserve high 32 bits. |
6104 if (shift > 31) { | 6104 if (shift > 31) { |
6105 __ movl(left_hi, left_lo); // Shift by 32. | 6105 __ movl(left_hi, left_lo); // Shift by 32. |
6106 if (shift > 32) { | 6106 if (shift > 32) { |
6107 __ shll(left_hi, Immediate(shift - 32)); | 6107 __ shll(left_hi, Immediate(shift - 32)); |
regis
2015/10/06 17:37:24
ditto
| |
6108 } | 6108 } |
6109 // Check for overflow by sign extending the high 32 bits | 6109 // Check for overflow by sign extending the high 32 bits |
6110 // and comparing with the input. | 6110 // and comparing with the input. |
6111 __ movl(temp2, left_hi); | 6111 __ movl(temp2, left_hi); |
6112 __ sarl(temp2, Immediate(31)); | 6112 __ sarl(temp2, Immediate(31)); |
6113 __ cmpl(temp1, temp2); | 6113 __ cmpl(temp1, temp2); |
6114 __ j(NOT_EQUAL, deopt); | 6114 __ j(NOT_EQUAL, deopt); |
6115 if (shift > 32) { | 6115 if (shift > 32) { |
6116 // Also compare low word from input with high word from | 6116 // Also compare low word from input with high word from |
6117 // output shifted back shift - 32. | 6117 // output shifted back shift - 32. |
6118 __ movl(temp2, left_hi); | 6118 __ movl(temp2, left_hi); |
6119 __ sarl(temp2, Immediate(shift - 32)); | 6119 __ sarl(temp2, Immediate(shift - 32)); |
regis
2015/10/06 17:37:24
ditto
| |
6120 __ cmpl(left_lo, temp2); | 6120 __ cmpl(left_lo, temp2); |
6121 __ j(NOT_EQUAL, deopt); | 6121 __ j(NOT_EQUAL, deopt); |
6122 } | 6122 } |
6123 __ xorl(left_lo, left_lo); // Zero left_lo. | 6123 __ xorl(left_lo, left_lo); // Zero left_lo. |
6124 } else { | 6124 } else { |
6125 __ shldl(left_hi, left_lo, Immediate(shift)); | 6125 __ shldl(left_hi, left_lo, Immediate(shift)); |
6126 __ shll(left_lo, Immediate(shift)); | 6126 __ shll(left_lo, Immediate(shift)); |
6127 // Check for overflow by shifting back the high 32 bits | 6127 // Check for overflow by shifting back the high 32 bits |
6128 // and comparing with the input. | 6128 // and comparing with the input. |
6129 __ movl(temp2, left_hi); | 6129 __ movl(temp2, left_hi); |
6130 __ sarl(temp2, Immediate(shift)); | 6130 __ sarl(temp2, Immediate(shift)); |
6131 __ cmpl(temp1, temp2); | 6131 __ cmpl(temp1, temp2); |
6132 __ j(NOT_EQUAL, deopt); | 6132 __ j(NOT_EQUAL, deopt); |
6133 } | 6133 } |
6134 } else { | 6134 } else { |
6135 if (shift > 31) { | 6135 if (shift > 31) { |
6136 __ movl(left_hi, left_lo); // Shift by 32. | 6136 __ movl(left_hi, left_lo); // Shift by 32. |
6137 __ xorl(left_lo, left_lo); // Zero left_lo. | 6137 __ xorl(left_lo, left_lo); // Zero left_lo. |
6138 if (shift > 32) { | 6138 if (shift > 32) { |
6139 __ shll(left_hi, Immediate(shift - 32)); | 6139 __ shll(left_hi, Immediate(shift - 32)); |
regis
2015/10/06 17:37:24
ditto
| |
6140 } | 6140 } |
6141 } else { | 6141 } else { |
6142 __ shldl(left_hi, left_lo, Immediate(shift)); | 6142 __ shldl(left_hi, left_lo, Immediate(shift)); |
6143 __ shll(left_lo, Immediate(shift)); | 6143 __ shll(left_lo, Immediate(shift)); |
6144 } | 6144 } |
6145 } | 6145 } |
6146 break; | 6146 break; |
6147 } | 6147 } |
6148 default: | 6148 default: |
6149 UNREACHABLE(); | 6149 UNREACHABLE(); |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6871 __ Drop(1); | 6871 __ Drop(1); |
6872 __ popl(result); | 6872 __ popl(result); |
6873 } | 6873 } |
6874 | 6874 |
6875 | 6875 |
6876 } // namespace dart | 6876 } // namespace dart |
6877 | 6877 |
6878 #undef __ | 6878 #undef __ |
6879 | 6879 |
6880 #endif // defined TARGET_ARCH_IA32 | 6880 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |