Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
Original file line number Diff line number Diff line change
Expand Up @@ -4188,7 +4188,9 @@ void MethodContext::repGetEEInfo(CORINFO_EE_INFO* pEEInfoOut)
pEEInfoOut->osPageSize = (size_t)0x1000;
pEEInfoOut->maxUncheckedOffsetForNullObject = (size_t)((32 * 1024) - 1);
pEEInfoOut->targetAbi = CORINFO_DESKTOP_ABI;
#ifdef TARGET_UNIX
#ifdef TARGET_OSX
pEEInfoOut->osType = CORINFO_MACOS;
#elif defined(TARGET_UNIX)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why we bother with faking up EEInfo instead of blowing things up.

@BruceForstall any idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the JIT (or JIT32/JIT64) only called getEEInfo() once and reused the info for all method compiles, so only some MCs would have it? Looks like RyuJIT calls it for every compile.

pEEInfoOut->osType = CORINFO_UNIX;
#else
pEEInfoOut->osType = CORINFO_WINNT;
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ function(set_target_definitions_to_custom_os_and_arch)
if ((TARGETDETAILS_ARCH STREQUAL "arm64") AND (TARGETDETAILS_OS STREQUAL "unix_osx"))
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE OSX_ARM64_ABI)
endif()
else()
if (TARGETDETAILS_OS STREQUAL "unix_osx")
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_OSX)
endif()
elseif (TARGETDETAILS_OS STREQUAL "win")
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_WINDOWS)
endif((TARGETDETAILS_OS MATCHES "^unix"))

Expand Down
26 changes: 16 additions & 10 deletions src/coreclr/crosscomponents.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@

if (CLR_CMAKE_HOST_OS STREQUAL CLR_CMAKE_TARGET_OS)
install_clr (TARGETS
clrjit
DESTINATIONS . sharedFramework
COMPONENT crosscomponents
)
install_clr (TARGETS
clrjit
jitinterface_${ARCH_HOST_NAME}
DESTINATIONS .
COMPONENT crosscomponents
)

if(CLR_CMAKE_TARGET_OSX AND ARCH_TARGET_NAME STREQUAL arm64)
if (CLR_CMAKE_TARGET_OSX AND ARCH_TARGET_NAME STREQUAL arm64)
install_clr (TARGETS
clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME}
DESTINATIONS .
COMPONENT crosscomponents
)
elseif (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
install_clr (TARGETS
clrjit_unix_osx_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME}
DESTINATIONS . sharedFramework
clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME}
DESTINATIONS .
COMPONENT crosscomponents
)
elseif (CLR_CMAKE_TARGET_UNIX)
install_clr (TARGETS
clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME}
DESTINATIONS . sharedFramework
DESTINATIONS .
COMPONENT crosscomponents
)
else()
install_clr (TARGETS
clrjit_win_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME}
DESTINATIONS .
COMPONENT crosscomponents
)
endif()
Expand Down
12 changes: 7 additions & 5 deletions src/coreclr/gcinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,18 @@ else()
set(TARGET_OS_NAME win)
endif()

# For clrjit we need to build an exact targetted gcinfo instead of the universal one
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
create_gcinfo_lib(TARGET gcinfo_${TARGET_OS_NAME}_${ARCH_TARGET_NAME} OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME})
endif()

if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
create_gcinfo_lib(TARGET gcinfo_unix_arm64 OS unix ARCH arm64)
create_gcinfo_lib(TARGET gcinfo_universal_arm64 OS universal ARCH arm64)
create_gcinfo_lib(TARGET gcinfo_unix_x64 OS unix ARCH x64)
create_gcinfo_lib(TARGET gcinfo_win_arm64 OS win ARCH arm64)
create_gcinfo_lib(TARGET gcinfo_win_x64 OS win ARCH x64)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)

create_gcinfo_lib(TARGET gcinfo_unix_armel OS unix ARCH armel)
create_gcinfo_lib(TARGET gcinfo_unix_arm OS unix ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_arm OS win ARCH arm)
create_gcinfo_lib(TARGET gcinfo_universal_arm OS universal ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/gcinfo/gcinfoencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdint.h>

#include "gcinfoencoder.h"
#include "targetosarch.h"

#ifdef _DEBUG
#ifndef LOGGING
Expand Down Expand Up @@ -577,10 +578,11 @@ GcSlotId GcInfoEncoder::GetStackSlotId( INT32 spOffset, GcSlotFlags flags, GcSta

_ASSERTE( (flags & (GC_SLOT_IS_REGISTER | GC_SLOT_IS_DELETED)) == 0 );

#if !defined(OSX_ARM64_ABI)
// the spOffset for the stack slot is required to be pointer size aligned
_ASSERTE((spOffset % TARGET_POINTER_SIZE) == 0);
#endif
if (!(TargetOS::IsMacOS && TargetArchitecture::IsArm64))
{
// the spOffset for the stack slot is required to be pointer size aligned
_ASSERTE((spOffset % TARGET_POINTER_SIZE) == 0);
}

m_SlotTable[ m_NumSlots ].Slot.Stack.SpOffset = spOffset;
m_SlotTable[ m_NumSlots ].Slot.Stack.Base = spBase;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,7 @@ enum CORINFO_OS
{
CORINFO_WINNT,
CORINFO_UNIX,
CORINFO_MACOS,
};

struct CORINFO_CPU
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* 5ed35c58-857b-48dd-a818-7c0136dc9f73 */
0x5ed35c58,
0x857b,
0x48dd,
{0xa8, 0x18, 0x7c, 0x01, 0x36, 0xdc, 0x9f, 0x73}
constexpr GUID JITEEVersionIdentifier = { /* 017b4b2e-80e1-41eb-afc3-f6f643df6bbc */
0x017b4b2e,
0x80e1,
0x41eb,
{0xaf, 0xc3, 0xf6, 0xf6, 0x43, 0xdf, 0x6b, 0xbc}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/inc/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,3 @@
#if !defined(TARGET_UNIX)
#define FEATURE_STACK_SAMPLING
#endif // defined (ALLOW_SXS_JIT)


67 changes: 67 additions & 0 deletions src/coreclr/inc/targetosarch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#ifndef targetosarch_h
#define targetosarch_h

class TargetOS
{
public:
#ifdef TARGET_WINDOWS
#define TARGET_WINDOWS_POSSIBLY_SUPPORTED
static const bool IsWindows = true;
static const bool IsUnix = false;
static const bool IsMacOS = false;
#elif defined(TARGET_UNIX)
#define TARGET_UNIX_POSSIBLY_SUPPORTED
static const bool IsWindows = false;
static const bool IsUnix = true;
#if defined(TARGET_OSX)
static const bool IsMacOS = true;
#else
static const bool IsMacOS = false;
#endif
#else
#define TARGET_WINDOWS_POSSIBLY_SUPPORTED
#define TARGET_UNIX_POSSIBLY_SUPPORTED
#define TARGET_OS_RUNTIMEDETERMINED
static bool OSSettingConfigured;
static bool IsWindows;
static bool IsUnix;
static bool IsMacOS;
#endif
};

class TargetArchitecture
{
public:
#ifdef TARGET_ARM
static const bool IsX86 = false;
static const bool IsX64 = false;
static const bool IsArm64 = false;
static const bool IsArm32 = true;
static const bool IsArmArch = true;
#elif defined(TARGET_ARM64)
static const bool IsX86 = false;
static const bool IsX64 = false;
static const bool IsArm64 = true;
static const bool IsArm32 = false;
static const bool IsArmArch = true;
#elif defined(TARGET_AMD64)
static const bool IsX86 = false;
static const bool IsX64 = true;
static const bool IsArm64 = false;
static const bool IsArm32 = false;
static const bool IsArmArch = false;
#elif defined(TARGET_X86)
static const bool IsX86 = true;
static const bool IsX64 = false;
static const bool IsArm64 = false;
static const bool IsArm32 = false;
static const bool IsArmArch = false;
#else
#error Unknown architecture
#endif
};

#endif // targetosarch_h
6 changes: 3 additions & 3 deletions src/coreclr/inc/winwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ inline DWORD GetMaxDBCSCharByteSize()
#endif // HOST_UNIX
}

#ifndef TARGET_UNIX
#ifndef HOST_UNIX
BOOL RunningInteractive();
#else // !TARGET_UNIX
#else // !HOST_UNIX
#define RunningInteractive() FALSE
#endif // !TARGET_UNIX
#endif // !HOST_UNIX

#ifndef Wsz_mbstowcs
#define Wsz_mbstowcs(szOut, szIn, iSize) WszMultiByteToWideChar(CP_ACP, 0, szIn, -1, szOut, iSize)
Expand Down
18 changes: 8 additions & 10 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,13 @@ install_clr(TARGETS clrjit DESTINATIONS . sharedFramework COMPONENT jit)
add_pgo(clrjit)

if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
create_standalone_jit(TARGET clrjit_unix_arm64_${ARCH_HOST_NAME} OS unix ARCH arm64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_unix_osx_arm64_${ARCH_HOST_NAME} OS unix_osx ARCH arm64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_universal_arm64_${ARCH_HOST_NAME} OS universal ARCH arm64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_unix_x64_${ARCH_HOST_NAME} OS unix ARCH x64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_win_arm64_${ARCH_HOST_NAME} OS win ARCH arm64 DESTINATIONS .)
create_standalone_jit(TARGET clrjit_win_x64_${ARCH_HOST_NAME} OS win ARCH x64 DESTINATIONS .)
Copy link
Contributor

Choose a reason for hiding this comment

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

are "universal" x64 and x86 also possible?

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory this is possible, but its quite a bit more difficult and would require a fair amount more changes. The Arm64 and Arm architecture jits produce very similar code, but the x64 ABI is quite different between Unix platforms and Windows (for instance, there are quite a lot of fields on GenTree structures that are different for Unix and Windows.

endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)

create_standalone_jit(TARGET clrjit_unix_arm_${ARCH_HOST_NAME} OS unix ARCH arm DESTINATIONS .)
target_compile_definitions(clrjit_unix_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
create_standalone_jit(TARGET clrjit_win_arm_${ARCH_HOST_NAME} OS win ARCH arm DESTINATIONS .)
create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm DESTINATIONS .)
target_compile_definitions(clrjit_universal_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
Expand All @@ -514,11 +511,12 @@ endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)

if (CLR_CMAKE_TARGET_UNIX)
if (NOT ARCH_TARGET_NAME STREQUAL s390x)
install_clr(TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
install_clr(TARGETS clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
else()
install_clr(TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
endif()
endif(NOT ARCH_TARGET_NAME STREQUAL s390x)
if (ARCH_TARGET_NAME STREQUAL arm)
target_compile_definitions(clrjit_unix_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
endif (ARCH_TARGET_NAME STREQUAL arm)
endif()

if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_PGO_INSTRUMENT)
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,9 +941,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void genIntrinsic(GenTree* treeNode);
void genPutArgStk(GenTreePutArgStk* treeNode);
void genPutArgReg(GenTreeOp* tree);
#if FEATURE_ARG_SPLIT
#if FEATURE_ARG_SPLIT_SUPPORTED
void genPutArgSplit(GenTreePutArgSplit* treeNode);
#endif // FEATURE_ARG_SPLIT
#endif // FEATURE_ARG_SPLIT_SUPPORTED

#if defined(TARGET_XARCH)
unsigned getBaseVarForPutArgStk(GenTree* treeNode);
Expand Down Expand Up @@ -1137,9 +1137,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
regNumber srcReg,
regNumber sizeReg);
#endif // FEATURE_PUT_STRUCT_ARG_STK
#if FEATURE_ARG_SPLIT
#if FEATURE_ARG_SPLIT_SUPPORTED
void genConsumeArgSplitStruct(GenTreePutArgSplit* putArgNode);
#endif // FEATURE_ARG_SPLIT
#endif // FEATURE_ARG_SPLIT_SUPPORTED

void genConsumeRegs(GenTree* tree);
void genConsumeOperands(GenTreeOp* tree);
Expand Down
8 changes: 2 additions & 6 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,10 @@ void CodeGen::genPrologSaveRegPair(regNumber reg1,
assert((spOffset % 8) == 0);
GetEmitter()->emitIns_R_R_R_I(INS_stp, EA_PTRSIZE, reg1, reg2, REG_SPBASE, spOffset);

#if defined(TARGET_UNIX)
if (compiler->generateCFIUnwindCodes())
if (TargetOS::IsUnix && compiler->generateCFIUnwindCodes())
{
useSaveNextPair = false;
}
#endif // TARGET_UNIX

if (useSaveNextPair)
{
Expand Down Expand Up @@ -381,12 +379,10 @@ void CodeGen::genEpilogRestoreRegPair(regNumber reg1,
{
GetEmitter()->emitIns_R_R_R_I(INS_ldp, EA_PTRSIZE, reg1, reg2, REG_SPBASE, spOffset);

#if defined(TARGET_UNIX)
if (compiler->generateCFIUnwindCodes())
if (TargetOS::IsUnix && compiler->generateCFIUnwindCodes())
{
useSaveNextPair = false;
}
#endif // TARGET_UNIX

if (useSaveNextPair)
{
Expand Down
Loading