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 2996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3007 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 3007 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
3008 DeoptimizeIf(ne, instr->environment()); | 3008 DeoptimizeIf(ne, instr->environment()); |
3009 __ bind(&done); | 3009 __ bind(&done); |
3010 } | 3010 } |
3011 } | 3011 } |
3012 | 3012 |
3013 | 3013 |
3014 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 3014 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
3015 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); | 3015 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
3016 Register result = ToRegister(instr->result()); | 3016 Register result = ToRegister(instr->result()); |
3017 Register scratch1 = result; | 3017 Register scratch = scratch0(); |
3018 Register scratch2 = scratch0(); | |
3019 Label done, check_sign_on_zero; | 3018 Label done, check_sign_on_zero; |
3020 | 3019 |
3021 // Extract exponent bits. | 3020 // Extract exponent bits. |
3022 __ vmov(scratch1, input.high()); | 3021 __ vmov(result, input.high()); |
3023 __ ubfx(scratch2, | 3022 __ ubfx(scratch, |
3024 scratch1, | 3023 result, |
3025 HeapNumber::kExponentShift, | 3024 HeapNumber::kExponentShift, |
3026 HeapNumber::kExponentBits); | 3025 HeapNumber::kExponentBits); |
3027 | 3026 |
3028 // If the number is in ]-0.5, +0.5[, the result is +/- 0. | 3027 // If the number is in ]-0.5, +0.5[, the result is +/- 0. |
3029 __ cmp(scratch2, Operand(HeapNumber::kExponentBias - 2)); | 3028 __ cmp(scratch, Operand(HeapNumber::kExponentBias - 2)); |
3030 __ mov(result, Operand(0), LeaveCC, le); | 3029 __ mov(result, Operand(0), LeaveCC, le); |
3031 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3030 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3032 __ b(le, &check_sign_on_zero); | 3031 __ b(le, &check_sign_on_zero); |
3033 } else { | 3032 } else { |
3034 __ b(le, &done); | 3033 __ b(le, &done); |
3035 } | 3034 } |
3036 | 3035 |
3037 // The following conversion will not work with numbers | 3036 // The following conversion will not work with numbers |
3038 // outside of ]-2^32, 2^32[. | 3037 // outside of ]-2^32, 2^32[. |
3039 __ cmp(scratch2, Operand(HeapNumber::kExponentBias + 32)); | 3038 __ cmp(scratch, Operand(HeapNumber::kExponentBias + 32)); |
3040 DeoptimizeIf(ge, instr->environment()); | 3039 DeoptimizeIf(ge, instr->environment()); |
3041 | 3040 |
3042 // Save the original sign for later comparison. | 3041 // Save the original sign for later comparison. |
3043 __ and_(scratch2, scratch1, Operand(HeapNumber::kSignMask)); | 3042 __ and_(scratch, result, Operand(HeapNumber::kSignMask)); |
3044 | 3043 |
3045 __ Vmov(double_scratch0(), 0.5); | 3044 __ Vmov(double_scratch0(), 0.5); |
3046 __ vadd(input, input, double_scratch0()); | 3045 __ vadd(input, input, double_scratch0()); |
3047 | 3046 |
3048 // Check sign of the result: if the sign changed, the input | 3047 // Check sign of the result: if the sign changed, the input |
3049 // value was in ]0.5, 0[ and the result should be -0. | 3048 // value was in ]0.5, 0[ and the result should be -0. |
3050 __ vmov(scratch1, input.high()); | 3049 __ vmov(result, input.high()); |
3051 __ eor(scratch1, scratch1, Operand(scratch2), SetCC); | 3050 __ eor(result, result, Operand(scratch), SetCC); |
3052 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3051 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3053 DeoptimizeIf(mi, instr->environment()); | 3052 DeoptimizeIf(mi, instr->environment()); |
3054 } else { | 3053 } else { |
3055 __ mov(result, Operand(0), LeaveCC, mi); | 3054 __ mov(result, Operand(0), LeaveCC, mi); |
3056 __ b(mi, &done); | 3055 __ b(mi, &done); |
3057 } | 3056 } |
3058 | 3057 |
3059 __ EmitVFPTruncate(kRoundToMinusInf, | 3058 __ EmitVFPTruncate(kRoundToMinusInf, |
3060 double_scratch0().low(), | 3059 double_scratch0().low(), |
3061 input, | 3060 input, |
3062 scratch1, | 3061 result, |
3063 scratch2); | 3062 scratch); |
3064 DeoptimizeIf(ne, instr->environment()); | 3063 DeoptimizeIf(ne, instr->environment()); |
3065 __ vmov(result, double_scratch0().low()); | 3064 __ vmov(result, double_scratch0().low()); |
3066 | 3065 |
3067 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3066 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3068 // Test for -0. | 3067 // Test for -0. |
3069 __ cmp(result, Operand(0)); | 3068 __ cmp(result, Operand(0)); |
3070 __ b(ne, &done); | 3069 __ b(ne, &done); |
3071 __ bind(&check_sign_on_zero); | 3070 __ bind(&check_sign_on_zero); |
3072 __ vmov(scratch1, input.high()); | 3071 __ vmov(scratch, input.high()); |
3073 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 3072 __ tst(scratch, Operand(HeapNumber::kSignMask)); |
3074 DeoptimizeIf(ne, instr->environment()); | 3073 DeoptimizeIf(ne, instr->environment()); |
3075 } | 3074 } |
3076 __ bind(&done); | 3075 __ bind(&done); |
3077 } | 3076 } |
3078 | 3077 |
3079 | 3078 |
3080 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 3079 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
3081 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); | 3080 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
3082 DoubleRegister result = ToDoubleRegister(instr->result()); | 3081 DoubleRegister result = ToDoubleRegister(instr->result()); |
3083 __ vsqrt(result, input); | 3082 __ vsqrt(result, input); |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4571 ASSERT(osr_pc_offset_ == -1); | 4570 ASSERT(osr_pc_offset_ == -1); |
4572 osr_pc_offset_ = masm()->pc_offset(); | 4571 osr_pc_offset_ = masm()->pc_offset(); |
4573 } | 4572 } |
4574 | 4573 |
4575 | 4574 |
4576 | 4575 |
4577 | 4576 |
4578 #undef __ | 4577 #undef __ |
4579 | 4578 |
4580 } } // namespace v8::internal | 4579 } } // namespace v8::internal |
OLD | NEW |