Skip to content

Commit ea282a9

Browse files
authored
[Wasm R2R] Report tracked GC vars as untracked in GC info (#129100)
The wasm JIT does not emit tracked GC slot lifetimes (noTrackedGCSlots is true on wasm). Ensure any (liveness) tracked GC vars get reported as untracked for GC purposes, and also get properly zero initialized. Fixes some more cases in #128234.
1 parent 08db7a3 commit ea282a9

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/coreclr/jit/codegencommon.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3799,6 +3799,14 @@ void CodeGen::genCheckUseBlockInit()
37993799
JITDUMP("must init a tracked V%02u because it a struct with a GC ref\n", varNum);
38003800
mustInitThisVar = true;
38013801
}
3802+
#ifdef TARGET_WASM
3803+
else if (hasGCPtr)
3804+
{
3805+
// On wasm all GC vars are reported as untracked, so the slot must be zero-inited.
3806+
JITDUMP("must init V%02u because wasm reports tracked GC vars as untracked\n", varNum);
3807+
mustInitThisVar = true;
3808+
}
3809+
#endif
38023810
else
38033811
{
38043812
// We are done with tracked or GC vars, now look at untracked vars without GC refs.

src/coreclr/jit/gcencode.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4134,7 +4134,9 @@ void GCInfo::gcMakeRegPtrTable(
41344134
// If it is pinned, it must be an untracked local.
41354135
assert(!varDsc->lvPinned || !varDsc->lvTracked);
41364136

4137-
if (varDsc->lvTracked || !varDsc->lvOnFrame)
4137+
// When noTrackedGCSlots is true (e.g. on wasm) tracked on-frame GC vars
4138+
// must be reported here as untracked, since gcVarPtrList is not populated.
4139+
if ((varDsc->lvTracked && !noTrackedGCSlots) || !varDsc->lvOnFrame)
41384140
{
41394141
continue;
41404142
}
@@ -4161,7 +4163,9 @@ void GCInfo::gcMakeRegPtrTable(
41614163
}
41624164
else
41634165
{
4164-
if (varDsc->lvIsRegArg && varDsc->lvTracked)
4166+
// When noTrackedGCSlots is true (e.g. on wasm) tracked register args
4167+
// must fall through and be reported as untracked.
4168+
if (varDsc->lvIsRegArg && varDsc->lvTracked && !noTrackedGCSlots)
41654169
{
41664170
// If this register-passed arg is tracked, then
41674171
// it has been allocated space near the other

0 commit comments

Comments
 (0)