Skip to content
Merged
Changes from 4 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
31 changes: 8 additions & 23 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,6 @@ int32_t InterpCompiler::GetInterpTypeStackSize(CORINFO_CLASS_HANDLE clsHnd, Inte
size = m_compHnd->getClassSize(clsHnd);
align = m_compHnd->getClassAlignmentRequirement(clsHnd);

assert(align <= INTERP_STACK_ALIGNMENT);

// All vars are stored at 8 byte aligned offsets
if (align < INTERP_STACK_SLOT_SIZE)
align = INTERP_STACK_SLOT_SIZE;
Expand Down Expand Up @@ -2303,25 +2301,9 @@ bool InterpCompiler::EmitNamedIntrinsicCall(NamedIntrinsic ni, CORINFO_CLASS_HAN
case NI_System_Runtime_CompilerServices_RuntimeHelpers_IsReferenceOrContainsReferences:
{
CORINFO_CLASS_HANDLE clsHnd = sig.sigInst.methInst[0];
bool isValueType = (m_compHnd->getClassAttribs(clsHnd) & CORINFO_FLG_VALUECLASS) != 0;
bool hasGCRefs = false;

if (isValueType)
{
// Walk the layout to see if any field is a GC pointer
const uint32_t maxSlots = 256;
BYTE gcLayout[maxSlots];
uint32_t numSlots = m_compHnd->getClassGClayout(clsHnd, gcLayout);

for (uint32_t i = 0; i < numSlots; ++i)
{
if (gcLayout[i] != TYPE_GC_NONE)
{
hasGCRefs = true;
break;
}
}
}
uint32_t clsAttribs = m_compHnd->getClassAttribs(clsHnd);
bool isValueType = (clsAttribs & CORINFO_FLG_VALUECLASS) != 0;
bool hasGCRefs = (clsAttribs & CORINFO_FLG_CONTAINS_GC_PTR) != 0;

int32_t result = (!isValueType || hasGCRefs) ? 1 : 0;

Expand Down Expand Up @@ -2732,12 +2714,15 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* pConstrainedToken, bool re

CORINFO_CALLINFO_FLAGS flags = (CORINFO_CALLINFO_FLAGS)(CORINFO_CALLINFO_ALLOWINSTPARAM | CORINFO_CALLINFO_SECURITYCHECKS | CORINFO_CALLINFO_DISALLOW_STUB);
if (isVirtual)
flags = (CORINFO_CALLINFO_FLAGS)(flags | CORINFO_CALLINFO_CALLVIRT);
flags = (CORINFO_CALLINFO_FLAGS)(flags | CORINFO_CALLINFO_CALLVIRT);

m_compHnd->getCallInfo(&resolvedCallToken, pConstrainedToken, m_methodInfo->ftn, flags, &callInfo);
if (callInfo.methodFlags & CORINFO_FLG_INTRINSIC)
{
if (InterpConfig.InterpMode() >= 3)
// If we are being asked explicitly to compile an intrinsic for interpreting, we need to forcibly enable
// intrinsics for the recursive call. Otherwise we will just recurse infinitely and overflow stack.
bool isMustExpand = (callInfo.hMethod == m_methodHnd);
if ((InterpConfig.InterpMode() == 3) || isMustExpand)
{
NamedIntrinsic ni = GetNamedIntrinsic(m_compHnd, m_methodHnd, callInfo.hMethod);
if (EmitNamedIntrinsicCall(ni, resolvedCallToken.hClass, callInfo.hMethod, callInfo.sig))
Expand Down
Loading