Repository navigation
Commit dc3757e
[wasm] Model class-init helper as value-returning in the JIT (#130813)
## Summary
On wasm, the class-init JIT helpers (`CORINFO_HELP_INITCLASS` /
`CORINFO_HELP_INITINSTCLASS`) are dispatched through portable entry
points to the managed `InitClass` / `InitInstantiatedClass` helpers
(`InitHelpers.cs`). Those helpers were changed to return `void*` (a
discarded dummy value) so the compiled `call_indirect` signature matches
the interpreter's value-returning portable-entry-point convention — but
the **JIT caller side was never updated** and still typed these helpers
as `TYP_VOID`.
As a result, R2R-compiled wasm code emits a `(...)->()` `call_indirect`
for the first class-init of a type, while the runtime dispatches the
cold class-init through the i32-returning thunk. The wasm engine traps
with `function signature mismatch`.
This change models the class-init helpers as value-returning
(`TYP_I_IMPL`) on wasm at the five sites that create them:
- `fgGetStaticsCCtorHelper` (the shared-cctor path used by non-generic
methods)
- `impInitClass` (runtime-lookup path)
- the three `fgInitThisClass` generic-lookup cases (`THISOBJ`,
`CLASSPARAM`, `METHODPARAM`)
The helper result is pushed and then discarded via the existing
unused-value `drop` in wasm codegen. The change is guarded by `#ifdef
TARGET_WASM`; other targets are unaffected.
## 1 parent c66d7e1 commit dc3757e
4 files changed
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3358 | 3358 | | |
3359 | 3359 | | |
3360 | 3360 | | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
3361 | 3369 | | |
3362 | 3370 | | |
3363 | 3371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
766 | 766 | | |
767 | 767 | | |
768 | 768 | | |
769 | | - | |
| 769 | + | |
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3909 | 3909 | | |
3910 | 3910 | | |
3911 | 3911 | | |
3912 | | - | |
| 3912 | + | |
3913 | 3913 | | |
3914 | 3914 | | |
3915 | 3915 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14674 | 14674 | | |
14675 | 14675 | | |
14676 | 14676 | | |
14677 | | - | |
| 14677 | + | |
14678 | 14678 | | |
14679 | 14679 | | |
14680 | 14680 | | |
14681 | 14681 | | |
14682 | 14682 | | |
14683 | 14683 | | |
14684 | | - | |
| 14684 | + | |
14685 | 14685 | | |
14686 | 14686 | | |
14687 | 14687 | | |
14688 | 14688 | | |
14689 | 14689 | | |
14690 | 14690 | | |
14691 | | - | |
| 14691 | + | |
| 14692 | + | |
14692 | 14693 | | |
14693 | 14694 | | |
14694 | 14695 | | |
| |||
0 commit comments