OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 // Deoptimize if minus zero. | 2766 // Deoptimize if minus zero. |
2767 __ movq(output_reg, input_reg); | 2767 __ movq(output_reg, input_reg); |
2768 __ subq(output_reg, Immediate(1)); | 2768 __ subq(output_reg, Immediate(1)); |
2769 DeoptimizeIf(overflow, instr->environment()); | 2769 DeoptimizeIf(overflow, instr->environment()); |
2770 } | 2770 } |
2771 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown); | 2771 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown); |
2772 __ cvttsd2si(output_reg, xmm_scratch); | 2772 __ cvttsd2si(output_reg, xmm_scratch); |
2773 __ cmpl(output_reg, Immediate(0x80000000)); | 2773 __ cmpl(output_reg, Immediate(0x80000000)); |
2774 DeoptimizeIf(equal, instr->environment()); | 2774 DeoptimizeIf(equal, instr->environment()); |
2775 } else { | 2775 } else { |
| 2776 // Deoptimize on negative inputs. |
2776 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. | 2777 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. |
2777 __ ucomisd(input_reg, xmm_scratch); | 2778 __ ucomisd(input_reg, xmm_scratch); |
2778 | 2779 DeoptimizeIf(below, instr->environment()); |
2779 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 2780 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
2780 DeoptimizeIf(below_equal, instr->environment()); | 2781 // Check for negative zero. |
2781 } else { | 2782 __ j(above, &positive_sign, Label::kNear); |
2782 DeoptimizeIf(below, instr->environment()); | 2783 __ movmskpd(output_reg, input_reg); |
| 2784 __ testq(output_reg, Immediate(1)); |
| 2785 DeoptimizeIf(not_zero, instr->environment()); |
| 2786 __ Set(output_reg, Immediate(0)); |
| 2787 __ jmp(&done); |
| 2788 __ bind(&positive_sign); |
2783 } | 2789 } |
2784 | 2790 |
2785 // Use truncating instruction (OK because input is positive). | 2791 // Use truncating instruction (OK because input is positive). |
2786 __ cvttsd2si(output_reg, input_reg); | 2792 __ cvttsd2si(output_reg, input_reg); |
2787 | 2793 |
2788 // Overflow is signalled with minint. | 2794 // Overflow is signalled with minint. |
2789 __ cmpl(output_reg, Immediate(0x80000000)); | 2795 __ cmpl(output_reg, Immediate(0x80000000)); |
2790 DeoptimizeIf(equal, instr->environment()); | 2796 DeoptimizeIf(equal, instr->environment()); |
2791 } | 2797 } |
| 2798 __ bind(&done); |
2792 } | 2799 } |
2793 | 2800 |
2794 | 2801 |
2795 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2802 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
2796 const XMMRegister xmm_scratch = xmm0; | 2803 const XMMRegister xmm_scratch = xmm0; |
2797 Register output_reg = ToRegister(instr->result()); | 2804 Register output_reg = ToRegister(instr->result()); |
2798 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2805 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
2799 | 2806 |
2800 Label done; | 2807 Label done; |
2801 // xmm_scratch = 0.5 | 2808 // xmm_scratch = 0.5 |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4184 RegisterEnvironmentForDeoptimization(environment); | 4191 RegisterEnvironmentForDeoptimization(environment); |
4185 ASSERT(osr_pc_offset_ == -1); | 4192 ASSERT(osr_pc_offset_ == -1); |
4186 osr_pc_offset_ = masm()->pc_offset(); | 4193 osr_pc_offset_ = masm()->pc_offset(); |
4187 } | 4194 } |
4188 | 4195 |
4189 #undef __ | 4196 #undef __ |
4190 | 4197 |
4191 } } // namespace v8::internal | 4198 } } // namespace v8::internal |
4192 | 4199 |
4193 #endif // V8_TARGET_ARCH_X64 | 4200 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |