Bug 202392 - [JSC] Thread JSGlobalObject* instead of ExecState*
Summary: [JSC] Thread JSGlobalObject* instead of ExecState*
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
: 134932 202340 (view as bug list)
Depends on: 202569
Blocks: 203274 203285 203290
  Show dependency treegraph
 
Reported: 2019-09-30 22:52 PDT by Yusuke Suzuki
Modified: 2023-03-27 11:44 PDT (History)
47 users (show)

See Also:


Attachments
Patch (4.82 MB, patch)
2019-10-10 17:54 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (4.82 MB, patch)
2019-10-10 21:06 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.32 MB, patch)
2019-10-16 21:40 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.32 MB, patch)
2019-10-16 21:56 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.32 MB, patch)
2019-10-16 22:02 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.32 MB, patch)
2019-10-16 22:18 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (3.65 MB, patch)
2019-10-16 22:35 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-16 23:47 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-16 23:52 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-17 01:22 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-17 14:20 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-17 16:25 PDT, Yusuke Suzuki
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews213 for win-future (14.30 MB, application/zip)
2019-10-17 19:24 PDT, EWS Watchlist
no flags Details
Patch (7.34 MB, patch)
2019-10-17 22:51 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-18 00:22 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.34 MB, patch)
2019-10-18 02:31 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.35 MB, patch)
2019-10-18 20:56 PDT, Yusuke Suzuki
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
Patch (7.35 MB, patch)
2019-10-21 12:58 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.36 MB, patch)
2019-10-21 16:45 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.36 MB, patch)
2019-10-21 17:51 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.36 MB, patch)
2019-10-21 18:06 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.36 MB, patch)
2019-10-21 18:16 PDT, Yusuke Suzuki
ggaren: review+
Details | Formatted Diff | Diff
Patch (7.36 MB, patch)
2019-10-21 21:21 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.38 MB, patch)
2019-10-22 00:29 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.38 MB, patch)
2019-10-22 01:11 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2019-09-30 22:52:23 PDT
But, it is super costly if we ends up calling lexicalGlobalObject().
So, we need to put JSGlobalObject* in JSFunction/InternalFunction. And trampoline for them will get objects and pass them to the host-function.
Then, the host-function signature is changed to `hostFunction(CallFrame*, JSGlobalObject*)`. CallFrame* is necessary since we still need to access thisValue, arguments etc. residing on the stack.
Comment 1 Yusuke Suzuki 2019-09-30 22:53:03 PDT
I think this is the simplest way given the followings

1. InternalFunction is not so many
2. sizeof(JSFunction) is 40. Increasing to 48 is OK.
Comment 2 Radar WebKit Bug Importer 2019-10-01 10:39:50 PDT
<rdar://problem/55881584>
Comment 3 Yusuke Suzuki 2019-10-04 00:45:48 PDT
The patch becomes too large, I'll spawn part of it.
Comment 4 Yusuke Suzuki 2019-10-10 17:54:51 PDT
Created attachment 380709 [details]
Patch
Comment 5 Yusuke Suzuki 2019-10-10 21:06:22 PDT
Created attachment 380719 [details]
Patch
Comment 6 Yusuke Suzuki 2019-10-16 21:40:30 PDT
Created attachment 381157 [details]
Patch
Comment 7 EWS Watchlist 2019-10-16 21:41:34 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 8 Yusuke Suzuki 2019-10-16 21:56:49 PDT
Created attachment 381160 [details]
Patch
Comment 9 Yusuke Suzuki 2019-10-16 22:02:31 PDT
Created attachment 381162 [details]
Patch
Comment 10 Yusuke Suzuki 2019-10-16 22:10:11 PDT
(In reply to Build Bot from comment #7)
> Thanks for the patch. If this patch contains new public API please make sure
> it follows the guidelines for new WebKit2 GTK+ API. See
> http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API

This is unrelated.
Comment 11 Yusuke Suzuki 2019-10-16 22:18:11 PDT
Created attachment 381163 [details]
Patch
Comment 12 Yusuke Suzuki 2019-10-16 22:35:19 PDT
Created attachment 381166 [details]
Patch
Comment 13 Yusuke Suzuki 2019-10-16 23:47:20 PDT
Created attachment 381172 [details]
Patch
Comment 14 Yusuke Suzuki 2019-10-16 23:52:40 PDT
Created attachment 381173 [details]
Patch
Comment 15 Yusuke Suzuki 2019-10-17 01:22:59 PDT
Created attachment 381179 [details]
Patch
Comment 16 Yusuke Suzuki 2019-10-17 14:20:54 PDT
Created attachment 381229 [details]
Patch
Comment 17 Yusuke Suzuki 2019-10-17 16:25:47 PDT
Created attachment 381246 [details]
Patch
Comment 18 EWS Watchlist 2019-10-17 19:24:36 PDT
Comment on attachment 381246 [details]
Patch

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

New failing tests:
fast/events/attribute-listener-cloned-from-frameless-doc-context-2.html
fast/events/attribute-listener-extracted-from-frameless-doc-context-2.html
fast/dom/HTMLObjectElement/object-as-frame.html
Comment 19 EWS Watchlist 2019-10-17 19:24:39 PDT
Created attachment 381259 [details]
Archive of layout-test-results from ews213 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews213  Port: win-future  Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Comment 20 Yusuke Suzuki 2019-10-17 22:51:12 PDT
Created attachment 381275 [details]
Patch
Comment 21 Yusuke Suzuki 2019-10-18 00:22:16 PDT
Created attachment 381282 [details]
Patch
Comment 22 Yusuke Suzuki 2019-10-18 02:31:43 PDT
Created attachment 381287 [details]
Patch
Comment 23 Yusuke Suzuki 2019-10-18 20:56:10 PDT
Created attachment 381365 [details]
Patch
Comment 24 EWS Watchlist 2019-10-18 23:37:49 PDT
Comment on attachment 381365 [details]
Patch

Attachment 381365 [details] did not pass jsc-ews (mac):
Output: https://webkit-queues.webkit.org/results/13150254

New failing tests:
apiTests
Comment 25 Yusuke Suzuki 2019-10-21 12:58:18 PDT
Created attachment 381431 [details]
Patch
Comment 26 Yusuke Suzuki 2019-10-21 16:45:36 PDT
Created attachment 381484 [details]
Patch
Comment 27 Yusuke Suzuki 2019-10-21 17:51:13 PDT
Created attachment 381488 [details]
Patch
Comment 28 Yusuke Suzuki 2019-10-21 18:06:02 PDT
Created attachment 381490 [details]
Patch
Comment 29 Yusuke Suzuki 2019-10-21 18:16:44 PDT
Created attachment 381492 [details]
Patch
Comment 30 Geoffrey Garen 2019-10-21 20:46:45 PDT
Comment on attachment 381492 [details]
Patch

r=me

This patch makes me happy. Good luck landing it :P.
Comment 31 Yusuke Suzuki 2019-10-21 20:59:50 PDT
(In reply to Geoffrey Garen from comment #30)
> Comment on attachment 381492 [details]
> Patch
> 
> r=me
> 
> This patch makes me happy. Good luck landing it :P.

This removes many of ExecState::vm() calls (we now call JSGlobalObject::vm() instead). And it allows us to use LargeAllocation for any JSCells, and then, it allows us to introduce lower tier of IsoSubspace allocation (similar to the thing done in IsoHeap). And... We start applying IsoSubspaces to all the JSObjects!
Comment 32 Yusuke Suzuki 2019-10-21 21:16:30 PDT
The JSC failure is due to my bug I added in the last patch (using COMPILER(GCC_OR_CLANG)). We should use `COMPILER(GCC_COMPATIBLE)`.
Comment 33 Yusuke Suzuki 2019-10-21 21:21:04 PDT
Created attachment 381507 [details]
Patch
Comment 34 Geoffrey Garen 2019-10-21 21:32:59 PDT
Another really nice feature of this patch is that it creates a clearer API to WebCore and WebKit programmers.
Comment 35 Keith Miller 2019-10-21 21:33:28 PDT
rs=me. I have a few comments from the parts that looked interesting: 

Can you explain the m_functionConstructor/m_regExpConstructor changes in JSGlobalObject in the ChangeLog? I'm guessing it was for a bug somewhere that was using the wrong value or something.

Can you add some comment to WebCore's ChangeLog explaining why we are making this change?

I also didn't know about `__builtin_frame_address`, which is pretty cool!
Comment 36 Yusuke Suzuki 2019-10-21 23:43:31 PDT
(In reply to Geoffrey Garen from comment #34)
> Another really nice feature of this patch is that it creates a clearer API
> to WebCore and WebKit programmers.

Yeah, we decouple lexical JSGlobalObject from CallFrame, making CallFrame actually just a CallFrame :)
Comment 37 Yusuke Suzuki 2019-10-21 23:44:16 PDT
(In reply to Keith Miller from comment #35)
> rs=me. I have a few comments from the parts that looked interesting: 
> 
> Can you explain the m_functionConstructor/m_regExpConstructor changes in
> JSGlobalObject in the ChangeLog? I'm guessing it was for a bug somewhere
> that was using the wrong value or something.

It is just used in some places to remove CallFrame* dependencies :) I'll note it.

> 
> Can you add some comment to WebCore's ChangeLog explaining why we are making
> this change?

Yeah :)

> 
> I also didn't know about `__builtin_frame_address`, which is pretty cool!
Comment 38 Yusuke Suzuki 2019-10-22 00:29:32 PDT
Created attachment 381517 [details]
Patch
Comment 39 Yusuke Suzuki 2019-10-22 01:11:52 PDT
Created attachment 381523 [details]
Patch
Comment 40 Yusuke Suzuki 2019-10-22 01:55:55 PDT
Hmm, I'm attempting to make 32bit JIT built, but seems that EWS for these builds is too slow, and I cannot get the result. I'll land this first and check the buildbot status after that, otherwise, this patch needs to be rebaselined forever...
Comment 41 Yusuke Suzuki 2019-10-22 02:25:01 PDT
Committed r251425: <https://trac.webkit.org/changeset/251425>
Comment 42 Yusuke Suzuki 2019-10-22 03:23:27 PDT
(In reply to Yusuke Suzuki from comment #40)
> Hmm, I'm attempting to make 32bit JIT built, but seems that EWS for these
> builds is too slow, and I cannot get the result. I'll land this first and
> check the buildbot status after that, otherwise, this patch needs to be
> rebaselined forever...

https://bugs.webkit.org/show_bug.cgi?id=203242
Comment 43 Saam Barati 2019-10-22 11:55:51 PDT
LGTM too
Comment 44 Yusuke Suzuki 2019-10-22 14:06:11 PDT
I'll do follow-up patch to improve things more.

1. Add more API tests using vm.topCallFrame related things from C++ world
2. Add assertions which makes DECLARE_CALL_FRAME safer
Comment 45 Yusuke Suzuki 2019-10-22 14:28:50 PDT
Committed r251459: <https://trac.webkit.org/changeset/251459>
Comment 46 Yusuke Suzuki 2019-10-22 14:35:40 PDT
(In reply to Yusuke Suzuki from comment #44)
> I'll do follow-up patch to improve things more.
> 
> 1. Add more API tests using vm.topCallFrame related things from C++ world
> 2. Add assertions which makes DECLARE_CALL_FRAME safer

Do this in https://bugs.webkit.org/show_bug.cgi?id=203274
Comment 47 Yusuke Suzuki 2019-10-22 22:19:22 PDT
Another stabilizing patch https://bugs.webkit.org/show_bug.cgi?id=203285
Comment 48 Pablo Saavedra 2019-10-23 07:30:20 PDT
(In reply to Yusuke Suzuki from comment #40)
> Hmm, I'm attempting to make 32bit JIT built, but seems that EWS for these
> builds is too slow, and I cannot get the result. I'll land this first and
> check the buildbot status after that, otherwise, this patch needs to be
> rebaselined forever...

(bug Reopened)

It seems that the EWS for are experimenting troubles. Unfortunately, it looks like the https://trac.webkit.org/r251425 is breaking the JSC test suite in https://build.webkit.org/waterfall?category=misc right now.

Hopefully you could take a look into this.
Comment 49 Zan Dobersek 2019-10-23 08:17:14 PDT
(In reply to Pablo Saavedra from comment #48)
> (In reply to Yusuke Suzuki from comment #40)
> > Hmm, I'm attempting to make 32bit JIT built, but seems that EWS for these
> > builds is too slow, and I cannot get the result. I'll land this first and
> > check the buildbot status after that, otherwise, this patch needs to be
> > rebaselined forever...
> 
> (bug Reopened)
> 
> It seems that the EWS for are experimenting troubles. Unfortunately, it
> looks like the https://trac.webkit.org/r251425 is breaking the JSC test
> suite in https://build.webkit.org/waterfall?category=misc right now.
> 
> Hopefully you could take a look into this.

The main issue from this patch is that there's a missing call to JIT::prepareCallOperation(VM&) in DFG::OSRExit::emitRestoreArguments() which would properly adjust the vm.topCallFrame value. This trips up OSR exits, resulting in crashes.

Besides that, there are other places in DFG where a call operation doesn't invoke prepareCallOperation(), but without any consequences.

I'd post a patch for it already, but r251468 broke things in a different way, so this is just a heads-up about the solution.
Comment 50 Yusuke Suzuki 2019-10-23 10:57:04 PDT
(In reply to Zan Dobersek from comment #49)
> (In reply to Pablo Saavedra from comment #48)
> > (In reply to Yusuke Suzuki from comment #40)
> > > Hmm, I'm attempting to make 32bit JIT built, but seems that EWS for these
> > > builds is too slow, and I cannot get the result. I'll land this first and
> > > check the buildbot status after that, otherwise, this patch needs to be
> > > rebaselined forever...
> > 
> > (bug Reopened)
> > 
> > It seems that the EWS for are experimenting troubles. Unfortunately, it
> > looks like the https://trac.webkit.org/r251425 is breaking the JSC test
> > suite in https://build.webkit.org/waterfall?category=misc right now.
> > 
> > Hopefully you could take a look into this.
> 
> The main issue from this patch is that there's a missing call to
> JIT::prepareCallOperation(VM&) in DFG::OSRExit::emitRestoreArguments() which
> would properly adjust the vm.topCallFrame value. This trips up OSR exits,
> resulting in crashes.
> 
> Besides that, there are other places in DFG where a call operation doesn't
> invoke prepareCallOperation(), but without any consequences.
> 
> I'd post a patch for it already, but r251468 broke things in a different
> way, so this is just a heads-up about the solution.

Thanks. I'm doing a bit mechanical way to find missing prepareCallOperation(VM&) in https://bugs.webkit.org/show_bug.cgi?id=203285
Can you try the part of this patch in your local 32bit JIT machine and test it?
Comment 51 Yusuke Suzuki 2019-10-23 16:37:09 PDT
32bit issues will be fixed in bug 203285
Comment 52 Yusuke Suzuki 2019-11-20 01:13:54 PST
*** Bug 134932 has been marked as a duplicate of this bug. ***
Comment 53 Yusuke Suzuki 2019-11-20 01:14:18 PST
*** Bug 202340 has been marked as a duplicate of this bug. ***
Comment 54 EWS 2023-03-27 11:44:14 PDT
Committed 262166@main (7a682381645f): <https://commits.webkit.org/262166@main>

Reviewed commits have been landed. Closing PR #11084 and removing active labels.