Skip to content

Commit bca1d6b

Browse files
committed
Check fast path of Math.pow in interpreter to make the result consistent with JIT code
1 parent 3ef374a commit bca1d6b

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)