Commit 718ec5eb authored by yangguo@chromium.org's avatar yangguo@chromium.org

Handle negative number in Math.floor,ia32,non-SSE4.1 code path.

Zheng Liu
zheng.z.liu@intel.com

Review URL: https://chromiumcodereview.appspot.com/10168001
Patch from Zheng Liu <zheng.z.liu@intel.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11517 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 05c195bd
...@@ -2925,11 +2925,13 @@ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { ...@@ -2925,11 +2925,13 @@ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
__ cmp(output_reg, 0x80000000u); __ cmp(output_reg, 0x80000000u);
DeoptimizeIf(equal, instr->environment()); DeoptimizeIf(equal, instr->environment());
} else { } else {
Label negative_sign;
Label done; Label done;
// Deoptimize on negative numbers. // Deoptimize on unordered.
__ xorps(xmm_scratch, xmm_scratch); // Zero the register. __ xorps(xmm_scratch, xmm_scratch); // Zero the register.
__ ucomisd(input_reg, xmm_scratch); __ ucomisd(input_reg, xmm_scratch);
DeoptimizeIf(below, instr->environment()); DeoptimizeIf(parity_even, instr->environment());
__ j(below, &negative_sign, Label::kNear);
if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
// Check for negative zero. // Check for negative zero.
...@@ -2945,10 +2947,21 @@ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { ...@@ -2945,10 +2947,21 @@ void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
// Use truncating instruction (OK because input is positive). // Use truncating instruction (OK because input is positive).
__ cvttsd2si(output_reg, Operand(input_reg)); __ cvttsd2si(output_reg, Operand(input_reg));
// Overflow is signalled with minint. // Overflow is signalled with minint.
__ cmp(output_reg, 0x80000000u); __ cmp(output_reg, 0x80000000u);
DeoptimizeIf(equal, instr->environment()); DeoptimizeIf(equal, instr->environment());
__ jmp(&done, Label::kNear);
// Non-zero negative reaches here
__ bind(&negative_sign);
// Truncate, then compare and compensate
__ cvttsd2si(output_reg, Operand(input_reg));
__ cvtsi2sd(xmm_scratch, output_reg);
__ ucomisd(input_reg, xmm_scratch);
__ j(equal, &done, Label::kNear);
__ sub(output_reg, Immediate(1));
DeoptimizeIf(overflow, instr->environment());
__ bind(&done); __ bind(&done);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment