Skip to content

Commit

Permalink
Fix interpreter build (#38673)
Browse files Browse the repository at this point in the history
Fix interpreter build
  • Loading branch information
BruceForstall authored Jul 2, 2020
1 parent 06fa941 commit 937f6e5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
33 changes: 19 additions & 14 deletions src/coreclr/src/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE
#ifdef TARGET_X86
int m_curOfs; // Current position of the stack iterator
int m_numRegistersUsed;
#ifdef FEATURE_INTERPRETER
bool m_fUnmanagedCallConv;
#endif
#endif

#ifdef TARGET_AMD64
Expand Down Expand Up @@ -988,6 +991,7 @@ int ArgIteratorTemplate<ARGITERATOR_BASE>::GetNextOffset()
m_fUnmanagedCallConv = false;
m_numRegistersUsed = numRegistersUsed;
m_curOfs = TransitionBlock::GetOffsetOfArgs() + SizeOfArgStack();
break;
}
#else
m_numRegistersUsed = numRegistersUsed;
Expand Down Expand Up @@ -1601,20 +1605,21 @@ void ArgIteratorTemplate<ARGITERATOR_BASE>::ForceSigWalk()
}

#ifdef FEATURE_INTERPRETER
BYTE callconv = CallConv();
switch (callconv)
{
case IMAGE_CEE_CS_CALLCONV_C:
case IMAGE_CEE_CS_CALLCONV_STDCALL:
numRegistersUsed = NUM_ARGUMENT_REGISTERS;
nSizeOfArgStack = TransitionBlock::GetOffsetOfArgs() + numRegistersUsed * sizeof(void *);
break;

case IMAGE_CEE_CS_CALLCONV_THISCALL:
case IMAGE_CEE_CS_CALLCONV_FASTCALL:
_ASSERTE_MSG(false, "Unsupported calling convention.");
default:
}
BYTE callconv = CallConv();
switch (callconv)
{
case IMAGE_CEE_CS_CALLCONV_C:
case IMAGE_CEE_CS_CALLCONV_STDCALL:
numRegistersUsed = NUM_ARGUMENT_REGISTERS;
nSizeOfArgStack = TransitionBlock::GetOffsetOfArgs() + numRegistersUsed * sizeof(void *);
break;

case IMAGE_CEE_CS_CALLCONV_THISCALL:
case IMAGE_CEE_CS_CALLCONV_FASTCALL:
_ASSERTE_MSG(false, "Unsupported calling convention.");
default:
break;
}
#endif // FEATURE_INTERPRETER

DWORD nArgs = this->NumFixedArgs();
Expand Down
25 changes: 17 additions & 8 deletions src/coreclr/src/vm/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
#elif defined(HOST_AMD64)
argState.AddArg(k, static_cast<short>(szSlots));
#elif defined(HOST_ARM) || defined(HOST_ARM64)
// TODO: handle Vector64, Vector128 types
CorInfoHFAElemType hfaType = comp->getHFAType(vcTypeRet);
if (CorInfoTypeIsFloatingPoint(hfaType))
{
Expand Down Expand Up @@ -1827,12 +1828,16 @@ AwareLock* Interpreter::GetMonitorForStaticMethod()
{
case CORINFO_LOOKUP_CLASSPARAM:
{
classHnd = (CORINFO_CLASS_HANDLE) GetPreciseGenericsContext();
CORINFO_CONTEXT_HANDLE ctxHnd = GetPreciseGenericsContext();
_ASSERTE_MSG((((size_t)ctxHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_CLASS), "Precise context not class context");
classHnd = (CORINFO_CLASS_HANDLE) ((size_t)ctxHnd & ~CORINFO_CONTEXTFLAGS_CLASS);
}
break;
case CORINFO_LOOKUP_METHODPARAM:
{
MethodDesc* pMD = (MethodDesc*) GetPreciseGenericsContext();
CORINFO_CONTEXT_HANDLE ctxHnd = GetPreciseGenericsContext();
_ASSERTE_MSG((((size_t)ctxHnd & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_METHOD), "Precise context not method context");
MethodDesc* pMD = (MethodDesc*) (CORINFO_METHOD_HANDLE) ((size_t)ctxHnd & ~CORINFO_CONTEXTFLAGS_METHOD);
classHnd = (CORINFO_CLASS_HANDLE) pMD->GetMethodTable();
}
break;
Expand Down Expand Up @@ -2249,8 +2254,8 @@ void Interpreter::ExecuteMethod(ARG_SLOT* retVal, __out bool* pDoJmpCall, __out
#if defined(FEATURE_HFA)
// Is it an HFA?
else if (m_methInfo->m_returnType == CORINFO_TYPE_VALUECLASS
&& (cit != CORINFO_HFA_ELEM_NONE))
&& (MetaSig(reinterpret_cast<MethodDesc*>(m_methInfo->m_method)).GetCallingConventionInfo() & CORINFO_CALLCONV_VARARG) == 0)
&& (cit != CORINFO_HFA_ELEM_NONE)
&& (MetaSig(reinterpret_cast<MethodDesc*>(m_methInfo->m_method)).GetCallingConventionInfo() & CORINFO_CALLCONV_VARARG) == 0)
{
if (retValIt.IsLargeStruct(&m_interpCeeInfo))
{
Expand Down Expand Up @@ -4012,6 +4017,10 @@ bool CorInfoTypeIsFloatingPoint(CorInfoType cit)
return cit == CORINFO_TYPE_FLOAT || cit == CORINFO_TYPE_DOUBLE;
}

bool CorInfoTypeIsFloatingPoint(CorInfoHFAElemType cihet)
{
return cihet == CORINFO_HFA_ELEM_FLOAT || cihet == CORINFO_HFA_ELEM_DOUBLE;
}

bool CorElemTypeIsUnsigned(CorElementType cet)
{
Expand Down Expand Up @@ -9073,25 +9082,25 @@ void Interpreter::DoCallWork(bool virtualCall, void* thisArg, CORINFO_RESOLVED_T
didIntrinsic = true;
}

// TODO: The following check for hardware intrinsics is not a production-level
// solution and may produce incorrect results.
#ifdef FEATURE_INTERPRETER
// TODO: The following check for hardware intrinsics is not a production-level
// solution and may produce incorrect results.
static ConfigDWORD s_InterpreterHWIntrinsicsIsSupportedFalse;
if (s_InterpreterHWIntrinsicsIsSupportedFalse.val(CLRConfig::INTERNAL_InterpreterHWIntrinsicsIsSupportedFalse) != 0)
{
if (strcmp(methToCall->GetModule()->GetSimpleName(), "System.Private.CoreLib") == 0 &&
#ifdef _DEBUG // GetDebugClassName() is only available in _DEBUG builds
#if defined(TARGET_X86) || defined(TARGET_AMD64)
strncmp(methToCall->GetClass()->GetDebugClassName(), "System.Runtime.Intrinsics.X86", 29) == 0 &&
#elif defined(TARGET_ARM64)
strncmp(methToCall->GetClass()->GetDebugClassName(), "System.Runtime.Intrinsics.Arm", 29) == 0 &&
#endif // defined(TARGET_X86) || defined(TARGET_AMD64)
#endif // _DEBUG
strcmp(methToCall->GetName(), "get_IsSupported") == 0)
{
DoGetIsSupported();
didIntrinsic = true;
}
}
#endif // FEATURE_INTERPRETER

#if FEATURE_SIMD
if (fFeatureSIMD.val(CLRConfig::EXTERNAL_FeatureSIMD) != 0)
Expand Down
12 changes: 8 additions & 4 deletions src/coreclr/src/vm/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ bool CorInfoTypeIsIntegral(CorInfoType cit);
// Returns true iff "cet" is an unsigned integral type.
bool CorElemTypeIsUnsigned(CorElementType cet);

// Returns true iff "cit" is an integral type.
// Returns true iff "cit" is a floating-point type.
bool CorInfoTypeIsFloatingPoint(CorInfoType cit);

// Returns true iff "cihet" is a floating-point type (float or double).
// TODO: Handle Vector64, Vector128?
bool CorInfoTypeIsFloatingPoint(CorInfoHFAElemType cihet);

// Returns true iff "cit" is a pointer type (mgd/unmgd pointer, or native int).
bool CorInfoTypeIsPointer(CorInfoType cit);

Expand Down Expand Up @@ -702,7 +706,7 @@ struct InterpreterMethodInfo
void SetPinningBit(unsigned locNum);
bool GetPinningBit(unsigned locNum);

CORINFO_METHOD_HANDLE GetPreciseGenericsContext(Object* thisArg, void* genericsCtxtArg);
CORINFO_CONTEXT_HANDLE GetPreciseGenericsContext(Object* thisArg, void* genericsCtxtArg);

#ifndef DACCESS_COMPILE
// Gets the proper cache for a call to a method with the current InterpreterMethodInfo, with the given
Expand Down Expand Up @@ -1773,9 +1777,9 @@ class Interpreter

// Returns the proper generics context for use in resolving tokens ("precise" in the sense of including generic instantiation
// information).
CORINFO_METHOD_HANDLE m_preciseGenericsContext;
CORINFO_CONTEXT_HANDLE m_preciseGenericsContext;

CORINFO_METHOD_HANDLE GetPreciseGenericsContext()
CORINFO_CONTEXT_HANDLE GetPreciseGenericsContext()
{
if (m_preciseGenericsContext == NULL)
{
Expand Down

0 comments on commit 937f6e5

Please sign in to comment.