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

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

Issue 10636057: Port r11517 (not deopt Math.floor on negative input) to x64, sse2. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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 | « src/x64/assembler-x64.h ('k') | test/mjsunit/math-floor-negative.js » ('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 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 3013 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 __ Integer32ToSmi(input_reg, input_reg); 3024 __ Integer32ToSmi(input_reg, input_reg);
3025 __ bind(deferred->exit()); 3025 __ bind(deferred->exit());
3026 } 3026 }
3027 } 3027 }
3028 3028
3029 3029
3030 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { 3030 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
3031 XMMRegister xmm_scratch = xmm0; 3031 XMMRegister xmm_scratch = xmm0;
3032 Register output_reg = ToRegister(instr->result()); 3032 Register output_reg = ToRegister(instr->result());
3033 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); 3033 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
3034 Label done;
3035 3034
3036 if (CpuFeatures::IsSupported(SSE4_1)) { 3035 if (CpuFeatures::IsSupported(SSE4_1)) {
3037 CpuFeatures::Scope scope(SSE4_1); 3036 CpuFeatures::Scope scope(SSE4_1);
3038 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3037 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3039 // Deoptimize if minus zero. 3038 // Deoptimize if minus zero.
3040 __ movq(output_reg, input_reg); 3039 __ movq(output_reg, input_reg);
3041 __ subq(output_reg, Immediate(1)); 3040 __ subq(output_reg, Immediate(1));
3042 DeoptimizeIf(overflow, instr->environment()); 3041 DeoptimizeIf(overflow, instr->environment());
3043 } 3042 }
3044 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown); 3043 __ roundsd(xmm_scratch, input_reg, Assembler::kRoundDown);
3045 __ cvttsd2si(output_reg, xmm_scratch); 3044 __ cvttsd2si(output_reg, xmm_scratch);
3046 __ cmpl(output_reg, Immediate(0x80000000)); 3045 __ cmpl(output_reg, Immediate(0x80000000));
3047 DeoptimizeIf(equal, instr->environment()); 3046 DeoptimizeIf(equal, instr->environment());
3048 } else { 3047 } else {
3048 Label negative_sign, done;
3049 // Deoptimize on negative inputs. 3049 // Deoptimize on negative inputs.
3050 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. 3050 __ xorps(xmm_scratch, xmm_scratch); // Zero the register.
3051 __ ucomisd(input_reg, xmm_scratch); 3051 __ ucomisd(input_reg, xmm_scratch);
3052 DeoptimizeIf(below, instr->environment()); 3052 DeoptimizeIf(parity_even, instr->environment());
3053 __ j(below, &negative_sign, Label::kNear);
3054
3053 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3055 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3054 // Check for negative zero. 3056 // Check for negative zero.
3055 Label positive_sign; 3057 Label positive_sign;
3056 __ j(above, &positive_sign, Label::kNear); 3058 __ j(above, &positive_sign, Label::kNear);
3057 __ movmskpd(output_reg, input_reg); 3059 __ movmskpd(output_reg, input_reg);
3058 __ testq(output_reg, Immediate(1)); 3060 __ testq(output_reg, Immediate(1));
3059 DeoptimizeIf(not_zero, instr->environment()); 3061 DeoptimizeIf(not_zero, instr->environment());
3060 __ Set(output_reg, 0); 3062 __ Set(output_reg, 0);
3061 __ jmp(&done); 3063 __ jmp(&done);
3062 __ bind(&positive_sign); 3064 __ bind(&positive_sign);
3063 } 3065 }
3064 3066
3065 // Use truncating instruction (OK because input is positive). 3067 // Use truncating instruction (OK because input is positive).
3066 __ cvttsd2si(output_reg, input_reg); 3068 __ cvttsd2si(output_reg, input_reg);
3067
3068 // Overflow is signalled with minint. 3069 // Overflow is signalled with minint.
3069 __ cmpl(output_reg, Immediate(0x80000000)); 3070 __ cmpl(output_reg, Immediate(0x80000000));
3070 DeoptimizeIf(equal, instr->environment()); 3071 DeoptimizeIf(equal, instr->environment());
3072 __ jmp(&done, Label::kNear);
3073
3074 // Non-zero negative reaches here.
3075 __ bind(&negative_sign);
3076 // Truncate, then compare and compensate.
3077 __ cvttsd2si(output_reg, input_reg);
3078 __ cvtlsi2sd(xmm_scratch, output_reg);
3079 __ ucomisd(input_reg, xmm_scratch);
3080 __ j(equal, &done, Label::kNear);
3081 __ subl(output_reg, Immediate(1));
3082 DeoptimizeIf(overflow, instr->environment());
3083
3084 __ bind(&done);
3071 } 3085 }
3072 __ bind(&done);
3073 } 3086 }
3074 3087
3075 3088
3076 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { 3089 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
3077 const XMMRegister xmm_scratch = xmm0; 3090 const XMMRegister xmm_scratch = xmm0;
3078 Register output_reg = ToRegister(instr->result()); 3091 Register output_reg = ToRegister(instr->result());
3079 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); 3092 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
3080 3093
3081 Label done; 3094 Label done;
3082 // xmm_scratch = 0.5 3095 // xmm_scratch = 0.5
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after
5035 FixedArray::kHeaderSize - kPointerSize)); 5048 FixedArray::kHeaderSize - kPointerSize));
5036 __ bind(&done); 5049 __ bind(&done);
5037 } 5050 }
5038 5051
5039 5052
5040 #undef __ 5053 #undef __
5041 5054
5042 } } // namespace v8::internal 5055 } } // namespace v8::internal
5043 5056
5044 #endif // V8_TARGET_ARCH_X64 5057 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | test/mjsunit/math-floor-negative.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698