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 2738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 EmitIntegerMathAbs(instr); | 2749 EmitIntegerMathAbs(instr); |
2750 __ bind(deferred->exit()); | 2750 __ bind(deferred->exit()); |
2751 } | 2751 } |
2752 } | 2752 } |
2753 | 2753 |
2754 | 2754 |
2755 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { | 2755 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
2756 XMMRegister xmm_scratch = xmm0; | 2756 XMMRegister xmm_scratch = xmm0; |
2757 Register output_reg = ToRegister(instr->result()); | 2757 Register output_reg = ToRegister(instr->result()); |
2758 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 2758 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 2759 Label done; |
| 2760 |
| 2761 // Deoptimize on negative numbers. |
2759 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. | 2762 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. |
2760 __ ucomisd(input_reg, xmm_scratch); | 2763 __ ucomisd(input_reg, xmm_scratch); |
| 2764 DeoptimizeIf(below, instr->environment()); |
2761 | 2765 |
2762 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 2766 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
2763 DeoptimizeIf(below_equal, instr->environment()); | 2767 // Check for negative zero. |
2764 } else { | 2768 Label positive_sign; |
2765 DeoptimizeIf(below, instr->environment()); | 2769 __ j(above, &positive_sign, Label::kNear); |
| 2770 __ movmskpd(output_reg, input_reg); |
| 2771 __ test(output_reg, Immediate(1)); |
| 2772 DeoptimizeIf(not_zero, instr->environment()); |
| 2773 __ Set(output_reg, Immediate(0)); |
| 2774 __ jmp(&done, Label::kNear); |
| 2775 __ bind(&positive_sign); |
2766 } | 2776 } |
2767 | 2777 |
2768 // Use truncating instruction (OK because input is positive). | 2778 // Use truncating instruction (OK because input is positive). |
2769 __ cvttsd2si(output_reg, Operand(input_reg)); | 2779 __ cvttsd2si(output_reg, Operand(input_reg)); |
2770 | 2780 |
2771 // Overflow is signalled with minint. | 2781 // Overflow is signalled with minint. |
2772 __ cmp(output_reg, 0x80000000u); | 2782 __ cmp(output_reg, 0x80000000u); |
2773 DeoptimizeIf(equal, instr->environment()); | 2783 DeoptimizeIf(equal, instr->environment()); |
| 2784 __ bind(&done); |
2774 } | 2785 } |
2775 | 2786 |
2776 | 2787 |
2777 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2788 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
2778 XMMRegister xmm_scratch = xmm0; | 2789 XMMRegister xmm_scratch = xmm0; |
2779 Register output_reg = ToRegister(instr->result()); | 2790 Register output_reg = ToRegister(instr->result()); |
2780 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 2791 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
2781 | 2792 |
2782 Label below_half, done; | 2793 Label below_half, done; |
2783 // xmm_scratch = 0.5 | 2794 // xmm_scratch = 0.5 |
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4399 env->deoptimization_index()); | 4410 env->deoptimization_index()); |
4400 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4411 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4401 } | 4412 } |
4402 | 4413 |
4403 | 4414 |
4404 #undef __ | 4415 #undef __ |
4405 | 4416 |
4406 } } // namespace v8::internal | 4417 } } // namespace v8::internal |
4407 | 4418 |
4408 #endif // V8_TARGET_ARCH_IA32 | 4419 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |