WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
234408
[JSC] OpPow should have a "small int exponent" fast path at lower tiers
https://bugs.webkit.org/show_bug.cgi?id=234408
Summary
[JSC] OpPow should have a "small int exponent" fast path at lower tiers
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
Details
Formatted Diff
Diff
Patch
(12.43 KB, patch)
2021-12-16 18:16 PST
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
Patch
(12.43 KB, patch)
2021-12-16 20:50 PST
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
Patch
(12.49 KB, patch)
2021-12-16 21:35 PST
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
Patch for landing
(12.36 KB, patch)
2021-12-18 23:17 PST
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Ross Kirsling
Comment 1
2021-12-16 15:31:53 PST
Created
attachment 447395
[details]
Patch
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
Created
attachment 447406
[details]
Patch
Ross Kirsling
Comment 4
2021-12-16 20:50:07 PST
Created
attachment 447418
[details]
Patch
Ross Kirsling
Comment 5
2021-12-16 21:35:26 PST
Created
attachment 447425
[details]
Patch
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)
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.)
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
<
rdar://problem/86680069
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug