Changeset 256500 in webkit


Ignore:
Timestamp:
Feb 12, 2020 8:11:51 PM (4 years ago)
Author:
mark.lam@apple.com
Message:

Add options for debugging WASM code.
https://bugs.webkit.org/show_bug.cgi?id=207677
<rdar://problem/59411390>

Reviewed by Yusuke Suzuki.

Specifically ...

JSC_useBBQJIT - allows the BBQ JIT to be used if true
JSC_useOMGJIT - allows the OMG JIT to be used if true
JSC_useWasmLLIntPrologueOSR - allows prologue OSR from Wasm LLInt if true
JSC_useWasmLLIntLoopOSR - allows loop OSR from Wasm LLInt if true
JSC_useWasmLLIntEpilogueOSR - allows epilogue OSR from Wasm LLInt if true
JSC_wasmFunctionIndexRangeToCompile=N:M - wasm function index range to allow compilation on, e.g. 1:100

(JSC::Options::ensureOptionsAreCoherent):

  • runtime/OptionsList.h:
  • wasm/WasmBBQPlan.cpp:

(JSC::Wasm::BBQPlan::BBQPlan):

  • wasm/WasmOMGForOSREntryPlan.cpp:

(JSC::Wasm::OMGForOSREntryPlan::OMGForOSREntryPlan):

  • wasm/WasmOMGPlan.cpp:

(JSC::Wasm::OMGPlan::OMGPlan):

  • wasm/WasmOperations.cpp:

(JSC::Wasm::shouldJIT):
(JSC::Wasm::operationWasmTriggerOSREntryNow):
(JSC::Wasm::operationWasmTriggerTierUpNow):

  • wasm/WasmSlowPaths.cpp:

(JSC::LLInt::shouldJIT):
(JSC::LLInt::WASM_SLOW_PATH_DECL):

Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r256498 r256500  
     12020-02-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Add options for debugging WASM code.
     4        https://bugs.webkit.org/show_bug.cgi?id=207677
     5        <rdar://problem/59411390>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        Specifically ...
     10
     11            JSC_useBBQJIT                            - allows the BBQ JIT to be used if true
     12            JSC_useOMGJIT                            - allows the OMG JIT to be used if true
     13            JSC_useWasmLLIntPrologueOSR              - allows prologue OSR from Wasm LLInt if true
     14            JSC_useWasmLLIntLoopOSR                  - allows loop OSR from Wasm LLInt if true
     15            JSC_useWasmLLIntEpilogueOSR              - allows epilogue OSR from Wasm LLInt if true
     16            JSC_wasmFunctionIndexRangeToCompile=N:M  - wasm function index range to allow compilation on, e.g. 1:100
     17
     18        * JavaScriptCore.xcodeproj/project.pbxproj:
     19        * runtime/Options.cpp:
     20        (JSC::Options::ensureOptionsAreCoherent):
     21        * runtime/OptionsList.h:
     22        * wasm/WasmBBQPlan.cpp:
     23        (JSC::Wasm::BBQPlan::BBQPlan):
     24        * wasm/WasmOMGForOSREntryPlan.cpp:
     25        (JSC::Wasm::OMGForOSREntryPlan::OMGForOSREntryPlan):
     26        * wasm/WasmOMGPlan.cpp:
     27        (JSC::Wasm::OMGPlan::OMGPlan):
     28        * wasm/WasmOperations.cpp:
     29        (JSC::Wasm::shouldJIT):
     30        (JSC::Wasm::operationWasmTriggerOSREntryNow):
     31        (JSC::Wasm::operationWasmTriggerTierUpNow):
     32        * wasm/WasmSlowPaths.cpp:
     33        (JSC::LLInt::shouldJIT):
     34        (JSC::LLInt::WASM_SLOW_PATH_DECL):
     35
    1362020-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
    237
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r255687 r256500  
    50745074                F692A8870255597D01FF60F7 /* JSCJSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCJSValue.cpp; sourceTree = "<group>"; tabWidth = 8; };
    50755075                F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSourceCode.cpp; sourceTree = "<group>"; };
     5076                FE00262223F3AF33003A358F /* WebAssembly.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; name = WebAssembly.asm; path = llint/WebAssembly.asm; sourceTree = "<group>"; };
    50765077                FE086BC92123DEFA003F2929 /* EntryFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EntryFrame.h; sourceTree = "<group>"; };
    50775078                FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExecutionTimeLimitTest.cpp; path = API/tests/ExecutionTimeLimitTest.cpp; sourceTree = "<group>"; };
     
    54775478                                86A054471556451B00445157 /* LowLevelInterpreter32_64.asm */,
    54785479                                86A054481556451B00445157 /* LowLevelInterpreter64.asm */,
     5480                                FE00262223F3AF33003A358F /* WebAssembly.asm */,
    54795481                        );
    54805482                        name = llint;
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r254735 r256500  
    950950        dataLog("INCOHERENT OPTIONS: at least one of useLLInt or useJIT must be true\n");
    951951    }
     952    if (useWebAssembly() && !(useWasmLLInt() || useBBQJIT())) {
     953        coherent = false;
     954        dataLog("INCOHERENT OPTIONS: at least one of useWasmLLInt or useBBQJIT must be true\n");
     955    }
    952956    if (!coherent)
    953957        CRASH();
  • trunk/Source/JavaScriptCore/runtime/OptionsList.h

    r255897 r256500  
    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
     
    468468    v(Bool, wasmBBQUsesAir, true, Normal, nullptr) \
    469469    v(Bool, useWasmLLInt, true, Normal, nullptr) \
     470    v(Bool, useBBQJIT, true, Normal, "allows the BBQ JIT to be used if true") \
     471    v(Bool, useOMGJIT, true, Normal, "allows the OMG JIT to be used if true") \
     472    v(Bool, useWasmLLIntPrologueOSR, true, Normal, "allows prologue OSR from Wasm LLInt if true") \
     473    v(Bool, useWasmLLIntLoopOSR, true, Normal, "allows loop OSR from Wasm LLInt if true") \
     474    v(Bool, useWasmLLIntEpilogueOSR, true, Normal, "allows epilogue OSR from Wasm LLInt if true") \
     475    v(OptionRange, wasmFunctionIndexRangeToCompile, 0, Normal, "wasm function index range to allow compilation on, e.g. 1:100") \
    470476    v(Bool, wasmLLIntTiersUpToBBQ, true, Normal, nullptr) \
    471477    v(Size, webAssemblyBBQAirModeThreshold, isIOS() ? (10 * MB) : 0, Normal, "If 0, we always use BBQ Air. If Wasm module code size hits this threshold, we compile Wasm module with B3 BBQ mode.") \
  • trunk/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp

    r253314 r256500  
    11/*
    2  * Copyright (C) 2016-2019 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
     
    5959    , m_functionIndex(functionIndex)
    6060{
     61    ASSERT(Options::useBBQJIT());
    6162    setMode(m_codeBlock->mode());
     63    dataLogLnIf(WasmBBQPlanInternal::verbose, "Starting BBQ plan for ", functionIndex);
    6264}
    6365
  • trunk/Source/JavaScriptCore/wasm/WasmOMGForOSREntryPlan.cpp

    r253314 r256500  
    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
     
    6262    , m_loopIndex(loopIndex)
    6363{
     64    ASSERT(Options::useOMGJIT());
    6465    setMode(mode);
    6566    ASSERT(m_codeBlock->runnable());
  • trunk/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp

    r253314 r256500  
    11/*
    2  * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6060    , m_functionIndex(functionIndex)
    6161{
     62    ASSERT(Options::useOMGJIT());
    6263    setMode(mode);
    6364    ASSERT(m_codeBlock->runnable());
  • trunk/Source/JavaScriptCore/wasm/WasmOperations.cpp

    r254735 r256500  
    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
     
    234234}
    235235
     236inline bool shouldJIT(unsigned functionIndex)
     237{
     238    if (!VM::canUseJIT())
     239        return false;
     240    if (!Options::useOMGJIT())
     241        return false;
     242    if (!Options::wasmFunctionIndexRangeToCompile().isInRange(functionIndex))
     243        return false;
     244    return true;
     245}
     246
    236247void JIT_OPERATION operationWasmTriggerOSREntryNow(Probe::Context& context)
    237248{
     
    254265    BBQCallee& callee = static_cast<BBQCallee&>(codeBlock.wasmBBQCalleeFromFunctionIndexSpace(functionIndexInSpace));
    255266    TierUpCount& tierUp = *callee.tierUpCount();
     267
     268    if (!shouldJIT(functionIndex)) {
     269        tierUp.deferIndefinitely();
     270        return returnWithoutOSREntry();
     271    }
     272
    256273    dataLogLnIf(Options::verboseOSR(), "Consider OMGForOSREntryPlan for [", functionIndex, "] loopIndex#", loopIndex, " with executeCounter = ", tierUp, " ", RawPointer(callee.replacement()));
    257274
     
    427444    BBQCallee& callee = static_cast<BBQCallee&>(codeBlock.wasmBBQCalleeFromFunctionIndexSpace(functionIndexInSpace));
    428445    TierUpCount& tierUp = *callee.tierUpCount();
     446
     447    if (!shouldJIT(functionIndex)) {
     448        tierUp.deferIndefinitely();
     449        return;
     450    }
     451
    429452    dataLogLnIf(Options::verboseOSR(), "Consider OMGPlan for [", functionIndex, "] with executeCounter = ", tierUp, " ", RawPointer(callee.replacement()));
    430453
  • trunk/Source/JavaScriptCore/wasm/WasmSlowPaths.cpp

    r255040 r256500  
    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
     
    8181        : callFrame->r(virtualRegister))
    8282
     83enum class RequiredWasmJIT { Any, OMG };
     84
     85inline bool shouldJIT(Wasm::FunctionCodeBlock* codeBlock, RequiredWasmJIT requiredJIT = RequiredWasmJIT::Any)
     86{
     87    if (!VM::canUseJIT())
     88        return false;
     89    if (requiredJIT == RequiredWasmJIT::OMG) {
     90        if (!Options::useOMGJIT())
     91            return false;
     92    } else {
     93        if (Options::wasmLLIntTiersUpToBBQ() && !Options::useBBQJIT())
     94            return false;
     95        if (!Options::wasmLLIntTiersUpToBBQ() && !Options::useOMGJIT())
     96            return false;
     97    }
     98    if (!Options::wasmFunctionIndexRangeToCompile().isInRange(codeBlock->functionIndex()))
     99        return false;
     100    return true;
     101}
     102
    83103inline bool jitCompileAndSetHeuristics(Wasm::LLIntCallee* callee, Wasm::FunctionCodeBlock* codeBlock, Wasm::Instance* instance)
    84104{
     
    136156    Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
    137157
    138     dataLogLnIf(Options::verboseOSR(), *callee, ": Entered epilogue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
     158    if (!shouldJIT(codeBlock)) {
     159        codeBlock->tierUpCounter().deferIndefinitely();
     160        WASM_RETURN_TWO(nullptr, nullptr);
     161    }
     162
     163    if (!Options::useWasmLLIntPrologueOSR())
     164        WASM_RETURN_TWO(nullptr, nullptr);
     165
     166    dataLogLnIf(Options::verboseOSR(), *callee, ": Entered prologue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
    139167
    140168    if (!jitCompileAndSetHeuristics(callee, codeBlock, instance))
    141         WASM_RETURN_TWO(0, 0);
     169        WASM_RETURN_TWO(nullptr, nullptr);
    142170
    143171    WASM_RETURN_TWO(callee->replacement()->entrypoint().executableAddress(), 0);
     
    146174WASM_SLOW_PATH_DECL(loop_osr)
    147175{
    148     if (!Options::useWebAssemblyOSR()) {
    149         slow_path_wasm_prologue_osr(callFrame, pc, instance);
    150         WASM_RETURN_TWO(0, 0);
    151     }
    152 
    153176    Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
    154177    Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
    155178    Wasm::LLIntTierUpCounter& tierUpCounter = codeBlock->tierUpCounter();
     179
     180    if (!Options::useWebAssemblyOSR() || !Options::useWasmLLIntLoopOSR() || !shouldJIT(codeBlock, RequiredWasmJIT::OMG)) {
     181        slow_path_wasm_prologue_osr(callFrame, pc, instance);
     182        WASM_RETURN_TWO(0, 0);
     183    }
    156184
    157185    dataLogLnIf(Options::verboseOSR(), *callee, ": Entered loop_osr with tierUpCounter = ", codeBlock->tierUpCounter());
     
    221249    Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
    222250    Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
     251
     252    if (!shouldJIT(codeBlock)) {
     253        codeBlock->tierUpCounter().deferIndefinitely();
     254        WASM_END_IMPL();
     255    }
     256    if (!Options::useWasmLLIntEpilogueOSR())
     257        WASM_END_IMPL();
    223258
    224259    dataLogLnIf(Options::verboseOSR(), *callee, ": Entered epilogue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
Note: See TracChangeset for help on using the changeset viewer.