diff --git a/src/coreclr/nativeaot/Runtime/amd64/GetThread.asm b/src/coreclr/nativeaot/Runtime/amd64/GetThread.asm deleted file mode 100644 index 806f8db2c72298..00000000000000 --- a/src/coreclr/nativeaot/Runtime/amd64/GetThread.asm +++ /dev/null @@ -1,27 +0,0 @@ -;; Licensed to the .NET Foundation under one or more agreements. -;; The .NET Foundation licenses this file to you under the MIT license. - -include asmmacros.inc - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; RhpGetThread -;; -;; -;; INPUT: -;; -;; OUTPUT: RAX: Thread pointer -;; -;; TRASHES: R10 -;; -;; MUST PRESERVE ARGUMENT REGISTERS -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -LEAF_ENTRY RhpGetThread, _TEXT - ;; rax = GetThread(), TRASHES r10 - INLINE_GETTHREAD rax, r10 - ret -LEAF_END RhpGetThread, _TEXT - - - end diff --git a/src/coreclr/nativeaot/Runtime/arm/GetThread.asm b/src/coreclr/nativeaot/Runtime/arm/GetThread.asm deleted file mode 100644 index b78319f8f15c24..00000000000000 --- a/src/coreclr/nativeaot/Runtime/arm/GetThread.asm +++ /dev/null @@ -1,32 +0,0 @@ -;; Licensed to the .NET Foundation under one or more agreements. -;; The .NET Foundation licenses this file to you under the MIT license. - -#include "AsmMacros.h" - - TEXTAREA - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; RhpGetThread -;; -;; -;; INPUT: none -;; -;; OUTPUT: r0: Thread pointer -;; -;; MUST PRESERVE ARGUMENT REGISTERS -;; @todo check the actual requirements here, r0 is both return and argument register -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - LEAF_ENTRY RhpGetThread - - ;; r0 = GetThread(), TRASHES r12 - INLINE_GETTHREAD r0, r12 - bx lr - - LEAF_END -FASTCALL_ENDFUNC - - INLINE_GETTHREAD_CONSTANT_POOL - - end diff --git a/src/coreclr/nativeaot/Runtime/arm64/AllocFast.asm b/src/coreclr/nativeaot/Runtime/arm64/AllocFast.asm index 560c6dcbad52d8..e6849b87312669 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/AllocFast.asm +++ b/src/coreclr/nativeaot/Runtime/arm64/AllocFast.asm @@ -48,8 +48,6 @@ RhpNewFast_RarePath b RhpNewObject LEAF_END RhpNewFast - INLINE_GETTHREAD_CONSTANT_POOL - ;; Allocate non-array object with finalizer. ;; x0 == MethodTable LEAF_ENTRY RhpNewFinalizable @@ -149,9 +147,6 @@ StringSizeOverflow b RhExceptionHandling_FailedAllocation LEAF_END RhNewString - INLINE_GETTHREAD_CONSTANT_POOL - - ;; Allocate one dimensional, zero based array (SZARRAY). ;; x0 == MethodTable ;; x1 == element count @@ -213,8 +208,6 @@ ArraySizeOverflow b RhExceptionHandling_FailedAllocation LEAF_END RhpNewArray - INLINE_GETTHREAD_CONSTANT_POOL - ;; Allocate one dimensional, zero based array (SZARRAY) using the slow path that calls a runtime helper. ;; x0 == MethodTable ;; x1 == element count diff --git a/src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h b/src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h index de4aef3d267773..589f0a24528245 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h +++ b/src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h @@ -200,18 +200,16 @@ CodeLbl SETS "$Name":CC:"Lbl" ;; ----------------------------------------------------------------------------- ;; -;; Macro to get a pointer to the Thread* object for the currently executing thread +;; Macro to get a pointer to a threadlocal symbol for the currently executing thread ;; __tls_array equ 0x58 ;; offsetof(TEB, ThreadLocalStoragePointer) - EXTERN _tls_index - - GBLS __SECTIONREL_tls_CurrentThread -__SECTIONREL_tls_CurrentThread SETS "SECTIONREL_tls_CurrentThread" - MACRO - INLINE_GETTHREAD $destReg, $trashReg + INLINE_GET_TLS_VAR $destReg, $trashReg, $variable + + EXTERN _tls_index + EXTERN $variable ;; The following macro variables are just some assembler magic to get the name of the 32-bit version ;; of $trashReg. It does it by string manipulation. Replaces something like x3 with w3. @@ -219,32 +217,27 @@ __SECTIONREL_tls_CurrentThread SETS "SECTIONREL_tls_CurrentThread" TrashRegister32Bit SETS "$trashReg" TrashRegister32Bit SETS "w":CC:("$TrashRegister32Bit":RIGHT:((:LEN:TrashRegister32Bit) - 1)) - ldr $trashReg, =_tls_index - ldr $TrashRegister32Bit, [$trashReg] + adrp $destReg, _tls_index + ldr $TrashRegister32Bit, [$destReg, _tls_index] ldr $destReg, [xpr, #__tls_array] - ldr $destReg, [$destReg, $trashReg lsl #3] - ldr $trashReg, =$__SECTIONREL_tls_CurrentThread - ldr $trashReg, [$trashReg] - add $destReg, $destReg, $trashReg + ldr $destReg, [$destReg, $TrashRegister32Bit uxtw #3] + add $destReg, $destReg, #0, lsl #0xC + RELOC 0xA, $variable ;; IMAGE_REL_ARM64_SECREL_HIGH12A + add $destReg, $destReg, #0, lsl #0 + RELOC 0x9, $variable ;; IMAGE_REL_ARM64_SECREL_LOW12A MEND - ;; INLINE_GETTHREAD_CONSTANT_POOL macro has to be used after the last function in the .asm file that used - ;; INLINE_GETTHREAD. Optionally, it can be also used after any function that used INLINE_GETTHREAD - ;; to improve density, or to reduce distance between the constant pool and its use. +;; ----------------------------------------------------------------------------- +;; +;; Macro to get a pointer to the Thread* object for the currently executing thread +;; MACRO - INLINE_GETTHREAD_CONSTANT_POOL - EXTERN tls_CurrentThread - - ;; Section relocs are 32 bits. Using an extra DCD initialized to zero for 8-byte alignment. -$__SECTIONREL_tls_CurrentThread - DCD tls_CurrentThread - RELOC 8, tls_CurrentThread ;; SECREL - DCD 0 - -__SECTIONREL_tls_CurrentThread SETS "$__SECTIONREL_tls_CurrentThread":CC:"_" + INLINE_GETTHREAD $destReg, $trashReg + INLINE_GET_TLS_VAR $destReg, $trashReg, tls_CurrentThread MEND + MACRO INLINE_THREAD_UNHIJACK $threadReg, $trashReg1, $trashReg2 ;; diff --git a/src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.asm b/src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.asm index 3db1d648c4deec..1af4fd19f0c664 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.asm +++ b/src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.asm @@ -624,6 +624,4 @@ SetSuccess NESTED_END RhpCallFilterFunclet - INLINE_GETTHREAD_CONSTANT_POOL - end diff --git a/src/coreclr/nativeaot/Runtime/arm64/GcProbe.asm b/src/coreclr/nativeaot/Runtime/arm64/GcProbe.asm index ef01e43b5e1ff4..d95ab7a0320708 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/GcProbe.asm +++ b/src/coreclr/nativeaot/Runtime/arm64/GcProbe.asm @@ -366,7 +366,5 @@ Success LEAF_END RhpSuppressGcStress #endif ;; FEATURE_GC_STRESS - INLINE_GETTHREAD_CONSTANT_POOL - end diff --git a/src/coreclr/nativeaot/Runtime/arm64/GetThread.asm b/src/coreclr/nativeaot/Runtime/arm64/GetThread.asm deleted file mode 100644 index 7c01e66453385c..00000000000000 --- a/src/coreclr/nativeaot/Runtime/arm64/GetThread.asm +++ /dev/null @@ -1,29 +0,0 @@ -;; Licensed to the .NET Foundation under one or more agreements. -;; The .NET Foundation licenses this file to you under the MIT license. - -#include "AsmMacros.h" - - TEXTAREA - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; RhpGetThread -;; -;; -;; INPUT: none -;; -;; OUTPUT: x9: Thread pointer -;; -;; MUST PRESERVE ARGUMENT REGISTERS -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - LEAF_ENTRY RhpGetThread - ;; x9 = GetThread(), TRASHES xip0 (which can be used as an intra-procedure-call scratch register) - INLINE_GETTHREAD x9, xip0 - ret - LEAF_END -FASTCALL_ENDFUNC - - INLINE_GETTHREAD_CONSTANT_POOL - - end diff --git a/src/coreclr/nativeaot/Runtime/arm64/PInvoke.asm b/src/coreclr/nativeaot/Runtime/arm64/PInvoke.asm index 475737fea71a0e..52d55ad2846c77 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/PInvoke.asm +++ b/src/coreclr/nativeaot/Runtime/arm64/PInvoke.asm @@ -34,8 +34,6 @@ ret NESTED_END RhpPInvoke - INLINE_GETTHREAD_CONSTANT_POOL - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; diff --git a/src/coreclr/nativeaot/Runtime/i386/GetThread.asm b/src/coreclr/nativeaot/Runtime/i386/GetThread.asm deleted file mode 100644 index b330406b9a098a..00000000000000 --- a/src/coreclr/nativeaot/Runtime/i386/GetThread.asm +++ /dev/null @@ -1,31 +0,0 @@ -;; Licensed to the .NET Foundation under one or more agreements. -;; The .NET Foundation licenses this file to you under the MIT license. - - .586 - .model flat - option casemap:none - .code - - -include AsmMacros.inc - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; RhpGetThread -;; -;; -;; INPUT: none -;; -;; OUTPUT: EAX: Thread pointer -;; -;; MUST PRESERVE ARGUMENT REGISTERS -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -FASTCALL_FUNC RhpGetThread, 0 - push ecx - INLINE_GETTHREAD eax, ecx ; eax dest, ecx trash - pop ecx - ret -FASTCALL_ENDFUNC - - end