Changeset 263117 in webkit


Ignore:
Timestamp:
Jun 16, 2020 2:30:06 PM (4 years ago)
Author:
mark.lam@apple.com
Message:

Make Options::useJIT() be the canonical source of truth on whether we should use the JIT.
https://bugs.webkit.org/show_bug.cgi?id=212556
<rdar://problem/63780436>

Reviewed by Saam Barati.

Source/JavaScriptCore:

After r263055, Options::useJIT() always equals VM::canUseJIT() after canUseJIT()
has been computed. This patch removes VM::canUseJIT(), and replaces all calls to
it with calls to Options::useJIT().

In the old code, VM::canUseJIT() would assert s_canUseJITIsSet to ensure that
its clients will not access s_canUseJIT before it is initialized. We not have an
equivalent mechanism with Options. This is how it works:

  1. There are 2 new Options flags in the g_jscConfig:

g_jscConfig.options.isFinalized
g_jscConfig.options.allowUnfinalizedAccess

g_jscConfig.options.isFinalized means that all Options values are finalized
i.e. initialization is complete and ready to be frozen in the Config.

g_jscConfig.options.isFinalized is set by initializeThreading() by calling
Options::finalize() once options initialization is complete.

g_jscConfig.options.allowUnfinalizedAccess is an allowance for clients to
access Options values before they are finalized. This is only needed in
options initialization code where Options values are read and written to.

g_jscConfig.options.allowUnfinalizedAccess is set and cleared using the
Options::AllowUnfinalizedAccessScope RAII object. The few pieces of code that
do options initialization will instantiate this scope object.

  1. All Options accessors (e.g. Option::useJIT()) will now assert that either g_jscConfig.options.allowUnfinalizedAccess or g_jscConfig.options.isFinalized is set.
  1. Since r263055, Options::recomputeDependentOptions() ensures that if useJIT() is false, all other JIT options (e.g. useBaselineJIT(), useDFTJIT(), useFTLJIT(), etc.) are also false. This patch also adds useBBQJIT() and useOMGJIT() to that list.

With this, checks for useJIT() are now redundant if there's also another JIT
option check, e.g. useRegExpJIT() or useDFGJIT(). When redundant, this patch
elides the useJIT() check (which used to be a VM::canUseJIT() check).

Ideally, we should also introduce a separate abstraction for requested option
values before finalization than the finalized option values that will be adopted
by the system. We'll do this as a separate exercise in a later patch.

  • API/tests/ExecutionTimeLimitTest.cpp:

(testExecutionTimeLimit):

  • API/tests/FunctionOverridesTest.cpp:

(testFunctionOverrides):

  • API/tests/PingPongStackOverflowTest.cpp:

(testPingPongStackOverflow):

  • Removed redundant calls to Options::initialize().
  • API/tests/testapi.c:

(main):

  • move the call to testExecutionTimeLimit() to after finalizeMultithreadedMultiVMExecutionTest() returns. This is because testExecutionTimeLimit() modifies JIT options at runtime as part of its testing. This can wreak havoc on the rest of the system that expects the options to be frozen. Ideally, we'll find a way for testExecutionTimeLimit() to do its work without changing JIT options, but that is not easy to do. For now, we'll just run it at the end as a workaround.
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::setNumParameters):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::numberOfArgumentValueProfiles):
(JSC::CodeBlock::valueProfileForArgument):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::isSupported):

  • heap/Heap.cpp:

(JSC::Heap::completeAllJITPlans):
(JSC::Heap::iterateExecutingAndCompilingCodeBlocks):
(JSC::Heap::gatherScratchBufferRoots):
(JSC::Heap::removeDeadCompilerWorklistEntries):
(JSC::Heap::stopThePeriphery):
(JSC::Heap::suspendCompilerThreads):
(JSC::Heap::resumeCompilerThreads):
(JSC::Heap::addCoreConstraints):

  • interpreter/AbstractPC.cpp:

(JSC::AbstractPC::AbstractPC):

  • jit/JITThunks.cpp:

(JSC::JITThunks::ctiNativeCall):
(JSC::JITThunks::ctiNativeConstruct):
(JSC::JITThunks::ctiNativeTailCall):
(JSC::JITThunks::ctiNativeTailCallWithoutSavedTags):
(JSC::JITThunks::ctiInternalFunctionCall):
(JSC::JITThunks::ctiInternalFunctionConstruct):
(JSC::JITThunks::hostFunctionStub):

  • jsc.cpp:

(CommandLine::parseArguments):
(jscmain):

  • llint/LLIntEntrypoint.cpp:

(JSC::LLInt::setFunctionEntrypoint):
(JSC::LLInt::setEvalEntrypoint):
(JSC::LLInt::setProgramEntrypoint):
(JSC::LLInt::setModuleProgramEntrypoint):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::shouldJIT):
(JSC::LLInt::jitCompileAndSetHeuristics):

  • runtime/InitializeThreading.cpp:

(JSC::initializeThreading):

  • runtime/JSCConfig.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::numberToStringWatchpointSet):

  • runtime/Options.cpp:

(JSC::jitEnabledByDefault):
(JSC::disableAllJITOptions):

(JSC::Options::initialize):

  • Move the calls to dumpOptionsIfNeeded() and ensureOptionsAreCoherent() to the end after all the options have been initialized because this where they belong.

(JSC::Options::finalize):
(JSC::Options::setOptions):
(JSC::Options::setOption):
(JSC::Options::dumpAllOptions):
(JSC::Options::ensureOptionsAreCoherent):

  • runtime/Options.h:

(JSC::Options::AllowUnfinalizedAccessScope::AllowUnfinalizedAccessScope):
(JSC::Options::AllowUnfinalizedAccessScope::~AllowUnfinalizedAccessScope):

  • runtime/OptionsList.h:
  • runtime/RegExp.cpp:

(JSC::RegExp::compile):
(JSC::RegExp::compileMatchOnly):

  • runtime/SymbolTable.h:

(JSC::SymbolTableEntry::isWatchable const):

  • runtime/VM.cpp:

(JSC::VM::computeCanUseJIT):
(JSC::VM::VM):
(JSC::VM::getHostFunction):
(JSC::VM::getCTIInternalFunctionTrampolineFor):

  • runtime/VM.h:

(JSC::VM::isInMiniMode):
(JSC::VM::canUseJIT): Deleted.

  • wasm/WasmCapabilities.h:

(JSC::Wasm::isSupported):

  • wasm/WasmOperations.cpp:

(JSC::Wasm::shouldJIT):

  • wasm/WasmSlowPaths.cpp:

(JSC::LLInt::shouldJIT):

Source/WebCore:

  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::compileSelector):

Source/WebKit:

  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::isJITEnabled):

Location:
trunk/Source
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp

    r261755 r263117  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    129129
    130130    JSC::initializeThreading();
    131     Options::initialize(); // Ensure options is initialized first.
    132131
    133132    for (auto tierOptions : tierOptionsList) {
  • trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp

    r261755 r263117  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939
    4040    JSC::initializeThreading();
    41     Options::initialize(); // Ensure options is initialized first.
    4241
    4342    const char* oldFunctionOverrides = Options::functionOverrides();
  • trunk/Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp

    r261755 r263117  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    118118
    119119    JSC::initializeThreading();
    120     Options::initialize(); // Ensure options is initialized first.
    121120
    122121    auto origSoftReservedZoneSize = Options::softReservedZoneSize();
  • trunk/Source/JavaScriptCore/API/tests/testapi.c

    r261755 r263117  
    11/*
    2  * Copyright (C) 2006-2019 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    21022102    }
    21032103    failed |= testTypedArrayCAPI();
    2104     failed |= testExecutionTimeLimit();
    21052104    failed |= testFunctionOverrides();
    21062105    failed |= testGlobalContextWithFinalizer();
     
    21572156
    21582157    failed = finalizeMultithreadedMultiVMExecutionTest() || failed;
     2158
     2159    // Don't run this till after the MultithreadedMultiVMExecutionTest has finished.
     2160    // This is because testExecutionTimeLimit() modifies JIT options at runtime
     2161    // as part of its testing. This can wreak havoc on the rest of the system that
     2162    // expects the options to be frozen. Ideally, we'll find a way for testExecutionTimeLimit()
     2163    // to do its work without changing JIT options, but that is not easy to do.
     2164    // For now, we'll just run it here at the end as a workaround.
     2165    failed |= testExecutionTimeLimit();
    21592166
    21602167    if (failed) {
  • trunk/Source/JavaScriptCore/ChangeLog

    r263116 r263117  
     12020-06-16  Mark Lam  <mark.lam@apple.com>
     2
     3        Make Options::useJIT() be the canonical source of truth on whether we should use the JIT.
     4        https://bugs.webkit.org/show_bug.cgi?id=212556
     5        <rdar://problem/63780436>
     6
     7        Reviewed by Saam Barati.
     8
     9        After r263055, Options::useJIT() always equals VM::canUseJIT() after canUseJIT()
     10        has been computed.  This patch removes VM::canUseJIT(), and replaces all calls to
     11        it with calls to Options::useJIT().
     12
     13        In the old code, VM::canUseJIT() would assert s_canUseJITIsSet to ensure that
     14        its clients will not access s_canUseJIT before it is initialized.  We not have an
     15        equivalent mechanism with Options.  This is how it works:
     16
     17        1. There are 2 new Options flags in the g_jscConfig:
     18                g_jscConfig.options.isFinalized
     19                g_jscConfig.options.allowUnfinalizedAccess
     20
     21           g_jscConfig.options.isFinalized means that all Options values are finalized
     22           i.e. initialization is complete and ready to be frozen in the Config.
     23
     24           g_jscConfig.options.isFinalized is set by initializeThreading() by calling
     25           Options::finalize() once options initialization is complete.
     26
     27           g_jscConfig.options.allowUnfinalizedAccess is an allowance for clients to
     28           access Options values before they are finalized.  This is only needed in
     29           options initialization code where Options values are read and written to.
     30
     31           g_jscConfig.options.allowUnfinalizedAccess is set and cleared using the
     32           Options::AllowUnfinalizedAccessScope RAII object.  The few pieces of code that
     33           do options initialization will instantiate this scope object.
     34
     35        2. All Options accessors (e.g. Option::useJIT()) will now assert that either
     36           g_jscConfig.options.allowUnfinalizedAccess or g_jscConfig.options.isFinalized
     37           is set.
     38
     39        3. Since r263055, Options::recomputeDependentOptions() ensures that if useJIT() is
     40           false, all other JIT options (e.g. useBaselineJIT(), useDFTJIT(), useFTLJIT(),
     41           etc.) are also false.  This patch also adds useBBQJIT() and useOMGJIT() to that
     42           list.
     43
     44           With this, checks for useJIT() are now redundant if there's also another JIT
     45           option check, e.g. useRegExpJIT() or useDFGJIT().  When redundant, this patch
     46           elides the useJIT() check (which used to be a VM::canUseJIT() check).
     47
     48        Ideally, we should also introduce a separate abstraction for requested option
     49        values before finalization than the finalized option values that will be adopted
     50        by the system.  We'll do this as a separate exercise in a later patch.
     51
     52        * API/tests/ExecutionTimeLimitTest.cpp:
     53        (testExecutionTimeLimit):
     54        * API/tests/FunctionOverridesTest.cpp:
     55        (testFunctionOverrides):
     56        * API/tests/PingPongStackOverflowTest.cpp:
     57        (testPingPongStackOverflow):
     58        - Removed redundant calls to Options::initialize().
     59
     60        * API/tests/testapi.c:
     61        (main):
     62        - move the call to testExecutionTimeLimit() to after finalizeMultithreadedMultiVMExecutionTest()
     63          returns.  This is because testExecutionTimeLimit() modifies JIT options at runtime
     64          as part of its testing.  This can wreak havoc on the rest of the system that expects
     65          the options to be frozen.  Ideally, we'll find a way for testExecutionTimeLimit() to
     66          do its work without changing JIT options, but that is not easy to do.  For now,
     67          we'll just run it at the end as a workaround.
     68
     69        * bytecode/CodeBlock.cpp:
     70        (JSC::CodeBlock::setNumParameters):
     71        * bytecode/CodeBlock.h:
     72        (JSC::CodeBlock::numberOfArgumentValueProfiles):
     73        (JSC::CodeBlock::valueProfileForArgument):
     74        * dfg/DFGCapabilities.cpp:
     75        (JSC::DFG::isSupported):
     76        * heap/Heap.cpp:
     77        (JSC::Heap::completeAllJITPlans):
     78        (JSC::Heap::iterateExecutingAndCompilingCodeBlocks):
     79        (JSC::Heap::gatherScratchBufferRoots):
     80        (JSC::Heap::removeDeadCompilerWorklistEntries):
     81        (JSC::Heap::stopThePeriphery):
     82        (JSC::Heap::suspendCompilerThreads):
     83        (JSC::Heap::resumeCompilerThreads):
     84        (JSC::Heap::addCoreConstraints):
     85        * interpreter/AbstractPC.cpp:
     86        (JSC::AbstractPC::AbstractPC):
     87        * jit/JITThunks.cpp:
     88        (JSC::JITThunks::ctiNativeCall):
     89        (JSC::JITThunks::ctiNativeConstruct):
     90        (JSC::JITThunks::ctiNativeTailCall):
     91        (JSC::JITThunks::ctiNativeTailCallWithoutSavedTags):
     92        (JSC::JITThunks::ctiInternalFunctionCall):
     93        (JSC::JITThunks::ctiInternalFunctionConstruct):
     94        (JSC::JITThunks::hostFunctionStub):
     95        * jsc.cpp:
     96        (CommandLine::parseArguments):
     97        (jscmain):
     98        * llint/LLIntEntrypoint.cpp:
     99        (JSC::LLInt::setFunctionEntrypoint):
     100        (JSC::LLInt::setEvalEntrypoint):
     101        (JSC::LLInt::setProgramEntrypoint):
     102        (JSC::LLInt::setModuleProgramEntrypoint):
     103        * llint/LLIntSlowPaths.cpp:
     104        (JSC::LLInt::shouldJIT):
     105        (JSC::LLInt::jitCompileAndSetHeuristics):
     106        * runtime/InitializeThreading.cpp:
     107        (JSC::initializeThreading):
     108        * runtime/JSCConfig.h:
     109        * runtime/JSGlobalObject.cpp:
     110        (JSC::JSGlobalObject::init):
     111        * runtime/JSGlobalObject.h:
     112        (JSC::JSGlobalObject::numberToStringWatchpointSet):
     113        * runtime/Options.cpp:
     114        (JSC::jitEnabledByDefault):
     115        (JSC::disableAllJITOptions):
     116
     117        (JSC::Options::initialize):
     118        - Move the calls to dumpOptionsIfNeeded() and ensureOptionsAreCoherent() to the
     119          end after all the options have been initialized because this where they belong.
     120
     121        (JSC::Options::finalize):
     122        (JSC::Options::setOptions):
     123        (JSC::Options::setOption):
     124        (JSC::Options::dumpAllOptions):
     125        (JSC::Options::ensureOptionsAreCoherent):
     126        * runtime/Options.h:
     127        (JSC::Options::AllowUnfinalizedAccessScope::AllowUnfinalizedAccessScope):
     128        (JSC::Options::AllowUnfinalizedAccessScope::~AllowUnfinalizedAccessScope):
     129        * runtime/OptionsList.h:
     130        * runtime/RegExp.cpp:
     131        (JSC::RegExp::compile):
     132        (JSC::RegExp::compileMatchOnly):
     133        * runtime/SymbolTable.h:
     134        (JSC::SymbolTableEntry::isWatchable const):
     135        * runtime/VM.cpp:
     136        (JSC::VM::computeCanUseJIT):
     137        (JSC::VM::VM):
     138        (JSC::VM::getHostFunction):
     139        (JSC::VM::getCTIInternalFunctionTrampolineFor):
     140        * runtime/VM.h:
     141        (JSC::VM::isInMiniMode):
     142        (JSC::VM::canUseJIT): Deleted.
     143        * wasm/WasmCapabilities.h:
     144        (JSC::Wasm::isSupported):
     145        * wasm/WasmOperations.cpp:
     146        (JSC::Wasm::shouldJIT):
     147        * wasm/WasmSlowPaths.cpp:
     148        (JSC::LLInt::shouldJIT):
     149
    11502020-06-16  Robin Morisset  <rmorisset@apple.com>
    2151
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r263035 r263117  
    949949    m_numParameters = newValue;
    950950
    951     m_argumentValueProfiles = RefCountedArray<ValueProfile>(vm().canUseJIT() ? newValue : 0);
     951    m_argumentValueProfiles = RefCountedArray<ValueProfile>(Options::useJIT() ? newValue : 0);
    952952}
    953953
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r262920 r263117  
    11/*
    2  * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
    44 *
     
    497497    {
    498498        ASSERT(m_numParameters >= 0);
    499         ASSERT(m_argumentValueProfiles.size() == static_cast<unsigned>(m_numParameters) || !vm().canUseJIT());
     499        ASSERT(m_argumentValueProfiles.size() == static_cast<unsigned>(m_numParameters) || !Options::useJIT());
    500500        return m_argumentValueProfiles.size();
    501501    }
     
    503503    ValueProfile& valueProfileForArgument(unsigned argumentIndex)
    504504    {
    505         ASSERT(vm().canUseJIT()); // This is only called from the various JIT compilers or places that first check numberOfArgumentValueProfiles before calling this.
     505        ASSERT(Options::useJIT()); // This is only called from the various JIT compilers or places that first check numberOfArgumentValueProfiles before calling this.
    506506        ValueProfile& result = m_argumentValueProfiles[argumentIndex];
    507507        return result;
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r263046 r263117  
    11/*
    2  * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737bool isSupported()
    3838{
    39     return VM::canUseJIT() && Options::useDFGJIT() && MacroAssembler::supportsFloatingPoint();
     39    return Options::useDFGJIT() && MacroAssembler::supportsFloatingPoint();
    4040}
    4141
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r263006 r263117  
    631631void Heap::completeAllJITPlans()
    632632{
    633     if (!VM::canUseJIT())
     633    if (!Options::useJIT())
    634634        return;
    635635#if ENABLE(JIT)
     
    643643{
    644644    m_codeBlocks->iterateCurrentlyExecuting(func);
    645     if (VM::canUseJIT())
     645    if (Options::useJIT())
    646646        DFG::iterateCodeBlocksForGC(m_vm, func);
    647647}
     
    702702{
    703703#if ENABLE(DFG_JIT)
    704     if (!VM::canUseJIT())
     704    if (!Options::useJIT())
    705705        return;
    706706    m_vm.gatherScratchBufferRoots(roots);
     
    722722{
    723723#if ENABLE(DFG_JIT)
    724     if (!VM::canUseJIT())
     724    if (!Options::useJIT())
    725725        return;
    726726    for (unsigned i = DFG::numberOfWorklists(); i--;)
     
    16391639
    16401640#if ENABLE(JIT)
    1641     if (VM::canUseJIT()) {
     1641    if (Options::useJIT()) {
    16421642        DeferGCForAWhile awhile(*this);
    16431643        if (JITWorklist::ensureGlobalWorklist().completeAllForVM(m_vm)
     
    21552155    // after we have suspended the ones that he had started before. That's not very expensive since
    21562156    // the worklists use AutomaticThreads anyway.
    2157     if (!VM::canUseJIT())
     2157    if (!Options::useJIT())
    21582158        return;
    21592159    for (unsigned i = DFG::numberOfWorklists(); i--;)
     
    23662366{
    23672367#if ENABLE(DFG_JIT)
    2368     if (!VM::canUseJIT())
     2368    if (!Options::useJIT())
    23692369        return;
    23702370    for (unsigned i = DFG::numberOfWorklists(); i--;)
     
    27162716                slotVisitor.append(conservativeRoots);
    27172717            }
    2718             if (VM::canUseJIT()) {
     2718            if (Options::useJIT()) {
    27192719                // JITStubRoutines must be visited after scanning ConservativeRoots since JITStubRoutines depend on the hook executed during gathering ConservativeRoots.
    27202720                SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::JITStubRoutines);
     
    28242824   
    28252825#if ENABLE(DFG_JIT)
    2826     if (VM::canUseJIT()) {
     2826    if (Options::useJIT()) {
    28272827        m_constraintSet->add(
    28282828            "Dw", "DFG Worklists",
  • trunk/Source/JavaScriptCore/interpreter/AbstractPC.cpp

    r261755 r263117  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3838   
    3939#if ENABLE(JIT)
    40     if (VM::canUseJIT()) {
     40    if (Options::useJIT()) {
    4141        m_pointer = callFrame->returnPC().value();
    4242        m_mode = JIT;
  • trunk/Source/JavaScriptCore/jit/JITThunks.cpp

    r261755 r263117  
    11/*
    2  * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9393MacroAssemblerCodePtr<JITThunkPtrTag> JITThunks::ctiNativeCall(VM& vm)
    9494{
    95     ASSERT(VM::canUseJIT());
     95    ASSERT(Options::useJIT());
    9696    return ctiStub(vm, nativeCallGenerator).code();
    9797}
     
    9999MacroAssemblerCodePtr<JITThunkPtrTag> JITThunks::ctiNativeConstruct(VM& vm)
    100100{
    101     ASSERT(VM::canUseJIT());
     101    ASSERT(Options::useJIT());
    102102    return ctiStub(vm, nativeConstructGenerator).code();
    103103}
     
    105105MacroAssemblerCodePtr<JITThunkPtrTag> JITThunks::ctiNativeTailCall(VM& vm)
    106106{
    107     ASSERT(VM::canUseJIT());
     107    ASSERT(Options::useJIT());
    108108    return ctiStub(vm, nativeTailCallGenerator).code();
    109109}
     
    111111MacroAssemblerCodePtr<JITThunkPtrTag> JITThunks::ctiNativeTailCallWithoutSavedTags(VM& vm)
    112112{
    113     ASSERT(VM::canUseJIT());
     113    ASSERT(Options::useJIT());
    114114    return ctiStub(vm, nativeTailCallWithoutSavedTagsGenerator).code();
    115115}
     
    117117MacroAssemblerCodePtr<JITThunkPtrTag> JITThunks::ctiInternalFunctionCall(VM& vm)
    118118{
    119     ASSERT(VM::canUseJIT());
     119    ASSERT(Options::useJIT());
    120120    return ctiStub(vm, internalFunctionCallGenerator).code();
    121121}
     
    123123MacroAssemblerCodePtr<JITThunkPtrTag> JITThunks::ctiInternalFunctionConstruct(VM& vm)
    124124{
    125     ASSERT(VM::canUseJIT());
     125    ASSERT(Options::useJIT());
    126126    return ctiStub(vm, internalFunctionConstructGenerator).code();
    127127}
     
    184184{
    185185    ASSERT(!isCompilationThread());   
    186     ASSERT(VM::canUseJIT());
     186    ASSERT(Options::useJIT());
    187187
    188188    auto hostFunctionKey = std::make_tuple(function, constructor, name);
  • trunk/Source/JavaScriptCore/jsc.cpp

    r263082 r263117  
    29262926void CommandLine::parseArguments(int argc, char** argv)
    29272927{
     2928    Options::AllowUnfinalizedAccessScope scope;
    29282929    Options::initialize();
    29292930   
     
    32423243    CommandLine options(argc, argv);
    32433244
    3244     processConfigFile(Options::configFile(), "jsc");
    3245     if (options.m_dump)
    3246         JSC::Options::dumpGeneratedBytecodes() = true;
     3245    {
     3246        Options::AllowUnfinalizedAccessScope scope;
     3247        processConfigFile(Options::configFile(), "jsc");
     3248        if (options.m_dump)
     3249            Options::dumpGeneratedBytecodes() = true;
     3250    }
    32473251
    32483252    // Initialize JSC before getting VM.
  • trunk/Source/JavaScriptCore/llint/LLIntEntrypoint.cpp

    r261895 r263117  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141   
    4242#if ENABLE(JIT)
    43     if (VM::canUseJIT()) {
     43    if (Options::useJIT()) {
    4444        if (kind == CodeForCall) {
    4545            static DirectJITCode* jitCode;
     
    8989{
    9090#if ENABLE(JIT)
    91     if (VM::canUseJIT()) {
     91    if (Options::useJIT()) {
    9292        static NativeJITCode* jitCode;
    9393        static std::once_flag onceKey;
     
    112112{
    113113#if ENABLE(JIT)
    114     if (VM::canUseJIT()) {
     114    if (Options::useJIT()) {
    115115        static NativeJITCode* jitCode;
    116116        static std::once_flag onceKey;
     
    135135{
    136136#if ENABLE(JIT)
    137     if (VM::canUseJIT()) {
     137    if (Options::useJIT()) {
    138138        static NativeJITCode* jitCode;
    139139        static std::once_flag onceKey;
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r262928 r263117  
    11/*
    2  * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    358358        return false;
    359359
    360     return VM::canUseJIT() && Options::useBaselineJIT();
     360    return Options::useBaselineJIT();
    361361}
    362362
     
    365365{
    366366    DeferGCForAWhile deferGC(vm.heap); // My callers don't set top callframe, so we don't want to GC here at all.
    367     ASSERT(VM::canUseJIT());
     367    ASSERT(Options::useJIT());
    368368   
    369369    codeBlock->updateAllValueProfilePredictions();
  • trunk/Source/JavaScriptCore/runtime/InitializeThreading.cpp

    r263055 r263117  
    6464        WriteBarrierCounters::initialize();
    6565#endif
    66 
    67         ExecutableAllocator::initialize();
    68         VM::computeCanUseJIT();
    69         if (!VM::canUseJIT()) {
    70             Options::useJIT() = false;
    71             Options::recomputeDependentOptions();
     66        {
     67            Options::AllowUnfinalizedAccessScope scope;
     68            ExecutableAllocator::initialize();
     69            VM::computeCanUseJIT();
     70            if (!g_jscConfig.vm.canUseJIT) {
     71                Options::useJIT() = false;
     72                Options::recomputeDependentOptions();
     73            }
    7274        }
     75        Options::finalize();
    7376
    7477        if (Options::useSigillCrashAnalyzer())
  • trunk/Source/JavaScriptCore/runtime/JSCConfig.h

    r262434 r263117  
    6565    bool initializeThreadingHasBeenCalled;
    6666
     67    struct {
     68#if ASSERT_ENABLED
     69        bool canUseJITIsSet;
     70#endif
     71        bool canUseJIT;
     72    } vm;
     73
    6774    ExecutableAllocator* executableAllocator;
    6875    FixedVMPoolExecutableAllocator* fixedVMPoolExecutableAllocator;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r263006 r263117  
    11/*
    2  * Copyright (C) 2007-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Cameron Zwarich (cwzwarich@uwaterloo.ca)
    44 *
     
    13501350
    13511351    // Unfortunately, the prototype objects of the builtin objects can be touched from concurrent compilers. So eagerly initialize them only if we use JIT.
    1352     if (VM::canUseJIT()) {
     1352    if (Options::useJIT()) {
    13531353        this->booleanPrototype();
    13541354        this->numberPrototype();
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r262827 r263117  
    465465    InlineWatchpointSet& numberToStringWatchpointSet()
    466466    {
    467         RELEASE_ASSERT(VM::canUseJIT());
     467        RELEASE_ASSERT(Options::useJIT());
    468468        return m_numberToStringWatchpointSet;
    469469    }
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r263055 r263117  
    220220}
    221221
    222 static bool jitEnabledByDefault()
     222static constexpr bool jitEnabledByDefault()
    223223{
    224224    return is32Bit() || isAddress64Bit();
     
    383383    Options::useDFGJIT() = false;
    384384    Options::useFTLJIT() = false;
     385    Options::useBBQJIT() = false;
     386    Options::useOMGJIT() = false;
    385387    Options::useDOMJIT() = false;
    386388    Options::useRegExpJIT() = false;
     
    568570        initializeOptionsOnceFlag,
    569571        [] {
     572            AllowUnfinalizedAccessScope scope;
     573
    570574            // Sanity check that options address computation is working.
    571575            RELEASE_ASSERT(Options::addressOfOption(useKernTCSMID) ==  &Options::useKernTCSM());
     
    632636            ASSERT(Options::criticalGCMemoryThreshold() > 0.0 && Options::criticalGCMemoryThreshold() < 1.0);
    633637
    634             dumpOptionsIfNeeded();
    635             ensureOptionsAreCoherent();
    636 
    637638#if HAVE(MACH_EXCEPTIONS)
    638639            if (Options::useMachForExceptions())
     
    664665                (hwPhysicalCPUMax() >= 4) && (hwL3CacheSize() >= static_cast<int64_t>(6 * MB));
    665666#endif
    666         });
     667
     668            // The following should only be done at the end after all options
     669            // have been initialized.
     670            dumpOptionsIfNeeded();
     671            ensureOptionsAreCoherent();
     672    });
    667673}
    668674
     
    695701}
    696702
     703void Options::finalize()
     704{
     705    ASSERT(!g_jscConfig.options.allowUnfinalizedAccess);
     706    g_jscConfig.options.isFinalized = true;
     707}
     708
    697709static bool isSeparator(char c)
    698710{
     
    702714bool Options::setOptions(const char* optionsStr)
    703715{
     716    AllowUnfinalizedAccessScope scope;
    704717    RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen());
    705718    Vector<char*> options;
     
    867880bool Options::setOption(const char* arg)
    868881{
     882    AllowUnfinalizedAccessScope scope;
    869883    bool success = setOptionWithoutAlias(arg);
    870884    if (success)
     
    877891    const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption dumpDefaultsOption)
    878892{
     893    AllowUnfinalizedAccessScope scope;
    879894    if (title) {
    880895        builder.append(title);
     
    979994void Options::ensureOptionsAreCoherent()
    980995{
     996    AllowUnfinalizedAccessScope scope;
    981997    bool coherent = true;
    982998    if (!(useLLInt() || useJIT())) {
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r263055 r263117  
    3030#include <stdint.h>
    3131#include <stdio.h>
     32#include <wtf/ForbidHeapAllocation.h>
     33#include <wtf/Noncopyable.h>
    3234#include <wtf/PrintStream.h>
    3335#include <wtf/StdLibExtras.h>
     
    7476    };
    7577
     78    class AllowUnfinalizedAccessScope {
     79        WTF_MAKE_NONCOPYABLE(AllowUnfinalizedAccessScope);
     80        WTF_FORBID_HEAP_ALLOCATION;
     81    public:
     82#if ASSERT_ENABLED
     83        AllowUnfinalizedAccessScope()
     84        {
     85            if (!g_jscConfig.options.isFinalized) {
     86                m_savedAllowUnfinalizedUse = g_jscConfig.options.allowUnfinalizedAccess;
     87                g_jscConfig.options.allowUnfinalizedAccess = true;
     88            }
     89        }
     90
     91        ~AllowUnfinalizedAccessScope()
     92        {
     93            if (!g_jscConfig.options.isFinalized)
     94                g_jscConfig.options.allowUnfinalizedAccess = m_savedAllowUnfinalizedUse;
     95        }
     96
     97    private:
     98        bool m_savedAllowUnfinalizedUse;
     99#else
     100        ALWAYS_INLINE AllowUnfinalizedAccessScope() = default;
     101        ALWAYS_INLINE ~AllowUnfinalizedAccessScope() { }
     102#endif
     103    };
     104
    76105    JS_EXPORT_PRIVATE static void initialize();
     106    static void finalize();
    77107
    78108    // Parses a string of options where each option is of the format "--<optionName>=<value>"
     
    91121
    92122#define DECLARE_OPTION_ACCESSORS(type_, name_, defaultValue_, availability_, description_) \
    93     ALWAYS_INLINE static OptionsStorage::type_& name_() { return g_jscConfig.options.name_; }  \
    94     ALWAYS_INLINE static OptionsStorage::type_& name_##Default() { return g_jscConfig.options.name_##Default; }
     123private: \
     124    ALWAYS_INLINE static OptionsStorage::type_& name_##Default() { return g_jscConfig.options.name_##Default; } \
     125public: \
     126    ALWAYS_INLINE static OptionsStorage::type_& name_() \
     127    { \
     128        ASSERT(g_jscConfig.options.allowUnfinalizedAccess || g_jscConfig.options.isFinalized); \
     129        return g_jscConfig.options.name_; \
     130    }
    95131
    96132    FOR_EACH_JSC_OPTION(DECLARE_OPTION_ACCESSORS)
  • trunk/Source/JavaScriptCore/runtime/OptionsList.h

    r263046 r263117  
    619619    using GCLogLevel = GCLogging::Level;
    620620
     621    bool allowUnfinalizedAccess;
     622    bool isFinalized;
     623
    621624#define DECLARE_OPTION(type_, name_, defaultValue_, availability_, description_) \
    622625    type_ name_; \
  • trunk/Source/JavaScriptCore/runtime/RegExp.cpp

    r261755 r263117  
    11/*
    22 *  Copyright (C) 1999-2001, 2004 Harri Porten (porten@kde.org)
    3  *  Copyright (c) 2007, 2008, 2016-2017 Apple Inc. All rights reserved.
     3 *  Copyright (c) 2007-2020 Apple Inc. All rights reserved.
    44 *  Copyright (C) 2009 Torch Mobile, Inc.
    55 *  Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged
     
    257257
    258258#if ENABLE(YARR_JIT)
    259     if (!pattern.containsUnsignedLengthPattern() && VM::canUseJIT() && Options::useRegExpJIT()
     259    if (!pattern.containsUnsignedLengthPattern() && Options::useRegExpJIT()
    260260#if !ENABLE(YARR_JIT_BACKREFERENCES)
    261261        && !pattern.m_containsBackreferences
     
    321321
    322322#if ENABLE(YARR_JIT)
    323     if (!pattern.containsUnsignedLengthPattern() && VM::canUseJIT() && Options::useRegExpJIT()
     323    if (!pattern.containsUnsignedLengthPattern() && Options::useRegExpJIT()
    324324#if !ENABLE(YARR_JIT_BACKREFERENCES)
    325325        && !pattern.m_containsBackreferences
  • trunk/Source/JavaScriptCore/runtime/SymbolTable.h

    r262613 r263117  
    232232    bool isWatchable() const
    233233    {
    234         return (m_bits & KindBitsMask) == ScopeKindBits && VM::canUseJIT();
     234        return (m_bits & KindBitsMask) == ScopeKindBits && Options::useJIT();
    235235    }
    236236   
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r263006 r263117  
    197197namespace JSC {
    198198
    199 #if ENABLE(JIT)
    200 #if ASSERT_ENABLED
    201 bool VM::s_canUseJITIsSet = false;
    202 #endif
    203 bool VM::s_canUseJIT = false;
    204 #endif
    205 
    206199Atomic<unsigned> VM::s_numberOfIDs;
    207200
     
    251244#if ENABLE(JIT)
    252245#if ASSERT_ENABLED
    253     RELEASE_ASSERT(!s_canUseJITIsSet);
    254     s_canUseJITIsSet = true;
    255 #endif
    256     s_canUseJIT = VM::canUseAssembler() && Options::useJIT();
     246    RELEASE_ASSERT(!g_jscConfig.vm.canUseJITIsSet);
     247    g_jscConfig.vm.canUseJITIsSet = true;
     248#endif
     249    g_jscConfig.vm.canUseJIT = VM::canUseAssembler() && Options::useJIT();
    257250#endif
    258251}
     
    468461
    469462    // Eagerly initialize constant cells since the concurrent compiler can access them.
    470     if (canUseJIT()) {
     463    if (Options::useJIT()) {
    471464        sentinelMapBucket();
    472465        sentinelSetBucket();
     
    548541#if ENABLE(JIT)
    549542    // Make sure that any stubs that the JIT is going to use are initialized in non-compilation threads.
    550     if (canUseJIT()) {
     543    if (Options::useJIT()) {
    551544        jitStubs = makeUnique<JITThunks>();
    552545#if ENABLE(FTL_JIT)
     
    798791{
    799792#if ENABLE(JIT)
    800     if (canUseJIT()) {
     793    if (Options::useJIT()) {
    801794        return jitStubs->hostFunctionStub(
    802795            *this, function, constructor,
     
    838831{
    839832#if ENABLE(JIT)
    840     if (canUseJIT()) {
     833    if (Options::useJIT()) {
    841834        if (kind == CodeForCall)
    842835            return jitStubs->ctiInternalFunctionCall(*this).retagged<JSEntryPtrTag>();
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r263006 r263117  
    790790    static bool isInMiniMode()
    791791    {
    792         return !canUseJIT() || Options::forceMiniVMMode();
     792        return !Options::useJIT() || Options::forceMiniVMMode();
    793793    }
    794794
     
    799799
    800800    static void computeCanUseJIT();
    801     ALWAYS_INLINE static bool canUseJIT()
    802     {
    803 #if ENABLE(JIT)
    804         ASSERT(s_canUseJITIsSet);
    805         return s_canUseJIT;
    806 #else
    807         return false;
    808 #endif
    809     }
    810801
    811802    SourceProviderCache* addSourceProviderCache(SourceProvider*);
     
    12341225    uintptr_t m_currentWeakRefVersion { 0 };
    12351226
    1236 #if ENABLE(JIT)
    1237 #if ASSERT_ENABLED
    1238     JS_EXPORT_PRIVATE static bool s_canUseJITIsSet;
    1239 #endif
    1240     JS_EXPORT_PRIVATE static bool s_canUseJIT;
    1241 #endif
    1242 
    12431227    VM* m_prev; // Required by DoublyLinkedListNode.
    12441228    VM* m_next; // Required by DoublyLinkedListNode.
  • trunk/Source/JavaScriptCore/wasm/WasmCapabilities.h

    r243312 r263117  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434inline bool isSupported()
    3535{
    36     return VM::canUseJIT() && Options::useWebAssembly();
     36    return Options::useWebAssembly();
    3737}
    3838
  • trunk/Source/JavaScriptCore/wasm/WasmOperations.cpp

    r261930 r263117  
    233233inline bool shouldJIT(unsigned functionIndex)
    234234{
    235     if (!VM::canUseJIT())
    236         return false;
    237235    if (!Options::useOMGJIT())
    238236        return false;
  • trunk/Source/JavaScriptCore/wasm/WasmSlowPaths.cpp

    r261755 r263117  
    8080inline bool shouldJIT(Wasm::FunctionCodeBlock* codeBlock, RequiredWasmJIT requiredJIT = RequiredWasmJIT::Any)
    8181{
    82     if (!VM::canUseJIT())
    83         return false;
    8482    if (requiredJIT == RequiredWasmJIT::OMG) {
    8583        if (!Options::useOMGJIT())
  • trunk/Source/WebCore/ChangeLog

    r263113 r263117  
     12020-06-16  Mark Lam  <mark.lam@apple.com>
     2
     3        Make Options::useJIT() be the canonical source of truth on whether we should use the JIT.
     4        https://bugs.webkit.org/show_bug.cgi?id=212556
     5        <rdar://problem/63780436>
     6
     7        Reviewed by Saam Barati.
     8
     9        * cssjit/SelectorCompiler.cpp:
     10        (WebCore::SelectorCompiler::compileSelector):
     11
    1122020-06-16  Sam Weinig  <weinig@apple.com>
    213
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r263049 r263117  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
    44 *
     
    401401    ASSERT(compiledSelector.status == SelectorCompilationStatus::NotCompiled);
    402402
    403     if (!JSC::VM::canUseJIT()) {
     403    if (!JSC::Options::useJIT()) {
    404404        compiledSelector.status = SelectorCompilationStatus::CannotCompile;
    405405        return;
  • trunk/Source/WebKit/ChangeLog

    r263112 r263117  
     12020-06-16  Mark Lam  <mark.lam@apple.com>
     2
     3        Make Options::useJIT() be the canonical source of truth on whether we should use the JIT.
     4        https://bugs.webkit.org/show_bug.cgi?id=212556
     5        <rdar://problem/63780436>
     6
     7        Reviewed by Saam Barati.
     8
     9        * WebProcess/WebProcess.cpp:
     10        (WebKit::WebProcess::isJITEnabled):
     11
    1122020-06-16  David Kilzer  <ddkilzer@apple.com>
    213
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r263094 r263117  
    10021002void WebProcess::isJITEnabled(CompletionHandler<void(bool)>&& completionHandler)
    10031003{
    1004     completionHandler(JSC::VM::canUseJIT());
     1004    completionHandler(JSC::Options::useJIT());
    10051005}
    10061006
Note: See TracChangeset for help on using the changeset viewer.