[webkit-changes] [WebKit/WebKit] 406449: [WASM] Subsequent comparisons and conditional bran...

David Degazio noreply at github.com
Tue Aug 27 10:17:08 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 406449de0ae5f7558bbcec552b8207ef3e7e6cff
      https://github.com/WebKit/WebKit/commit/406449de0ae5f7558bbcec552b8207ef3e7e6cff
  Author: David Degazio <d_degazio at apple.com>
  Date:   2024-08-27 (Tue, 27 Aug 2024)

  Changed paths:
    M Source/JavaScriptCore/b3/testb3_7.cpp
    M Source/JavaScriptCore/jit/CCallHelpers.cpp
    M Source/JavaScriptCore/jit/RegisterSet.cpp
    M Source/JavaScriptCore/jit/RegisterSet.h
    M Source/JavaScriptCore/wasm/WasmBBQJIT.cpp
    M Source/JavaScriptCore/wasm/WasmBBQJIT.h
    M Source/JavaScriptCore/wasm/WasmBBQJIT32_64.cpp
    M Source/JavaScriptCore/wasm/WasmBBQJIT64.cpp
    M Source/JavaScriptCore/wasm/WasmCallingConvention.h
    M Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmFunctionParser.h
    M Source/JavaScriptCore/wasm/WasmIPIntGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmOMGIRGenerator32_64.cpp
    M Source/JavaScriptCore/wasm/WasmParser.h
    M Source/JavaScriptCore/wasm/generateWasm.py
    M Source/JavaScriptCore/wasm/generateWasmOpsHeader.py

  Log Message:
  -----------
  [WASM] Subsequent comparisons and conditional branches should be fused in BBQ
https://bugs.webkit.org/show_bug.cgi?id=277703
rdar://133317430

Reviewed by Yusuke Suzuki.

Adds fusion for sequential compare/branch opcode pairs to BBQ. We detect
fusion straightforwardly in the function parser - for unary and binary
comparison opcodes, we peek one opcode ahead, and if it's a br_if or if
we try to fuse with it if our current compiler tier supports it. Then,
in the actual generator, we expose new addFusedBranchCompare and
addFusedIfCompare methods - analogous to addBranch and addIf, but given
the opcode and operands of the compare op instead of a condition.

This patch also simplifies our register allocation around branches. For
br_if, we currently use a scratch register to hold the condition, but
since our condition is a popped value, its register can't overlap with
any live value, so it shouldn't be clobbered when we flush the stack.
For if, it's more complicated, since we need to shuffle block arguments
into position. Currently we have to select a scratch, move our condition
into it, then tell the new block not to use that scratch as a parameter.
Instead, we should just be able to tell the new block not to use the
register the condition value already inhabits. This generally saves one
or two moves when emitting an if or br_if.

* Source/JavaScriptCore/wasm/WasmBBQJIT.cpp:
(JSC::Wasm::BBQJITImpl::ControlData::ControlData):
(JSC::Wasm::BBQJITImpl::BBQJIT::addIf):
(JSC::Wasm::BBQJITImpl::BBQJIT::addBranch):
(JSC::Wasm::BBQJITImpl::BBQJIT::emitTailCall):
(JSC::Wasm::BBQJITImpl::BBQJIT::emitIndirectCall):
(JSC::Wasm::BBQJITImpl::BBQJIT::emitIndirectTailCall):
(JSC::Wasm::BBQJITImpl::BBQJIT::addCallIndirect):
* Source/JavaScriptCore/wasm/WasmBBQJIT.h:
* Source/JavaScriptCore/wasm/WasmBBQJIT32_64.cpp:
(JSC::Wasm::BBQJITImpl::BBQJIT::tryFoldFusedBranchCompare):
(JSC::Wasm::BBQJITImpl::BBQJIT::emitFusedBranchCompareBranch):
(JSC::Wasm::BBQJITImpl::BBQJIT::addFusedBranchCompare):
(JSC::Wasm::BBQJITImpl::BBQJIT::addFusedIfCompare):
(JSC::Wasm::BBQJITImpl::BBQJIT::addCallRef):
* Source/JavaScriptCore/wasm/WasmBBQJIT64.cpp:
(JSC::Wasm::BBQJITImpl::BBQJIT::tryFoldFusedBranchCompare):
(JSC::Wasm::BBQJITImpl::BBQJIT::emitFusedBranchCompareBranch):
(JSC::Wasm::BBQJITImpl::BBQJIT::addFusedBranchCompare):
(JSC::Wasm::BBQJITImpl::BBQJIT::addFusedIfCompare):
(JSC::Wasm::BBQJITImpl::emitBranchI32):
(JSC::Wasm::BBQJITImpl::emitBranchI64):
(JSC::Wasm::BBQJITImpl::emitBranchF32):
(JSC::Wasm::BBQJITImpl::emitBranchF64):
(JSC::Wasm::BBQJITImpl::BBQJIT::addCallRef):
* Source/JavaScriptCore/wasm/WasmCallingConvention.h:
(JSC::Wasm::WasmCallingConvention::argumentGPRs const):
(JSC::Wasm::WasmCallingConvention::argumentGPRS const): Deleted.
* Source/JavaScriptCore/wasm/WasmConstExprGenerator.cpp:
* Source/JavaScriptCore/wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser<Context>::binaryCompareCase):
(JSC::Wasm::FunctionParser<Context>::unaryCompareCase):
(JSC::Wasm::FunctionParser<Context>::parseExpression):
* Source/JavaScriptCore/wasm/WasmIPIntGenerator.cpp:
(JSC::Wasm::IPIntGenerator::addFusedBranchCompare):
(JSC::Wasm::IPIntGenerator::addFusedIfCompare):
* Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::addFusedBranchCompare):
(JSC::Wasm::LLIntGenerator::addFusedIfCompare):
* Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp:
(JSC::Wasm::OMGIRGenerator::addFusedBranchCompare):
(JSC::Wasm::OMGIRGenerator::addFusedIfCompare):
* Source/JavaScriptCore/wasm/WasmOMGIRGenerator32_64.cpp:
(JSC::Wasm::OMGIRGenerator::addFusedBranchCompare):
(JSC::Wasm::OMGIRGenerator::addFusedIfCompare):
* Source/JavaScriptCore/wasm/WasmParser.h:
(JSC::Wasm::ParserBase::peekUInt8):
* Source/JavaScriptCore/wasm/generateWasm.py:
* Source/JavaScriptCore/wasm/generateWasmOpsHeader.py:

Canonical link: https://commits.webkit.org/282799@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list