Skip to content

Commit

Permalink
Clear the init-locals bit for CoreLib to workaround #1279
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Aug 31, 2017
1 parent d52cbdb commit 5efb622
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/mscorlib/src/System/RtType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,11 @@ private unsafe RuntimeMethodInfo[] PopulateMethods(Filter filter)
while (RuntimeTypeHandle.IsGenericVariable(declaringType))
declaringType = declaringType.GetBaseType();

bool* overrides = stackalloc bool[RuntimeTypeHandle.GetNumVirtuals(declaringType)];
int numVirtuals = RuntimeTypeHandle.GetNumVirtuals(declaringType);

bool* overrides = stackalloc bool[numVirtuals];
new Span<bool>(overrides, numVirtuals).Clear();

bool isValueType = declaringType.IsValueType;

do
Expand Down
48 changes: 29 additions & 19 deletions src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7190,31 +7190,41 @@ getMethodInfoHelper(
bool fILIntrinsic = false;

MethodTable * pMT = ftn->GetMethodTable();

if (MscorlibBinder::IsClass(pMT, CLASS__JIT_HELPERS))
{
fILIntrinsic = getILIntrinsicImplementation(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__UNSAFE))
{
fILIntrinsic = getILIntrinsicImplementationForUnsafe(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__INTERLOCKED))
{
fILIntrinsic = getILIntrinsicImplementationForInterlocked(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__VOLATILE))
{
fILIntrinsic = getILIntrinsicImplementationForVolatile(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__RUNTIME_HELPERS))

if (pMT->GetModule()->IsSystem())
{
fILIntrinsic = getILIntrinsicImplementationForRuntimeHelpers(ftn, methInfo);
if (MscorlibBinder::IsClass(pMT, CLASS__JIT_HELPERS))
{
fILIntrinsic = getILIntrinsicImplementation(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__UNSAFE))
{
fILIntrinsic = getILIntrinsicImplementationForUnsafe(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__INTERLOCKED))
{
fILIntrinsic = getILIntrinsicImplementationForInterlocked(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__VOLATILE))
{
fILIntrinsic = getILIntrinsicImplementationForVolatile(ftn, methInfo);
}
else if (MscorlibBinder::IsClass(pMT, CLASS__RUNTIME_HELPERS))
{
fILIntrinsic = getILIntrinsicImplementationForRuntimeHelpers(ftn, methInfo);
}
}

if (!fILIntrinsic)
{
getMethodInfoILMethodHeaderHelper(header, methInfo);

// Workaround for https://github.com/dotnet/coreclr/issues/1279
// Set init locals bit to zero for system module unless profiler may have overrided it. Remove once we have
// better solution for this issue.
if (pMT->GetModule()->IsSystem() && !(CORProfilerDisableAllNGenImages() || CORProfilerUseProfileImages()))
methInfo->options = (CorInfoOptions)0;

pLocalSig = header->LocalVarSig;
cbLocalSig = header->cbLocalVarSig;
}
Expand Down

0 comments on commit 5efb622

Please sign in to comment.