| 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 6020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6031 } | 6031 } |
| 6032 } else { | 6032 } else { |
| 6033 __ shld(left_hi, left_lo, Immediate(shift)); | 6033 __ shld(left_hi, left_lo, Immediate(shift)); |
| 6034 __ shll(left_lo, Immediate(shift)); | 6034 __ shll(left_lo, Immediate(shift)); |
| 6035 } | 6035 } |
| 6036 } | 6036 } |
| 6037 break; | 6037 break; |
| 6038 } | 6038 } |
| 6039 default: | 6039 default: |
| 6040 UNREACHABLE(); | 6040 UNREACHABLE(); |
| 6041 break; | |
| 6042 } | 6041 } |
| 6043 } else { | 6042 } else { |
| 6044 // Code for a variable shift amount. | 6043 // Code for a variable shift amount. |
| 6045 // Deoptimize if shift count is > 63. | 6044 // Deoptimize if shift count is > 63. |
| 6046 // sarl operation masks the count to 5 bits and | 6045 // sarl operation masks the count to 5 bits and |
| 6047 // shrd is undefined with count > operand size (32) | 6046 // shrd is undefined with count > operand size (32) |
| 6048 __ SmiUntag(ECX); | 6047 __ SmiUntag(ECX); |
| 6049 if (has_shift_count_check()) { | 6048 if (has_shift_count_check()) { |
| 6050 __ cmpl(ECX, Immediate(kMintShiftCountLimit)); | 6049 __ cmpl(ECX, Immediate(kMintShiftCountLimit)); |
| 6051 __ j(ABOVE, deopt); | 6050 __ j(ABOVE, deopt); |
| 6052 } | 6051 } |
| 6053 Label done, large_shift; | 6052 Label done, large_shift; |
| 6054 switch (op_kind()) { | 6053 switch (op_kind()) { |
| 6055 case Token::kSHR: { | 6054 case Token::kSHR: { |
| 6056 __ cmpl(ECX, Immediate(31)); | 6055 __ cmpl(ECX, Immediate(31)); |
| 6057 __ j(ABOVE, &large_shift); | 6056 __ j(ABOVE, &large_shift); |
| 6058 | 6057 |
| 6059 __ shrd(left_lo, left_hi); // Shift count in CL. | 6058 __ shrd(left_lo, left_hi); // Shift count in CL. |
| 6060 __ sarl(left_hi, ECX); // Shift count in CL. | 6059 __ sarl(left_hi, ECX); // Shift count in CL. |
| 6061 __ jmp(&done, Assembler::kNearJump); | 6060 __ jmp(&done, Assembler::kNearJump); |
| 6062 | 6061 |
| 6063 __ Bind(&large_shift); | 6062 __ Bind(&large_shift); |
| 6064 __ subl(ECX, Immediate(32)); | 6063 // No need to subtract 32 from CL, only 5 bits used by sarl. |
| 6065 __ movl(left_lo, left_hi); // Shift by 32. | 6064 __ movl(left_lo, left_hi); // Shift by 32. |
| 6066 __ sarl(left_hi, Immediate(31)); // Sign extend left hi. | 6065 __ sarl(left_hi, Immediate(31)); // Sign extend left hi. |
| 6067 __ sarl(left_lo, ECX); // Shift count - 32 in CL. | 6066 __ sarl(left_lo, ECX); // Shift count: CL % 32. |
| 6068 break; | 6067 break; |
| 6069 } | 6068 } |
| 6070 case Token::kSHL: { | 6069 case Token::kSHL: { |
| 6071 if (can_overflow()) { | 6070 if (can_overflow()) { |
| 6072 Register temp1 = locs()->temp(0).reg(); | 6071 Register temp1 = locs()->temp(0).reg(); |
| 6073 Register temp2 = locs()->temp(1).reg(); | 6072 Register temp2 = locs()->temp(1).reg(); |
| 6074 __ movl(temp1, left_hi); // Preserve high 32 bits. | 6073 __ movl(temp1, left_hi); // Preserve high 32 bits. |
| 6075 __ cmpl(ECX, Immediate(31)); | 6074 __ cmpl(ECX, Immediate(31)); |
| 6076 __ j(ABOVE, &large_shift); | 6075 __ j(ABOVE, &large_shift); |
| 6077 | 6076 |
| 6078 __ shld(left_hi, left_lo); // Shift count in CL. | 6077 __ shld(left_hi, left_lo); // Shift count in CL. |
| 6079 __ shll(left_lo, ECX); // Shift count in CL. | 6078 __ shll(left_lo, ECX); // Shift count in CL. |
| 6080 // Check for overflow by shifting back the high 32 bits | 6079 // Check for overflow by shifting back the high 32 bits |
| 6081 // and comparing with the input. | 6080 // and comparing with the input. |
| 6082 __ movl(temp2, left_hi); | 6081 __ movl(temp2, left_hi); |
| 6083 __ sarl(temp2, ECX); | 6082 __ sarl(temp2, ECX); |
| 6084 __ cmpl(temp1, temp2); | 6083 __ cmpl(temp1, temp2); |
| 6085 __ j(NOT_EQUAL, deopt); | 6084 __ j(NOT_EQUAL, deopt); |
| 6086 __ jmp(&done, Assembler::kNearJump); | 6085 __ jmp(&done, Assembler::kNearJump); |
| 6087 | 6086 |
| 6088 __ Bind(&large_shift); | 6087 __ Bind(&large_shift); |
| 6089 __ subl(ECX, Immediate(32)); | 6088 // No need to subtract 32 from CL, only 5 bits used by shll. |
| 6090 __ movl(left_hi, left_lo); // Shift by 32. | 6089 __ movl(left_hi, left_lo); // Shift by 32. |
| 6091 __ xorl(left_lo, left_lo); // Zero left_lo. | 6090 __ xorl(left_lo, left_lo); // Zero left_lo. |
| 6092 __ shll(left_hi, ECX); // Shift count in CL. | 6091 __ shll(left_hi, ECX); // Shift count: CL % 32. |
| 6093 // Check for overflow by sign extending the high 32 bits | 6092 // Check for overflow by sign extending the high 32 bits |
| 6094 // and comparing with the input. | 6093 // and comparing with the input. |
| 6095 __ movl(temp2, left_hi); | 6094 __ movl(temp2, left_hi); |
| 6096 __ sarl(temp2, Immediate(31)); | 6095 __ sarl(temp2, Immediate(31)); |
| 6097 __ cmpl(temp1, temp2); | 6096 __ cmpl(temp1, temp2); |
| 6098 __ j(NOT_EQUAL, deopt); | 6097 __ j(NOT_EQUAL, deopt); |
| 6099 } else { | 6098 } else { |
| 6100 __ cmpl(ECX, Immediate(31)); | 6099 __ cmpl(ECX, Immediate(31)); |
| 6101 __ j(ABOVE, &large_shift); | 6100 __ j(ABOVE, &large_shift); |
| 6102 | 6101 |
| 6103 __ shld(left_hi, left_lo); // Shift count in CL. | 6102 __ shld(left_hi, left_lo); // Shift count in CL. |
| 6104 __ shll(left_lo, ECX); // Shift count in CL. | 6103 __ shll(left_lo, ECX); // Shift count in CL. |
| 6105 __ jmp(&done, Assembler::kNearJump); | 6104 __ jmp(&done, Assembler::kNearJump); |
| 6106 | 6105 |
| 6107 __ Bind(&large_shift); | 6106 __ Bind(&large_shift); |
| 6108 __ subl(ECX, Immediate(32)); | 6107 // No need to subtract 32 from CL, only 5 bits used by shll. |
| 6109 __ movl(left_hi, left_lo); // Shift by 32. | 6108 __ movl(left_hi, left_lo); // Shift by 32. |
| 6110 __ xorl(left_lo, left_lo); // Zero left_lo. | 6109 __ xorl(left_lo, left_lo); // Zero left_lo. |
| 6111 __ shll(left_hi, ECX); // Shift count in CL. | 6110 __ shll(left_hi, ECX); // Shift count: CL % 32. |
| 6112 } | 6111 } |
| 6113 break; | 6112 break; |
| 6114 } | 6113 } |
| 6115 default: | 6114 default: |
| 6116 UNREACHABLE(); | 6115 UNREACHABLE(); |
| 6117 break; | 6116 break; |
| 6118 } | 6117 } |
| 6119 __ Bind(&done); | 6118 __ Bind(&done); |
| 6120 } | 6119 } |
| 6121 if (FLAG_throw_on_javascript_int_overflow) { | 6120 if (FLAG_throw_on_javascript_int_overflow) { |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6831 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6830 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
| 6832 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6831 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
| 6833 #endif | 6832 #endif |
| 6834 } | 6833 } |
| 6835 | 6834 |
| 6836 } // namespace dart | 6835 } // namespace dart |
| 6837 | 6836 |
| 6838 #undef __ | 6837 #undef __ |
| 6839 | 6838 |
| 6840 #endif // defined TARGET_ARCH_IA32 | 6839 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |