Skip to content

Commit 74ecc46

Browse files
radekdoulikjkotas
andauthored
[wasm][coreclr] Fix native calls to instance methods with 0 parameters (#121312)
The `nSizeOfArgStack` was calculated wrong, because the size of This argument was not included. For cases with more than zero parameters it is included in first arg offset. It is different on wasm, because we don't use register for This argument as all the other architectures. It fixes the problem in #121107 where the `GetExceptionMessage` call ended without the `OBJECTREF throwable` on the stack, resulting in random pointer instead. --------- Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 74fba8a commit 74ecc46

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/coreclr/vm/callingconvention.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,15 @@ void ArgIteratorTemplate<ARGITERATOR_BASE>::ForceSigWalk()
21902190
// Clear the iterator started flag
21912191
m_dwFlags &= ~ITERATION_STARTED;
21922192

2193+
#ifdef TARGET_WASM
2194+
if (this->NumFixedArgs() == 0)
2195+
{
2196+
// We have zero arguments, but we still need to reserve space for hidden arguments which are in registers on other architectures
2197+
// in non-zero argument cases, the offset is already included in first argument offset.
2198+
maxOffset += m_ofsStack;
2199+
}
2200+
#endif // TARGET_WASM
2201+
21932202
int nSizeOfArgStack = maxOffset - TransitionBlock::GetOffsetOfArgs();
21942203

21952204
#if defined(TARGET_AMD64) && !defined(UNIX_AMD64_ABI)

0 commit comments

Comments
 (0)