Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (256499 => 256500)
--- trunk/Source/_javascript_Core/ChangeLog 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,3 +1,38 @@
+2020-02-12 Mark Lam <[email protected]>
+
+ 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
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * runtime/Options.cpp:
+ (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):
+
2020-02-12 Yusuke Suzuki <[email protected]>
[JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (256499 => 256500)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2020-02-13 04:11:51 UTC (rev 256500)
@@ -5073,6 +5073,7 @@
F692A87E0255597D01FF60F7 /* RegExp.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RegExp.h; sourceTree = "<group>"; tabWidth = 8; };
F692A8870255597D01FF60F7 /* JSCJSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCJSValue.cpp; sourceTree = "<group>"; tabWidth = 8; };
F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSourceCode.cpp; sourceTree = "<group>"; };
+ FE00262223F3AF33003A358F /* WebAssembly.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; name = WebAssembly.asm; path = llint/WebAssembly.asm; sourceTree = "<group>"; };
FE086BC92123DEFA003F2929 /* EntryFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EntryFrame.h; sourceTree = "<group>"; };
FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExecutionTimeLimitTest.cpp; path = API/tests/ExecutionTimeLimitTest.cpp; sourceTree = "<group>"; };
FE0D4A051AB8DD0A002F54BF /* ExecutionTimeLimitTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionTimeLimitTest.h; path = API/tests/ExecutionTimeLimitTest.h; sourceTree = "<group>"; };
@@ -5476,6 +5477,7 @@
0F4680C814BBB16900BFE272 /* LowLevelInterpreter.h */,
86A054471556451B00445157 /* LowLevelInterpreter32_64.asm */,
86A054481556451B00445157 /* LowLevelInterpreter64.asm */,
+ FE00262223F3AF33003A358F /* WebAssembly.asm */,
);
name = llint;
sourceTree = "<group>";
Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (256499 => 256500)
--- trunk/Source/_javascript_Core/runtime/Options.cpp 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp 2020-02-13 04:11:51 UTC (rev 256500)
@@ -949,6 +949,10 @@
coherent = false;
dataLog("INCOHERENT OPTIONS: at least one of useLLInt or useJIT must be true\n");
}
+ if (useWebAssembly() && !(useWasmLLInt() || useBBQJIT())) {
+ coherent = false;
+ dataLog("INCOHERENT OPTIONS: at least one of useWasmLLInt or useBBQJIT must be true\n");
+ }
if (!coherent)
CRASH();
}
Modified: trunk/Source/_javascript_Core/runtime/OptionsList.h (256499 => 256500)
--- trunk/Source/_javascript_Core/runtime/OptionsList.h 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/runtime/OptionsList.h 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-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
@@ -467,6 +467,12 @@
v(Bool, useFastTLSForWasmContext, true, Normal, "If true, we will store context in fast TLS. If false, we will pin it to a register.") \
v(Bool, wasmBBQUsesAir, true, Normal, nullptr) \
v(Bool, useWasmLLInt, true, Normal, nullptr) \
+ v(Bool, useBBQJIT, true, Normal, "allows the BBQ JIT to be used if true") \
+ v(Bool, useOMGJIT, true, Normal, "allows the OMG JIT to be used if true") \
+ v(Bool, useWasmLLIntPrologueOSR, true, Normal, "allows prologue OSR from Wasm LLInt if true") \
+ v(Bool, useWasmLLIntLoopOSR, true, Normal, "allows loop OSR from Wasm LLInt if true") \
+ v(Bool, useWasmLLIntEpilogueOSR, true, Normal, "allows epilogue OSR from Wasm LLInt if true") \
+ v(OptionRange, wasmFunctionIndexRangeToCompile, 0, Normal, "wasm function index range to allow compilation on, e.g. 1:100") \
v(Bool, wasmLLIntTiersUpToBBQ, true, Normal, nullptr) \
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.") \
v(Bool, useWebAssemblyStreamingApi, enableWebAssemblyStreamingApi, Normal, "Allow to run WebAssembly's Streaming API") \
Modified: trunk/Source/_javascript_Core/wasm/WasmBBQPlan.cpp (256499 => 256500)
--- trunk/Source/_javascript_Core/wasm/WasmBBQPlan.cpp 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/wasm/WasmBBQPlan.cpp 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-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
@@ -58,7 +58,9 @@
, m_codeBlock(codeBlock)
, m_functionIndex(functionIndex)
{
+ ASSERT(Options::useBBQJIT());
setMode(m_codeBlock->mode());
+ dataLogLnIf(WasmBBQPlanInternal::verbose, "Starting BBQ plan for ", functionIndex);
}
bool BBQPlan::prepareImpl()
Modified: trunk/Source/_javascript_Core/wasm/WasmOMGForOSREntryPlan.cpp (256499 => 256500)
--- trunk/Source/_javascript_Core/wasm/WasmOMGForOSREntryPlan.cpp 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/wasm/WasmOMGForOSREntryPlan.cpp 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-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
@@ -61,6 +61,7 @@
, m_functionIndex(functionIndex)
, m_loopIndex(loopIndex)
{
+ ASSERT(Options::useOMGJIT());
setMode(mode);
ASSERT(m_codeBlock->runnable());
ASSERT(m_codeBlock.ptr() == m_module->codeBlockFor(m_mode));
Modified: trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp (256499 => 256500)
--- trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017-2019 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
@@ -59,6 +59,7 @@
, m_codeBlock(*m_module->codeBlockFor(mode))
, m_functionIndex(functionIndex)
{
+ ASSERT(Options::useOMGJIT());
setMode(mode);
ASSERT(m_codeBlock->runnable());
ASSERT(m_codeBlock.ptr() == m_module->codeBlockFor(m_mode));
Modified: trunk/Source/_javascript_Core/wasm/WasmOperations.cpp (256499 => 256500)
--- trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-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
@@ -233,6 +233,17 @@
context.gpr(GPRInfo::argumentGPR1) = bitwise_cast<UCPURegister>(osrEntryCallee.entrypoint().executableAddress<>());
}
+inline bool shouldJIT(unsigned functionIndex)
+{
+ if (!VM::canUseJIT())
+ return false;
+ if (!Options::useOMGJIT())
+ return false;
+ if (!Options::wasmFunctionIndexRangeToCompile().isInRange(functionIndex))
+ return false;
+ return true;
+}
+
void JIT_OPERATION operationWasmTriggerOSREntryNow(Probe::Context& context)
{
OSREntryData& osrEntryData = *context.arg<OSREntryData*>();
@@ -253,6 +264,12 @@
ASSERT(codeBlock.wasmBBQCalleeFromFunctionIndexSpace(functionIndexInSpace).compilationMode() == Wasm::CompilationMode::BBQMode);
BBQCallee& callee = static_cast<BBQCallee&>(codeBlock.wasmBBQCalleeFromFunctionIndexSpace(functionIndexInSpace));
TierUpCount& tierUp = *callee.tierUpCount();
+
+ if (!shouldJIT(functionIndex)) {
+ tierUp.deferIndefinitely();
+ return returnWithoutOSREntry();
+ }
+
dataLogLnIf(Options::verboseOSR(), "Consider OMGForOSREntryPlan for [", functionIndex, "] loopIndex#", loopIndex, " with executeCounter = ", tierUp, " ", RawPointer(callee.replacement()));
if (!Options::useWebAssemblyOSR()) {
@@ -426,6 +443,12 @@
ASSERT(codeBlock.wasmBBQCalleeFromFunctionIndexSpace(functionIndexInSpace).compilationMode() == Wasm::CompilationMode::BBQMode);
BBQCallee& callee = static_cast<BBQCallee&>(codeBlock.wasmBBQCalleeFromFunctionIndexSpace(functionIndexInSpace));
TierUpCount& tierUp = *callee.tierUpCount();
+
+ if (!shouldJIT(functionIndex)) {
+ tierUp.deferIndefinitely();
+ return;
+ }
+
dataLogLnIf(Options::verboseOSR(), "Consider OMGPlan for [", functionIndex, "] with executeCounter = ", tierUp, " ", RawPointer(callee.replacement()));
if (shouldTriggerOMGCompile(tierUp, callee.replacement(), functionIndex))
Modified: trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp (256499 => 256500)
--- trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2020-02-13 02:47:01 UTC (rev 256499)
+++ trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2020-02-13 04:11:51 UTC (rev 256500)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-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
@@ -80,6 +80,26 @@
? JSValue::decode(CODE_BLOCK()->getConstant(virtualRegister)) \
: callFrame->r(virtualRegister))
+enum class RequiredWasmJIT { Any, OMG };
+
+inline bool shouldJIT(Wasm::FunctionCodeBlock* codeBlock, RequiredWasmJIT requiredJIT = RequiredWasmJIT::Any)
+{
+ if (!VM::canUseJIT())
+ return false;
+ if (requiredJIT == RequiredWasmJIT::OMG) {
+ if (!Options::useOMGJIT())
+ return false;
+ } else {
+ if (Options::wasmLLIntTiersUpToBBQ() && !Options::useBBQJIT())
+ return false;
+ if (!Options::wasmLLIntTiersUpToBBQ() && !Options::useOMGJIT())
+ return false;
+ }
+ if (!Options::wasmFunctionIndexRangeToCompile().isInRange(codeBlock->functionIndex()))
+ return false;
+ return true;
+}
+
inline bool jitCompileAndSetHeuristics(Wasm::LLIntCallee* callee, Wasm::FunctionCodeBlock* codeBlock, Wasm::Instance* instance)
{
Wasm::LLIntTierUpCounter& tierUpCounter = codeBlock->tierUpCounter();
@@ -135,10 +155,18 @@
Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
- dataLogLnIf(Options::verboseOSR(), *callee, ": Entered epilogue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
+ if (!shouldJIT(codeBlock)) {
+ codeBlock->tierUpCounter().deferIndefinitely();
+ WASM_RETURN_TWO(nullptr, nullptr);
+ }
+ if (!Options::useWasmLLIntPrologueOSR())
+ WASM_RETURN_TWO(nullptr, nullptr);
+
+ dataLogLnIf(Options::verboseOSR(), *callee, ": Entered prologue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
+
if (!jitCompileAndSetHeuristics(callee, codeBlock, instance))
- WASM_RETURN_TWO(0, 0);
+ WASM_RETURN_TWO(nullptr, nullptr);
WASM_RETURN_TWO(callee->replacement()->entrypoint().executableAddress(), 0);
}
@@ -145,15 +173,15 @@
WASM_SLOW_PATH_DECL(loop_osr)
{
- if (!Options::useWebAssemblyOSR()) {
+ Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
+ Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
+ Wasm::LLIntTierUpCounter& tierUpCounter = codeBlock->tierUpCounter();
+
+ if (!Options::useWebAssemblyOSR() || !Options::useWasmLLIntLoopOSR() || !shouldJIT(codeBlock, RequiredWasmJIT::OMG)) {
slow_path_wasm_prologue_osr(callFrame, pc, instance);
WASM_RETURN_TWO(0, 0);
}
- Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
- Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
- Wasm::LLIntTierUpCounter& tierUpCounter = codeBlock->tierUpCounter();
-
dataLogLnIf(Options::verboseOSR(), *callee, ": Entered loop_osr with tierUpCounter = ", codeBlock->tierUpCounter());
unsigned loopOSREntryBytecodeOffset = codeBlock->bytecodeOffset(pc);
@@ -221,6 +249,13 @@
Wasm::LLIntCallee* callee = static_cast<Wasm::LLIntCallee*>(callFrame->callee().asWasmCallee());
Wasm::FunctionCodeBlock* codeBlock = CODE_BLOCK();
+ if (!shouldJIT(codeBlock)) {
+ codeBlock->tierUpCounter().deferIndefinitely();
+ WASM_END_IMPL();
+ }
+ if (!Options::useWasmLLIntEpilogueOSR())
+ WASM_END_IMPL();
+
dataLogLnIf(Options::verboseOSR(), *callee, ": Entered epilogue_osr with tierUpCounter = ", codeBlock->tierUpCounter());
jitCompileAndSetHeuristics(callee, codeBlock, instance);