OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2917 __ test(output_reg, Immediate(1)); | 2917 __ test(output_reg, Immediate(1)); |
2918 DeoptimizeIf(not_zero, instr->environment()); | 2918 DeoptimizeIf(not_zero, instr->environment()); |
2919 __ bind(&non_zero); | 2919 __ bind(&non_zero); |
2920 } | 2920 } |
2921 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown); | 2921 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown); |
2922 __ cvttsd2si(output_reg, Operand(xmm_scratch)); | 2922 __ cvttsd2si(output_reg, Operand(xmm_scratch)); |
2923 // Overflow is signalled with minint. | 2923 // Overflow is signalled with minint. |
2924 __ cmp(output_reg, 0x80000000u); | 2924 __ cmp(output_reg, 0x80000000u); |
2925 DeoptimizeIf(equal, instr->environment()); | 2925 DeoptimizeIf(equal, instr->environment()); |
2926 } else { | 2926 } else { |
| 2927 Label negative_sign; |
2927 Label done; | 2928 Label done; |
2928 // Deoptimize on negative numbers. | 2929 // Deoptimize on unordered. |
2929 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. | 2930 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. |
2930 __ ucomisd(input_reg, xmm_scratch); | 2931 __ ucomisd(input_reg, xmm_scratch); |
2931 DeoptimizeIf(below, instr->environment()); | 2932 DeoptimizeIf(parity_even, instr->environment()); |
| 2933 __ j(below, &negative_sign, Label::kNear); |
2932 | 2934 |
2933 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 2935 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
2934 // Check for negative zero. | 2936 // Check for negative zero. |
2935 Label positive_sign; | 2937 Label positive_sign; |
2936 __ j(above, &positive_sign, Label::kNear); | 2938 __ j(above, &positive_sign, Label::kNear); |
2937 __ movmskpd(output_reg, input_reg); | 2939 __ movmskpd(output_reg, input_reg); |
2938 __ test(output_reg, Immediate(1)); | 2940 __ test(output_reg, Immediate(1)); |
2939 DeoptimizeIf(not_zero, instr->environment()); | 2941 DeoptimizeIf(not_zero, instr->environment()); |
2940 __ Set(output_reg, Immediate(0)); | 2942 __ Set(output_reg, Immediate(0)); |
2941 __ jmp(&done, Label::kNear); | 2943 __ jmp(&done, Label::kNear); |
2942 __ bind(&positive_sign); | 2944 __ bind(&positive_sign); |
2943 } | 2945 } |
2944 | 2946 |
2945 // Use truncating instruction (OK because input is positive). | 2947 // Use truncating instruction (OK because input is positive). |
2946 __ cvttsd2si(output_reg, Operand(input_reg)); | 2948 __ cvttsd2si(output_reg, Operand(input_reg)); |
2947 | |
2948 // Overflow is signalled with minint. | 2949 // Overflow is signalled with minint. |
2949 __ cmp(output_reg, 0x80000000u); | 2950 __ cmp(output_reg, 0x80000000u); |
2950 DeoptimizeIf(equal, instr->environment()); | 2951 DeoptimizeIf(equal, instr->environment()); |
| 2952 __ jmp(&done, Label::kNear); |
| 2953 |
| 2954 // Non-zero negative reaches here |
| 2955 __ bind(&negative_sign); |
| 2956 // Truncate, then compare and compensate |
| 2957 __ cvttsd2si(output_reg, Operand(input_reg)); |
| 2958 __ cvtsi2sd(xmm_scratch, output_reg); |
| 2959 __ ucomisd(input_reg, xmm_scratch); |
| 2960 __ j(equal, &done, Label::kNear); |
| 2961 __ sub(output_reg, Immediate(1)); |
| 2962 DeoptimizeIf(overflow, instr->environment()); |
| 2963 |
2951 __ bind(&done); | 2964 __ bind(&done); |
2952 } | 2965 } |
2953 } | 2966 } |
2954 | 2967 |
2955 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2968 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
2956 XMMRegister xmm_scratch = xmm0; | 2969 XMMRegister xmm_scratch = xmm0; |
2957 Register output_reg = ToRegister(instr->result()); | 2970 Register output_reg = ToRegister(instr->result()); |
2958 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 2971 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
2959 | 2972 |
2960 Label below_half, done; | 2973 Label below_half, done; |
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5025 FixedArray::kHeaderSize - kPointerSize)); | 5038 FixedArray::kHeaderSize - kPointerSize)); |
5026 __ bind(&done); | 5039 __ bind(&done); |
5027 } | 5040 } |
5028 | 5041 |
5029 | 5042 |
5030 #undef __ | 5043 #undef __ |
5031 | 5044 |
5032 } } // namespace v8::internal | 5045 } } // namespace v8::internal |
5033 | 5046 |
5034 #endif // V8_TARGET_ARCH_IA32 | 5047 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |