Skip to content

Cranelift: update ValueDataPacked to support full Value range.#12613

Open
cfallin wants to merge 1 commit intobytecodealliance:mainfrom
cfallin:bigger-valuedata
Open

Cranelift: update ValueDataPacked to support full Value range.#12613
cfallin wants to merge 1 commit intobytecodealliance:mainfrom
cfallin:bigger-valuedata

Conversation

@cfallin
Copy link
Member

@cfallin cfallin commented Feb 18, 2026

This updates the ValueDataPacked scheme from the old

            (enum tag)    (CLIF type)    (value 1)     (value 2)
///        | tag:2 |  type:14        |    x:24       | y:24          |

encoding in a u64 to a new

///        | tag:2 |  type:14        |    x:32       | y:32
|

encoding, with a packed tag attribute to ensure the struct fits in 10 bytes. This permits the full range of Value (a u32 entity index) to be encoded, removing the remaining major limit on function body size after the work in #12611 to address #12229.

Curiously, this appears to be a speedup in compile time of 3-5% on bz2 and 3% on spidermonkey-json (Sightglass, 50 data points each). My best guess as to why is that putting the value fields in their own u32s allows for quick access without shifts/masks, which is actually better than the unaligned accesses (caused by 10-byte size) -- which have no penalty on modern mainstream CPUs -- and 25% size inflation of the value-definitions array.

@cfallin cfallin requested a review from a team as a code owner February 18, 2026 00:07
@cfallin cfallin requested review from fitzgen and removed request for a team February 18, 2026 00:07
This updates the `ValueDataPacked` scheme from the old

```
            (enum tag)    (CLIF type)    (value 1)     (value 2)
///        | tag:2 |  type:14        |    x:24       | y:24
```

encoding in a `u64` to a new

```
///        | tag:2 |  type:14        |    x:32       | y:32
```

encoding, with a `packed` tag attribute to ensure the struct fits in
10 bytes. This permits the full range of `Value` (a `u32` entity
index) to be encoded, removing the remaining major limit on function
body size after the work in bytecodealliance#12611 to address bytecodealliance#12229.

Curiously, this appears to be a *speedup* in compile time of 3-5% on
bz2 and 3% on spidermonkey-json (Sightglass, 50 data points each). My
best guess as to why is that putting the value fields in their own
`u32`s allows for quick access without shifts/masks, which is actually
better than the unaligned accesses (caused by 10-byte size) -- which
have no penalty on modern mainstream CPUs -- and 25% size inflation of
the value-definitions array.
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant