Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix this pointer in generics issue
  • Loading branch information
davidwrighton committed Nov 18, 2025
commit cda2252542a61bcec5b0bbc8ed3f3560cf91985c
15 changes: 8 additions & 7 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,7 @@ void InterpCompiler::CreateILVars()
assert(interpType == InterpTypeO);
assert(!hasParamArg); // We don't support both a param arg and a this pointer shadow copy
m_paramArgIndex = m_numILVars; // The param arg is stored after the IL locals in the m_pVars array
INTERP_DUMP("Set m_paramArgIndex to %d for hasThisPointerShadowCopyAsParamIndex\n", m_paramArgIndex);
}

int thisVar = hasThisPointerShadowCopyAsParamIndex ? m_paramArgIndex : 0;
Expand All @@ -2029,7 +2030,7 @@ void InterpCompiler::CreateILVars()

if (hasContinuationArg)
{
m_continuationArgIndex = hasParamArg ? m_numILVars + 1 : m_numILVars;
m_continuationArgIndex = (hasParamArg || hasThisPointerShadowCopyAsParamIndex) ? m_numILVars + 1 : m_numILVars;
CreateNextLocalVar(m_continuationArgIndex, NULL, InterpTypeO, &offset);
INTERP_DUMP("alloc continuation var(var %d) to offset %d\n", m_continuationArgIndex, m_pVars[m_continuationArgIndex].offset);
}
Expand Down Expand Up @@ -2068,12 +2069,6 @@ void InterpCompiler::CreateILVars()
index++;
}

if (hasContinuationArg)
{
assert(index == m_continuationArgIndex);
index++;
}

if (hasThisPointerShadowCopyAsParamIndex)
{
// This is the allocation of memory space for the shadow copy of the this pointer, operations like starg 0, and ldarga 0 will operate on this copy
Expand All @@ -2084,6 +2079,12 @@ void InterpCompiler::CreateILVars()
index++; // We need to account for the shadow copy in the variable index
}

if (hasContinuationArg)
{
assert(index == m_continuationArgIndex);
index++;
}

if (m_isAsyncMethodWithContextSaveRestore)
{
m_execContextVarIndex = index;
Expand Down