Skip to content
Permalink
Browse files
Do not install the VMTraps signal handler if Options::useJIT=false.
https://bugs.webkit.org/show_bug.cgi?id=212543
<rdar://problem/63772519>

Reviewed by Keith Miller.

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.

With this change, we no longer install any signal handling machinery if
Options::useJIT() is false.

Because we may still disable the JIT even if useJIT() is true (due to failure to
allocate JIT memory or a number of other factors), we will also add a check of
VM::canUseJIT() in initializeThreading(), and disable useJIT() if needed.  Of
course, this also means we need to call Options::recomputeDependentOptions() to
make other options consistent with useJIT() being false.

* runtime/InitializeThreading.cpp:
(JSC::initializeThreading):
* runtime/Options.cpp:
(JSC::disableAllJITOptions):
(JSC::Options::recomputeDependentOptions):
(JSC::recomputeDependentOptions): Deleted.
* runtime/Options.h:
* runtime/VMTraps.cpp:
(JSC::VMTraps::initializeSignals):
* tools/SigillCrashAnalyzer.cpp:
(JSC::SigillCrashAnalyzer::instance):



Canonical link: https://commits.webkit.org/225993@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263055 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Lam committed Jun 15, 2020
1 parent 788ef3a commit 0ae6aa264e2e2c6582a61b068021372489865bab
Showing 6 changed files with 61 additions and 10 deletions.
@@ -1,3 +1,35 @@
2020-06-15 Mark Lam <mark.lam@apple.com>

Do not install the VMTraps signal handler if Options::useJIT=false.
https://bugs.webkit.org/show_bug.cgi?id=212543
<rdar://problem/63772519>

Reviewed by Keith Miller.

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.

With this change, we no longer install any signal handling machinery if
Options::useJIT() is false.

Because we may still disable the JIT even if useJIT() is true (due to failure to
allocate JIT memory or a number of other factors), we will also add a check of
VM::canUseJIT() in initializeThreading(), and disable useJIT() if needed. Of
course, this also means we need to call Options::recomputeDependentOptions() to
make other options consistent with useJIT() being false.

* runtime/InitializeThreading.cpp:
(JSC::initializeThreading):
* runtime/Options.cpp:
(JSC::disableAllJITOptions):
(JSC::Options::recomputeDependentOptions):
(JSC::recomputeDependentOptions): Deleted.
* runtime/Options.h:
* runtime/VMTraps.cpp:
(JSC::VMTraps::initializeSignals):
* tools/SigillCrashAnalyzer.cpp:
(JSC::SigillCrashAnalyzer::instance):

2020-06-15 Keith Miller <keith_miller@apple.com>

CheckIsConstant should not use BadCache exit kind
@@ -66,8 +66,12 @@ void initializeThreading()

ExecutableAllocator::initialize();
VM::computeCanUseJIT();
if (!VM::canUseJIT()) {
Options::useJIT() = false;
Options::recomputeDependentOptions();
}

if (VM::canUseJIT() && Options::useSigillCrashAnalyzer())
if (Options::useSigillCrashAnalyzer())
enableSigillCrashAnalyzer();

LLInt::initialize();
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2019 Apple Inc. All rights reserved.
* Copyright (C) 2011-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -375,19 +375,24 @@ static void correctOptions()
Options::thresholdForGlobalLexicalBindingEpoch() = UINT_MAX;
}

static void recomputeDependentOptions()
static void disableAllJITOptions()
{
#if !defined(NDEBUG)
Options::validateDFGExceptionHandling() = true;
#endif
#if !ENABLE(JIT)
Options::useLLInt() = true;
Options::useJIT() = false;
Options::useBaselineJIT() = false;
Options::useDFGJIT() = false;
Options::useFTLJIT() = false;
Options::useDOMJIT() = false;
Options::useRegExpJIT() = false;
}

void Options::recomputeDependentOptions()
{
#if !defined(NDEBUG)
Options::validateDFGExceptionHandling() = true;
#endif
#if !ENABLE(JIT)
disableAllJITOptions();
#endif
#if !ENABLE(CONCURRENT_JS)
Options::useConcurrentJIT() = false;
@@ -407,9 +412,15 @@ static void recomputeDependentOptions()
Options::useConcurrentGC() = false;
#endif

// At initialization time, we may decide that useJIT should be false for any
// number of reasons (including failing to allocate JIT memory), and therefore,
// will / should not be able to enable any JIT related services.
if (!Options::useJIT()) {
disableAllJITOptions();
Options::useConcurrentJIT() = false;
Options::useSigillCrashAnalyzer() = false;
Options::useWebAssembly() = false;
Options::usePollingTraps() = true;
}

if (!jitEnabledByDefault() && !Options::useJIT())
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2019 Apple Inc. All rights reserved.
* Copyright (C) 2011-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -87,6 +87,7 @@ class Options {
JS_EXPORT_PRIVATE static void dumpAllOptionsInALine(StringBuilder&);

JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent();
static void recomputeDependentOptions();

#define DECLARE_OPTION_ACCESSORS(type_, name_, defaultValue_, availability_, description_) \
ALWAYS_INLINE static OptionsStorage::type_& name_() { return g_jscConfig.options.name_; } \
@@ -297,8 +297,10 @@ class VMTraps::SignalSender final : public AutomaticThread {
void VMTraps::initializeSignals()
{
#if ENABLE(SIGNAL_BASED_VM_TRAPS)
if (!Options::usePollingTraps())
if (!Options::usePollingTraps()) {
ASSERT(Options::useJIT());
SignalSender::initializeSignals();
}
#endif
}

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Apple Inc. All rights reserved.
* Copyright (C) 2017-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -199,6 +199,7 @@ SigillCrashAnalyzer& SigillCrashAnalyzer::instance()
static SigillCrashAnalyzer* analyzer;
static std::once_flag once;
std::call_once(once, [] {
ASSERT(Options::useJIT());
installCrashHandler();
analyzer = new SigillCrashAnalyzer;
});

0 comments on commit 0ae6aa2

Please sign in to comment.