Bug 234408

Summary: [JSC] OpPow should have a "small int exponent" fast path at lower tiers
Product: WebKit Reporter: Ross Kirsling <ross.kirsling>
Component: New BugsAssignee: Ross Kirsling <ross.kirsling>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Ross Kirsling
Reported 2021-12-16 15:27:02 PST
[JSC] OpPow should have a "small int exponent" fast path at lower tiers
Attachments
Patch (6.45 KB, patch)
2021-12-16 15:31 PST, Ross Kirsling
no flags
Patch (12.43 KB, patch)
2021-12-16 18:16 PST, Ross Kirsling
no flags
Patch (12.43 KB, patch)
2021-12-16 20:50 PST, Ross Kirsling
no flags
Patch (12.49 KB, patch)
2021-12-16 21:35 PST, Ross Kirsling
no flags
Patch for landing (12.36 KB, patch)
2021-12-18 23:17 PST, Ross Kirsling
no flags
Ross Kirsling
Comment 1 2021-12-16 15:31:53 PST
Yusuke Suzuki
Comment 2 2021-12-16 15:34:00 PST
Comment on attachment 447395 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447395&action=review > Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:1120 > + bigt t1, 1000, .slow Let's define 1000 as a constant in C++. And use `constexpr XXX` here. And in power implementation, we should use that constant too.
Ross Kirsling
Comment 3 2021-12-16 18:16:17 PST
Ross Kirsling
Comment 4 2021-12-16 20:50:07 PST
Ross Kirsling
Comment 5 2021-12-16 21:35:26 PST
Ross Kirsling
Comment 6 2021-12-16 22:07:18 PST
Comment on attachment 447425 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447425&action=review A couple of notes. > Source/JavaScriptCore/jit/JITArithmetic.cpp:496 > + addSlowCase(branch32(GreaterThan, rightRegs.payloadGPR(), TrustedImm32(maxExponentForIntegerMathPow))); I do wonder if maxExponentForIntegerMathPow should be 1024 instead of 1000. It hardly matters but it seems weird to use a base-10 threshold for bitshifting. > Source/JavaScriptCore/jit/JITArithmetic.cpp:-964 > -/* ------------------------------ END: OP_ADD, OP_SUB, OP_MUL, OP_POW ------------------------------ */ (Removing this since it's an END with no BEGIN and this file has not had an OP_POW.)
Ross Kirsling
Comment 7 2021-12-16 22:07:20 PST Comment hidden (obsolete)
Yusuke Suzuki
Comment 8 2021-12-18 22:14:26 PST
Comment on attachment 447425 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447425&action=review r=me > Source/JavaScriptCore/llint/LowLevelInterpreter64.asm:1341 > + addq numberTag, t0 What is the purpose of this addition? t0 is already 1, so just ci2ds is fine (it is not boxed double etc.). > JSTests/microbenchmarks/pow-double-int.js:7 > +for (let i = -50; i <= 50; i += 0.1) > + for (let j = 0; j <= 1000; j++) > + exponentiate(i, j); Can you add a test case getting Infinity, -Infinity, and NaN for double input?
Ross Kirsling
Comment 9 2021-12-18 23:16:29 PST
(In reply to Yusuke Suzuki from comment #8) > > Source/JavaScriptCore/llint/LowLevelInterpreter64.asm:1341 > > + addq numberTag, t0 > > What is the purpose of this addition? t0 is already 1, so just ci2ds is fine > (it is not boxed double etc.). Thanks for pointing this out -- I assumed that I needed it in order to do a double calculation with an immediate, but apparently I was wrong. > > JSTests/microbenchmarks/pow-double-int.js:7 > > +for (let i = -50; i <= 50; i += 0.1) > > + for (let j = 0; j <= 1000; j++) > > + exponentiate(i, j); > > Can you add a test case getting Infinity, -Infinity, and NaN for double > input? I think this is covered by the following: stress/pow-nan-behaviors.js stress/pow-with-constants.js But let me know if we need more.
Ross Kirsling
Comment 10 2021-12-18 23:17:00 PST
Created attachment 447541 [details] Patch for landing
EWS
Comment 11 2021-12-19 00:34:19 PST
Committed r287236 (245396@main): <https://commits.webkit.org/245396@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 447541 [details].
Radar WebKit Bug Importer
Comment 12 2021-12-19 00:35:19 PST
Note You need to log in before you can comment on or make changes to this bug.