OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/x87/lithium-codegen-x87.h" | 9 #include "src/x87/lithium-codegen-x87.h" |
10 #include "src/ic.h" | 10 #include "src/ic.h" |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 __ sar(dividend, shift); | 1539 __ sar(dividend, shift); |
1540 return; | 1540 return; |
1541 } | 1541 } |
1542 | 1542 |
1543 // If the divisor is negative, we have to negate and handle edge cases. | 1543 // If the divisor is negative, we have to negate and handle edge cases. |
1544 __ neg(dividend); | 1544 __ neg(dividend); |
1545 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1545 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1546 DeoptimizeIf(zero, instr->environment()); | 1546 DeoptimizeIf(zero, instr->environment()); |
1547 } | 1547 } |
1548 | 1548 |
| 1549 // Dividing by -1 is basically negation, unless we overflow. |
| 1550 if (divisor == -1) { |
| 1551 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
| 1552 DeoptimizeIf(overflow, instr->environment()); |
| 1553 } |
| 1554 return; |
| 1555 } |
| 1556 |
| 1557 // If the negation could not overflow, simply shifting is OK. |
1549 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { | 1558 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
1550 __ sar(dividend, shift); | 1559 __ sar(dividend, shift); |
1551 return; | 1560 return; |
1552 } | 1561 } |
1553 | 1562 |
1554 // Dividing by -1 is basically negation, unless we overflow. | |
1555 if (divisor == -1) { | |
1556 DeoptimizeIf(overflow, instr->environment()); | |
1557 return; | |
1558 } | |
1559 | |
1560 Label not_kmin_int, done; | 1563 Label not_kmin_int, done; |
1561 __ j(no_overflow, ¬_kmin_int, Label::kNear); | 1564 __ j(no_overflow, ¬_kmin_int, Label::kNear); |
1562 __ mov(dividend, Immediate(kMinInt / divisor)); | 1565 __ mov(dividend, Immediate(kMinInt / divisor)); |
1563 __ jmp(&done, Label::kNear); | 1566 __ jmp(&done, Label::kNear); |
1564 __ bind(¬_kmin_int); | 1567 __ bind(¬_kmin_int); |
1565 __ sar(dividend, shift); | 1568 __ sar(dividend, shift); |
1566 __ bind(&done); | 1569 __ bind(&done); |
1567 } | 1570 } |
1568 | 1571 |
1569 | 1572 |
(...skipping 4125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5695 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); | 5698 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); |
5696 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5699 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5697 } | 5700 } |
5698 | 5701 |
5699 | 5702 |
5700 #undef __ | 5703 #undef __ |
5701 | 5704 |
5702 } } // namespace v8::internal | 5705 } } // namespace v8::internal |
5703 | 5706 |
5704 #endif // V8_TARGET_ARCH_X87 | 5707 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |