Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c7bfc7c0ca52b4fea117da64c8f15d5fcab32167
      
https://github.com/WebKit/WebKit/commit/c7bfc7c0ca52b4fea117da64c8f15d5fcab32167
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-07-07 (Tue, 07 Jul 2026)

  Changed paths:
    A JSTests/wasm/stress/wasm-gc-eliminate-allocations-basic.js
    A JSTests/wasm/stress/wasm-gc-eliminate-allocations-control-flow.js
    A JSTests/wasm/stress/wasm-gc-eliminate-allocations-escape.js
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/Sources.txt
    A Source/JavaScriptCore/b3/B3EliminateWasmGCAllocations.cpp
    A Source/JavaScriptCore/b3/B3EliminateWasmGCAllocations.h
    M Source/JavaScriptCore/b3/B3Generate.cpp
    M Source/JavaScriptCore/b3/B3MemoryValue.h
    M Source/JavaScriptCore/b3/B3Procedure.h
    M Source/JavaScriptCore/runtime/OptionsList.h
    M Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp

  Log Message:
  -----------
  [JSC] Add B3::eliminateWasmGCAllocations phase
https://bugs.webkit.org/show_bug.cgi?id=318768

Reviewed by Justin Michaud.

This patch adds B3::eliminateWasmGCAllocations phase. This is super
duper simple scalar replacement for WasmGC struct types. We record
usesWasmGCStructAllocations and run this phase only when this is
recorded as this phase is meaningless if we do not have WasmStructNew.

The key insight here is we already run CSE with WasmGC structs, which
can successfully remove load-elimination and store-elimination. Thus, at
this point, most of related WasmGC struct loads are no longer associated
with the WasmGC struct. Thus we only need to care about WasmStructSet
here since WasmStructGet should be already converted to the pointed
value if the struct is not escaped and CSE ran already. This assumption
(of course, this is not covering all the cases, but most of beneficial
cases should be in this class) makes this phase extremely simple.
Basically just collecting WasmStructSet-use-only WasmStructNew since it
is not escaped. And then we convert all of them into Nop.

Tests: JSTests/wasm/stress/wasm-gc-eliminate-allocations-basic.js
       JSTests/wasm/stress/wasm-gc-eliminate-allocations-control-flow.js
       JSTests/wasm/stress/wasm-gc-eliminate-allocations-escape.js

* JSTests/wasm/stress/wasm-gc-eliminate-allocations-basic.js: Added.
(async test):
* JSTests/wasm/stress/wasm-gc-eliminate-allocations-control-flow.js: Added.
(loopLocalExpected):
(async test):
* JSTests/wasm/stress/wasm-gc-eliminate-allocations-escape.js: Added.
(async test):
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/b3/B3EliminateWasmGCAllocations.cpp: Added.
(JSC::B3::eliminateWasmGCAllocations):
* Source/JavaScriptCore/b3/B3EliminateWasmGCAllocations.h: Added.
* Source/JavaScriptCore/b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* Source/JavaScriptCore/b3/B3MemoryValue.h:
* Source/JavaScriptCore/b3/B3Procedure.h:
(JSC::B3::Procedure::setUsesWasmGCStructAllocations):
(JSC::B3::Procedure::usesWasmGCStructAllocations const):
(JSC::B3::Procedure::setUsesWasmGCArrayAllocations):
(JSC::B3::Procedure::usesWasmGCArrayAllocations const):
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp:
(JSC::Wasm::OMGIRGenerator::addArrayNew):
(JSC::Wasm::OMGIRGenerator::addArrayNewDefault):
(JSC::Wasm::OMGIRGenerator::addArrayNewFixed):
(JSC::Wasm::OMGIRGenerator::addStructNew):
(JSC::Wasm::OMGIRGenerator::addStructNewDefault):

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



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

Reply via email to