Skip to content

Commit 91d9e36

Browse files
committed
[wasi][prototype] Apply Andy's SPC gate #2: class-init helper return arity
Cherry-pick InitHelpers.cs from AndyAyersMS:next-blocker-spc — InitClass and InitInstantiatedClass return void* (null) instead of void, so the compiled wasm call_indirect signature matches the interp's value-returning P_ helper convention. Fixes the class-init helper arity mismatch (Console.cctor trap) that the rebaselined corelib-R2R composite hit at func 61854 after Gates 1+2 (dotnet#130384/dotnet#130446). Prototype-only; for the future WASI R2R PR. Co-authored-by: Copilot App <[email protected]>
1 parent c9915a4 commit 91d9e36

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

  • src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices

‎src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/InitHelpers.cs‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ internal static void InitClassSlow(MethodTable* mt)
2222
}
2323

2424
[DebuggerHidden]
25-
private static void InitClass(MethodTable* mt)
25+
private static void* InitClass(MethodTable* mt)
2626
{
27-
if (mt->AuxiliaryData->IsClassInited)
28-
return;
29-
else
27+
if (!mt->AuxiliaryData->IsClassInited)
3028
InitClassSlow(mt);
29+
30+
// The InitClass JIT helper is modeled as value-returning by the JIT and interpreter
31+
// (the result is pushed and then discarded). On targets that use portable entry points
32+
// (wasm), the call_indirect signature must match the compiled method exactly, including
33+
// return arity, so this helper returns a (dummy) value rather than void.
34+
return null;
3135
}
3236

3337
[DebuggerHidden]
34-
private static void InitInstantiatedClass(MethodTable* mt, MethodDesc* methodDesc)
38+
private static void* InitInstantiatedClass(MethodTable* mt, MethodDesc* methodDesc)
3539
{
3640
MethodTable *pTemplateMT = methodDesc->MethodTable;
3741
MethodTable *pMT;
@@ -45,10 +49,11 @@ private static void InitInstantiatedClass(MethodTable* mt, MethodDesc* methodDes
4549
pMT = pTemplateMT;
4650
}
4751

48-
if (pMT->AuxiliaryData->IsClassInitedAndActive)
49-
return;
50-
else
52+
if (!pMT->AuxiliaryData->IsClassInitedAndActive)
5153
InitClassSlow(pMT);
54+
55+
// See the comment in InitClass for why this helper returns a value rather than void.
56+
return null;
5257
}
5358

5459
[DebuggerHidden]

0 commit comments

Comments
 (0)