+++ /dev/null
-;; 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
+++ /dev/null
-;; 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
;; -----------------------------------------------------------------------------
;;
-;; 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.
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
;;
+++ /dev/null
-;; 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