Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5729,6 +5729,23 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
{
AddIns(INTOP_LOAD_EXCEPTION);
m_pLastNewIns->SetDVar(m_pCBB->clauseVarIndex);

// To allow filter clauses in generic methods to access the generic argument,
// we copy that argument variable from the parent frame to the filter's frame.
// The target variable offset is the same as the one in the parent frame.
if ((m_pCBB->clauseType == BBClauseFilter) && (m_paramArgIndex != -1))
{
AddIns(INTOP_LOAD_FRAMEVAR);
PushInterpType(InterpTypeI, NULL);
m_pLastNewIns->SetDVar(m_pStackPointer[-1].var);

m_pStackPointer--;
int32_t opcode = GetLdindForType(m_pVars[m_paramArgIndex].interpType);
AddIns(opcode);
m_pLastNewIns->SetSVar(m_pStackPointer[0].var);
m_pLastNewIns->SetDVar(m_paramArgIndex);
m_pLastNewIns->data[0] = m_pVars[m_paramArgIndex].offset;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/interpreter/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ class InterpCompiler
int32_t m_varsSize = 0;
int32_t m_varsCapacity = 0;
int32_t m_numILVars = 0;
int32_t m_paramArgIndex = 0; // Index of the type parameter argument in the m_pVars array.
int32_t m_paramArgIndex = -1; // Index of the type parameter argument in the m_pVars array.
// For each catch or filter clause, we create a variable that holds the exception object.
// This is the index of the first such variable.
int32_t m_clauseVarsIndex = 0;
Expand Down
Loading