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 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2700 __ cmp(output_reg, 0x80000000u); | 2700 __ cmp(output_reg, 0x80000000u); |
2701 DeoptimizeIf(equal, instr->environment()); | 2701 DeoptimizeIf(equal, instr->environment()); |
2702 } | 2702 } |
2703 | 2703 |
2704 | 2704 |
2705 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2705 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
2706 XMMRegister xmm_scratch = xmm0; | 2706 XMMRegister xmm_scratch = xmm0; |
2707 Register output_reg = ToRegister(instr->result()); | 2707 Register output_reg = ToRegister(instr->result()); |
2708 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2708 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
2709 | 2709 |
2710 Label below_half, done; | |
Vitaly Repeshko
2011/04/13 21:16:34
I think you can use NearLabel here.
| |
2710 // xmm_scratch = 0.5 | 2711 // xmm_scratch = 0.5 |
2711 ExternalReference one_half = ExternalReference::address_of_one_half(); | 2712 ExternalReference one_half = ExternalReference::address_of_one_half(); |
2712 __ movdbl(xmm_scratch, Operand::StaticVariable(one_half)); | 2713 __ movdbl(xmm_scratch, Operand::StaticVariable(one_half)); |
2713 | 2714 |
2715 __ ucomisd(xmm_scratch, input_reg); | |
2716 __ j(above, &below_half); | |
2714 // input = input + 0.5 | 2717 // input = input + 0.5 |
2715 __ addsd(input_reg, xmm_scratch); | 2718 __ addsd(input_reg, xmm_scratch); |
2716 | 2719 |
2717 // We need to return -0 for the input range [-0.5, 0[, otherwise | |
2718 // compute Math.floor(value + 0.5). | |
2719 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
2720 __ ucomisd(input_reg, xmm_scratch); | |
2721 DeoptimizeIf(below_equal, instr->environment()); | |
2722 } else { | |
2723 // If we don't need to bailout on -0, we check only bailout | |
2724 // on negative inputs. | |
2725 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register. | |
2726 __ ucomisd(input_reg, xmm_scratch); | |
2727 DeoptimizeIf(below, instr->environment()); | |
2728 } | |
2729 | 2720 |
2730 // Compute Math.floor(value + 0.5). | 2721 // Compute Math.floor(value + 0.5). |
2731 // Use truncating instruction (OK because input is positive). | 2722 // Use truncating instruction (OK because input is positive). |
2732 __ cvttsd2si(output_reg, Operand(input_reg)); | 2723 __ cvttsd2si(output_reg, Operand(input_reg)); |
2733 | 2724 |
2734 // Overflow is signalled with minint. | 2725 // Overflow is signalled with minint. |
2735 __ cmp(output_reg, 0x80000000u); | 2726 __ cmp(output_reg, 0x80000000u); |
2736 DeoptimizeIf(equal, instr->environment()); | 2727 DeoptimizeIf(equal, instr->environment()); |
2728 __ jmp(&done); | |
2729 | |
2730 __ bind(&below_half); | |
2731 | |
2732 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if | |
2733 // we can ignore the difference between a result of -0 and +0. | |
2734 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
2735 // If the sign is positive, we return +0. | |
2736 __ movmskpd(output_reg, input_reg); | |
2737 __ test(output_reg, Immediate(1)); | |
2738 DeoptimizeIf(not_zero, instr->environment()); | |
2739 } else { | |
2740 // If the input is >= -0.5, we return +0. | |
2741 __ mov(output_reg, Immediate(0xBF000000)); | |
2742 __ movd(xmm_scratch, Operand(output_reg)); | |
2743 __ cvtss2sd(xmm_scratch, xmm_scratch); | |
2744 __ ucomisd(input_reg, xmm_scratch); | |
2745 DeoptimizeIf(below, instr->environment()); | |
2746 } | |
2747 __ Set(output_reg, Immediate(0)); | |
2748 __ bind(&done); | |
2737 } | 2749 } |
2738 | 2750 |
2739 | 2751 |
2740 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2752 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
2741 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2753 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
2742 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 2754 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
2743 __ sqrtsd(input_reg, input_reg); | 2755 __ sqrtsd(input_reg, input_reg); |
2744 } | 2756 } |
2745 | 2757 |
2746 | 2758 |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4165 ASSERT(osr_pc_offset_ == -1); | 4177 ASSERT(osr_pc_offset_ == -1); |
4166 osr_pc_offset_ = masm()->pc_offset(); | 4178 osr_pc_offset_ = masm()->pc_offset(); |
4167 } | 4179 } |
4168 | 4180 |
4169 | 4181 |
4170 #undef __ | 4182 #undef __ |
4171 | 4183 |
4172 } } // namespace v8::internal | 4184 } } // namespace v8::internal |
4173 | 4185 |
4174 #endif // V8_TARGET_ARCH_IA32 | 4186 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |