Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 3 additions & 2 deletions src/coreclr/debug/daccess/nidump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,8 @@ NativeImageDumper::PrintManifestTokenName(mdToken token,

BOOL NativeImageDumper::HandleFixupForHistogram(PTR_CORCOMPILE_IMPORT_SECTION pSection,
SIZE_T fixupIndex,
SIZE_T *fixupCell)
SIZE_T *fixupCell,
BOOL mayUsePrecompiledNDirectMethods)
{
COUNT_T nImportSections;
PTR_CORCOMPILE_IMPORT_SECTION pImportSections = m_decoder.GetNativeImportSections(&nImportSections);
Expand Down Expand Up @@ -3577,7 +3578,7 @@ size_t NativeImageDumper::TranslateSymbol(IXCLRDisassemblySupport *dis,
return 0;
}

BOOL NativeImageDumper::HandleFixupForMethodDump(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell)
BOOL NativeImageDumper::HandleFixupForMethodDump(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell, BOOL mayUsePrecompiledNDirectMethods)
{
PTR_SIZE_T fixupPtr(TO_TADDR(fixupCell));
m_display->StartElement( "Fixup" );
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/nidump.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ class NativeImageDumper
IMetaDataAssemblyImport *m_manifestAssemblyImport;

//helper for ComputeMethodFixupHistogram
BOOL HandleFixupForHistogram(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell);
BOOL HandleFixupForHistogram(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell, BOOL mayUsePrecompiledNDirectMethods = TRUE);

//helper for DumpMethodFixups
BOOL HandleFixupForMethodDump(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell);
BOOL HandleFixupForMethodDump(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell, BOOL mayUsePrecompiledNDirectMethods = TRUE);

// Dependencies

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10262,7 +10262,7 @@ PTR_BYTE Module::GetNativeDebugInfo(MethodDesc * pMD)

//-----------------------------------------------------------------------------

BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupIndex, SIZE_T* fixupCell)
BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupIndex, SIZE_T* fixupCell, BOOL mayUsePrecompiledNDirectMethods)
{
CONTRACTL
{
Expand All @@ -10280,7 +10280,7 @@ BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupI
{
PTR_DWORD pSignatures = dac_cast<PTR_DWORD>(GetNativeOrReadyToRunImage()->GetRvaData(pSection->Signatures));

if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell))
if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell, mayUsePrecompiledNDirectMethods))
return FALSE;

_ASSERTE(*fixupCell != NULL);
Expand All @@ -10291,7 +10291,7 @@ BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupI
if (CORCOMPILE_IS_FIXUP_TAGGED(fixup, pSection))
{
// Fixup has not been fixed up yet
if (!LoadDynamicInfoEntry(this, (RVA)CORCOMPILE_UNTAG_TOKEN(fixup), fixupCell))
if (!LoadDynamicInfoEntry(this, (RVA)CORCOMPILE_UNTAG_TOKEN(fixup), fixupCell, mayUsePrecompiledNDirectMethods))
return FALSE;

_ASSERTE(!CORCOMPILE_IS_FIXUP_TAGGED(*fixupCell, pSection));
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -2679,17 +2679,17 @@ class Module
IMDInternalImport *GetNativeAssemblyImport(BOOL loadAllowed = TRUE);
IMDInternalImport *GetNativeAssemblyImportIfLoaded();

BOOL FixupNativeEntry(CORCOMPILE_IMPORT_SECTION * pSection, SIZE_T fixupIndex, SIZE_T *fixup);
BOOL FixupNativeEntry(CORCOMPILE_IMPORT_SECTION * pSection, SIZE_T fixupIndex, SIZE_T *fixup, BOOL mayUsePrecompiledNDirectMethods = TRUE);

//this split exists to support new CLR Dump functionality in DAC. The
//template removes any indirections.
BOOL FixupDelayList(TADDR pFixupList);
BOOL FixupDelayList(TADDR pFixupList, BOOL mayUsePrecompiledNDirectMethods = TRUE);

template<typename Ptr, typename FixupNativeEntryCallback>
BOOL FixupDelayListAux(TADDR pFixupList,
Ptr pThis, FixupNativeEntryCallback pfnCB,
PTR_CORCOMPILE_IMPORT_SECTION pImportSections, COUNT_T nImportSections,
PEDecoder * pNativeImage);
PEDecoder * pNativeImage, BOOL mayUsePrecompiledNDirectMethods = TRUE);
void RunEagerFixups();
void RunEagerFixupsUnlocked();

Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/vm/ceeload.inl
Original file line number Diff line number Diff line change
Expand Up @@ -463,21 +463,21 @@ FORCEINLINE PTR_DomainLocalModule Module::GetDomainLocalModule()

#include "nibblestream.h"

FORCEINLINE BOOL Module::FixupDelayList(TADDR pFixupList)
FORCEINLINE BOOL Module::FixupDelayList(TADDR pFixupList, BOOL mayUsePrecompiledNDirectMethods)
{
WRAPPER_NO_CONTRACT;

COUNT_T nImportSections;
PTR_CORCOMPILE_IMPORT_SECTION pImportSections = GetImportSections(&nImportSections);

return FixupDelayListAux(pFixupList, this, &Module::FixupNativeEntry, pImportSections, nImportSections, GetNativeOrReadyToRunImage());
return FixupDelayListAux(pFixupList, this, &Module::FixupNativeEntry, pImportSections, nImportSections, GetNativeOrReadyToRunImage(), mayUsePrecompiledNDirectMethods);
}

template<typename Ptr, typename FixupNativeEntryCallback>
BOOL Module::FixupDelayListAux(TADDR pFixupList,
Ptr pThis, FixupNativeEntryCallback pfnCB,
PTR_CORCOMPILE_IMPORT_SECTION pImportSections, COUNT_T nImportSections,
PEDecoder * pNativeImage)
PEDecoder * pNativeImage, BOOL mayUsePrecompiledNDirectMethods)
{
CONTRACTL
{
Expand Down Expand Up @@ -567,7 +567,7 @@ BOOL Module::FixupDelayListAux(TADDR pFixupList,
{
CONSISTENCY_CHECK(fixupIndex * sizeof(TADDR) < cbData);

if (!(pThis->*pfnCB)(pImportSection, fixupIndex, dac_cast<PTR_SIZE_T>(pData + fixupIndex * sizeof(TADDR))))
if (!(pThis->*pfnCB)(pImportSection, fixupIndex, dac_cast<PTR_SIZE_T>(pData + fixupIndex * sizeof(TADDR)), mayUsePrecompiledNDirectMethods))
return FALSE;

int delta = reader.ReadEncodedU32();
Expand Down
30 changes: 26 additions & 4 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10162,6 +10162,20 @@ bool CEEInfo::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SI
#endif
}

PrepareCodeConfig *config = GetThread()->GetCurrentPrepareCodeConfig();
if (config != nullptr && config->IsForMulticoreJit())
{
bool suppressGCTransition = false;
CorInfoCallConvExtension unmanagedCallConv = getUnmanagedCallConv(method, callSiteSig, &suppressGCTransition);

if (suppressGCTransition)
{
// MultiCoreJit thread can't inline PInvoke with SuppressGCTransitionAttribute,
// because it can't be resolved in mcj thread
result = TRUE;
}
}

EE_TO_JIT_TRANSITION();

return result;
Expand Down Expand Up @@ -13777,7 +13791,8 @@ bool IsInstructionSetSupported(CORJIT_FLAGS jitFlags, ReadyToRunInstructionSet r

BOOL LoadDynamicInfoEntry(Module *currentModule,
RVA fixupRva,
SIZE_T *entry)
SIZE_T *entry,
BOOL mayUsePrecompiledNDirectMethods)
{
STANDARD_VM_CONTRACT;

Expand Down Expand Up @@ -14005,10 +14020,17 @@ BOOL LoadDynamicInfoEntry(Module *currentModule,

case ENCODE_PINVOKE_TARGET:
{
MethodDesc *pMethod = ZapSig::DecodeMethod(currentModule, pInfoModule, pBlob);
if (mayUsePrecompiledNDirectMethods)
{
MethodDesc *pMethod = ZapSig::DecodeMethod(currentModule, pInfoModule, pBlob);

_ASSERTE(pMethod->IsNDirect());
result = (size_t)(LPVOID)NDirectMethodDesc::ResolveAndSetNDirectTarget((NDirectMethodDesc*)pMethod);
_ASSERTE(pMethod->IsNDirect());
result = (size_t)(LPVOID)NDirectMethodDesc::ResolveAndSetNDirectTarget((NDirectMethodDesc*)pMethod);
}
else
{
return FALSE;
}
}
break;

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/jitinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void getMethodInfoILMethodHeaderHelper(

BOOL LoadDynamicInfoEntry(Module *currentModule,
RVA fixupRva,
SIZE_T *entry);
SIZE_T *entry,
BOOL mayUsePrecompiledNDirectMethods = TRUE);

//
// The legacy x86 monitor helpers do not need a state argument
Expand Down Expand Up @@ -1163,4 +1164,3 @@ FCDECL1(INT64, GetCompiledMethodCount, CLR_BOOL currentThread);
FCDECL1(INT64, GetCompilationTimeInTicks, CLR_BOOL currentThread);

#endif // JITINTERFACE_H

6 changes: 6 additions & 0 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig)
#endif
}

if (pConfig->IsForMulticoreJit() && pCode == NULL && pConfig->ReadyToRunRejectedPrecompiledCode())
{
// Was unable to load code from r2r image in mcj thread, don't try to jit it, this method will be loaded later
return NULL;
}

if (pCode == NULL)
{
LOG((LF_CLASSLOADER, LL_INFO1000000,
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/vm/readytoruninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,12 @@ PCODE ReadyToRunInfo::GetEntryPoint(MethodDesc * pMD, PrepareCodeConfig* pConfig

if (fFixups)
{
if (!m_pModule->FixupDelayList(dac_cast<TADDR>(GetImage()->GetBase()) + offset))
BOOL mayUsePrecompiledNDirectMethods = TRUE;
#ifndef CROSSGEN_COMPILE
mayUsePrecompiledNDirectMethods = !pConfig->IsForMulticoreJit();
#endif // CROSSGEN_COMPILE

if (!m_pModule->FixupDelayList(dac_cast<TADDR>(GetImage()->GetBase()) + offset, mayUsePrecompiledNDirectMethods))
{
#ifndef CROSSGEN_COMPILE
pConfig->SetReadyToRunRejectedPrecompiledCode();
Expand Down