OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdarg.h> | 5 #include <stdarg.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #if V8_TARGET_ARCH_S390 | 9 #if V8_TARGET_ARCH_S390 |
10 | 10 |
(...skipping 6486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6497 int32_t r2_val = get_low_register<int32_t>(r2); | 6497 int32_t r2_val = get_low_register<int32_t>(r2); |
6498 SetS390ConditionCode<int32_t>(r2_val, 0); | 6498 SetS390ConditionCode<int32_t>(r2_val, 0); |
6499 set_low_register(r1, r2_val); | 6499 set_low_register(r1, r2_val); |
6500 return length; | 6500 return length; |
6501 } | 6501 } |
6502 | 6502 |
6503 EVALUATE(LCR) { | 6503 EVALUATE(LCR) { |
6504 DCHECK_OPCODE(LCR); | 6504 DCHECK_OPCODE(LCR); |
6505 DECODE_RR_INSTRUCTION(r1, r2); | 6505 DECODE_RR_INSTRUCTION(r1, r2); |
6506 int32_t r2_val = get_low_register<int32_t>(r2); | 6506 int32_t r2_val = get_low_register<int32_t>(r2); |
6507 int32_t original_r2_val = r2_val; | |
6508 r2_val = ~r2_val; | 6507 r2_val = ~r2_val; |
6509 r2_val = r2_val + 1; | 6508 r2_val = r2_val + 1; |
6510 set_low_register(r1, r2_val); | 6509 set_low_register(r1, r2_val); |
6511 SetS390ConditionCode<int32_t>(r2_val, 0); | 6510 SetS390ConditionCode<int32_t>(r2_val, 0); |
6512 // Checks for overflow where r2_val = -2147483648. | 6511 // Checks for overflow where r2_val = -2147483648. |
6513 // Cannot do int comparison due to GCC 4.8 bug on x86. | 6512 // Cannot do int comparison due to GCC 4.8 bug on x86. |
6514 // Detect INT_MIN alternatively, as it is the only value where both | 6513 // Detect INT_MIN alternatively, as it is the only value where both |
6515 // original and result are negative due to overflow. | 6514 // original and result are negative due to overflow. |
6516 if (r2_val < 0 && original_r2_val < 0) { | 6515 if (r2_val == (static_cast<int32_t>(1) << 31)) { |
6517 SetS390OverflowCode(true); | 6516 SetS390OverflowCode(true); |
6518 } | 6517 } |
6519 return length; | 6518 return length; |
6520 } | 6519 } |
6521 | 6520 |
6522 EVALUATE(NR) { | 6521 EVALUATE(NR) { |
6523 DCHECK_OPCODE(NR); | 6522 DCHECK_OPCODE(NR); |
6524 DECODE_RR_INSTRUCTION(r1, r2); | 6523 DECODE_RR_INSTRUCTION(r1, r2); |
6525 int32_t r1_val = get_low_register<int32_t>(r1); | 6524 int32_t r1_val = get_low_register<int32_t>(r1); |
6526 int32_t r2_val = get_low_register<int32_t>(r2); | 6525 int32_t r2_val = get_low_register<int32_t>(r2); |
(...skipping 3303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9830 | 9829 |
9831 EVALUATE(LCGR) { | 9830 EVALUATE(LCGR) { |
9832 DCHECK_OPCODE(LCGR); | 9831 DCHECK_OPCODE(LCGR); |
9833 DECODE_RRE_INSTRUCTION(r1, r2); | 9832 DECODE_RRE_INSTRUCTION(r1, r2); |
9834 int64_t r2_val = get_register(r2); | 9833 int64_t r2_val = get_register(r2); |
9835 r2_val = ~r2_val; | 9834 r2_val = ~r2_val; |
9836 r2_val = r2_val + 1; | 9835 r2_val = r2_val + 1; |
9837 set_register(r1, r2_val); | 9836 set_register(r1, r2_val); |
9838 SetS390ConditionCode<int64_t>(r2_val, 0); | 9837 SetS390ConditionCode<int64_t>(r2_val, 0); |
9839 // if the input is INT_MIN, loading its compliment would be overflowing | 9838 // if the input is INT_MIN, loading its compliment would be overflowing |
9840 if (r2_val < 0 && (r2_val + 1) > 0) { | 9839 if (r2_val == (static_cast<int64_t>(1) << 63)) { |
9841 SetS390OverflowCode(true); | 9840 SetS390OverflowCode(true); |
9842 } | 9841 } |
9843 return length; | 9842 return length; |
9844 } | 9843 } |
9845 | 9844 |
9846 EVALUATE(SGR) { | 9845 EVALUATE(SGR) { |
9847 DCHECK_OPCODE(SGR); | 9846 DCHECK_OPCODE(SGR); |
9848 DECODE_RRE_INSTRUCTION(r1, r2); | 9847 DECODE_RRE_INSTRUCTION(r1, r2); |
9849 int64_t r1_val = get_register(r1); | 9848 int64_t r1_val = get_register(r1); |
9850 int64_t r2_val = get_register(r2); | 9849 int64_t r2_val = get_register(r2); |
(...skipping 2787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12638 return 0; | 12637 return 0; |
12639 } | 12638 } |
12640 | 12639 |
12641 #undef EVALUATE | 12640 #undef EVALUATE |
12642 | 12641 |
12643 } // namespace internal | 12642 } // namespace internal |
12644 } // namespace v8 | 12643 } // namespace v8 |
12645 | 12644 |
12646 #endif // USE_SIMULATOR | 12645 #endif // USE_SIMULATOR |
12647 #endif // V8_TARGET_ARCH_S390 | 12646 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |