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
1 change: 1 addition & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ RETAIL_CONFIG_STRING_INFO(EXTERNAL_JitName, W("JitName"), "Primary Jit to use")
#if defined(ALLOW_SXS_JIT)
RETAIL_CONFIG_STRING_INFO(EXTERNAL_AltJitName, W("AltJitName"), "Alternative Jit to use, will fall back to primary jit.")
RETAIL_CONFIG_STRING_INFO(EXTERNAL_AltJit, W("AltJit"), "Enables AltJit and selectively limits it to the specified methods.")
RETAIL_CONFIG_STRING_INFO(EXTERNAL_AltJitOs, W("AltJitOS"), "Sets target OS for AltJit or uses native one by default. Only applicable for ARM/AMR64 at the moment.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would use EXTERNAL_AltJitOS so the name exactly matches (including case) the variable name.

Also: typo: AMR64 => ARM64

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, will fix in a follow up!

Regarding SuperPMI - not sure, I just wanted to test ABI differences on ARM64

RETAIL_CONFIG_STRING_INFO(EXTERNAL_AltJitExcludeAssemblies, W("AltJitExcludeAssemblies"), "Do not use AltJit on this semicolon-delimited list of assemblies.")
#endif // defined(ALLOW_SXS_JIT)

Expand Down
46 changes: 34 additions & 12 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,9 +1731,10 @@ CORINFO_OS getClrVmOs();
// is used to help understand problems we see with JIT loading that come in via Watson dumps. Since we don't throw
// an exception immediately upon failure, we can lose information about what the failure was if we don't store this
// information in a way that persists into a process dump.
// targetOs - Target OS for JIT
//

static void LoadAndInitializeJIT(LPCWSTR pwzJitName, OUT HINSTANCE* phJit, OUT ICorJitCompiler** ppICorJitCompiler, IN OUT JIT_LOAD_DATA* pJitLoadData)
static void LoadAndInitializeJIT(LPCWSTR pwzJitName, OUT HINSTANCE* phJit, OUT ICorJitCompiler** ppICorJitCompiler, IN OUT JIT_LOAD_DATA* pJitLoadData, CORINFO_OS targetOs)
{
STANDARD_VM_CONTRACT;

Expand Down Expand Up @@ -1823,7 +1824,7 @@ static void LoadAndInitializeJIT(LPCWSTR pwzJitName, OUT HINSTANCE* phJit, OUT I
pJitLoadData->jld_status = JIT_LOAD_STATUS_DONE_VERSION_CHECK;

// Specify to the JIT that it is working with the OS that we are compiled against
pICorJitCompiler->setTargetOS(getClrVmOs());
pICorJitCompiler->setTargetOS(targetOs);

// The JIT has loaded and passed the version identifier test, so publish the JIT interface to the caller.
*ppICorJitCompiler = pICorJitCompiler;
Expand Down Expand Up @@ -1907,7 +1908,7 @@ BOOL EEJitManager::LoadJIT()
#endif

g_JitLoadData.jld_id = JIT_LOAD_MAIN;
LoadAndInitializeJIT(ExecutionManager::GetJitName(), &m_JITCompiler, &newJitCompiler, &g_JitLoadData);
LoadAndInitializeJIT(ExecutionManager::GetJitName(), &m_JITCompiler, &newJitCompiler, &g_JitLoadData, getClrVmOs());
#endif // !FEATURE_MERGE_JIT_AND_ENGINE

#ifdef ALLOW_SXS_JIT
Expand Down Expand Up @@ -1938,26 +1939,47 @@ BOOL EEJitManager::LoadJIT()
altJitName = MAKEDLLNAME_W(W("clrjit_win_x86_x86"));
#elif defined(TARGET_AMD64)
altJitName = MAKEDLLNAME_W(W("clrjit_win_x64_x64"));
#elif defined(TARGET_ARM)
altJitName = MAKEDLLNAME_W(W("clrjit_win_arm_arm"));
#elif defined(TARGET_ARM64)
altJitName = MAKEDLLNAME_W(W("clrjit_win_arm64_arm64"));
#endif
#else // TARGET_WINDOWS
#ifdef TARGET_X86
altJitName = MAKEDLLNAME_W(W("clrjit_unix_x86_x86"));
#elif defined(TARGET_AMD64)
altJitName = MAKEDLLNAME_W(W("clrjit_unix_x64_x64"));
#elif defined(TARGET_ARM)
altJitName = MAKEDLLNAME_W(W("clrjit_unix_arm_arm"));
#elif defined(TARGET_ARM64)
altJitName = MAKEDLLNAME_W(W("clrjit_unix_arm64_arm64"));
#endif
#endif // TARGET_WINDOWS

#if defined(TARGET_ARM)
altJitName = MAKEDLLNAME_W(W("clrjit_universal_arm_arm"));
#elif defined(TARGET_ARM64)
altJitName = MAKEDLLNAME_W(W("clrjit_universal_arm64_arm64"));
#endif // TARGET_ARM
}

CORINFO_OS targetOs = getClrVmOs();
LPWSTR altJitOsConfig;
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_AltJitOs, &altJitOsConfig));
if (altJitOsConfig != NULL)
{
// We have some inconsistency all over the place with osx vs macos, let's handle both here
if ((_wcsicmp(altJitOsConfig, W("macos")) == 0) || (_wcsicmp(altJitOsConfig, W("osx")) == 0))
{
targetOs = CORINFO_MACOS;
}
else if ((_wcsicmp(altJitOsConfig, W("linux")) == 0) || (_wcsicmp(altJitOsConfig, W("unix")) == 0))
{
targetOs = CORINFO_UNIX;
}
else if (_wcsicmp(altJitOsConfig, W("windows")) == 0)
{
targetOs = CORINFO_WINNT;
}
else
{
_ASSERTE(!"Unknown AltJitOS, it has to be either Windows, Linux or macOS");
}
}
g_JitLoadData.jld_id = JIT_LOAD_ALTJIT;
LoadAndInitializeJIT(altJitName, &m_AltJITCompiler, &newAltJitCompiler, &g_JitLoadData);
LoadAndInitializeJIT(altJitName, &m_AltJITCompiler, &newAltJitCompiler, &g_JitLoadData, targetOs);
}

#endif // ALLOW_SXS_JIT
Expand Down