Replacing some calls to GetThread with an inlined version (#23771)
authorFadi Hanna <fadim@microsoft.com>
Fri, 5 Apr 2019 21:46:02 +0000 (14:46 -0700)
committerGitHub <noreply@github.com>
Fri, 5 Apr 2019 21:46:02 +0000 (14:46 -0700)
src/vm/arm/asmhelpers.asm
src/vm/arm64/asmhelpers.asm
src/vm/i386/jithelp.asm

index c0fef0c..67de4f4 100644 (file)
@@ -16,7 +16,6 @@
     SETALIAS CTPMethodTable__s_pThunkTable, ?s_pThunkTable@CTPMethodTable@@0PAVMethodTable@@A
     SETALIAS g_pObjectClass, ?g_pObjectClass@@3PAVMethodTable@@A
 
-    IMPORT GetThread
     IMPORT JIT_InternalThrow
     IMPORT JIT_WriteBarrier
     IMPORT TheUMEntryPrestubWorker
@@ -386,7 +385,8 @@ UMThunkStub_StackArgs SETA 10*4
 
         CHECK_STACK_ALIGNMENT
 
-        bl                  GetThread
+        ; r0 = GetThread(). Trashes r5
+        INLINE_GETTHREAD    r0, r5
         cbz                 r0, UMThunkStub_DoThreadSetup
 
 UMThunkStub_HaveThread
@@ -457,6 +457,8 @@ UMThunkStub_DoTrapReturningThreads
         b                   UMThunkStub_InCooperativeMode
 
         NESTED_END
+        
+        INLINE_GETTHREAD_CONSTANT_POOL
 
 ; ------------------------------------------------------------------
 
index 7d8aad3..dfdca9c 100644 (file)
@@ -24,7 +24,6 @@
     IMPORT UMEntryPrestubUnwindFrameChainHandler
     IMPORT UMThunkStubUnwindFrameChainHandler
     IMPORT TheUMEntryPrestubWorker
-    IMPORT GetThread
     IMPORT CreateThreadBlockThrow
     IMPORT UMThunkStubRareDisableWorker
     IMPORT GetCurrentSavedRedirectContext
@@ -935,8 +934,8 @@ UMThunkStub_StackArgs SETA 112
     ; save UMEntryThunk*
     str                 x12, [sp, #UMThunkStub_HiddenArg]
 
-    ; assuming GetThread does not clobber FP Args
-    bl                  GetThread
+    ; x0 = GetThread(). Trashes x19
+    INLINE_GETTHREAD    x0, x19
     cbz                 x0, UMThunkStub_DoThreadSetup
 
 UMThunkStub_HaveThread
@@ -1025,6 +1024,8 @@ UMThunkStub_DoTrapReturningThreads
 
     NESTED_END
 
+    INLINE_GETTHREAD_CONSTANT_POOL
+    
 #ifdef FEATURE_HIJACK
 ; ------------------------------------------------------------------
 ; Hijack function for functions which return a scalar type or a struct (value type)
index 2dd96d7..00bd3df 100644 (file)
@@ -16,6 +16,7 @@
         .model  flat
 
         include asmconstants.inc
+        include asmmacros.inc
 
         option  casemap:none
         .code
@@ -65,7 +66,6 @@ endif
 EXTERN _g_TailCallFrameVptr:DWORD
 EXTERN @JIT_FailFast@0:PROC
 EXTERN _s_gsCookie:DWORD
-EXTERN _GetThread@0:PROC
 EXTERN @JITutil_IsInstanceOfInterface@8:PROC
 EXTERN @JITutil_ChkCastInterface@8:PROC
 EXTERN @JITutil_IsInstanceOfAny@8:PROC
@@ -970,7 +970,9 @@ ExtraSpace      = 0
         push    ecx
         push    edx
 
-        call    _GetThread@0; eax = Thread*
+        ; eax = GetThread(). Trashes edx
+        INLINE_GETTHREAD eax, edx
+
         mov     [esp + 8], eax
 
 ExtraSpace      = 12    ; pThread, ecx, edx