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 5903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5914 } | 5914 } |
5915 break; | 5915 break; |
5916 } | 5916 } |
5917 case Token::kSHL: { | 5917 case Token::kSHL: { |
5918 if (can_overflow()) { | 5918 if (can_overflow()) { |
5919 Register temp1 = locs()->temp(0).reg(); | 5919 Register temp1 = locs()->temp(0).reg(); |
5920 Register temp2 = locs()->temp(1).reg(); | 5920 Register temp2 = locs()->temp(1).reg(); |
5921 __ movl(temp1, left_hi); // Preserve high 32 bits. | 5921 __ movl(temp1, left_hi); // Preserve high 32 bits. |
5922 if (shift > 31) { | 5922 if (shift > 31) { |
5923 __ movl(left_hi, left_lo); // Shift by 32. | 5923 __ movl(left_hi, left_lo); // Shift by 32. |
5924 __ xorl(left_lo, left_lo); // Zero left_lo. | |
5925 if (shift > 32) { | 5924 if (shift > 32) { |
5926 __ shll(left_hi, Immediate(shift - 32)); | 5925 __ shll(left_hi, Immediate(shift - 32)); |
5927 } | 5926 } |
5928 // Check for overflow by sign extending the high 32 bits | 5927 // Check for overflow by sign extending the high 32 bits |
5929 // and comparing with the input. | 5928 // and comparing with the input. |
5930 __ movl(temp2, left_hi); | 5929 __ movl(temp2, left_hi); |
5931 __ sarl(temp2, Immediate(31)); | 5930 __ sarl(temp2, Immediate(31)); |
5932 __ cmpl(temp1, temp2); | 5931 __ cmpl(temp1, temp2); |
5933 __ j(NOT_EQUAL, deopt); | 5932 __ j(NOT_EQUAL, deopt); |
| 5933 if (shift > 32) { |
| 5934 // Also compare low word from input with high word from |
| 5935 // output shifted back shift - 32. |
| 5936 __ movl(temp2, left_hi); |
| 5937 __ sarl(temp2, Immediate(shift - 32)); |
| 5938 __ cmpl(left_lo, temp2); |
| 5939 __ j(NOT_EQUAL, deopt); |
| 5940 } |
| 5941 __ xorl(left_lo, left_lo); // Zero left_lo. |
5934 } else { | 5942 } else { |
5935 __ shldl(left_hi, left_lo, Immediate(shift)); | 5943 __ shldl(left_hi, left_lo, Immediate(shift)); |
5936 __ shll(left_lo, Immediate(shift)); | 5944 __ shll(left_lo, Immediate(shift)); |
5937 // Check for overflow by shifting back the high 32 bits | 5945 // Check for overflow by shifting back the high 32 bits |
5938 // and comparing with the input. | 5946 // and comparing with the input. |
5939 __ movl(temp2, left_hi); | 5947 __ movl(temp2, left_hi); |
5940 __ sarl(temp2, Immediate(shift)); | 5948 __ sarl(temp2, Immediate(shift)); |
5941 __ cmpl(temp1, temp2); | 5949 __ cmpl(temp1, temp2); |
5942 __ j(NOT_EQUAL, deopt); | 5950 __ j(NOT_EQUAL, deopt); |
5943 } | 5951 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5999 // and comparing with the input. | 6007 // and comparing with the input. |
6000 __ movl(temp2, left_hi); | 6008 __ movl(temp2, left_hi); |
6001 __ sarl(temp2, ECX); | 6009 __ sarl(temp2, ECX); |
6002 __ cmpl(temp1, temp2); | 6010 __ cmpl(temp1, temp2); |
6003 __ j(NOT_EQUAL, deopt); | 6011 __ j(NOT_EQUAL, deopt); |
6004 __ jmp(&done, Assembler::kNearJump); | 6012 __ jmp(&done, Assembler::kNearJump); |
6005 | 6013 |
6006 __ Bind(&large_shift); | 6014 __ Bind(&large_shift); |
6007 // No need to subtract 32 from CL, only 5 bits used by shll. | 6015 // No need to subtract 32 from CL, only 5 bits used by shll. |
6008 __ movl(left_hi, left_lo); // Shift by 32. | 6016 __ movl(left_hi, left_lo); // Shift by 32. |
6009 __ xorl(left_lo, left_lo); // Zero left_lo. | |
6010 __ shll(left_hi, ECX); // Shift count: CL % 32. | 6017 __ shll(left_hi, ECX); // Shift count: CL % 32. |
6011 // Check for overflow by sign extending the high 32 bits | 6018 // Check for overflow by sign extending the high 32 bits |
6012 // and comparing with the input. | 6019 // and comparing with the input. |
6013 __ movl(temp2, left_hi); | 6020 __ movl(temp2, left_hi); |
6014 __ sarl(temp2, Immediate(31)); | 6021 __ sarl(temp2, Immediate(31)); |
6015 __ cmpl(temp1, temp2); | 6022 __ cmpl(temp1, temp2); |
6016 __ j(NOT_EQUAL, deopt); | 6023 __ j(NOT_EQUAL, deopt); |
| 6024 // Also compare low word from input with high word from |
| 6025 // output shifted back shift - 32. |
| 6026 __ movl(temp2, left_hi); |
| 6027 __ sarl(temp2, ECX); // Shift count: CL % 32. |
| 6028 __ cmpl(left_lo, temp2); |
| 6029 __ j(NOT_EQUAL, deopt); |
| 6030 __ xorl(left_lo, left_lo); // Zero left_lo. |
6017 } else { | 6031 } else { |
6018 __ cmpl(ECX, Immediate(31)); | 6032 __ cmpl(ECX, Immediate(31)); |
6019 __ j(ABOVE, &large_shift); | 6033 __ j(ABOVE, &large_shift); |
6020 | 6034 |
6021 __ shldl(left_hi, left_lo); // Shift count in CL. | 6035 __ shldl(left_hi, left_lo); // Shift count in CL. |
6022 __ shll(left_lo, ECX); // Shift count in CL. | 6036 __ shll(left_lo, ECX); // Shift count in CL. |
6023 __ jmp(&done, Assembler::kNearJump); | 6037 __ jmp(&done, Assembler::kNearJump); |
6024 | 6038 |
6025 __ Bind(&large_shift); | 6039 __ Bind(&large_shift); |
6026 // No need to subtract 32 from CL, only 5 bits used by shll. | 6040 // No need to subtract 32 from CL, only 5 bits used by shll. |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 #if defined(DEBUG) | 6622 #if defined(DEBUG) |
6609 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6623 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6610 #endif | 6624 #endif |
6611 } | 6625 } |
6612 | 6626 |
6613 } // namespace dart | 6627 } // namespace dart |
6614 | 6628 |
6615 #undef __ | 6629 #undef __ |
6616 | 6630 |
6617 #endif // defined TARGET_ARCH_IA32 | 6631 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |