Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial CoreCLR compilation support for Apple Silicon #40435

Merged
merged 100 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
1c1083e
Add initial CoreCLR compilation support for Apple Silicon
sdmaclea Aug 3, 2020
83a45b8
Remove compact unwind entries from assembly files
sdmaclea Aug 5, 2020
af1acc4
Disable FEATURE_WRITEBARRIER_COPY
sdmaclea Aug 5, 2020
37d29f8
CONTEXT_SEGMENTS feedback
sdmaclea Aug 6, 2020
8d21b27
Revert incidental change
sdmaclea Aug 6, 2020
e72e45c
Revise StepWithCompactEncoding
sdmaclea Aug 6, 2020
657a57b
Fix CLR_CMAKE_HOST_* arch
sdmaclea Aug 8, 2020
7457f37
Workaround using dotnet/msbuild with rosetta
sdmaclea Aug 8, 2020
f3dcdf3
Feedback on OSX does not support X86
sdmaclea Aug 10, 2020
96d4787
Feedback fix typo
sdmaclea Aug 10, 2020
ba2f9ae
Fix init-os-and-arch.sh
sdmaclea Aug 10, 2020
6cb8ceb
Fix cmake closing conditonal mismatch
sdmaclea Aug 10, 2020
27ebc7a
Fix crossgen2 by adding HostArchitecture
sdmaclea Aug 10, 2020
02423a1
Merge branch 'master' into dev/Arm64MacOS
sdmaclea Aug 10, 2020
b80e9c0
Fix typo
sdmaclea Aug 12, 2020
bca94f7
Fix HostArchitecture Condition
sdmaclea Aug 12, 2020
0e7b3c8
Fix libraries native build
sdmaclea Aug 13, 2020
06eef47
Fix typo
sdmaclea Aug 14, 2020
d13d6bc
Reenable FEATURE_WRITEBARRIER_COPY
sdmaclea Aug 14, 2020
0a827d5
Add crude os-arm64 generate layout script
sdmaclea Aug 14, 2020
7d202fa
First Write^Execute patch
sdmaclea Aug 14, 2020
69d14ed
Fix comment typos
sdmaclea Aug 15, 2020
8f678c0
Fix IsRunningOnMojaveHardenedRuntime()
sdmaclea Aug 17, 2020
d8935a7
Add comment
sdmaclea Aug 17, 2020
061ecc4
Set CMAKE_OSX_ARCHITECTURES in configureplatform.cmake
sdmaclea Aug 17, 2020
3c1a830
Fix threadSP initialization order
sdmaclea Aug 20, 2020
cdd5da3
Add PAL_JITWriteEnable()
sdmaclea Aug 20, 2020
59e9888
Fix JIT_WriteBarrier
sdmaclea Aug 20, 2020
7ffe655
Prefer arm_thread_state64_get_*_fptr() form
sdmaclea Aug 20, 2020
e588304
Strip libunwind pointer authentication bits
sdmaclea Aug 20, 2020
c6658cd
Disable RunStartupHooks()
sdmaclea Aug 20, 2020
a051fe7
Remove incorrect consistency check
sdmaclea Aug 20, 2020
7404605
Fix Windows compilation
sdmaclea Aug 21, 2020
7ca8f3e
Set OSX_ARCHITECTURES to fix 41164
sdmaclea Aug 21, 2020
82ff768
Fix Windows compilation+
sdmaclea Aug 21, 2020
757ee92
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Aug 21, 2020
c38cd7c
Add HOST_OSX
sdmaclea Aug 22, 2020
8aa1381
Fix JIT_WriteBarrier_Loc usage
sdmaclea Aug 22, 2020
26ff8a3
Revise generate-osx-arm64-layout.sh
sdmaclea Aug 22, 2020
2564ebd
Reenable RunStartupHooks()
sdmaclea Aug 22, 2020
325d184
Rework CMAKE_OSX_ARCHITECTURES again
sdmaclea Aug 25, 2020
8b4fd1f
Set clang -arch flag
sdmaclea Aug 26, 2020
e48b63b
Remove workarounds from generate-osx-arm64-layout.sh
sdmaclea Aug 26, 2020
1a87f7d
Remove generate-osx-arm64-layout.sh
sdmaclea Aug 26, 2020
79ee527
More CMAKE_OSX_ARCH rework
sdmaclea Aug 26, 2020
9d2d5dd
Handle osx-arm64 uname parsing
sdmaclea Aug 26, 2020
0a89117
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Aug 26, 2020
ab869de
Fix arm64/stubs.cpp W^X
sdmaclea Aug 26, 2020
45788c5
Fix TheUMEntryPrestubWorker
sdmaclea Aug 26, 2020
5440278
Fix GetCapturedRegister
sdmaclea Aug 27, 2020
8015a0c
Revert "Fix TheUMEntryPrestubWorker"
sdmaclea Aug 27, 2020
389c9cb
Fix kRunTimeInited write
sdmaclea Aug 27, 2020
af4db13
Fix more W^X issues
sdmaclea Aug 27, 2020
49eb289
Add/use PAL_JITWriteEnableHolder
sdmaclea Aug 31, 2020
af0d7eb
Restore constistency check
sdmaclea Aug 31, 2020
6677bce
Use fpAddress name
sdmaclea Aug 31, 2020
bf2ae4f
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 1, 2020
6a884d0
Add HAVE_SYSCTLBYNAME to PAL_GetJitCpuCapabilityFlags
sdmaclea Sep 1, 2020
29edb16
Rename SafeUpdateWriteBarrierState
sdmaclea Sep 1, 2020
1747d55
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 1, 2020
012febf
Fix LazyMachState::setLazyStateFromUnwind(...)
sdmaclea Sep 2, 2020
b06e8b3
Flush NONPAL_TRACE messages
sdmaclea Sep 3, 2020
b725312
Fix PAL_JITWriteEnableHolder::JITWriteEnable
sdmaclea Sep 3, 2020
923ecbb
Fix exception handling
sdmaclea Sep 3, 2020
ad5eabc
Fix assertion when crossgen prints an empty string
sdmaclea Sep 3, 2020
7eced9d
Fix EventPipe::InvokeCallback
sdmaclea Sep 3, 2020
d94eba5
Fix GcInfoDecoder::ReportRegisterToGC
sdmaclea Sep 3, 2020
05214ef
Disable JITWrite on Activation
sdmaclea Sep 4, 2020
03af208
Only activate for ESR.EC == SVC
sdmaclea Sep 4, 2020
24532ac
Fix HostCodeHeap::AddToFreeList
sdmaclea Sep 4, 2020
c291613
Fix comment
sdmaclea Sep 4, 2020
60ac6e5
Fix NONPAL_TRACING induced deadlock
sdmaclea Sep 4, 2020
6ba565a
Use MachSetThreadContext for RtlRestoreContext
sdmaclea Sep 5, 2020
7651eb5
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 5, 2020
59682d3
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 8, 2020
80b9126
Revert "Use MachSetThreadContext for RtlRestoreContext"
sdmaclea Sep 8, 2020
62575e2
Use MachSetThreadContext in ActivationHandler
sdmaclea Sep 8, 2020
68a08bf
Remove unnecessary PAL_JITWriteEnable
sdmaclea Sep 8, 2020
1025180
Fix configurecompiler.cmake typo
sdmaclea Sep 8, 2020
44eeb38
Fix foreign thread callbacks to managed code
sdmaclea Sep 9, 2020
ef69659
Fix corehost build
sdmaclea Sep 9, 2020
50c931c
Fix more dllimportcallback W^X issues
sdmaclea Sep 9, 2020
7e525b3
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 9, 2020
93d8866
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 11, 2020
5c725ce
Enable cross-build of coreclr on OSX x64
janvorli Sep 17, 2020
0e61103
Fix JIT bug
janvorli Sep 17, 2020
ef57726
Fix shell build scripts
janvorli Sep 18, 2020
e641d6a
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Sep 21, 2020
9667e8c
Remove stray comment
sdmaclea Sep 21, 2020
c5cee94
Fix SSLSetEnabledCiphers call
sdmaclea Sep 21, 2020
bcdc032
Fix test build script
sdmaclea Sep 22, 2020
260b5dd
Fix x64 cross compile
sdmaclea Sep 24, 2020
271d396
Move remote-unwind to coreclrpal_dac library for Unix
sdmaclea Sep 24, 2020
78d00a2
Disable coreclrpal_dac in cross bit compiles
sdmaclea Sep 28, 2020
fcf3424
Fix Windows build
sdmaclea Sep 29, 2020
e186f01
Fix arm64 crossdac build
sdmaclea Sep 29, 2020
6817c64
Merge remote-tracking branch 'origin/master' into dev/Arm64MacOS
sdmaclea Oct 1, 2020
f9b9fff
Review feedback
sdmaclea Oct 1, 2020
d3e49f0
Add missing semicolon
sdmaclea Oct 6, 2020
0d4eba8
PR Feedback
sdmaclea Oct 7, 2020
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
3 changes: 2 additions & 1 deletion src/coreclr/src/pal/src/arch/arm64/context2.S
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ LEAF_END CONTEXT_CaptureContext, _TEXT

// Incoming:
// x0: Context*

LEAF_ENTRY RtlCaptureContext, _TEXT
PROLOG_STACK_ALLOC 16
.cfi_adjust_cfa_offset 16
Expand All @@ -129,6 +128,7 @@ LEAF_ENTRY RtlCaptureContext, _TEXT
b C_FUNC(CONTEXT_CaptureContext)
LEAF_END RtlCaptureContext, _TEXT

#ifndef HOST_OSX
// Incoming:
// x0: Context*
// x1: Exception*
Expand Down Expand Up @@ -213,3 +213,4 @@ LOCAL_LABEL(No_Restore_CONTEXT_CONTROL):
ret

LEAF_END RtlRestoreContext, _TEXT
#endif // !HOST_OSX
17 changes: 16 additions & 1 deletion src/coreclr/src/pal/src/exception/machexception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,19 @@ ActivationHandler(CONTEXT* context)
DebugBreak();
}

#if defined(TARGET_ARM64)
extern "C"
void
RtlRestoreContext(CONTEXT* context, PEXCEPTION_RECORD ExceptionRecord)
sdmaclea marked this conversation as resolved.
Show resolved Hide resolved
{
// RtlRestoreContext assembly corrupts X16 & X17, so it cannot be
// used in thread hijacking situations
// Since we have the higher fidelity MachSetThreadContext, use it in
// all situations
MachSetThreadContext(context);
}
#endif

extern "C" void ActivationHandlerWrapper();
extern "C" int ActivationHandlerReturnOffset;
extern "C" unsigned int XmmYmmStateSupport();
Expand Down Expand Up @@ -1489,7 +1502,9 @@ InjectActivationInternal(CPalThread* pThread)
static const int MaxHardwareExceptionVector = 31;
if (ExceptionState.__trapno > MaxHardwareExceptionVector)
#elif defined(HOST_ARM64)
// TBD // Inject the activation only if the thread doesn't have a pending hardware exception
// Inject the activation only if the last ESR.EC was an SVC and therefore the thread doesn't have
// a pending hardware exception
if ((ExceptionState.__esr >> 26) == 0x15)
Copy link
Member

Choose a reason for hiding this comment

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

Where did these constants come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should probably use the bit field extract macros....

The constants come from Arm reference manual. D13.2.36 ESR_EL1, Exception Syndrome Register (EL1)

Copy link
Member

Choose a reason for hiding this comment

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

Can you please make these named constants or defines to make it clear?
E.g. ESR_EC_SHIFT for the 26 and EC_SVC for 0x15 or something like that.

#else
#error Unexpected architecture
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/src/vm/dynamicmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ void HostCodeHeap::AddToFreeList(TrackAllocation *pBlockToInsert)

LOG((LF_BCL, LL_INFO100, "Level2 - CodeHeap [0x%p] - Add to FreeList [%p, 0x%X]\n", this, pBlockToInsert, pBlockToInsert->size));

#if defined(HOST_OSX) && defined(HOST_ARM64)
auto jitWriteEnableHolder = PAL_JITWriteEnable(true);
#endif // defined(HOST_OSX) && defined(HOST_ARM64)

// append to the list in the proper position and coalesce if needed
if (m_pFreeList)
{
Expand Down