Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7e85ef8b2e2817032b0255afe64b809b1a193258
https://github.com/WebKit/WebKit/commit/7e85ef8b2e2817032b0255afe64b809b1a193258
Author: Yusuke Suzuki <[email protected]>
Date: 2026-06-22 (Mon, 22 Jun 2026)
Changed paths:
M Source/JavaScriptCore/b3/B3Generate.cpp
M Source/JavaScriptCore/b3/B3Procedure.h
M Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp
Log Message:
-----------
[JSC] Disable InferSwitch in B3 for Wasm
https://bugs.webkit.org/show_bug.cgi?id=317502
rdar://180151237
Reviewed by Marcus Plutowski.
In JS, bytecode cannot emit a switch when it involves variables for
example since these things need to be evaluated at each case clause
evaluation.
switch (expr) {
case 1 + 2: {
}
case Variable.Expression: {
}
}
So, these code generates if-else chain (since we cannot evaluate 1 + 2
before jumping. If side effect exists, that's wrong semantics). And DFG
/ FTL will put type speculation / constant folding to make them much
cleaner form. Then if we identified that case conditions are actually
constant, we can use Switch form. So B3 InferSwitch is analyzing these
form and reconstruct Switch from if-else chain for that.
But Wasm does not need it. Wasm has br_table instruction which
constructs a switch table. And Wasm compiler will emit it if necessary.
This patch disables InferSwitch when B3 is compiling Wasm to skip B3
graph iteration.
* Source/JavaScriptCore/b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* Source/JavaScriptCore/b3/B3Procedure.h:
(JSC::B3::Procedure::setIsWasm):
(JSC::B3::Procedure::isWasm const):
* Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp:
(JSC::Wasm::parseAndCompileOMG):
Canonical link: https://commits.webkit.org/315613@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications