Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 6840051: ARM: Implement correct rounding in the lithium codegenerator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = result;
2865 Register scratch2 = result; 2865 Register scratch2 = scratch0();
2866 __ EmitVFPTruncate(kRoundToNearest, 2866 Label done, check_sign_on_zero;
2867
2868 // Extract exponent bits.
2869 __ vmov(scratch1, input.high());
2870 __ ubfx(scratch2,
2871 scratch1,
2872 HeapNumber::kExponentShift,
2873 HeapNumber::kExponentBits);
2874
2875 // If the number is in ]-0.5, +0.5[, the result is +/- 0.
2876 __ cmp(scratch2, Operand(HeapNumber::kExponentBias - 2));
2877 __ mov(result, Operand(0), LeaveCC, le);
2878 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2879 __ b(le, &check_sign_on_zero);
2880 } else {
2881 __ b(le, &done);
2882 }
2883
2884 // The following conversion will not work with numbers
2885 // outside of ]-2^32, 2^32[.
2886 __ cmp(scratch2, Operand(HeapNumber::kExponentBias + 32));
2887 DeoptimizeIf(ge, instr->environment());
2888
2889 // Save the original sign for later comparison.
2890 __ and_(scratch2, scratch1, Operand(HeapNumber::kSignMask));
2891
2892 __ vmov(double_scratch0(), 0.5);
2893 __ vadd(input, input, double_scratch0());
2894
2895 // Check sign of the result: if the sign changed, the input
2896 // value was in ]0.5, 0[ and the result should be -0.
2897 __ vmov(scratch1, input.high());
2898 __ eor(scratch1, scratch1, Operand(scratch2), SetCC);
2899 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2900 DeoptimizeIf(mi, instr->environment());
2901 } else {
2902 __ mov(result, Operand(0), LeaveCC, mi);
2903 __ b(mi, &done);
2904 }
2905
2906 __ EmitVFPTruncate(kRoundToMinusInf,
2867 double_scratch0().low(), 2907 double_scratch0().low(),
2868 input, 2908 input,
2869 scratch1, 2909 scratch1,
2870 scratch2); 2910 scratch2);
2871 DeoptimizeIf(ne, instr->environment()); 2911 DeoptimizeIf(ne, instr->environment());
2872 __ vmov(result, double_scratch0().low()); 2912 __ vmov(result, double_scratch0().low());
2873 2913
2874 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 2914 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2875 // Test for -0. 2915 // Test for -0.
2876 Label done;
2877 __ cmp(result, Operand(0)); 2916 __ cmp(result, Operand(0));
2878 __ b(ne, &done); 2917 __ b(ne, &done);
2918 __ bind(&check_sign_on_zero);
2879 __ vmov(scratch1, input.high()); 2919 __ vmov(scratch1, input.high());
2880 __ tst(scratch1, Operand(HeapNumber::kSignMask)); 2920 __ tst(scratch1, Operand(HeapNumber::kSignMask));
2881 DeoptimizeIf(ne, instr->environment()); 2921 DeoptimizeIf(ne, instr->environment());
2882 __ bind(&done);
2883 } 2922 }
2923 __ bind(&done);
2884 } 2924 }
2885 2925
2886 2926
2887 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { 2927 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) {
2888 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); 2928 DoubleRegister input = ToDoubleRegister(instr->InputAt(0));
2889 ASSERT(ToDoubleRegister(instr->result()).is(input)); 2929 ASSERT(ToDoubleRegister(instr->result()).is(input));
2890 __ vsqrt(input, input); 2930 __ vsqrt(input, input);
2891 } 2931 }
2892 2932
2893 2933
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
4198 ASSERT(!environment->HasBeenRegistered()); 4238 ASSERT(!environment->HasBeenRegistered());
4199 RegisterEnvironmentForDeoptimization(environment); 4239 RegisterEnvironmentForDeoptimization(environment);
4200 ASSERT(osr_pc_offset_ == -1); 4240 ASSERT(osr_pc_offset_ == -1);
4201 osr_pc_offset_ = masm()->pc_offset(); 4241 osr_pc_offset_ = masm()->pc_offset();
4202 } 4242 }
4203 4243
4204 4244
4205 #undef __ 4245 #undef __
4206 4246
4207 } } // namespace v8::internal 4247 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698