Bug 202767

Summary: GetByVal should use polymorphic access and hook into a status object
Product: WebKit Reporter: Saam Barati <saam>
Component: JavaScriptCoreAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, ews-watchlist, fpizlo, ggaren, gskachkov, guijemont, keith_miller, mark.lam, msaboff, rmorisset, ticaiolima, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 203693    
Bug Blocks: 203865, 203866, 204082, 204392    
Attachments:
Description Flags
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
none
WIP
ews-watchlist: commit-queue-
Archive of layout-test-results from ews214 for win-future
none
WIP
none
WIP
none
patch
none
patch
none
patch
none
patch
none
patch
none
patch
none
patch
none
patch
keith_miller: review+
patch for landing
none
patch for landing
none
Patch none

Description Saam Barati 2019-10-09 15:06:22 PDT
...
Comment 1 Saam Barati 2019-11-05 19:28:16 PST
Created attachment 382886 [details]
WIP
Comment 2 Saam Barati 2019-11-06 15:37:02 PST
Created attachment 382970 [details]
WIP
Comment 3 Saam Barati 2019-11-06 16:43:08 PST
Created attachment 382983 [details]
WIP

it cached some things
Comment 4 Saam Barati 2019-11-06 19:04:24 PST
Created attachment 383005 [details]
WIP
Comment 5 Saam Barati 2019-11-06 19:22:57 PST
Created attachment 383011 [details]
WIP
Comment 6 Saam Barati 2019-11-07 19:01:53 PST
Created attachment 383103 [details]
WIP

Works for strings and array loads.

Need to do:
- arguments object loads
- typed array loads
- string[index] loads
Comment 7 Saam Barati 2019-11-08 11:28:15 PST
Created attachment 383147 [details]
WIP
Comment 8 Saam Barati 2019-11-08 14:10:31 PST
Created attachment 383163 [details]
WIP

scoped/direct arguments loads work now
Comment 9 Saam Barati 2019-11-08 17:22:29 PST
Created attachment 383185 [details]
WIP

Implemented direct/scoped argumetns
Implemented typed arrays

Going to do strings next
Comment 10 Saam Barati 2019-11-08 18:37:10 PST
Created attachment 383191 [details]
WIP

ok, I think all the ICs are implemented. What's left to do:
1. make DFG/FTL emit this inline cache
2. hook into the status objects
Comment 11 Saam Barati 2019-11-11 12:10:58 PST
Created attachment 383286 [details]
WIP

Now handles symbol properties
Comment 12 Saam Barati 2019-11-11 14:35:32 PST
Created attachment 383300 [details]
WIP

piping it through DFG/FTL
Comment 13 Saam Barati 2019-11-11 15:08:24 PST
Created attachment 383305 [details]
WIP

I think it now works in all the tiers.
Comment 14 Saam Barati 2019-11-11 18:32:52 PST
Created attachment 383329 [details]
WIP

Fixed a bug where we did the wrong thing by loading a union member and used the wrong |this| :-(
Comment 15 Saam Barati 2019-11-11 19:16:16 PST
Created attachment 383332 [details]
WIP
Comment 16 Saam Barati 2019-11-12 10:54:57 PST
Created attachment 383366 [details]
WIP

Ok, it seems to pass all tests. Now I need to hook it into a status object and then I think it could be done
Comment 17 Saam Barati 2019-11-12 16:38:53 PST
Created attachment 383402 [details]
WIP

GetByIdStatus is starting to work
Comment 18 Saam Barati 2019-11-12 18:00:15 PST
Created attachment 383416 [details]
WIP

some renaming
Comment 19 Saam Barati 2019-11-13 17:19:00 PST
Created attachment 383524 [details]
WIP

It's almost done. Just looking into a bug that only happens with the concurrent JIT.
Comment 20 Saam Barati 2019-11-13 17:49:52 PST
Created attachment 383529 [details]
WIP
Comment 21 Saam Barati 2019-11-13 19:10:33 PST
Created attachment 383534 [details]
WIP
Comment 22 Saam Barati 2019-11-13 19:31:03 PST
Created attachment 383535 [details]
WIP
Comment 23 Saam Barati 2019-11-14 19:00:49 PST
Created attachment 383592 [details]
WIP

might be done. Just need to clean a few things up.
Comment 24 Saam Barati 2019-11-14 19:07:43 PST
Created attachment 383594 [details]
WIP

test EWS
Comment 25 Saam Barati 2019-11-14 19:18:32 PST
Created attachment 383595 [details]
WIP
Comment 26 EWS Watchlist 2019-11-14 23:37:37 PST
Comment on attachment 383595 [details]
WIP

Attachment 383595 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/13257609

New failing tests:
animations/no-style-recalc-during-accelerated-animation.html
fast/workers/worker-cloneport.html
Comment 27 EWS Watchlist 2019-11-14 23:37:41 PST
Created attachment 383604 [details]
Archive of layout-test-results from ews214 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews214  Port: win-future  Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Comment 28 Saam Barati 2019-11-15 12:29:55 PST
It’s neutral on JetStream2. Testing Speedometer2 now
Comment 29 Saam Barati 2019-11-15 15:51:45 PST
Seems like it's a 1% speedo2 regression. Investigating...
Comment 30 Saam Barati 2019-11-15 16:41:52 PST
Created attachment 383664 [details]
WIP
Comment 31 Saam Barati 2019-11-18 12:20:17 PST
I think I have fixed the speedometer2 regression
Comment 32 Saam Barati 2019-11-18 17:01:23 PST
Created attachment 383810 [details]
WIP
Comment 33 Saam Barati 2019-11-18 17:45:05 PST
Created attachment 383819 [details]
patch
Comment 34 Saam Barati 2019-11-18 17:50:03 PST
Created attachment 383821 [details]
patch
Comment 35 Saam Barati 2019-11-18 17:50:40 PST
I have some tests and microbenchmarks I will upload in a bit, but this patch is ready to be reviewed
Comment 36 Saam Barati 2019-11-18 17:52:26 PST
rebasing now
Comment 37 Saam Barati 2019-11-18 17:56:45 PST
Created attachment 383822 [details]
patch

rebased
Comment 38 Saam Barati 2019-11-18 17:59:24 PST
Created attachment 383824 [details]
patch
Comment 39 Saam Barati 2019-11-18 18:02:33 PST
Created attachment 383826 [details]
patch
Comment 40 Saam Barati 2019-11-18 18:19:32 PST
Created attachment 383831 [details]
patch

fix scoped arguments part after index masking being rolled out
Comment 41 Saam Barati 2019-11-19 12:06:08 PST
Created attachment 383892 [details]
patch
Comment 42 Saam Barati 2019-11-19 12:07:15 PST
Comment on attachment 383892 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383892&action=review

> Source/JavaScriptCore/bytecode/GetByStatus.cpp:345
> -    for (ICStatusContext* context : icContextStack) {
> +    if (icContextStack.size()) {

this old code seems clearly wrong. We're asking about ICs from the top most frame in random inline call frames (including possible doing OOB access on the instruction stream!). I'll verify with Phil if perhaps I'm missing something and there are cases where this helps.
Comment 43 Saam Barati 2019-11-19 13:50:32 PST
Created attachment 383901 [details]
patch

remove bad debug assert I forgot to delete
Comment 44 Keith Miller 2019-11-19 14:41:22 PST
Comment on attachment 383892 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383892&action=review

r=me with some comments.

> Source/JavaScriptCore/bytecode/AccessCase.cpp:734
> +            jit.loadPtr(MacroAssembler::Address(propertyGPR, JSString::offsetOfValue()), scratchGPR);

How do we know the string is uniqued? Do we always unique strings? Or do we always hit the slow path?

> Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp:464
> +    for (auto& accessCase : cases) {
> +        if (accessCase->needsScratchFPR()) {
> +            state.scratchFPR = allocator.allocateScratchFPR();
> +            break;
> +        }
> +    }

I doubt it matters but it seems like this could be a bit on the PolymorphicAccess itself.
Comment 45 Saam Barati 2019-11-19 14:51:35 PST
Comment on attachment 383892 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383892&action=review

>> Source/JavaScriptCore/bytecode/AccessCase.cpp:734
>> +            jit.loadPtr(MacroAssembler::Address(propertyGPR, JSString::offsetOfValue()), scratchGPR);
> 
> How do we know the string is uniqued? Do we always unique strings? Or do we always hit the slow path?

We know it's a unique string because it'll be pointer equal to the cached string of the access case. If it's not unique, we'll hit the slow path. (AccessCase stores a ref to a uniqued string implies)

>> Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp:464
>> +    }
> 
> I doubt it matters but it seems like this could be a bit on the PolymorphicAccess itself.

I don't think that's quite right, since this depends on the cases, which may change for the same polymorphic access instance.
Comment 46 Saam Barati 2019-11-19 19:11:16 PST
Created attachment 383936 [details]
patch for landing
Comment 47 Saam Barati 2019-11-19 19:13:04 PST
Created attachment 383937 [details]
patch for landing
Comment 48 WebKit Commit Bot 2019-11-19 21:53:49 PST
Comment on attachment 383937 [details]
patch for landing

Clearing flags on attachment: 383937

Committed r252684: <https://trac.webkit.org/changeset/252684>
Comment 49 WebKit Commit Bot 2019-11-19 21:53:52 PST
All reviewed patches have been landed.  Closing bug.
Comment 50 Radar WebKit Bug Importer 2019-11-19 21:54:25 PST
<rdar://problem/57348889>
Comment 51 Caio Lima 2019-11-21 11:04:54 PST
Reopening to attach new patch.
Comment 52 Caio Lima 2019-11-21 11:04:58 PST
Created attachment 384073 [details]
Patch
Comment 53 Saam Barati 2019-11-21 11:15:03 PST
(In reply to Caio Lima from comment #52)
> Created attachment 384073 [details]
> Patch

can we use a different bug for this?
Comment 54 Caio Lima 2019-11-21 11:47:50 PST
Comment on attachment 384073 [details]
Patch

Oops, uploaded to the wrong bug...