diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/InitHelpers.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/InitHelpers.cs index bf2794b5c5ed99..e2a52e15d1ab70 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/InitHelpers.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/InitHelpers.cs @@ -22,16 +22,20 @@ internal static void InitClassSlow(MethodTable* mt) } [DebuggerHidden] - private static void InitClass(MethodTable* mt) + private static void* InitClass(MethodTable* mt) { - if (mt->AuxiliaryData->IsClassInited) - return; - else + if (!mt->AuxiliaryData->IsClassInited) InitClassSlow(mt); + + // The InitClass JIT helper is modeled as value-returning by the JIT and interpreter + // (the result is pushed and then discarded). On targets that use portable entry points + // (wasm), the call_indirect signature must match the compiled method exactly, including + // return arity, so this helper returns a (dummy) value rather than void. + return null; } [DebuggerHidden] - private static void InitInstantiatedClass(MethodTable* mt, MethodDesc* methodDesc) + private static void* InitInstantiatedClass(MethodTable* mt, MethodDesc* methodDesc) { MethodTable *pTemplateMT = methodDesc->MethodTable; MethodTable *pMT; @@ -45,10 +49,11 @@ private static void InitInstantiatedClass(MethodTable* mt, MethodDesc* methodDes pMT = pTemplateMT; } - if (pMT->AuxiliaryData->IsClassInitedAndActive) - return; - else + if (!pMT->AuxiliaryData->IsClassInitedAndActive) InitClassSlow(pMT); + + // See the comment in InitClass for why this helper returns a value rather than void. + return null; } [DebuggerHidden]