RESOLVED FIXED 212543
Do not install the VMTraps signal handler if Options::useJIT=false.
https://bugs.webkit.org/show_bug.cgi?id=212543
Summary Do not install the VMTraps signal handler if Options::useJIT=false.
Mark Lam
Reported 2020-05-29 14:01:15 PDT
VMTraps is only needed for JITted code. Hence, if the JIT is disabled, we should set Options::usePollingTraps() to true to indicate that we won't be using VMTraps.
Attachments
proposed patch. (3.29 KB, patch)
2020-05-29 14:37 PDT, Mark Lam
saam: review+
proposed patch. (6.71 KB, patch)
2020-06-15 11:37 PDT, Mark Lam
keith_miller: review+
Radar WebKit Bug Importer
Comment 1 2020-05-29 14:01:40 PDT
Mark Lam
Comment 2 2020-05-29 14:37:34 PDT
Created attachment 400619 [details] proposed patch.
Saam Barati
Comment 3 2020-05-29 14:47:07 PDT
Comment on attachment 400619 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=400619&action=review > Source/JavaScriptCore/runtime/Options.cpp:413 > + Options::usePollingTraps() = true; why not actually look at vm.canUseJIT or whatever?
Saam Barati
Comment 4 2020-05-29 14:47:50 PDT
Comment on attachment 400619 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=400619&action=review > Source/JavaScriptCore/tools/SigillCrashAnalyzer.cpp:201 > + ASSERT(Options::useJIT()); and then relatedly, same check here.
Geoffrey Garen
Comment 5 2020-05-29 14:48:28 PDT
> Source/JavaScriptCore/runtime/VMTraps.cpp:299 > + if (!Options::usePollingTraps()) { > + ASSERT(Options::useJIT()); Could Options::usePollingTraps() check useJIT() explicitly instead? Seems better for Options::usePollingTraps() to always do the right thing, instead of having callers check whether it did the right thing or not in an ASSERT.
Saam Barati
Comment 6 2020-05-29 15:00:08 PDT
(In reply to Saam Barati from comment #3) > Comment on attachment 400619 [details] > proposed patch. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=400619&action=review > > > Source/JavaScriptCore/runtime/Options.cpp:413 > > + Options::usePollingTraps() = true; > > why not actually look at vm.canUseJIT or whatever? this is slightly tricky, since we rely on VM canUseJIT to be initialized after. I propose having "recomputeJITDependentOptions" that runs after we compute VM canUseJIT
Mark Lam
Comment 7 2020-05-29 15:05:46 PDT
(In reply to Geoffrey Garen from comment #5) > > Source/JavaScriptCore/runtime/VMTraps.cpp:299 > > + if (!Options::usePollingTraps()) { > > + ASSERT(Options::useJIT()); > > Could Options::usePollingTraps() check useJIT() explicitly instead? > > Seems better for Options::usePollingTraps() to always do the right thing, > instead of having callers check whether it did the right thing or not in an > ASSERT. That's what this patch is about: making Options::usePollingTraps() check useJIT(). Note: 1. if useJIT is true, then usePollingTraps is allowed to be true (for testing) or false (normal behavior). 2. if useJIT is false, then usePollingTraps should always be true (which is what this patch is making true).
Geoffrey Garen
Comment 8 2020-05-29 15:26:24 PDT
> 2. if useJIT is false, then usePollingTraps should always be true (which is > what this patch is making true). Currently, this condition is enforced by an assignment upon initialization and an ASSERT at a call site to verify that the assignment happened. I'm asking if this condition could be enforced by a direct check inside Options::usePollingTraps() instead. That way, the behavior is more local and encapsulated, and harder / impossible to get wrong.
Mark Lam
Comment 9 2020-05-29 15:35:28 PDT
(In reply to Geoffrey Garen from comment #8) > > 2. if useJIT is false, then usePollingTraps should always be true (which is > > what this patch is making true). > > Currently, this condition is enforced by an assignment upon initialization > and an ASSERT at a call site to verify that the assignment happened. I'm > asking if this condition could be enforced by a direct check inside > Options::usePollingTraps() instead. That way, the behavior is more local and > encapsulated, and harder / impossible to get wrong. OK. Can't do it in Options::usePollingTraps() literally (because this is an auto generated accessors to a bool somewhere), but I can just check both conditions there.
Mark Lam
Comment 10 2020-05-29 15:38:33 PDT
(In reply to Mark Lam from comment #9) > (In reply to Geoffrey Garen from comment #8) > > > 2. if useJIT is false, then usePollingTraps should always be true (which is > > > what this patch is making true). > > > > Currently, this condition is enforced by an assignment upon initialization > > and an ASSERT at a call site to verify that the assignment happened. I'm > > asking if this condition could be enforced by a direct check inside > > Options::usePollingTraps() instead. That way, the behavior is more local and > > encapsulated, and harder / impossible to get wrong. > > OK. Can't do it in Options::usePollingTraps() literally (because this is an > auto generated accessors to a bool somewhere), but I can just check both > conditions there. Still feels redundant though. Options::usePollingTraps() is the canonical switch for the VMTraps feature. The right thing to do is to set it properly and have less conditions. The assert is there for documentation of the contract in addition to the check.
Keith Miller
Comment 11 2020-06-15 11:16:04 PDT
FYI, I think I disabled the ensure-crash.js test on 32-bit since I couldn't figure out why my change to expected crashing tests wasn't working. You might want to reenable it with this patch.
Mark Lam
Comment 12 2020-06-15 11:17:24 PDT
(In reply to Keith Miller from comment #11) > FYI, I think I disabled the ensure-crash.js test on 32-bit since I couldn't > figure out why my change to expected crashing tests wasn't working. You > might want to reenable it with this patch. I'll investigate and re-enable it in a separate patch if appropriate. Will truly to land this one first today.
Mark Lam
Comment 13 2020-06-15 11:37:32 PDT
Created attachment 401916 [details] proposed patch.
Keith Miller
Comment 14 2020-06-15 12:55:04 PDT
Comment on attachment 401916 [details] proposed patch. r=me. Is the idea the following should always be true Options::useJIT() == VM::canUseJIT()?
Mark Lam
Comment 15 2020-06-15 12:56:26 PDT
(In reply to Keith Miller from comment #14) > Comment on attachment 401916 [details] > proposed patch. > > r=me. Is the idea the following should always be true Options::useJIT() == > VM::canUseJIT()? After this patch, yes. But I won't leave the use of VM::canUseJIT() in place for now. Will address that in a separate patch. Removing it is not trivial.
Mark Lam
Comment 16 2020-06-15 13:00:56 PDT
Thanks for the reviews. Landed in r263055: <http://trac.webkit.org/r263055>.
Note You need to log in before you can comment on or make changes to this bug.