Skip to content

Commit

Permalink
Unify hardware feature detection between CoreCLR JIT and AOT
Browse files Browse the repository at this point in the history
Follow up on dotnet#87865
  • Loading branch information
jkotas committed Jul 22, 2023
1 parent a2ce877 commit 539b8e5
Show file tree
Hide file tree
Showing 25 changed files with 192 additions and 1,447 deletions.
1 change: 0 additions & 1 deletion src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ include_directories("debug/inc/${ARCH_SOURCES_DIR}")
include_directories("debug/inc/dump")
include_directories("md/inc")
include_directories("classlibnative/bcltype")
include_directories("classlibnative/cryptography")
include_directories("classlibnative/inc")
include_directories("${GENERATED_INCLUDE_DIR}")
include_directories("hosts/inc")
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/classlibnative/bcltype/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "array.h"
#include "eepolicy.h"


#include <minipal/cpuid.h>


FCIMPL0(UINT32, SystemNative::GetTickCount)
Expand All @@ -50,8 +50,6 @@ FCIMPL0(UINT64, SystemNative::GetTickCount64)
FCIMPLEND;




extern "C" VOID QCALLTYPE Environment_Exit(INT32 exitcode)
{
QCALL_CONTRACT;
Expand Down
24 changes: 1 addition & 23 deletions src/coreclr/gc/vxsort/isa_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,6 @@ enum class SupportedISA

#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS)

static DWORD64 GetEnabledXStateFeaturesHelper()
{
// On Windows we have an api(GetEnabledXStateFeatures) to check if AVX is supported
typedef DWORD64(WINAPI* PGETENABLEDXSTATEFEATURES)();
PGETENABLEDXSTATEFEATURES pfnGetEnabledXStateFeatures = NULL;

HMODULE hMod = LoadLibraryExW(L"kernel32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hMod == NULL)
return 0;

pfnGetEnabledXStateFeatures = (PGETENABLEDXSTATEFEATURES)GetProcAddress(hMod, "GetEnabledXStateFeatures");

if (pfnGetEnabledXStateFeatures == NULL)
{
return 0;
}

DWORD64 FeatureMask = pfnGetEnabledXStateFeatures();

return FeatureMask;
}

SupportedISA DetermineSupportedISA()
{
// register definitions to make the following code more readable
Expand Down Expand Up @@ -78,7 +56,7 @@ SupportedISA DetermineSupportedISA()
DWORD64 xcr0 = _xgetbv(0);

// get OS XState info
DWORD64 FeatureMask = GetEnabledXStateFeaturesHelper();
DWORD64 FeatureMask = GetEnabledXStateFeatures();

// get processor extended feature flag info
__cpuidex(reg, 7, 0);
Expand Down
17 changes: 15 additions & 2 deletions src/coreclr/minipal/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
add_library(coreclrminipal
STATIC
set(SOURCES
doublemapping.cpp
dn-u16.cpp
)

if(NOT CLR_CROSS_COMPONENTS_BUILD)
list(APPEND SOURCES
${CLR_SRC_NATIVE_DIR}/minipal/cpufeatures.c
)
endif()

add_library(coreclrminipal
STATIC
${SOURCES}
)

include(${CLR_SRC_NATIVE_DIR}/minipal/configure.cmake)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
14 changes: 12 additions & 2 deletions src/coreclr/minipal/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
add_library(coreclrminipal
STATIC
set(SOURCES
doublemapping.cpp
dn-u16.cpp
)

if(NOT CLR_CROSS_COMPONENTS_BUILD)
list(APPEND SOURCES
${CLR_SRC_NATIVE_DIR}/minipal/cpufeatures.c
)
endif()

add_library(coreclrminipal
STATIC
${SOURCES}
)
99 changes: 0 additions & 99 deletions src/coreclr/nativeaot/Runtime/amd64/MemClrForGC.asm

This file was deleted.

148 changes: 0 additions & 148 deletions src/coreclr/nativeaot/Runtime/i386/MemClrForGC.asm

This file was deleted.

Loading

0 comments on commit 539b8e5

Please sign in to comment.