Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 1 addition & 4 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,9 @@ enum CorInfoHelpFunc

CORINFO_HELP_MON_ENTER,
CORINFO_HELP_MON_EXIT,
CORINFO_HELP_MON_ENTER_STATIC,
CORINFO_HELP_MON_EXIT_STATIC,

CORINFO_HELP_GETCLASSFROMMETHODPARAM, // Given a generics method handle, returns a class handle
CORINFO_HELP_GETSYNCFROMCLASSHANDLE, // Given a generics class handle, returns the sync monitor
// in its ManagedClassObject
CORINFO_HELP_GETSYNCFROMCLASSHANDLE, // Given a generics class handle return the ManagedClassObject that is used to lock a static method

/* GC support */

Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* b75a5475-ff22-4078-9551-2024ce03d383 */
0xb75a5475,
0xff22,
0x4078,
{0x95, 0x51, 0x20, 0x24, 0xce, 0x03, 0xd3, 0x83}
constexpr GUID JITEEVersionIdentifier = { /* 7a8070f8-2951-4394-b97b-3d7c9bd8c91f */
0x7a8070f8,
0x2951,
0x4394,
{0xb9, 0x7b, 0x3d, 0x7c, 0x9b, 0xd8, 0xc9, 0x1f}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@

JITHELPER(CORINFO_HELP_MON_ENTER, JIT_MonEnterWorker, METHOD__NIL)
JITHELPER(CORINFO_HELP_MON_EXIT, JIT_MonExitWorker, METHOD__NIL)
JITHELPER(CORINFO_HELP_MON_ENTER_STATIC, JIT_MonEnterStatic,METHOD__NIL)
JITHELPER(CORINFO_HELP_MON_EXIT_STATIC, JIT_MonExitStatic,METHOD__NIL)

JITHELPER(CORINFO_HELP_GETCLASSFROMMETHODPARAM, JIT_GetClassFromMethodParam, METHOD__NIL)
JITHELPER(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, JIT_GetSyncFromClassHandle, METHOD__NIL)
JITHELPER(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, JIT_GetRuntimeType, METHOD__NIL)

// GC support
DYNAMICJITHELPER(CORINFO_HELP_STOP_FOR_GC, JIT_RareDisableHelper, METHOD__NIL)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6196,15 +6196,13 @@ void CodeGen::genCall(GenTreeCall* call)
switch (helperNum)
{
case CORINFO_HELP_MON_ENTER:
case CORINFO_HELP_MON_ENTER_STATIC:
noway_assert(compiler->syncStartEmitCookie == nullptr);
compiler->syncStartEmitCookie =
GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur);
noway_assert(compiler->syncStartEmitCookie != nullptr);
break;
case CORINFO_HELP_MON_EXIT:
case CORINFO_HELP_MON_EXIT_STATIC:
noway_assert(compiler->syncEndEmitCookie == nullptr);
compiler->syncEndEmitCookie =
GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
Expand Down
35 changes: 23 additions & 12 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,11 +1241,23 @@ GenTree* Compiler::fgGetCritSectOfStaticMethod()

if (!kind.needsRuntimeLookup)
{
void *critSect = nullptr, **pCrit = nullptr;
critSect = info.compCompHnd->getMethodSync(info.compMethodHnd, (void**)&pCrit);
noway_assert((!critSect) != (!pCrit));
CORINFO_OBJECT_HANDLE ptr = info.compCompHnd->getRuntimeTypePointer(info.compClassHnd);
if (ptr != NULL)
{
setMethodHasFrozenObjects();
tree = gtNewIconEmbHndNode((void*)ptr, nullptr, GTF_ICON_OBJ_HDL, nullptr);
}
else
{
void *critSect = nullptr, **pCrit = nullptr;
critSect = info.compCompHnd->getMethodSync(info.compMethodHnd, (void**)&pCrit);
noway_assert((!critSect) != (!pCrit));

tree = gtNewIconEmbHndNode(critSect, pCrit, GTF_ICON_GLOBAL_PTR, info.compMethodHnd);

tree = gtNewIconEmbHndNode(critSect, pCrit, GTF_ICON_GLOBAL_PTR, info.compMethodHnd);
// Given the class handle, get the pointer to the Monitor.
tree = gtNewHelperCallNode(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, TYP_REF, tree);
}
}
else
{
Expand Down Expand Up @@ -1291,7 +1303,7 @@ GenTree* Compiler::fgGetCritSectOfStaticMethod()
noway_assert(tree); // tree should now contain the CORINFO_CLASS_HANDLE for the exact class.

// Given the class handle, get the pointer to the Monitor.
tree = gtNewHelperCallNode(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, TYP_I_IMPL, tree);
tree = gtNewHelperCallNode(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, TYP_REF, tree);
}

noway_assert(tree);
Expand Down Expand Up @@ -1578,15 +1590,14 @@ GenTree* Compiler::fgCreateMonitorTree(unsigned lvaMonAcquired, unsigned lvaThis
if (info.compIsStatic)
{
tree = fgGetCritSectOfStaticMethod();
tree = gtNewHelperCallNode(enter ? CORINFO_HELP_MON_ENTER_STATIC : CORINFO_HELP_MON_EXIT_STATIC, TYP_VOID, tree,
varAddrNode);
}
else
{
tree = gtNewLclvNode(lvaThisVar, TYP_REF);
tree = gtNewHelperCallNode(enter ? CORINFO_HELP_MON_ENTER : CORINFO_HELP_MON_EXIT, TYP_VOID, tree, varAddrNode);
}

tree = gtNewHelperCallNode(enter ? CORINFO_HELP_MON_ENTER : CORINFO_HELP_MON_EXIT, TYP_VOID, tree, varAddrNode);

#ifdef DEBUG
if (verbose)
{
Expand Down Expand Up @@ -2494,15 +2505,15 @@ PhaseStatus Compiler::fgAddInternal()
if (info.compIsStatic)
{
tree = fgGetCritSectOfStaticMethod();
tree = gtNewHelperCallNode(CORINFO_HELP_MON_ENTER_STATIC, TYP_VOID, tree);
}
else
{
noway_assert(lvaTable[info.compThisArg].lvType == TYP_REF);
tree = gtNewLclvNode(info.compThisArg, TYP_REF);
tree = gtNewHelperCallNode(CORINFO_HELP_MON_ENTER, TYP_VOID, tree);
}

tree = gtNewHelperCallNode(CORINFO_HELP_MON_ENTER, TYP_VOID, tree);

/* Create a new basic block and stick the call in it */

fgEnsureFirstBBisScratch();
Expand All @@ -2527,14 +2538,14 @@ PhaseStatus Compiler::fgAddInternal()
if (info.compIsStatic)
{
tree = fgGetCritSectOfStaticMethod();
tree = gtNewHelperCallNode(CORINFO_HELP_MON_EXIT_STATIC, TYP_VOID, tree);
}
else
{
tree = gtNewLclvNode(info.compThisArg, TYP_REF);
tree = gtNewHelperCallNode(CORINFO_HELP_MON_EXIT, TYP_VOID, tree);
}

tree = gtNewHelperCallNode(CORINFO_HELP_MON_EXIT, TYP_VOID, tree);

fgNewStmtNearEnd(genReturnBB, tree);

#ifdef DEBUG
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1802,10 +1802,6 @@ void HelperCallProperties::init()
alwaysThrow = true;
break;

// These helper calls may throw an exception
case CORINFO_HELP_MON_EXIT_STATIC:
break;

// This is a debugging aid; it simply returns a constant address.
case CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR:
isPure = true;
Expand All @@ -1821,7 +1817,6 @@ void HelperCallProperties::init()
case CORINFO_HELP_POLL_GC:
case CORINFO_HELP_MON_ENTER:
case CORINFO_HELP_MON_EXIT:
case CORINFO_HELP_MON_ENTER_STATIC:
case CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT:
case CORINFO_HELP_GETFIELDADDR:
case CORINFO_HELP_JIT_PINVOKE_BEGIN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,7 @@ private static void MonitorExit(object obj, ref bool lockTaken)
lockTaken = false;
}

private static unsafe void MonitorEnterStatic(MethodTable* pMT, ref bool lockTaken)
{
// Inlined Monitor.Enter with a few tweaks
object obj = GetStaticLockObject(pMT);
int currentThreadID = ManagedThreadId.CurrentManagedThreadIdUnchecked;
int resultOrIndex = ObjectHeader.Acquire(obj, currentThreadID);
if (resultOrIndex < 0)
{
lockTaken = true;
return;
}

Lock lck = resultOrIndex == 0 ?
ObjectHeader.GetLockObject(obj) :
SyncTable.GetLockObject(resultOrIndex);

lck.TryEnterSlow(Timeout.Infinite, currentThreadID);
lockTaken = true;
}
private static unsafe void MonitorExitStatic(MethodTable* pMT, ref bool lockTaken)
{
// Inlined Monitor.Exit with a few tweaks
if (!lockTaken)
return;

object obj = GetStaticLockObject(pMT);
ObjectHeader.Release(obj);
lockTaken = false;
}

private static unsafe RuntimeType GetStaticLockObject(MethodTable* pMT)
{
return Type.GetTypeFromMethodTable(pMT);
}

private static unsafe MethodTable* GetSyncFromClassHandle(MethodTable* pMT) => pMT;
private static unsafe RuntimeType GetSyncFromClassHandle(MethodTable* pMT) => Type.GetTypeFromMethodTable(pMT);

private static unsafe MethodTable* GetClassFromMethodParam(IntPtr pDictionary)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ public enum ReadyToRunHelper
CheckInstanceInterface,
CheckInstanceClass,

MonitorEnterStatic,
MonitorExitStatic,

NewMultiDimArrRare,

// GVM lookup helper
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ which is the right helper to use to allocate an object of a given type. */

CORINFO_HELP_MON_ENTER,
CORINFO_HELP_MON_EXIT,
CORINFO_HELP_MON_ENTER_STATIC,
CORINFO_HELP_MON_EXIT_STATIC,

CORINFO_HELP_GETCLASSFROMMETHODPARAM, // Given a generics method handle, returns a class handle
CORINFO_HELP_GETSYNCFROMCLASSHANDLE, // Given a generics class handle, returns the sync monitor
// in its ManagedClassObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,6 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id,
case ReadyToRunHelper.MonitorExit:
methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorExit");
break;
case ReadyToRunHelper.MonitorEnterStatic:
methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorEnterStatic");
break;
case ReadyToRunHelper.MonitorExitStatic:
methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorExitStatic");
break;

case ReadyToRunHelper.GVMLookupForSlot:
methodDesc = context.SystemModule.GetKnownType("System.Runtime", "TypeLoaderExports").GetKnownMethod("GVMLookupForSlot", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ public ILImporter(ILScanner compilation, MethodDesc method, MethodIL methodIL =
if (_canonMethod.IsSynchronized)
{
const string reason = "Synchronized method";
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorEnter), reason);
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExit), reason);
if (_canonMethod.Signature.IsStatic)
{
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorEnterStatic), reason);
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExitStatic), reason);
_dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle")), reason);

MethodDesc method = _methodIL.OwningMethod;
if (method.OwningType.IsRuntimeDeterminedSubtype)
Expand All @@ -166,18 +167,10 @@ public ILImporter(ILScanner compilation, MethodDesc method, MethodIL methodIL =

if (_canonMethod.IsCanonicalMethod(CanonicalFormKind.Any))
{
_dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle")), reason);

if (_canonMethod.RequiresInstMethodDescArg())
_dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam")), reason);
}
}
else
{
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorEnter), reason);
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExit), reason);
}

}

FindBasicBlocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2954,7 +2954,6 @@ private void expandRawHandleIntrinsic(ref CORINFO_RESOLVED_TOKEN pResolvedToken,

private void* getMethodSync(CORINFO_METHOD_STRUCT_* ftn, ref void* ppIndirection)
{
// Used with CORINFO_HELP_MON_ENTER_STATIC/CORINFO_HELP_MON_EXIT_STATIC - we don't have this fixup in R2R.
throw new RequiresRuntimeJitException($"{MethodBeingCompiled} -> {nameof(getMethodSync)}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,6 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
id = ReadyToRunHelper.MonitorExit;
break;

case CorInfoHelpFunc.CORINFO_HELP_MON_ENTER_STATIC:
id = ReadyToRunHelper.MonitorEnterStatic;
break;
case CorInfoHelpFunc.CORINFO_HELP_MON_EXIT_STATIC:
id = ReadyToRunHelper.MonitorExitStatic;
break;

case CorInfoHelpFunc.CORINFO_HELP_GETSYNCFROMCLASSHANDLE:
return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle"));
case CorInfoHelpFunc.CORINFO_HELP_GETCLASSFROMMETHODPARAM:
Expand Down
Loading