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 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/crankshaft/x87/lithium-codegen-x87.h" | 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 } | 3473 } |
3474 | 3474 |
3475 // Positive input. | 3475 // Positive input. |
3476 // rc=01B, round down. | 3476 // rc=01B, round down. |
3477 __ bind(¬_minus_zero); | 3477 __ bind(¬_minus_zero); |
3478 __ fnclex(); | 3478 __ fnclex(); |
3479 __ X87SetRC(0x0400); | 3479 __ X87SetRC(0x0400); |
3480 __ sub(esp, Immediate(kPointerSize)); | 3480 __ sub(esp, Immediate(kPointerSize)); |
3481 __ fist_s(Operand(esp, 0)); | 3481 __ fist_s(Operand(esp, 0)); |
3482 __ pop(output_reg); | 3482 __ pop(output_reg); |
| 3483 __ X87SetRC(0x0000); |
3483 __ X87CheckIA(); | 3484 __ X87CheckIA(); |
3484 DeoptimizeIf(equal, instr, Deoptimizer::kOverflow); | 3485 DeoptimizeIf(equal, instr, Deoptimizer::kOverflow); |
3485 __ fnclex(); | 3486 __ fnclex(); |
3486 __ X87SetRC(0x0000); | 3487 __ X87SetRC(0x0000); |
3487 __ bind(&done); | 3488 __ bind(&done); |
3488 } | 3489 } |
3489 | 3490 |
3490 | 3491 |
3491 void LCodeGen::DoMathRound(LMathRound* instr) { | 3492 void LCodeGen::DoMathRound(LMathRound* instr) { |
3492 X87Register input_reg = ToX87Register(instr->value()); | 3493 X87Register input_reg = ToX87Register(instr->value()); |
(...skipping 12 matching lines...) Expand all Loading... |
3505 | 3506 |
3506 // Use rounds towards zero, since 0.5 <= x, we use floor(0.5 + x) | 3507 // Use rounds towards zero, since 0.5 <= x, we use floor(0.5 + x) |
3507 __ fld(0); | 3508 __ fld(0); |
3508 __ fadd_d(Operand::StaticVariable(one_half)); | 3509 __ fadd_d(Operand::StaticVariable(one_half)); |
3509 // rc=11B, round toward zero. | 3510 // rc=11B, round toward zero. |
3510 __ X87SetRC(0x0c00); | 3511 __ X87SetRC(0x0c00); |
3511 __ sub(esp, Immediate(kPointerSize)); | 3512 __ sub(esp, Immediate(kPointerSize)); |
3512 // Clear exception bits. | 3513 // Clear exception bits. |
3513 __ fnclex(); | 3514 __ fnclex(); |
3514 __ fistp_s(MemOperand(esp, 0)); | 3515 __ fistp_s(MemOperand(esp, 0)); |
| 3516 // Restore round mode. |
| 3517 __ X87SetRC(0x0000); |
3515 // Check overflow. | 3518 // Check overflow. |
3516 __ X87CheckIA(); | 3519 __ X87CheckIA(); |
3517 __ pop(result); | 3520 __ pop(result); |
3518 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow); | 3521 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow); |
3519 __ fnclex(); | 3522 __ fnclex(); |
3520 // Restore round mode. | 3523 // Restore round mode. |
3521 __ X87SetRC(0x0000); | 3524 __ X87SetRC(0x0000); |
3522 __ jmp(&done); | 3525 __ jmp(&done); |
3523 | 3526 |
3524 __ bind(&below_one_half); | 3527 __ bind(&below_one_half); |
(...skipping 14 matching lines...) Expand all Loading... |
3539 | 3542 |
3540 __ bind(&below_minus_one_half); | 3543 __ bind(&below_minus_one_half); |
3541 __ fld(0); | 3544 __ fld(0); |
3542 __ fadd_d(Operand::StaticVariable(one_half)); | 3545 __ fadd_d(Operand::StaticVariable(one_half)); |
3543 // rc=01B, round down. | 3546 // rc=01B, round down. |
3544 __ X87SetRC(0x0400); | 3547 __ X87SetRC(0x0400); |
3545 __ sub(esp, Immediate(kPointerSize)); | 3548 __ sub(esp, Immediate(kPointerSize)); |
3546 // Clear exception bits. | 3549 // Clear exception bits. |
3547 __ fnclex(); | 3550 __ fnclex(); |
3548 __ fistp_s(MemOperand(esp, 0)); | 3551 __ fistp_s(MemOperand(esp, 0)); |
| 3552 // Restore round mode. |
| 3553 __ X87SetRC(0x0000); |
3549 // Check overflow. | 3554 // Check overflow. |
3550 __ X87CheckIA(); | 3555 __ X87CheckIA(); |
3551 __ pop(result); | 3556 __ pop(result); |
3552 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow); | 3557 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow); |
3553 __ fnclex(); | 3558 __ fnclex(); |
3554 // Restore round mode. | 3559 // Restore round mode. |
3555 __ X87SetRC(0x0000); | 3560 __ X87SetRC(0x0000); |
3556 | 3561 |
3557 __ bind(&done); | 3562 __ bind(&done); |
3558 } | 3563 } |
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5820 __ bind(deferred->exit()); | 5825 __ bind(deferred->exit()); |
5821 __ bind(&done); | 5826 __ bind(&done); |
5822 } | 5827 } |
5823 | 5828 |
5824 #undef __ | 5829 #undef __ |
5825 | 5830 |
5826 } // namespace internal | 5831 } // namespace internal |
5827 } // namespace v8 | 5832 } // namespace v8 |
5828 | 5833 |
5829 #endif // V8_TARGET_ARCH_X87 | 5834 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |