Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 21 additions & 1 deletion src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13409,8 +13409,28 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config,
ret = portableEntryPoint;

#else // !FEATURE_PORTABLE_ENTRYPOINTS
InterpreterPrecode* pPrecode = NULL;
AllocMemTracker amt;
InterpreterPrecode* pPrecode = Precode::AllocateInterpreterPrecode(ret, ftn->GetLoaderAllocator(), &amt);
if (ftn->IsDynamicMethod())
{
// For LCG methods, the precode is stashed in the DynamicMethodDesc, and is shared across all future uses of the DynamicMethodDesc
DynamicMethodDesc* pDMD = ftn->AsDynamicMethodDesc();
if (pDMD->m_interpreterPrecode != NULL)
{
pPrecode = pDMD->m_interpreterPrecode;
pPrecode->GetData()->ByteCodeAddr = ret;
FlushCacheForDynamicMappedStub(pPrecode, sizeof(InterpreterPrecode));
}
else
{
pPrecode = Precode::AllocateInterpreterPrecode(ret, ftn->GetLoaderAllocator(), &amt);
pDMD->m_interpreterPrecode = pPrecode;
}
}
else
{
pPrecode = Precode::AllocateInterpreterPrecode(ret, ftn->GetLoaderAllocator(), &amt);
}
amt.SuppressRelease();
ret = PINSTRToPCODE(pPrecode->GetEntryPoint());

Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,11 @@ void MethodDesc::Reset()
{
*GetAddrOfNativeCodeSlot() = (PCODE)NULL;
}

#ifdef FEATURE_INTERPRETER
ClearInterpreterCodePointer();
#endif

_ASSERTE(!HasNativeCode());
}

Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,11 @@ class MethodDesc
LIMITED_METHOD_CONTRACT;
VolatileStore(&m_interpreterCode, interpreterCode);
}
void ClearInterpreterCodePointer()
{
LIMITED_METHOD_CONTRACT;
VolatileStore(&m_interpreterCode, dac_cast<PTR_InterpByteCodeStart>((TADDR)NULL));
}
#endif // FEATURE_INTERPRETER

#ifdef _DEBUG
Expand Down Expand Up @@ -2707,6 +2712,11 @@ class DynamicMethodDesc : public StoredSigMethodDesc
PTR_DynamicResolver m_pResolver;

public:

#ifdef FEATURE_INTERPRETER
DPTR(struct InterpreterPrecode) m_interpreterPrecode;
#endif

enum ILStubType : DWORD
{
StubNotSet = 0,
Expand Down