Preserve VASigCookieReg across PInvokeStubWorker call (#17521)
authorAditya Mandaleeka <adityamandaleeka@users.noreply.github.com>
Fri, 13 Apr 2018 12:25:39 +0000 (05:25 -0700)
committerJan Kotas <jkotas@microsoft.com>
Fri, 13 Apr 2018 12:25:39 +0000 (05:25 -0700)
The call to PInvokeStubWorker can do all kinds of stuff to the
VASigCookieReg in the GenericPInvokeCalli case, since x15 is just a
temporary register. Let's save it in a callee-saved register so that
when we come back after stub generation, we still have the correct value
for the VASigCookie.

src/vm/arm64/PInvokeStubs.asm

index 34d634a..afe2fb4 100644 (file)
@@ -80,15 +80,21 @@ __PInvokeGenStubFuncName SETS "$__PInvokeGenStubFuncName":CC:"_RetBuffArg"
         ENDIF
 
         ; x0 = pTransitionBlock
-        add                 x0, sp, #__PWTB_TransitionBlock      
+        add                 x0, sp, #__PWTB_TransitionBlock
 
         ; save hidden arg
         mov                 x19, $HiddenArg 
 
+        ; save VASigCookieReg
+        mov                 x20, $VASigCookieReg
+
         bl                  $__PInvokeStubWorkerName
 
+        ; restore VASigCookieReg
+        mov                 $VASigCookieReg, x20
+
         ; restore hidden arg (method desc or unmanaged target)
-        mov                 $HiddenArg , x19
+        mov                 $HiddenArg, x19
 
 
         EPILOG_WITH_TRANSITION_BLOCK_TAILCALL