macovedj opened PR #14149 from macovedj:winch-throw-exceptions to bytecodealliance:main:
This PR adds implementations for
visit_throwandvisit_throw_refrather than trapping.The
gc_alloc_rawbuiltin supports the only DRC and copying collectors, so I also added
an inline allocation path for the null collector, following Cranelift's pattern.Reference fields in a newly allocated exception have no old value to
release, so I add a DRC initialization barrier that retains the new
reference before storing it.This PR restricts reference-typed exception payloads to
funcrefand
externref, which are the heap types Winch currently supports.
Other reference heap types are reported as unsupported
macovedj requested fitzgen for a review on PR #14149.
macovedj requested wasmtime-compiler-reviewers for a review on PR #14149.
macovedj requested wasmtime-core-reviewers for a review on PR #14149.
macovedj updated PR #14149.
github-actions[bot] added the label winch on PR #14149.
github-actions[bot] commented on PR #14149:
Subscribe to Label Action
cc @saulecabrera
<details>
This issue or pull request has been labeled: "winch"Thus the following users have been cc'd because of the following labels:
- saulecabrera: winch
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
saulecabrera requested saulecabrera for a review on PR #14149.
saulecabrera unassigned fitzgen from PR #14149 winch: throw exceptions.
:memo: saulecabrera submitted PR review.
:speech_balloon: saulecabrera created PR review comment:
Could we add disassembly tests for
-C collector=drcas well?
:speech_balloon: saulecabrera created PR review comment:
Similar here as in https://github.com/bytecodealliance/wasmtime/pull/14149/changes#r3812945374
:speech_balloon: saulecabrera created PR review comment:
I would have expected this to be another type of error? Seems like a configuration error more than a type error? Also, could we move this check higher in the compilation call chain? Else we'd probably have to do a similar check in other places where the layout is needed?
:speech_balloon: saulecabrera created PR review comment:
Can we pass
&Layouthere instead? Without a dedicated type it becomes easier for a caller to inverse them, which might cause bugs down the line.
:speech_balloon: saulecabrera created PR review comment:
Can we use
assert_eqhere instead? I think we want this to be reported in release builds as well in case lengths do no match.
:speech_balloon: saulecabrera created PR review comment:
It looks like this piece is similar to
emit_drc_write_barrier, I wonder if we could refactor these pieces to be called from both methods so that they cannot drift? I'm particularly concerned about the usage of literal offsets on both. Aside from the refactoring can we make the header extend addend (+8) a constant and add some documentation to it?
:speech_balloon: saulecabrera created PR review comment:
I wonder if there would be a way to extract this such that it can be called from within
emit_exception_payload_fieldsrather than passing the&field_typesto that method? The reason I bring this up is that I see that insideemit_exception_payload_fieldswe have a catch-all arm, that depends on the validation above (r.heap_type == WasmHeapType::Func || r.heap_type == WasmHeapType::Extern); if this condition is relaxed, which I think it will in the future, the codegen for the catch-all arm inemit_exception_payload_fieldswill potentially be incorrect.
:speech_balloon: saulecabrera created PR review comment:
Would it make sense to ensure that the value fits in the unused bits:
ensure!( VMGcKind::value_fits_in_unused_bits(size), // New: we would have to introduce this error. CodeGenError::allocation_too_large() );
:speech_balloon: saulecabrera created PR review comment:
This is duplicated above as well, I wonder if we could move this to the
FuncEnv?
:speech_balloon: saulecabrera created PR review comment:
I think in general we only have coverage for the other two? (
nullandcopying)
macovedj updated PR #14149.
macovedj updated PR #14149.
:thumbs_up: saulecabrera submitted PR review.
saulecabrera added PR #14149 winch: throw exceptions to the merge queue.
:check: saulecabrera merged PR #14149.
saulecabrera removed PR #14149 winch: throw exceptions from the merge queue.
Last updated: Aug 30 2026 at 09:07 UTC