Revision: 10177
Author: [email protected]
Date: Tue Dec 6 05:14:46 2011
Log: Fixing mozilla test failures regarding Math.pow.
BUG=
TEST=
Review URL: http://codereview.chromium.org/8820011
http://code.google.com/p/v8/source/detail?r=10177
Modified:
/branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/test/mjsunit/math-pow.js
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Dec 6 03:56:56
2011
+++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Dec 6 05:14:46
2011
@@ -2997,7 +2997,7 @@
__ cmp(eax, Immediate(0x80000000u));
__ j(equal, &generic_runtime);
__ cvtsi2sd(xmm4, eax);
- __ ucomisd(xmm2, xmm4);
+ __ ucomisd(xmm2, xmm4); // Already ruled out NaNs for exponent.
__ j(equal, &int_exponent);
if (exponent_type_ == ON_STACK) {
@@ -3011,7 +3011,7 @@
__ movd(xmm4, ecx);
__ cvtss2sd(xmm4, xmm4);
// xmm4 now has 0.5.
- __ ucomisd(xmm4, xmm2);
+ __ ucomisd(xmm4, xmm2); // Already ruled out NaNs for exponent.
__ j(not_equal, ¬_plus_half, Label::kNear);
// Calculates square root of base. Check for the special case of
@@ -3022,7 +3022,10 @@
__ movd(xmm4, ecx);
__ cvtss2sd(xmm4, xmm4);
__ ucomisd(xmm1, xmm4);
+ // Comparing -Infinity with NaN results in "unordered", which sets
the
+ // zero flag as if both were equal. However, it also sets the carry
flag.
__ j(not_equal, &continue_sqrt, Label::kNear);
+ __ j(carry, &continue_sqrt, Label::kNear);
// Set result to Infinity in the special case.
__ xorps(xmm3, xmm3);
@@ -3042,7 +3045,7 @@
// Since xmm3 is 1 and xmm4 is 0.5 this is simply xmm4 - xmm3.
__ subsd(xmm4, xmm3);
// xmm4 now has -0.5.
- __ ucomisd(xmm4, xmm2);
+ __ ucomisd(xmm4, xmm2); // Already ruled out NaNs for exponent.
__ j(not_equal, &fast_power, Label::kNear);
// Calculates reciprocal of square root of base. Check for the
special
@@ -3053,7 +3056,10 @@
__ movd(xmm4, ecx);
__ cvtss2sd(xmm4, xmm4);
__ ucomisd(xmm1, xmm4);
+ // Comparing -Infinity with NaN results in "unordered", which sets
the
+ // zero flag as if both were equal. However, it also sets the carry
flag.
__ j(not_equal, &continue_rsqrt, Label::kNear);
+ __ j(carry, &continue_rsqrt, Label::kNear);
// Set result to 0 in the special case.
__ xorps(xmm3, xmm3);
@@ -3143,7 +3149,7 @@
// Test whether result is zero. Bail out to check for subnormal result.
// Due to subnormals, x^-y == (1/x)^y does not hold in all cases.
__ xorps(xmm2, xmm2);
- __ ucomisd(xmm2, xmm3);
+ __ ucomisd(xmm2, xmm3); // Result cannot be NaN.
__ j(equal, &double_int_runtime);
// Returning or bailing out.
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Dec 6
04:11:08 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Dec 6
05:14:46 2011
@@ -2970,7 +2970,10 @@
__ movd(xmm_scratch, scratch);
__ cvtss2sd(xmm_scratch, xmm_scratch);
__ ucomisd(input_reg, xmm_scratch);
+ // Comparing -Infinity with NaN results in "unordered", which sets the
+ // zero flag as if both were equal. However, it also sets the carry
flag.
__ j(not_equal, &sqrt, Label::kNear);
+ __ j(carry, &sqrt, Label::kNear);
// If input is -Infinity, return Infinity.
__ xorps(input_reg, input_reg);
__ subsd(input_reg, xmm_scratch);
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Dec 6
04:11:08 2011
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Dec 6
05:14:46 2011
@@ -2861,7 +2861,10 @@
__ movq(kScratchRegister, V8_INT64_C(0xFFF0000000000000),
RelocInfo::NONE);
__ movq(xmm_scratch, kScratchRegister);
__ ucomisd(xmm_scratch, input_reg);
+ // Comparing -Infinity with NaN results in "unordered", which sets the
+ // zero flag as if both were equal. However, it also sets the carry
flag.
__ j(not_equal, &sqrt, Label::kNear);
+ __ j(carry, &sqrt, Label::kNear);
// If input is -Infinity, return Infinity.
__ xorps(input_reg, input_reg);
__ subsd(input_reg, xmm_scratch);
=======================================
--- /branches/bleeding_edge/test/mjsunit/math-pow.js Tue Dec 6 01:20:00
2011
+++ /branches/bleeding_edge/test/mjsunit/math-pow.js Tue Dec 6 05:14:46
2011
@@ -140,6 +140,20 @@
assertEquals(NaN, Math.pow(-16, 0.5));
assertEquals(0.25, Math.pow(16, -0.5));
assertEquals(NaN, Math.pow(-16, -0.5));
+
+ // Tests from Mozilla 15.8.2.13.
+ assertEquals(2, Math.pow.length);
+ assertEquals(NaN, Math.pow());
+ assertEquals(1, Math.pow(null, null));
+ assertEquals(NaN, Math.pow(void 0, void 0));
+ assertEquals(1, Math.pow(true, false));
+ assertEquals(0, Math.pow(false, true));
+ assertEquals(Infinity, Math.pow(-Infinity, Infinity));
+ assertEquals(0, Math.pow(-Infinity, -Infinity));
+ assertEquals(1, Math.pow(0, 0));
+ assertEquals(0, Math.pow(0, Infinity));
+ assertEquals(NaN, Math.pow(NaN, 0.5));
+ assertEquals(NaN, Math.pow(NaN, -0.5));
// Tests from Sputnik S8.5_A13_T1.
assertTrue(
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev