JIT: make funclet order correspond to EH clause order#127590
JIT: make funclet order correspond to EH clause order#127590AndyAyersMS merged 6 commits intodotnet:mainfrom
Conversation
For Wasm the JIT host will need to match up funclets with EH clauses without relying on the offset data in the EH clause. To allow this, set things up so that the host can infer which funclets are associated with an EH clause by making the ordering of EH clauses and the order of funclets (reported via unwind info) correspond. Note this is not 1-1 as EH clauses with filters will inspire two funclets. In those cases the JIT will always put the filter funclet before the catch funclet.
|
@dotnet/jit-contrib PTAL A handful of (zero size) diffs for methods where there are mutual protect trys where some catch clauses have EH in them -- those are the cases where the JIT's EH table and the EH info reported to the VM end up differently ordered. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR aims to make EH funclet ordering match the order that EH clauses are reported to the VM (specifically, the “VM EH clause order” derived from try-region ordering), so Wasm can associate funclets with EH clauses without depending on EH offset data. The implementation introduces a shared “EH clause order” mapping computed during funclet creation and reuses it during EH reporting and Wasm virtual-IP clause construction.
Changes:
- Compute and store a VM-EH-clause-order mapping in
fgCreateFuncletsand publish it via a newCompiler::compEHorderTab. - Update EH clause reporting (
genReportEH/genReportEHClauses) to use the precomputed clause order instead of sorting at report time. - Update Wasm EH virtual-IP clause prefill/update logic to (attempt to) respect VM clause order.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/flowgraph.cpp | Builds and stores the EH-clause ordering map while creating funclets. |
| src/coreclr/jit/fgwasm.cpp | Adjusts Wasm EH virtual-IP clause construction to use the new ordering map. |
| src/coreclr/jit/fgbasic.cpp | Removes comment notes from fgRelocateEHRange header. |
| src/coreclr/jit/compiler.h | Adds compEHorderTab to persist the ordering map. |
| src/coreclr/jit/codegencommon.cpp | Switches EH reporting to use compEHorderTab rather than sorting clauses at report time. |
|
Looks like we should keep both jit->vm and vm->jit mappings. Will revise this. |
|
@adamperlin want to review this? |
|
@adamperlin any other feedback? |
adamperlin
left a comment
There was a problem hiding this comment.
I think this looks good to me!
For Wasm the JIT host will need to match up funclets with EH clauses without relying on the offset data in the EH clause.
To allow this, set things up so that the host can infer which funclets are associated with an EH clause by making the ordering of EH clauses and the order of funclets (reported via unwind info) correspond.
Note this is not 1-1 as EH clauses with filters will inspire two funclets. In those cases the JIT will always put the filter funclet before the catch funclet.