Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,13 @@ private static bool InternalEqualMethodHandles(Delegate left, Delegate right)

internal static IntPtr AdjustTarget(object target, IntPtr methodPtr)
{
return AdjustTarget(ObjectHandleOnStack.Create(ref target), methodPtr);
IntPtr result = AdjustTarget(RuntimeHelpers.GetMethodTable(target), methodPtr);
GC.KeepAlive(target);
return result;
}

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Delegate_AdjustTarget")]
private static partial IntPtr AdjustTarget(ObjectHandleOnStack target, IntPtr methodPtr);
private static partial IntPtr AdjustTarget(MethodTable* targetMT, IntPtr methodPtr);

Comment on lines 543 to 545
internal void InitializeVirtualCallStub(IntPtr methodPtr)
{
Expand Down
11 changes: 9 additions & 2 deletions src/coreclr/debug/ee/funceval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,7 @@ void GatherFuncEvalMethodInfo(DebuggerEval *pDE,
//
if ((pDE->m_evalType != DB_IPCE_FET_NEW_OBJECT) && !pDE->m_md->IsStatic() && pDE->m_md->IsUnboxingStub())
{
GCX_PREEMP();
*ppUnboxedMD = pDE->m_md->GetMethodTable()->GetUnboxedEntryPointMD(pDE->m_md);
}

Expand Down Expand Up @@ -2213,13 +2214,19 @@ void GatherFuncEvalMethodInfo(DebuggerEval *pDE,
// Now, find the proper MethodDesc for this interface method based on the object we're invoking the
// method on.
//
pDE->m_targetCodeAddr = pDE->m_md->GetCallTarget(&objRef, pDE->m_ownerTypeHandle);
{
GCX_PREEMP();
pDE->m_targetCodeAddr = pDE->m_md->GetCallTarget(&objRef, pDE->m_ownerTypeHandle);
}

GCPROTECT_END();
}
else
{
pDE->m_targetCodeAddr = pDE->m_md->GetCallTarget(NULL, pDE->m_ownerTypeHandle);
{
GCX_PREEMP();
pDE->m_targetCodeAddr = pDE->m_md->GetCallTarget(NULL, pDE->m_ownerTypeHandle);
}
}

//
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/vm/amd64/cgenamd64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include "clrtocomcall.h"
#endif // FEATURE_COMINTEROP

#ifdef FEATURE_PERFMAP
#include "perfmap.h"
#endif

void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegisters * pRegs)
{
Expand Down Expand Up @@ -607,17 +605,11 @@ DWORD GetOffsetAtEndOfFunction(ULONGLONG uImageBase,
size_t rxOffset = pStartRX - pStart; \
BYTE * p = pStart;

#ifdef FEATURE_PERFMAP
#define BEGIN_DYNAMIC_HELPER_EMIT(size) \
BEGIN_DYNAMIC_HELPER_EMIT_WORKER(size) \
PerfMap::LogStubs(__FUNCTION__, "DynamicHelper", (PCODE)p, size, PerfMapStubType::Individual);
#else
#define BEGIN_DYNAMIC_HELPER_EMIT(size) BEGIN_DYNAMIC_HELPER_EMIT_WORKER(size)
#endif

#define END_DYNAMIC_HELPER_EMIT() \
_ASSERTE(pStart + cb == p); \
while (p < pStart + cbAligned) *p++ = X86_INSTR_INT3; \
ClrFlushInstructionCache(pStartRX, cbAligned); \
return (PCODE)pStartRX
Comment on lines 608 to 614

Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/vm/arm/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
#include "ecall.h"
#include "threadsuspend.h"

#ifdef FEATURE_PERFMAP
#include "perfmap.h"
#endif

// target write barriers
EXTERN_C void JIT_WriteBarrier(Object **dst, Object *ref);
Expand Down Expand Up @@ -1505,13 +1503,9 @@ void MovRegImm(BYTE* p, int reg, TADDR imm)
size_t rxOffset = pStartRX - pStart; \
BYTE * p = pStart;

#ifdef FEATURE_PERFMAP
#define BEGIN_DYNAMIC_HELPER_EMIT(size) \
BEGIN_DYNAMIC_HELPER_EMIT_WORKER(size) \
PerfMap::LogStubs(__FUNCTION__, "DynamicHelper", (PCODE)p, size, PerfMapStubType::Individual);
#else
#define BEGIN_DYNAMIC_HELPER_EMIT(size) BEGIN_DYNAMIC_HELPER_EMIT_WORKER(size)
#endif


#define END_DYNAMIC_HELPER_EMIT() \
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/vm/arm64/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
#include "ecall.h"
#include "writebarriermanager.h"

#ifdef FEATURE_PERFMAP
#include "perfmap.h"
#endif

#ifndef DACCESS_COMPILE
//-----------------------------------------------------------------------
Expand Down Expand Up @@ -951,13 +949,9 @@ void StubLinkerCPU::EmitCallManagedMethod(MethodDesc *pMD, BOOL fTailCall)
size_t rxOffset = pStartRX - pStart; \
BYTE * p = pStart;

#ifdef FEATURE_PERFMAP
#define BEGIN_DYNAMIC_HELPER_EMIT(size) \
BEGIN_DYNAMIC_HELPER_EMIT_WORKER(size) \
PerfMap::LogStubs(__FUNCTION__, "DynamicHelper", (PCODE)p, size, PerfMapStubType::Individual);
#else
#define BEGIN_DYNAMIC_HELPER_EMIT(size) BEGIN_DYNAMIC_HELPER_EMIT_WORKER(size)
#endif


#define END_DYNAMIC_HELPER_EMIT() \
Expand Down
6 changes: 5 additions & 1 deletion src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,11 @@ static void RunMainInternal(Param* pParam)
StrArgArray = *pParam->stringArgs;

pParam->pFD->EnsureActive();
PCODE entryPoint = pParam->pFD->GetSingleCallableAddrOfCode();
PCODE entryPoint;
{
GCX_PREEMP();
entryPoint = pParam->pFD->GetSingleCallableAddrOfCode();
}

BOOL hasReturnValue = !pParam->pFD->IsVoid();
PTRARRAYREF* pArgument = (pParam->EntryType == EntryManagedMain) ? &StrArgArray : NULL;
Expand Down
10 changes: 8 additions & 2 deletions src/coreclr/vm/callhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,17 @@ void CallDefaultConstructor(OBJECTREF ref)

GCPROTECT_BEGIN (ref);

MethodDesc *pMD = pMT->GetDefaultConstructor();

PCODE methodEntry;
{
GCX_PREEMP();
MethodDesc *pMD = pMT->GetDefaultConstructor();
methodEntry = pMD->GetSingleCallableAddrOfCode();
}

UnmanagedCallersOnlyCaller defaultCtorInvoker{METHOD__RUNTIME_HELPERS__CALL_DEFAULT_CONSTRUCTOR};

defaultCtorInvoker.InvokeThrowing(&ref, pMD->GetSingleCallableAddrOfCode());
defaultCtorInvoker.InvokeThrowing(&ref, methodEntry);

GCPROTECT_END ();
}
169 changes: 0 additions & 169 deletions src/coreclr/vm/callhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,178 +104,9 @@ class MethodDescCallSite
}
#endif // _DEBUG

void DefaultInit(OBJECTREF* porProtectedThis)
{
CONTRACTL
{
MODE_ANY;
GC_TRIGGERS;
THROWS;
}
CONTRACTL_END;

#ifdef _DEBUG
//
// Make sure we are passing in a 'this' if and only if it is required
//
if (m_pMD->IsVtableMethod())
{
CONSISTENCY_CHECK_MSG(NULL != porProtectedThis, "You did not pass in the 'this' object for a vtable method");
}
else
{
if (NULL != porProtectedThis)
{
if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_AssertOnUnneededThis))
{
CONSISTENCY_CHECK_MSG(NULL == porProtectedThis, "You passed in a 'this' object to a non-vtable method.");
}
else
{
LogWeakAssert();
}

}
}
#endif // _DEBUG

m_pCallTarget = m_pMD->GetCallTarget(porProtectedThis);

m_argIt.ForceSigWalk();
}

void DefaultInit(TypeHandle th)
{
CONTRACTL
{
MODE_ANY;
GC_TRIGGERS;
THROWS;
}
CONTRACTL_END;

m_pCallTarget = m_pMD->GetCallTarget(NULL, th);

m_argIt.ForceSigWalk();
}

void CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT *pReturnValue, int cbReturnValue);

public:
// Used to avoid touching metadata for CoreLib methods.
// instance methods must pass in the 'this' object
// static methods must pass null
MethodDescCallSite(BinderMethodID id, OBJECTREF* porProtectedThis = NULL) :
m_pMD(
CoreLibBinder::GetMethod(id)
),
m_methodSig(id),
m_argIt(&m_methodSig)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
}
CONTRACTL_END;
DefaultInit(porProtectedThis);
}

// Used to avoid touching metadata for CoreLib methods.
// instance methods must pass in the 'this' object
// static methods must pass null
MethodDescCallSite(BinderMethodID id, OBJECTHANDLE hThis) :
m_pMD(
CoreLibBinder::GetMethod(id)
),
m_methodSig(id),
m_argIt(&m_methodSig)
{
WRAPPER_NO_CONTRACT;

DefaultInit((OBJECTREF*)hThis);
}

// instance methods must pass in the 'this' object
// static methods must pass null
MethodDescCallSite(MethodDesc* pMD, OBJECTREF* porProtectedThis = NULL) :
m_pMD(pMD),
m_methodSig(pMD),
m_argIt(&m_methodSig)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
}
CONTRACTL_END;

if (porProtectedThis == NULL)
{
// We don't have a "this" pointer - ensure that we have activated the containing module
m_pMD->EnsureActive();
}

DefaultInit(porProtectedThis);
}

// instance methods must pass in the 'this' object
// static methods must pass null
MethodDescCallSite(MethodDesc* pMD, OBJECTHANDLE hThis) :
m_pMD(pMD),
m_methodSig(pMD),
m_argIt(&m_methodSig)
{
WRAPPER_NO_CONTRACT;

if (hThis == NULL)
{
// We don't have a "this" pointer - ensure that we have activated the containing module
m_pMD->EnsureActive();
}

DefaultInit((OBJECTREF*)hThis);
}

// instance methods must pass in the 'this' object
// static methods must pass null
MethodDescCallSite(MethodDesc* pMD, LPHARDCODEDMETASIG pwzSignature, OBJECTREF* porProtectedThis = NULL) :
m_pMD(pMD),
m_methodSig(pwzSignature),
m_argIt(&m_methodSig)
{
WRAPPER_NO_CONTRACT;

if (porProtectedThis == NULL)
{
// We don't have a "this" pointer - ensure that we have activated the containing module
m_pMD->EnsureActive();
}

DefaultInit(porProtectedThis);
}

MethodDescCallSite(MethodDesc* pMD, TypeHandle th) :
m_pMD(pMD),
m_methodSig(pMD, th),
m_argIt(&m_methodSig)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
}
CONTRACTL_END;

// We don't have a "this" pointer - ensure that we have activated the containing module
m_pMD->EnsureActive();

DefaultInit(th);
}

//
// Only use this constructor if you're certain you know where
// you're going and it cannot be affected by generics/virtual
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@
#include "profilinghelper.h"
#endif // PROFILING_SUPPORTED

#ifdef FEATURE_PERFMAP
#include "perfmap.h"
#endif

#include "diagnosticserveradapter.h"
#include "eventpipeadapter.h"
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,7 @@ void TypeHandle::NotifyDebuggerUnload() const
MethodDesc* MethodTable::GetBoxedEntryPointMD(MethodDesc *pMD)
{
CONTRACT (MethodDesc *) {
MODE_PREEMPTIVE;
THROWS;
GC_TRIGGERS;
INJECT_FAULT(COMPlusThrowOM(););
Expand All @@ -1732,6 +1733,7 @@ MethodDesc* MethodTable::GetBoxedEntryPointMD(MethodDesc *pMD)
MethodDesc* MethodTable::GetUnboxedEntryPointMD(MethodDesc *pMD)
{
CONTRACT (MethodDesc *) {
MODE_PREEMPTIVE;
THROWS;
GC_TRIGGERS;
INJECT_FAULT(COMPlusThrowOM(););
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
#include "../debug/daccess/fntableaccess.h"
#endif // HOST_64BIT

#ifdef FEATURE_PERFMAP
#include "perfmap.h"
#endif

// Default number of jump stubs in a jump stub block
#define DEFAULT_JUMPSTUBS_PER_BLOCK 32
Expand Down Expand Up @@ -6237,9 +6235,7 @@ PCODE ExecutionManager::getNextJumpStub(MethodDesc* pMD, PCODE target,

emitBackToBackJump(jumpStub, jumpStubRW, (void*) target);

#ifdef FEATURE_PERFMAP
PerfMap::LogStubs(__FUNCTION__, "emitBackToBackJump", (PCODE)jumpStub, BACK_TO_BACK_JUMP_ALLOCATE_SIZE, PerfMapStubType::IndividualWithinBlock);
#endif

// We always add the new jumpstub to the jumpStubCache
//
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/vm/codeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void ReportStubBlock(void* start, size_t size, StubCodeBlockKind kind);
#ifndef FEATURE_PERFMAP
inline void ReportStubBlock(void* start, size_t size, StubCodeBlockKind kind)
{
CONTRACTL
{
GC_NOTRIGGER;
MODE_PREEMPTIVE;
}
CONTRACTL_END;
}
#endif

Expand Down
Loading
Loading