From a230fe2a47f681496e5818668197bacbb52cab57 Mon Sep 17 00:00:00 2001 From: "Steve MacLean, Qualcomm Datacenter Technologies, Inc" Date: Wed, 15 Mar 2017 15:36:27 +0000 Subject: [Arm64/Windows] Backport #9500 changes Fixes #9526 --- src/vm/arm64/CallDescrWorkerARM64.asm | 5 ++++- src/vm/arm64/asmhelpers.asm | 36 +++++++++++++++++++++++++---------- src/vm/arm64/calldescrworkerarm64.S | 2 +- 3 files changed, 31 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/vm/arm64/CallDescrWorkerARM64.asm b/src/vm/arm64/CallDescrWorkerARM64.asm index b9f8a6090d..4bd0de7f2b 100644 --- a/src/vm/arm64/CallDescrWorkerARM64.asm +++ b/src/vm/arm64/CallDescrWorkerARM64.asm @@ -21,7 +21,8 @@ ;;void CallDescrWorkerInternal(CallDescrData * pCallDescrData); NESTED_ENTRY CallDescrWorkerInternal,,CallDescrWorkerUnwindFrameChainHandler PROLOG_SAVE_REG_PAIR fp, lr, #-32! - PROLOG_SAVE_REG x19, #16 ;the stack slot at sp+24 is empty for 16 byte alligment + PROLOG_SAVE_REG x19, #16 + PROLOG_SAVE_REG x0, #24 mov x19, x0 ; save pCallDescrData in x19 @@ -76,6 +77,8 @@ LNoFloatingPoint ldr x9, [x19,#CallDescrData__pTarget] blr x9 + ldr x19, [fp, 24] ; Fixup corrupted X19 callee preserved register + ldr w3, [x19,#CallDescrData__fpReturnSize] ;; Int return case diff --git a/src/vm/arm64/asmhelpers.asm b/src/vm/arm64/asmhelpers.asm index d760765885..42e8c59bfc 100644 --- a/src/vm/arm64/asmhelpers.asm +++ b/src/vm/arm64/asmhelpers.asm @@ -159,6 +159,7 @@ RestoreRegMS 26, X26 RestoreRegMS 27, X27 RestoreRegMS 28, X28 + RestoreRegMS 29, X29 Done ; Its imperative that the return value of HelperMethodFrameRestoreState is zero @@ -991,16 +992,6 @@ UM2MThunk_WrapperHelper_RegArgumentsSetup ; This helper enables us to call into a funclet after restoring Fp register NESTED_ENTRY CallEHFunclet - - ; Using below prolog instead of PROLOG_SAVE_REG_PAIR fp,lr, #-16! - ; is intentional. Above statement would also emit instruction to save - ; sp in fp. If sp is saved in fp in prolog then it is not expected that fp can change in the body - ; of method. However, this method needs to be able to change fp before calling funclet. - ; This is required to access locals in funclet. - PROLOG_SAVE_REG_PAIR x19,x20, #-16! - PROLOG_SAVE_REG fp, #0 - PROLOG_SAVE_REG lr, #8 - ; On entry: ; ; X0 = throwable @@ -1008,16 +999,41 @@ UM2MThunk_WrapperHelper_RegArgumentsSetup ; X2 = address of X19 register in CONTEXT record; used to restore the non-volatile registers of CrawlFrame ; X3 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. ; + + ; Using below prolog instead of PROLOG_SAVE_REG_PAIR fp,lr, #-16! + ; is intentional. Above statement would also emit instruction to save + ; sp in fp. If sp is saved in fp in prolog then it is not expected that fp can change in the body + ; of method. However, this method needs to be able to change fp before calling funclet. + ; This is required to access locals in funclet. + PROLOG_SAVE_REG_PAIR x29,lr, #-96! + + ; Spill callee saved registers + PROLOG_SAVE_REG_PAIR x19, x20, 16 + PROLOG_SAVE_REG_PAIR x21, x22, 32 + PROLOG_SAVE_REG_PAIR x23, x24, 48 + PROLOG_SAVE_REG_PAIR x25, x26, 64 + PROLOG_SAVE_REG_PAIR x27, x28, 80 + ; Save the SP of this function. We cannot store SP directly. mov fp, sp str fp, [x3] + ldp x19, x20, [x2, #0] + ldp x21, x22, [x2, #16] + ldp x23, x24, [x2, #32] + ldp x25, x26, [x2, #48] + ldp x27, x28, [x2, #64] ldr fp, [x2, #80] ; offset of fp in CONTEXT relative to X19 ; Invoke the funclet blr x1 nop + EPILOG_RESTORE_REG_PAIR x19, x20, 16 + EPILOG_RESTORE_REG_PAIR x21, x22, 32 + EPILOG_RESTORE_REG_PAIR x23, x24, 48 + EPILOG_RESTORE_REG_PAIR x25, x26, 64 + EPILOG_RESTORE_REG_PAIR x27, x28, 80 EPILOG_RESTORE_REG_PAIR fp, lr, #16! EPILOG_RETURN diff --git a/src/vm/arm64/calldescrworkerarm64.S b/src/vm/arm64/calldescrworkerarm64.S index 2210d70523..f3ea970d2d 100644 --- a/src/vm/arm64/calldescrworkerarm64.S +++ b/src/vm/arm64/calldescrworkerarm64.S @@ -69,7 +69,7 @@ LOCAL_LABEL(NoFloatingPoint): ldr x9, [x19,#CallDescrData__pTarget] blr x9 - ldr x19, [fp, 24] // Fixup corrupted X19 caller preserved register + ldr x19, [fp, 24] // Fixup corrupted X19 callee preserved register ldr w3, [x19,#CallDescrData__fpReturnSize] -- cgit v1.2.3 From 15f2e26d4cdc2ad4a2b1ac5b1386c29640602bf8 Mon Sep 17 00:00:00 2001 From: "Steve MacLean, Qualcomm Datacenter Technologies, Inc" Date: Fri, 17 Mar 2017 17:49:42 +0000 Subject: [Arm64/Windows] Revert changes per #10260 & review --- src/vm/arm64/CallDescrWorkerARM64.asm | 5 +---- src/vm/arm64/calldescrworkerarm64.S | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/vm/arm64/CallDescrWorkerARM64.asm b/src/vm/arm64/CallDescrWorkerARM64.asm index 4bd0de7f2b..b9f8a6090d 100644 --- a/src/vm/arm64/CallDescrWorkerARM64.asm +++ b/src/vm/arm64/CallDescrWorkerARM64.asm @@ -21,8 +21,7 @@ ;;void CallDescrWorkerInternal(CallDescrData * pCallDescrData); NESTED_ENTRY CallDescrWorkerInternal,,CallDescrWorkerUnwindFrameChainHandler PROLOG_SAVE_REG_PAIR fp, lr, #-32! - PROLOG_SAVE_REG x19, #16 - PROLOG_SAVE_REG x0, #24 + PROLOG_SAVE_REG x19, #16 ;the stack slot at sp+24 is empty for 16 byte alligment mov x19, x0 ; save pCallDescrData in x19 @@ -77,8 +76,6 @@ LNoFloatingPoint ldr x9, [x19,#CallDescrData__pTarget] blr x9 - ldr x19, [fp, 24] ; Fixup corrupted X19 callee preserved register - ldr w3, [x19,#CallDescrData__fpReturnSize] ;; Int return case diff --git a/src/vm/arm64/calldescrworkerarm64.S b/src/vm/arm64/calldescrworkerarm64.S index f3ea970d2d..2210d70523 100644 --- a/src/vm/arm64/calldescrworkerarm64.S +++ b/src/vm/arm64/calldescrworkerarm64.S @@ -69,7 +69,7 @@ LOCAL_LABEL(NoFloatingPoint): ldr x9, [x19,#CallDescrData__pTarget] blr x9 - ldr x19, [fp, 24] // Fixup corrupted X19 callee preserved register + ldr x19, [fp, 24] // Fixup corrupted X19 caller preserved register ldr w3, [x19,#CallDescrData__fpReturnSize] -- cgit v1.2.3 From 5d1922d82e7e418769ccf5b173188966d26dbe4d Mon Sep 17 00:00:00 2001 From: "Steve MacLean, Qualcomm Datacenter Technologies, Inc" Date: Fri, 17 Mar 2017 18:00:37 +0000 Subject: [Arm64/Windows] Fix per review comment --- src/vm/arm64/asmhelpers.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/vm/arm64/asmhelpers.asm b/src/vm/arm64/asmhelpers.asm index 42e8c59bfc..865bca9837 100644 --- a/src/vm/arm64/asmhelpers.asm +++ b/src/vm/arm64/asmhelpers.asm @@ -1034,7 +1034,7 @@ UM2MThunk_WrapperHelper_RegArgumentsSetup EPILOG_RESTORE_REG_PAIR x23, x24, 48 EPILOG_RESTORE_REG_PAIR x25, x26, 64 EPILOG_RESTORE_REG_PAIR x27, x28, 80 - EPILOG_RESTORE_REG_PAIR fp, lr, #16! + EPILOG_RESTORE_REG_PAIR fp, lr, #96! EPILOG_RETURN NESTED_END CallEHFunclet -- cgit v1.2.3 From e59ab7b62492173eae2be6f96723c2500e080868 Mon Sep 17 00:00:00 2001 From: "Steve MacLean, Qualcomm Datacenter Technologies, Inc" Date: Mon, 27 Mar 2017 18:21:30 +0000 Subject: Fix unwinding issue caught by CI Debugged by Rahul Kumar (Thanks) --- src/vm/arm64/asmhelpers.asm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/vm/arm64/asmhelpers.asm b/src/vm/arm64/asmhelpers.asm index 865bca9837..90ab9d966e 100644 --- a/src/vm/arm64/asmhelpers.asm +++ b/src/vm/arm64/asmhelpers.asm @@ -1005,7 +1005,9 @@ UM2MThunk_WrapperHelper_RegArgumentsSetup ; sp in fp. If sp is saved in fp in prolog then it is not expected that fp can change in the body ; of method. However, this method needs to be able to change fp before calling funclet. ; This is required to access locals in funclet. - PROLOG_SAVE_REG_PAIR x29,lr, #-96! + PROLOG_SAVE_REG_PAIR x19,x20, #-96! + PROLOG_SAVE_REG fp, #0 + PROLOG_SAVE_REG lr, #8 ; Spill callee saved registers PROLOG_SAVE_REG_PAIR x19, x20, 16 -- cgit v1.2.3 From 4db5a72bc2209c6f56c7f335ae318f79d1fe2a4f Mon Sep 17 00:00:00 2001 From: "Steve MacLean, Qualcomm Datacenter Technologies, Inc" Date: Mon, 27 Mar 2017 19:25:56 +0000 Subject: Use PROLOG_SAVE_REG_PAIR_NO_FP per review comments --- src/vm/arm64/asmhelpers.asm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/vm/arm64/asmhelpers.asm b/src/vm/arm64/asmhelpers.asm index 90ab9d966e..e8b16ded6a 100644 --- a/src/vm/arm64/asmhelpers.asm +++ b/src/vm/arm64/asmhelpers.asm @@ -1005,9 +1005,7 @@ UM2MThunk_WrapperHelper_RegArgumentsSetup ; sp in fp. If sp is saved in fp in prolog then it is not expected that fp can change in the body ; of method. However, this method needs to be able to change fp before calling funclet. ; This is required to access locals in funclet. - PROLOG_SAVE_REG_PAIR x19,x20, #-96! - PROLOG_SAVE_REG fp, #0 - PROLOG_SAVE_REG lr, #8 + PROLOG_SAVE_REG_PAIR_NO_FP fp,lr, #-96! ; Spill callee saved registers PROLOG_SAVE_REG_PAIR x19, x20, 16 -- cgit v1.2.3