Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3eee8becf0b5d458f667d35392b2dc62aeb8b847
      
https://github.com/WebKit/WebKit/commit/3eee8becf0b5d458f667d35392b2dc62aeb8b847
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-08-11 (Tue, 11 Aug 2026)

  Changed paths:
    A JSTests/wasm/gc/struct-field-gap-filling.js
    M Source/JavaScriptCore/tools/JSDollarVM.cpp
    M Source/JavaScriptCore/wasm/WasmFormat.h
    M Source/JavaScriptCore/wasm/WasmTypeDefinition.cpp
    M Source/JavaScriptCore/wasm/WasmTypeDefinitionInlines.h

  Log Message:
  -----------
  [JSC] Fill alignment gap in WasmGC structs
https://bugs.webkit.org/show_bug.cgi?id=321545
rdar://184655909

Reviewed by Vassili Bykov.

WasmGC Struct may have padding like what C++ struct is because of
alignment requirement of fields. But since offset of fields are not
exposed as ABI, we can fill gaps with smaller fields to compact the size
of WasmGC structs. This is effective for example if we are interleaving
i8 and i32.

    struct {
        i8;
        i32;
        i8;
        i32;
    };

This can be like,

    struct {
        i8;
        i8;
        i32;
        i32;
    };

We apply V8's heuristics[1]. Tracking one gap we found so far, and
reusing this gap when we encounter a field which can fit in this gap.

To make the layout itself testable, $vm gains wasmStructFieldOffsets and
wasmStructPayloadSize, which reflect the placement decisions of a struct
instance back to JS.

[1]: https://chromium-review.googlesource.com/c/v8/v8/+/4092494

Test: JSTests/wasm/gc/struct-field-gap-filling.js

* JSTests/wasm/gc/struct-field-gap-filling.js: Added.
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::functionWasmStructFieldOffsets):
(JSC::functionWasmStructPayloadSize):
(JSC::JSDollarVM::finishCreation):
* Source/JavaScriptCore/wasm/WasmFormat.h:
(JSC::Wasm::placeStructField):
* Source/JavaScriptCore/wasm/WasmTypeDefinition.cpp:
(JSC::Wasm::TypeInformation::typeDefinitionForStruct):
* Source/JavaScriptCore/wasm/WasmTypeDefinitionInlines.h:
(JSC::Wasm::TypeInformation::typeDefinitionForStructFromProvider):

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



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

Reply via email to