Fixing MathPowHalf on ARM.

BUG=v8:397
TEST=regress-397.js

Review URL: http://codereview.chromium.org/8800009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10166 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2011-12-06 08:28:12 +00:00
parent 5bcb4d30ed
commit b37ee7bcce
2 changed files with 15 additions and 0 deletions

View File

@ -3097,9 +3097,19 @@ void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) {
void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) {
DoubleRegister input = ToDoubleRegister(instr->InputAt(0));
DoubleRegister result = ToDoubleRegister(instr->result());
// Note that according to ECMA-262 15.8.2.13:
// Math.pow(-Infinity, 0.5) == Infinity
// Math.sqrt(-Infinity) == NaN
Label done;
__ VFPCompareAndSetFlags(input, -V8_INFINITY);
__ vneg(result, input, eq);
__ b(&done, eq);
// Add +0 to convert -0 to +0.
__ vadd(result, input, kDoubleRegZero);
__ vsqrt(result, result);
__ bind(&done);
}

View File

@ -135,6 +135,11 @@ function test() {
assertEquals(+Infinity, Math.pow(-0, -0.6));
assertEquals(-Infinity, Math.pow(-0, -1));
assertEquals(-Infinity, Math.pow(-0, -10000000001));
assertEquals(4, Math.pow(16, 0.5));
assertEquals(NaN, Math.pow(-16, 0.5));
assertEquals(0.25, Math.pow(16, -0.5));
assertEquals(NaN, Math.pow(-16, -0.5));
// Tests from Sputnik S8.5_A13_T1.
assertTrue(