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
Next Next commit
Introduce AltJitOs
  • Loading branch information
EgorBo committed Feb 8, 2022
commit 41ab1f5a25be41726732ce4e5d57f9dbc103062e
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, it uses native OS by default.")
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
36 changes: 32 additions & 4 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 @@ -1956,8 +1957,35 @@ BOOL EEJitManager::LoadJIT()
#endif // TARGET_WINDOWS
}

CORINFO_OS targetOs;
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");
}
}
else
{
targetOs = getClrVmOs();
}
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