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 2843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2854 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 2854 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
2855 DeoptimizeIf(ne, instr->environment()); | 2855 DeoptimizeIf(ne, instr->environment()); |
2856 __ bind(&done); | 2856 __ bind(&done); |
2857 } | 2857 } |
2858 } | 2858 } |
2859 | 2859 |
2860 | 2860 |
2861 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2861 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
2862 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); | 2862 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
2863 Register result = ToRegister(instr->result()); | 2863 Register result = ToRegister(instr->result()); |
2864 Register scratch1 = scratch0(); | 2864 Register scratch1 = ToRegister(instr->TempAt(0)); |
2865 Register scratch2 = result; | 2865 Register scratch2 = scratch0(); |
2866 __ EmitVFPTruncate(kRoundToNearest, | 2866 Register scratch3 = result; |
2867 Label done, check_sign_on_zero; | |
2868 | |
2869 // Extract exponent bits. | |
2870 __ vmov(scratch1, input.high()); | |
2871 __ ubfx(scratch3, | |
2872 scratch1, | |
2873 HeapNumber::kExponentShift, | |
2874 HeapNumber::kExponentBits); | |
2875 | |
2876 // If the number is in ]-0.5, +0.5[, the result is +/- 0. | |
2877 __ cmp(scratch3, Operand(HeapNumber::kExponentBias - 2)); | |
2878 __ mov(result, Operand(0), LeaveCC, le); | |
2879 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
2880 __ b(le, &check_sign_on_zero); | |
2881 } else { | |
2882 __ b(le, &done); | |
2883 } | |
2884 | |
2885 // The following conversion will not work with numbers | |
2886 // outside of ]-2^32, 2^32[. | |
2887 __ cmp(scratch3, Operand(HeapNumber::kExponentBias + 32)); | |
2888 DeoptimizeIf(ge, instr->environment()); | |
2889 | |
2890 // Save the original sign for later comparison. | |
2891 __ and_(scratch3, scratch1, Operand(HeapNumber::kSignMask)); | |
2892 | |
2893 // Construct and add 0.5 to the input. | |
Rodolph Perfetta
2011/04/15 09:37:54
there is a vmov immediate instruction which for 0.
Karl Klose
2011/04/15 11:26:06
Done.
| |
2894 __ mov(scratch1, Operand(0)); | |
2895 __ mov(scratch2, Operand(0x3FE00000)); | |
2896 __ vmov(double_scratch0(), scratch1, scratch2); | |
2897 __ vadd(input, input, double_scratch0()); | |
2898 | |
2899 // Check sign of the result: if the sign changed, the input | |
2900 // value was in ]0.5, 0[ and the result should be -0. | |
2901 __ vmov(scratch1, input.high()); | |
2902 __ and_(scratch1, scratch1, Operand(HeapNumber::kSignMask)); | |
Lasse Reichstein
2011/04/15 09:42:04
Just eor scratch3 with scratch1 and make sure it s
Karl Klose
2011/04/15 11:26:06
Done.
| |
2903 __ cmp(scratch1, scratch3); | |
2904 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
2905 DeoptimizeIf(ne, instr->environment()); | |
2906 } else { | |
2907 __ mov(result, Operand(0), LeaveCC, ne); | |
2908 __ b(ne, &done); | |
2909 } | |
2910 | |
2911 __ EmitVFPTruncate(kRoundToMinusInf, | |
2867 double_scratch0().low(), | 2912 double_scratch0().low(), |
2868 input, | 2913 input, |
2869 scratch1, | 2914 scratch1, |
2870 scratch2); | 2915 scratch2); |
2871 DeoptimizeIf(ne, instr->environment()); | 2916 DeoptimizeIf(ne, instr->environment()); |
2872 __ vmov(result, double_scratch0().low()); | 2917 __ vmov(result, double_scratch0().low()); |
2873 | 2918 |
2874 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 2919 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
2875 // Test for -0. | 2920 // Test for -0. |
2876 Label done; | |
2877 __ cmp(result, Operand(0)); | 2921 __ cmp(result, Operand(0)); |
2878 __ b(ne, &done); | 2922 __ b(ne, &done); |
2923 __ bind(&check_sign_on_zero); | |
2879 __ vmov(scratch1, input.high()); | 2924 __ vmov(scratch1, input.high()); |
2880 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 2925 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
2881 DeoptimizeIf(ne, instr->environment()); | 2926 DeoptimizeIf(ne, instr->environment()); |
2882 __ bind(&done); | |
2883 } | 2927 } |
2928 __ bind(&done); | |
2884 } | 2929 } |
2885 | 2930 |
2886 | 2931 |
2887 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2932 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
2888 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); | 2933 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
2889 ASSERT(ToDoubleRegister(instr->result()).is(input)); | 2934 ASSERT(ToDoubleRegister(instr->result()).is(input)); |
2890 __ vsqrt(input, input); | 2935 __ vsqrt(input, input); |
2891 } | 2936 } |
2892 | 2937 |
2893 | 2938 |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4198 ASSERT(!environment->HasBeenRegistered()); | 4243 ASSERT(!environment->HasBeenRegistered()); |
4199 RegisterEnvironmentForDeoptimization(environment); | 4244 RegisterEnvironmentForDeoptimization(environment); |
4200 ASSERT(osr_pc_offset_ == -1); | 4245 ASSERT(osr_pc_offset_ == -1); |
4201 osr_pc_offset_ = masm()->pc_offset(); | 4246 osr_pc_offset_ = masm()->pc_offset(); |
4202 } | 4247 } |
4203 | 4248 |
4204 | 4249 |
4205 #undef __ | 4250 #undef __ |
4206 | 4251 |
4207 } } // namespace v8::internal | 4252 } } // namespace v8::internal |
OLD | NEW |