Bug 237306

Summary: Add a DeferTraps scope
Product: WebKit Reporter: Saam Barati <saam>
Component: JavaScriptCoreAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ews-watchlist, keith_miller, mark.lam, msaboff, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 237409    
Bug Blocks:    
Attachments:
Description Flags
patch
none
patch
none
patch
none
patch
none
patch
mark.lam: review+
patch for landing
none
patch none

Saam Barati
Reported 2022-02-28 20:05:37 PST
...
Attachments
patch (24.64 KB, patch)
2022-02-28 21:14 PST, Saam Barati
no flags
patch (24.64 KB, patch)
2022-02-28 21:17 PST, Saam Barati
no flags
patch (24.86 KB, patch)
2022-02-28 21:46 PST, Saam Barati
no flags
patch (25.17 KB, patch)
2022-02-28 21:48 PST, Saam Barati
no flags
patch (25.13 KB, patch)
2022-03-01 10:20 PST, Saam Barati
mark.lam: review+
patch for landing (24.97 KB, patch)
2022-03-01 18:00 PST, Saam Barati
no flags
patch (26.06 KB, patch)
2022-03-03 10:33 PST, Saam Barati
no flags
Saam Barati
Comment 1 2022-02-28 20:06:11 PST
Saam Barati
Comment 2 2022-02-28 21:14:40 PST
Saam Barati
Comment 3 2022-02-28 21:17:50 PST
Saam Barati
Comment 4 2022-02-28 21:46:07 PST
Saam Barati
Comment 5 2022-02-28 21:48:08 PST
Mark Lam
Comment 6 2022-02-28 22:03:19 PST
Comment on attachment 453475 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=453475&action=review > Source/JavaScriptCore/interpreter/InterpreterInlines.h:99 > + { nit: You can remove this inner { } since this is already in the DeferTraps scope and is at the tail end. > Source/JavaScriptCore/interpreter/InterpreterInlines.h:104 > + // Execute the code: > + throwScope.release(); I think it's more logical to group these 2 lines with the execute call below. There's no reason this needs to be here.
Saam Barati
Comment 7 2022-02-28 23:12:53 PST
Comment on attachment 453475 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=453475&action=review >> Source/JavaScriptCore/interpreter/InterpreterInlines.h:99 >> + { > > nit: You can remove this inner { } since this is already in the DeferTraps scope and is at the tail end. I think it’s nice to keep this isolated as is. It shows exactly the region of code we’re asserting against >> Source/JavaScriptCore/interpreter/InterpreterInlines.h:104 >> + throwScope.release(); > > I think it's more logical to group these 2 lines with the execute call below. There's no reason this needs to be here. If we make release() ever service traps we wouldn’t want to put it below. We want maximal things in this scope as long as we don’t recurse. Maybe we won’t ever make release() do that, but I see no downside to keeping it in here. An alternative I considered is to add a release() style function call to DeferTraps, and to use it in these types of situations so we have fewer scopes, but it seems a bit overkill
Mark Lam
Comment 8 2022-02-28 23:17:37 PST
Comment on attachment 453475 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=453475&action=review >>> Source/JavaScriptCore/interpreter/InterpreterInlines.h:99 >>> + { >> >> nit: You can remove this inner { } since this is already in the DeferTraps scope and is at the tail end. > > I think it’s nice to keep this isolated as is. It shows exactly the region of code we’re asserting against ok, SGTM. >>> Source/JavaScriptCore/interpreter/InterpreterInlines.h:104 >>> + throwScope.release(); >> >> I think it's more logical to group these 2 lines with the execute call below. There's no reason this needs to be here. > > If we make release() ever service traps we wouldn’t want to put it below. We want maximal things in this scope as long as we don’t recurse. Maybe we won’t ever make release() do that, but I see no downside to keeping it in here. An alternative I considered is to add a release() style function call to DeferTraps, and to use it in these types of situations so we have fewer scopes, but it seems a bit overkill ok.
Saam Barati
Comment 9 2022-03-01 10:20:12 PST
Created attachment 453509 [details] patch rebased
Mark Lam
Comment 10 2022-03-01 14:55:38 PST
Comment on attachment 453509 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=453509&action=review r=me > Source/JavaScriptCore/interpreter/Interpreter.cpp:955 > + DeferTraps deferTraps(vm); // We can't jettison this code if we're about to run it. nit: can you add a newline after this decl? > Source/JavaScriptCore/interpreter/Interpreter.cpp:1020 > + DeferTraps deferTraps(vm); // We can't jettison this code if we're about to run it. nit: can you add a newline after this decl? > Source/JavaScriptCore/interpreter/Interpreter.cpp:1311 > + DeferTraps deferTraps(vm); // We can't jettison this code if we're about to run it. nit: can you add a newline after this decl? > Source/JavaScriptCore/interpreter/Interpreter.cpp:1407 > // Execute the code: > throwScope.release(); You didn't put this ThrowScope::release() in the DeferScope unlike in `Interpreter::execute(CallFrameClosure& closure)` below. The same is true for all Interpreter execute functions above. Realistically, I don't think we will or should ever handle traps in ThrowScope::release() because on release builds, we rely on it being a no-op. I still think that it is the better idiom to keep the ThrowScope::release() close to the statement that the release applies to i.e. the execute. Also, the code reads more naturally this way. Regardless, let's make it consistent every where. > Source/JavaScriptCore/interpreter/InterpreterInlines.h:91 > + DeferTraps deferTraps(vm); // We can't jettison this code if we're about to run it. nit: can you add a newline after this decl?
Saam Barati
Comment 11 2022-03-01 18:00:30 PST
Created attachment 453557 [details] patch for landing
EWS
Comment 12 2022-03-01 19:43:53 PST
Committed r290717 (247964@main): <https://commits.webkit.org/247964@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 453557 [details].
WebKit Commit Bot
Comment 13 2022-03-02 23:06:12 PST
Re-opened since this is blocked by bug 237409
Saam Barati
Comment 14 2022-03-03 10:33:15 PST
Mark Lam
Comment 15 2022-03-03 10:36:53 PST
Comment on attachment 453759 [details] patch r=me
EWS
Comment 16 2022-03-03 11:52:40 PST
Committed r290788 (248030@main): <https://commits.webkit.org/248030@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 453759 [details].
Note You need to log in before you can comment on or make changes to this bug.