Bug 226676

Summary: Optimize compareStrictEq when neither side is a double and at least one is neither a string nor a BigInt
Product: WebKit Reporter: Robin Morisset <rmorisset>
Component: JavaScriptCoreAssignee: Robin Morisset <rmorisset>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, fpizlo, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=226755
Bug Depends on:    
Bug Blocks: 226786, 227119    
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch none

Description Robin Morisset 2021-06-04 22:06:13 PDT
NaN === NaN must return false, even if the bits are the same.
42 === 42.0 must return true, even if the bits are different
"foo" === "foo" must return true, even if the bits of the pointers to the strings are different
42n === 42n must return true, even if the bits of the pointers to the big integers are different

In all other cases we can do === by just comparing the bits of the JSValue

So we should speculate aggressively on this. According to profiling done by Phil, this optimization should be applicable to lots of functions in Speedometer2.
Comment 1 Robin Morisset 2021-06-04 23:00:07 PDT
Created attachment 430646 [details]
Patch
Comment 2 Robin Morisset 2021-06-04 23:31:30 PDT
Comment on attachment 430646 [details]
Patch

I just realized that the optimization is wrong in the case of HeapBigInt/BigInt32 if they are allowed to be equal.

I will put a guard with #if !USE(BIGINT32) around the part in DFGFixupPhase, then whenever I restore BIGINT32 I will have to either fix this optimization, or (more and more likely in my opinion) add an invariant that we never have small HeapBigInts when BigInt32 are available.
Comment 3 Robin Morisset 2021-06-04 23:33:02 PDT
Comment on attachment 430646 [details]
Patch

I've also clearly broken the build on 32-bits, so taking this off the r? flag until I have fixed both problems.
Comment 4 Robin Morisset 2021-06-05 08:19:14 PDT
Created attachment 430649 [details]
Patch
Comment 5 Robin Morisset 2021-06-05 10:41:05 PDT
Created attachment 430651 [details]
Patch

Another attempt at fixing the 32-bit build.
Comment 6 Robin Morisset 2021-06-05 11:45:14 PDT
Created attachment 430654 [details]
Patch

Fixing yet another issue with 32-bits builds.
Comment 7 EWS 2021-06-07 12:55:36 PDT
Committed r278568 (238566@main): <https://commits.webkit.org/238566@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430654 [details].
Comment 8 Radar WebKit Bug Importer 2021-06-07 12:56:21 PDT
<rdar://problem/78959047>