Skip to content

Commit f06dd7f

Browse files
committed
[MERGE #1396 @ThomsonTan] Check fast path of Math.pow in interpreter to make the result consistent with JIT code
Merge pull request #1396 from ThomsonTan:FixMathPowInconsistency Interpreter always go to slow path of Math.pow because the perf win is not substantial in interpreter, and but could give more accurate float point result. This leads to result inconsistency between JIT code and interpreter. This fix checks fast path in interpreter to make the result consistent.
2 parents 446e6cc + bca1d6b commit f06dd7f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/Runtime/Library/JavascriptNumber.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ namespace Js
283283
// For AMD64/ARM calling convention already uses SSE2/VFP registers so we don't have to use assembler.
284284
// We can't just use "if (0 == y)" because NaN compares
285285
// equal to 0 according to our compilers.
286+
int32 intY;
286287
if (0 == NumberUtilities::LuLoDbl(y) && 0 == (NumberUtilities::LuHiDbl(y) & 0x7FFFFFFF))
287288
{
288289
// pow(x, 0) = 1 even if x is NaN.
@@ -293,6 +294,11 @@ namespace Js
293294
// pow([+/-] 1, Infinity) = NaN according to javascript, but not for CRT pow.
294295
return JavascriptNumber::NaN;
295296
}
297+
else if (TryGetInt32Value(y, &intY))
298+
{
299+
// check fast path
300+
return DirectPowDoubleInt(x, intY);
301+
}
296302

297303
return ::pow(x, y);
298304
}

0 commit comments

Comments
 (0)