Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 23b9690343a3b05b81f169079c1a84d91c9eb08a
https://github.com/WebKit/WebKit/commit/23b9690343a3b05b81f169079c1a84d91c9eb08a
Author: Yusuke Suzuki <[email protected]>
Date: 2026-09-03 (Thu, 03 Sep 2026)
Changed paths:
A JSTests/wasm/gc/extended-const-expr-replay-simd.js
A JSTests/wasm/gc/extended-const-expr-replay.js
M Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp
M Source/JavaScriptCore/wasm/WasmConstExprGenerator.h
M Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
M Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
M Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
M Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h
Log Message:
-----------
[JSC] Split validation and evaluation of wasm constant expression
https://bugs.webkit.org/show_bug.cgi?id=323289
rdar://186541346
Reviewed by Keith Miller.
Complex wasm binaries include significant amount of constant
expressions. For example, Dart-flute-todomvc-wasm's binary includes
4000~ constant expression, thus making it fast is critical for
performance.
This patch accelerates constant expression by splitting validator and
interpreter.
Validator can run without any actual values and interpreter does not
need to have costly validation. Also since constant expressions are only
including straight forward wasm instructions, interpreter is just
reading and running the wasm instructions and even there is no control
flow instructions.
Now ConstExprGenerator is only validating the constant expressions.
Removing Value representation and removing m_mode as it is now
Validation only. Instead, we have ConstExprInterpreter which runs
constant expressions by reading the already validated wasm instruction span.
Tests: JSTests/wasm/gc/extended-const-expr-replay-simd.js
JSTests/wasm/gc/extended-const-expr-replay.js
* JSTests/wasm/gc/extended-const-expr-replay-simd.js: Added.
* JSTests/wasm/gc/extended-const-expr-replay.js: Added.
(check):
* Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp:
(JSC::Wasm::ConstExprInterpreter::ConstExprInterpreter):
(JSC::Wasm::ConstExprInterpreter::run):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::isInvalid const):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::getValue const):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::getVector const):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::type const):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::operator+ const):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::operator- const):
(JSC::Wasm::ConstExprInterpreter::ConstExprValue::operator* const):
(JSC::Wasm::ConstExprInterpreter::failedToAllocate const):
(JSC::Wasm::ConstExprInterpreter::loadGlobal):
(JSC::Wasm::ConstExprInterpreter::refFunc):
(JSC::Wasm::ConstExprInterpreter::refI31):
(JSC::Wasm::ConstExprInterpreter::anyConvertExtern):
(JSC::Wasm::ConstExprInterpreter::trackAllocation):
(JSC::Wasm::ConstExprInterpreter::createNewArray):
(JSC::Wasm::ConstExprInterpreter::createNewDefaultArray):
(JSC::Wasm::ConstExprInterpreter::createNewStruct):
(JSC::Wasm::ConstExprGenerator::fail const):
(JSC::Wasm::ConstExprGenerator::ConstExprGenerator):
(JSC::Wasm::ConstExprGenerator::addConstant):
(JSC::Wasm::ConstExprGenerator::getGlobal):
(JSC::Wasm::ConstExprGenerator::addRefI31):
(JSC::Wasm::ConstExprGenerator::addArrayNew):
(JSC::Wasm::ConstExprGenerator::addArrayNewDefault):
(JSC::Wasm::ConstExprGenerator::addArrayNewFixed):
(JSC::Wasm::ConstExprGenerator::addStructNewDefault):
(JSC::Wasm::ConstExprGenerator::addStructNew):
(JSC::Wasm::ConstExprGenerator::addAnyConvertExtern):
(JSC::Wasm::ConstExprGenerator::addExternConvertAny):
(JSC::Wasm::ConstExprGenerator::addI32Add):
(JSC::Wasm::ConstExprGenerator::addI64Add):
(JSC::Wasm::ConstExprGenerator::addI32Sub):
(JSC::Wasm::ConstExprGenerator::addI64Sub):
(JSC::Wasm::ConstExprGenerator::addI32Mul):
(JSC::Wasm::ConstExprGenerator::addI64Mul):
(JSC::Wasm::ConstExprGenerator::addRefFunc):
(JSC::Wasm::ConstExprGenerator::endBlock):
(JSC::Wasm::ConstExprGenerator::addSIMDConstant):
(JSC::Wasm::parseExtendedConstExpr):
(JSC::Wasm::evaluateExtendedConstExpr):
(JSC::Wasm::ConstExprGenerator::ConstExprValue::ConstExprValue): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::isInvalid): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::getValue): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::getVector): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::type): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::operator+): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::operator-): Deleted.
(JSC::Wasm::ConstExprGenerator::ConstExprValue::operator*): Deleted.
(JSC::Wasm::ConstExprGenerator::result const): Deleted.
(JSC::Wasm::ConstExprGenerator::createNewArray): Deleted.
(JSC::Wasm::ConstExprGenerator::createNewStruct): Deleted.
* Source/JavaScriptCore/wasm/WasmConstExprGenerator.h:
* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::evaluateConstantExpression):
(JSC::JSWebAssemblyInstance::ensureConstantExpressionValue):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h:
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::initializeExports):
(JSC::WebAssemblyModuleRecord::evaluateConstantExpression):
(JSC::WebAssemblyModuleRecord::evaluate):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h:
Canonical link: https://commits.webkit.org/320453@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications