Stream: git-wasmtime

Topic: wasmtime / PR #13586 feat(MachO): Cranelift: align stack ...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 08:50):

marxin opened PR #13586 from marxin:macho-eh-main to bytecodealliance:main:

This change is motivated by a compatibility difference between LLVM and the Cranelift compiler. The PR enables Cranelift to emit proper compact unwind information for the Mach-O AArch64 platform, based on UnwindInst and FinalizedMachCallSite.

The change has two parts:

  1. Unwind instructions only describe which pairs of callee-save registers are saved and restored. The canonical stack frame layout is still expected: nonvolatile registers must be placed near the top of the frame, immediately below the return address.
  2. The unwind encoding only supports register pairs emitted with stp; it cannot encode individual registers. This results in slightly larger stack frames, but the increase should hopefully be manageable.

Collected statistics for a larger WASM module (total function count: ~37K):

function count: diff: newly spilled registers
9828 diff=+0: newly spilled=0
1958 diff=+0: newly spilled=10
3457 diff=+0: newly spilled=2
3828 diff=+0: newly spilled=4
1038 diff=+0: newly spilled=6
 552 diff=+0: newly spilled=8
 639 diff=+1: newly spilled=10
 882 diff=+1: newly spilled=2
6639 diff=+1: newly spilled=4
2393 diff=+1: newly spilled=6
1072 diff=+1: newly spilled=8
 359 diff=+2: newly spilled=10
2229 diff=+2: newly spilled=4
1062 diff=+2: newly spilled=6
 523 diff=+2: newly spilled=8
 118 diff=+3: newly spilled=10
 505 diff=+3: newly spilled=6
 226 diff=+3: newly spilled=8
  54 diff=+4: newly spilled=10
  68 diff=+4: newly spilled=8
   7 diff=+5: newly spilled=10

Pair-register encoding constant defined in LLVM:
https://github.com/llvm/llvm-project/blob/main/libunwind/include/mach-o/compact_unwind_encoding.h?utm_source=chatgpt.com#L292-L300

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 08:50):

marxin requested alexcrichton for a review on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 08:50):

marxin requested wasmtime-compiler-reviewers for a review on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 09:04):

:speech_balloon: bjorn3 created PR review comment:

Instead of unconditionally doing this on Mach-O, maybe add a flag for it? rustc_codegen_cranelift will not use compact unwind info (it only allows 3 distinct personality functions, but non-rust languages on apple platforms already use 3 personality functions combined, so rustc has to use dwarf debuginfo to ensure it can always use its own personality function), so there is no reason it has to incur the code quality hit.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 09:04):

:memo: bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 09:36):

marxin updated PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 09:37):

:memo: marxin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 09:37):

:speech_balloon: marxin created PR review comment:

Sure - makes fully sense to me. The new flag has been added, with the default value being false.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 10:14):

marxin requested wasmtime-core-reviewers for a review on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 10:14):

marxin updated PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 14:04):

github-actions[bot] added the label cranelift:area:aarch64 on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 14:04):

github-actions[bot] added the label wasmtime:api on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 14:04):

github-actions[bot] added the label cranelift:meta on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 14:04):

github-actions[bot] added the label cranelift on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 15:55):

:memo: cfallin submitted PR review:

This seems reasonable to me -- thanks a bunch for the contribution!

In addition to the nit below, could you add a compile filetest showing the assembly (including cases where the logic adds a new clobber) as well?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 15:55):

:speech_balloon: cfallin created PR review comment:

We generally use crate::FxHashSet throughout cranelift-codegen -- could you switch to that?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:34):

marxin updated PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:34):

:memo: marxin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:34):

:speech_balloon: marxin created PR review comment:

Sure!

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:35):

:thumbs_up: cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:35):

alexcrichton requested cfallin for a review on PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:35):

cfallin has enabled auto merge for PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:35):

alexcrichton unassigned alexcrichton from PR #13586 feat(MachO): Cranelift: align stack prologue/epilogue with compact unwind format.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:36):

marxin commented on PR #13586:

In addition to the nit below, could you add a compile filetest showing the assembly (including cases where the logic adds a new clobber) as well?

Included a test-case, where switching set enable_compact_unwind_abi=true to false leads to the following diff:

    --- expected
    +++ actual
    @@ -1,8 +1,8 @@
     VCode:
       stp fp, lr, [sp, #-16]!
       mov fp, sp

    -  stp x20, x19, [sp, #-16]!
    -  stp x22, x21, [sp, #-16]!
    +  str x21, [sp, #-16]!
    +  stp x19, x20, [sp, #-16]!
     block0:
       mov x19, x2
       mov x20, x1
    @@ -13,8 +13,8 @@
       add x6, x0, x1
       mov x2, x19
       add x0, x6, x2

    -  ldp x22, x21, [sp], #16
    -  ldp x20, x19, [sp], #16
    +  ldp x19, x20, [sp], #16
    +  ldr x21, [sp], #16
       ldp fp, lr, [sp], #16
       ret

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 18:46):

cfallin added PR #13586 feat(MachO): Cranelift: align stack prologue/epilogue with compact unwind format to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 19:10):

:check: cfallin merged PR #13586.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 08 2026 at 19:10):

cfallin removed PR #13586 feat(MachO): Cranelift: align stack prologue/epilogue with compact unwind format from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 12 2026 at 08:51):

marxin commented on PR #13586:

Given the nature of the change and that it's opt-in, can we please cherry pick it into the upcoming 0.133 version?
Thank you.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 12 2026 at 14:31):

alexcrichton commented on PR #13586:

That seems reasonable yeah, can you send a cherry-pick to the release-46.0.0 branch for that?


Last updated: Jul 29 2026 at 05:03 UTC