diff --git a/src/coreclr/vm/amd64/AsmHelpers.asm b/src/coreclr/vm/amd64/AsmHelpers.asm index 7d2f40deaf2440..8464102ef23730 100644 --- a/src/coreclr/vm/amd64/AsmHelpers.asm +++ b/src/coreclr/vm/amd64/AsmHelpers.asm @@ -492,32 +492,33 @@ NESTED_ENTRY CallEHFunclet, _TEXT ; ; RCX = throwable ; RDX = PC to invoke - ; R8 = address of RBX register in CONTEXT record; used to restore the non-volatile registers of CrawlFrame + ; R8 = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame ; R9 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. ; FUNCLET_CALL_PROLOGUE 0, 1 ; Restore RBX, RBP, RSI, RDI, R12, R13, R14, R15 from CONTEXT - mov rbp, [r8 + OFFSETOF__CONTEXT__Rbp - OFFSETOF__CONTEXT__Rbx] - mov rsi, [r8 + OFFSETOF__CONTEXT__Rsi - OFFSETOF__CONTEXT__Rbx] - mov rdi, [r8 + OFFSETOF__CONTEXT__Rdi - OFFSETOF__CONTEXT__Rbx] - mov r12, [r8 + OFFSETOF__CONTEXT__R12 - OFFSETOF__CONTEXT__Rbx] - mov r13, [r8 + OFFSETOF__CONTEXT__R13 - OFFSETOF__CONTEXT__Rbx] - mov r14, [r8 + OFFSETOF__CONTEXT__R14 - OFFSETOF__CONTEXT__Rbx] - mov r15, [r8 + OFFSETOF__CONTEXT__R15 - OFFSETOF__CONTEXT__Rbx] + mov rbx, [r8 + OFFSETOF__CONTEXT__Rbx] + mov rbp, [r8 + OFFSETOF__CONTEXT__Rbp] + mov rsi, [r8 + OFFSETOF__CONTEXT__Rsi] + mov rdi, [r8 + OFFSETOF__CONTEXT__Rdi] + mov r12, [r8 + OFFSETOF__CONTEXT__R12] + mov r13, [r8 + OFFSETOF__CONTEXT__R13] + mov r14, [r8 + OFFSETOF__CONTEXT__R14] + mov r15, [r8 + OFFSETOF__CONTEXT__R15] ; Restore XMM registers from CONTEXT - movdqa xmm6, [r8 + OFFSETOF__CONTEXT__Xmm6 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm7, [r8 + OFFSETOF__CONTEXT__Xmm7 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm8, [r8 + OFFSETOF__CONTEXT__Xmm8 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm9, [r8 + OFFSETOF__CONTEXT__Xmm9 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm10, [r8 + OFFSETOF__CONTEXT__Xmm10 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm11, [r8 + OFFSETOF__CONTEXT__Xmm11 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm12, [r8 + OFFSETOF__CONTEXT__Xmm12 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm13, [r8 + OFFSETOF__CONTEXT__Xmm13 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm14, [r8 + OFFSETOF__CONTEXT__Xmm14 - OFFSETOF__CONTEXT__Rbx] - movdqa xmm15, [r8 + OFFSETOF__CONTEXT__Xmm15 - OFFSETOF__CONTEXT__Rbx] + movdqa xmm6, [r8 + OFFSETOF__CONTEXT__Xmm6] + movdqa xmm7, [r8 + OFFSETOF__CONTEXT__Xmm7] + movdqa xmm8, [r8 + OFFSETOF__CONTEXT__Xmm8] + movdqa xmm9, [r8 + OFFSETOF__CONTEXT__Xmm9] + movdqa xmm10, [r8 + OFFSETOF__CONTEXT__Xmm10] + movdqa xmm11, [r8 + OFFSETOF__CONTEXT__Xmm11] + movdqa xmm12, [r8 + OFFSETOF__CONTEXT__Xmm12] + movdqa xmm13, [r8 + OFFSETOF__CONTEXT__Xmm13] + movdqa xmm14, [r8 + OFFSETOF__CONTEXT__Xmm14] + movdqa xmm15, [r8 + OFFSETOF__CONTEXT__Xmm15] ; Save the SP of this function. mov [r9], rsp diff --git a/src/coreclr/vm/amd64/asmhelpers.S b/src/coreclr/vm/amd64/asmhelpers.S index 805855a65035a6..79b6b520617b7a 100644 --- a/src/coreclr/vm/amd64/asmhelpers.S +++ b/src/coreclr/vm/amd64/asmhelpers.S @@ -382,18 +382,19 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // // RDI = throwable // RSI = PC to invoke - // RDX = address of RBX register in CONTEXT record; used to restore the non-volatile registers of CrawlFrame + // RDX = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame // RCX = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. // FUNCLET_CALL_PROLOGUE 0, 1 // Restore RBX, RBP, R12, R13, R14, R15 from CONTEXT - mov rbp, [rdx + OFFSETOF__CONTEXT__Rbp - OFFSETOF__CONTEXT__Rbx] - mov r12, [rdx + OFFSETOF__CONTEXT__R12 - OFFSETOF__CONTEXT__Rbx] - mov r13, [rdx + OFFSETOF__CONTEXT__R13 - OFFSETOF__CONTEXT__Rbx] - mov r14, [rdx + OFFSETOF__CONTEXT__R14 - OFFSETOF__CONTEXT__Rbx] - mov r15, [rdx + OFFSETOF__CONTEXT__R15 - OFFSETOF__CONTEXT__Rbx] + mov rbx, [rdx + OFFSETOF__CONTEXT__Rbx] + mov rbp, [rdx + OFFSETOF__CONTEXT__Rbp] + mov r12, [rdx + OFFSETOF__CONTEXT__R12] + mov r13, [rdx + OFFSETOF__CONTEXT__R13] + mov r14, [rdx + OFFSETOF__CONTEXT__R14] + mov r15, [rdx + OFFSETOF__CONTEXT__R15] // Save the SP of this function. mov [rcx], rsp diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index 1183c5619fde05..c19a2efbd8a68a 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -84,6 +84,9 @@ ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); #define SIZEOF__CONTEXT 0x1a0 ASMCONSTANTS_C_ASSERT(SIZEOF__CONTEXT == sizeof(T_CONTEXT)); +#define OFFSETOF__CONTEXT__R4 0x14 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R4 == offsetof(T_CONTEXT, R4)); + #define SIZEOF__CalleeSavedRegisters 0x24 ASMCONSTANTS_C_ASSERT(SIZEOF__CalleeSavedRegisters == sizeof(CalleeSavedRegisters)) diff --git a/src/coreclr/vm/arm/ehhelpers.S b/src/coreclr/vm/arm/ehhelpers.S index ab75b1cb6c1ef9..30c0a299ce7d6f 100644 --- a/src/coreclr/vm/arm/ehhelpers.S +++ b/src/coreclr/vm/arm/ehhelpers.S @@ -105,12 +105,13 @@ GenerateRedirectedStubWithFrame RedirectForThreadAbort, RedirectForThreadAbort2 // // R0 = throwable // R1 = PC to invoke - // R2 = address of R4 register in CONTEXT record// used to restore the non-volatile registers of CrawlFrame + // R2 = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame // R3 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. // // Save the SP of this function str sp, [r3] // apply the non-volatiles corresponding to the CrawlFrame + add r2, r2, OFFSETOF__CONTEXT__R4 ldm r2!, {r4-r6} add r2, r2, #4 ldm r2!, {r8-r11} diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index cb772c16bd1a95..e8d32ab3b76dc9 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -101,6 +101,12 @@ ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); #endif ASMCONSTANTS_C_ASSERT(SIZEOF__CONTEXT == sizeof(T_CONTEXT)); +#define OFFSETOF__CONTEXT__X19 0xA0 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__X19 == offsetof(T_CONTEXT, X19)); + +#define OFFSETOF__CONTEXT__Fp 0xF0 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Fp == offsetof(T_CONTEXT, Fp)); + #define OFFSETOF__DynamicHelperStubArgs__Constant1 0x0 ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicHelperStubArgs__Constant1 == offsetof(DynamicHelperStubArgs, Constant1)); diff --git a/src/coreclr/vm/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index 080a98f0351017..0d039e396321ed 100644 --- a/src/coreclr/vm/arm64/asmhelpers.S +++ b/src/coreclr/vm/arm64/asmhelpers.S @@ -189,7 +189,7 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // // X0 = throwable // X1 = PC to invoke - // X2 = address of X19 register in CONTEXT record// used to restore the non-volatile registers of CrawlFrame + // X2 = address of 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. // @@ -211,12 +211,12 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler mov x4, sp str x4, [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 + ldp x19, x20, [x2, #OFFSETOF__CONTEXT__X19] + ldp x21, x22, [x2, #(OFFSETOF__CONTEXT__X19 + 16)] + ldp x23, x24, [x2, #(OFFSETOF__CONTEXT__X19 + 32)] + ldp x25, x26, [x2, #(OFFSETOF__CONTEXT__X19 + 48)] + ldp x27, x28, [x2, #(OFFSETOF__CONTEXT__X19 + 64)] + ldr fp, [x2, #OFFSETOF__CONTEXT__Fp] // Invoke the funclet blr x1 diff --git a/src/coreclr/vm/arm64/asmhelpers.asm b/src/coreclr/vm/arm64/asmhelpers.asm index 44371193e3b85e..edcd6d709ac032 100644 --- a/src/coreclr/vm/arm64/asmhelpers.asm +++ b/src/coreclr/vm/arm64/asmhelpers.asm @@ -523,7 +523,7 @@ COMToCLRDispatchHelper_RegSetup ; ; X0 = throwable ; X1 = PC to invoke - ; X2 = address of X19 register in CONTEXT record; used to restore the non-volatile registers of CrawlFrame + ; X2 = address of 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. ; @@ -545,12 +545,12 @@ COMToCLRDispatchHelper_RegSetup 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 + ldp x19, x20, [x2, #OFFSETOF__CONTEXT__X19] + ldp x21, x22, [x2, #(OFFSETOF__CONTEXT__X19 + 16)] + ldp x23, x24, [x2, #(OFFSETOF__CONTEXT__X19 + 32)] + ldp x25, x26, [x2, #(OFFSETOF__CONTEXT__X19 + 48)] + ldp x27, x28, [x2, #(OFFSETOF__CONTEXT__X19 + 64)] + ldr fp, [x2, #OFFSETOF__CONTEXT__Fp] ; Invoke the funclet blr x1 diff --git a/src/coreclr/vm/eetwain.cpp b/src/coreclr/vm/eetwain.cpp index 3400cd4b57ecac..39844aa3171080 100644 --- a/src/coreclr/vm/eetwain.cpp +++ b/src/coreclr/vm/eetwain.cpp @@ -2009,7 +2009,7 @@ void EECodeManager::LeaveCatch(GCInfoToken gcInfoToken, #ifndef TARGET_WASM // This is an assembly helper that enables us to call into EH funclets. -EXTERN_C DWORD_PTR STDCALL CallEHFunclet(Object *pThrowable, UINT_PTR pFuncletToInvoke, UINT_PTR *pFirstNonVolReg, UINT_PTR *pFuncletCallerSP); +EXTERN_C DWORD_PTR STDCALL CallEHFunclet(Object *pThrowable, UINT_PTR pFuncletToInvoke, CONTEXT *pContext, UINT_PTR *pFuncletCallerSP); // This is an assembly helper that enables us to call into EH filter funclets. EXTERN_C DWORD_PTR STDCALL CallEHFilterFunclet(Object *pThrowable, TADDR FP, UINT_PTR pFuncletToInvoke, UINT_PTR *pFuncletCallerSP); @@ -2025,26 +2025,6 @@ static inline UINT_PTR CastHandlerFn(HandlerFn *pfnHandler) #endif } -static inline UINT_PTR *GetFirstNonVolatileRegisterAddress(PCONTEXT pContextRecord) -{ -#if defined(TARGET_AMD64) - return (UINT_PTR*)&(pContextRecord->Rbx); -#elif defined(TARGET_ARM) - return (UINT_PTR*)&(pContextRecord->R4); -#elif defined(TARGET_ARM64) - return (UINT_PTR*)&(pContextRecord->X19); -#elif defined(TARGET_LOONGARCH64) - return (UINT_PTR*)&(pContextRecord->S0); -#elif defined(TARGET_X86) - return (UINT_PTR*)&(pContextRecord->Edi); -#elif defined(TARGET_RISCV64) - return (UINT_PTR*)&(pContextRecord->Fp); -#else - PORTABILITY_ASSERT("GetFirstNonVolatileRegisterAddress"); - return NULL; -#endif -} - #endif // TARGET_WASM // Call catch, finally or filter funclet. @@ -2078,7 +2058,7 @@ DWORD_PTR EECodeManager::CallFunclet(OBJECTREF throwable, void* pHandler, REGDIS { dwResult = CallEHFunclet(OBJECTREFToObject(throwable), CastHandlerFn(pfnHandler), - GetFirstNonVolatileRegisterAddress(pRD->pCurrentContext), + pRD->pCurrentContext, pFuncletCallerSP); } diff --git a/src/coreclr/vm/i386/ehhelpers.S b/src/coreclr/vm/i386/ehhelpers.S index 3b65e1b384d916..c518558fcb30da 100644 --- a/src/coreclr/vm/i386/ehhelpers.S +++ b/src/coreclr/vm/i386/ehhelpers.S @@ -5,7 +5,7 @@ #include "unixasmmacros.inc" #include "asmconstants.h" -// DWORD_PTR STDCALL CallEHFunclet(Object *pThrowable, UINT_PTR pFuncletToInvoke, UINT_PTR *pFirstNonVolReg, UINT_PTR *pFuncletCallerSP); +// DWORD_PTR STDCALL CallEHFunclet(Object *pThrowable, UINT_PTR pFuncletToInvoke, CONTEXT *pContext, UINT_PTR *pFuncletCallerSP); // ESP based frame NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler @@ -23,7 +23,7 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // // [ebp+ 8] = throwable // [ebp+12] = PC to invoke - // [ebp+16] = address of EDI register in CONTEXT record // used to restore the non-volatile registers of CrawlFrame + // [ebp+16] = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame // [ebp+20] = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. // @@ -36,10 +36,10 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler mov eax, [ebp + 8] // Restore non-volatiles registers mov ecx, [ebp + 16] - mov edi, [ecx] - mov esi, [ecx + 4] - mov ebx, [ecx + 8] - mov ebp, [ecx + 24] + mov edi, [ecx + CONTEXT_Edi] + mov esi, [ecx + CONTEXT_Esi] + mov ebx, [ecx + CONTEXT_Ebx] + mov ebp, [ecx + CONTEXT_Ebp] // Invoke the funclet call edx diff --git a/src/coreclr/vm/i386/ehhelpers.asm b/src/coreclr/vm/i386/ehhelpers.asm index ddae1ff34a7577..e2259b178d9d68 100644 --- a/src/coreclr/vm/i386/ehhelpers.asm +++ b/src/coreclr/vm/i386/ehhelpers.asm @@ -12,7 +12,7 @@ include asmconstants.inc ifdef FEATURE_EH_FUNCLETS -; DWORD_PTR STDCALL CallEHFunclet(Object *pThrowable, UINT_PTR pFuncletToInvoke, UINT_PTR *pFirstNonVolReg, UINT_PTR *pFuncletCallerSP); +; DWORD_PTR STDCALL CallEHFunclet(Object *pThrowable, UINT_PTR pFuncletToInvoke, CONTEXT *pContext, UINT_PTR *pFuncletCallerSP); ; ESP based frame _CallEHFunclet@16 proc public @@ -27,7 +27,7 @@ _CallEHFunclet@16 proc public ; ; [ebp+ 8] = throwable ; [ebp+12] = PC to invoke - ; [ebp+16] = address of EDI register in CONTEXT record ; used to restore the non-volatile registers of CrawlFrame + ; [ebp+16] = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame ; [ebp+20] = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. ; @@ -40,10 +40,10 @@ _CallEHFunclet@16 proc public mov eax, [ebp + 8] ; Restore non-volatiles registers mov ecx, [ebp + 16] - mov edi, [ecx] - mov esi, [ecx + 4] - mov ebx, [ecx + 8] - mov ebp, [ecx + 24] + mov edi, [ecx + CONTEXT_Edi] + mov esi, [ecx + CONTEXT_Esi] + mov ebx, [ecx + CONTEXT_Ebx] + mov ebp, [ecx + CONTEXT_Ebp] ; Invoke the funclet call edx diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index bd030820c814c8..2ca6ef9a5499db 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -99,6 +99,12 @@ ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); #define SIZEOF__CONTEXT 0x520 ASMCONSTANTS_C_ASSERT(SIZEOF__CONTEXT == sizeof(T_CONTEXT)); +#define OFFSETOF__CONTEXT__S0 0xC0 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__S0 == offsetof(T_CONTEXT, S0)); + +#define OFFSETOF__CONTEXT__Fp 0xB8 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Fp == offsetof(T_CONTEXT, Fp)); + //========================================= #define OFFSETOF__MethodTable__m_dwFlags 0x0 ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_dwFlags == offsetof(MethodTable, m_dwFlags)); diff --git a/src/coreclr/vm/loongarch64/asmhelpers.S b/src/coreclr/vm/loongarch64/asmhelpers.S index 33cb262cd644be..c40821314bc2ac 100644 --- a/src/coreclr/vm/loongarch64/asmhelpers.S +++ b/src/coreclr/vm/loongarch64/asmhelpers.S @@ -723,7 +723,7 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // // $a0 = throwable // $a1 = PC to invoke - // $a2 = address of s0 register in CONTEXT record// used to restore the non-volatile registers of CrawlFrame + // $a2 = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame // $a3 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. // @@ -741,16 +741,16 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // Save the SP of this function st.d $sp, $a3, 0 - ld.d $fp, $a2, -8 // offset of fp in PCONTEXT relative to S0. - ld.d $s0, $a2, 0 - ld.d $s1, $a2, 8 - ld.d $s2, $a2, 16 - ld.d $s3, $a2, 24 - ld.d $s4, $a2, 32 - ld.d $s5, $a2, 40 - ld.d $s6, $a2, 48 - ld.d $s7, $a2, 56 - ld.d $s8, $a2, 64 + ld.d $fp, $a2, OFFSETOF__CONTEXT__Fp + ld.d $s0, $a2, OFFSETOF__CONTEXT__S0 + ld.d $s1, $a2, OFFSETOF__CONTEXT__S0+8 + ld.d $s2, $a2, OFFSETOF__CONTEXT__S0+16 + ld.d $s3, $a2, OFFSETOF__CONTEXT__S0+24 + ld.d $s4, $a2, OFFSETOF__CONTEXT__S0+32 + ld.d $s5, $a2, OFFSETOF__CONTEXT__S0+40 + ld.d $s6, $a2, OFFSETOF__CONTEXT__S0+48 + ld.d $s7, $a2, OFFSETOF__CONTEXT__S0+56 + ld.d $s8, $a2, OFFSETOF__CONTEXT__S0+64 // Invoke the funclet jirl $ra, $a1, 0 diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index d933a33898ab41..0b88275bc32870 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -94,6 +94,20 @@ ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); #define SIZEOF__CONTEXT 0x220 ASMCONSTANTS_C_ASSERT(SIZEOF__CONTEXT == sizeof(T_CONTEXT)); +#define OFFSETOF__CONTEXT__Gp 0x20 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Gp == offsetof(T_CONTEXT, Gp)); + +#define OFFSETOF__CONTEXT__Tp 0x28 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Tp == offsetof(T_CONTEXT, Tp)); + +#define OFFSETOF__CONTEXT__Fp 0x48 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Fp == offsetof(T_CONTEXT, Fp)); + +#define OFFSETOF__CONTEXT__S1 0x50 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__S1 == offsetof(T_CONTEXT, S1)); + +#define OFFSETOF__CONTEXT__S2 0x98 +ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__S2 == offsetof(T_CONTEXT, S2)); //========================================= #define OFFSETOF__MethodTable__m_dwFlags 0x0 diff --git a/src/coreclr/vm/riscv64/asmhelpers.S b/src/coreclr/vm/riscv64/asmhelpers.S index 479706eb117b4f..69e1acee43767f 100644 --- a/src/coreclr/vm/riscv64/asmhelpers.S +++ b/src/coreclr/vm/riscv64/asmhelpers.S @@ -568,7 +568,7 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // // a0 = throwable // a1 = PC to invoke - // a2 = address of s0 register in CONTEXT record// used to restore the non-volatile registers of CrawlFrame + // a2 = address of CONTEXT record; used to restore the non-volatile registers of CrawlFrame // a3 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. // @@ -586,20 +586,20 @@ NESTED_ENTRY CallEHFunclet, _TEXT, NoHandler // Save the SP of this function sd sp, 0(a3) - ld gp, (-40)(a2) // offset of tp in PCONTEXT relative to S0. - ld tp, (-32)(a2) // offset of tp in PCONTEXT relative to S0. - ld fp, 0(a2) // offset of fp in PCONTEXT relative to S0. - ld s1, 8(a2) - ld s2, 80(a2) - ld s3, 88(a2) - ld s4, 96(a2) - ld s5, 104(a2) - ld s6, 112(a2) - ld s7, 120(a2) - ld s8, 128(a2) - ld s9, 136(a2) - ld s10, 144(a2) - ld s11, 152(a2) + ld gp, OFFSETOF__CONTEXT__Gp(a2) + ld tp, OFFSETOF__CONTEXT__Tp(a2) + ld fp, OFFSETOF__CONTEXT__Fp(a2) + ld s1, OFFSETOF__CONTEXT__S1(a2) + ld s2, OFFSETOF__CONTEXT__S2(a2) + ld s3, OFFSETOF__CONTEXT__S2+8(a2) + ld s4, OFFSETOF__CONTEXT__S2+16(a2) + ld s5, OFFSETOF__CONTEXT__S2+24(a2) + ld s6, OFFSETOF__CONTEXT__S2+32(a2) + ld s7, OFFSETOF__CONTEXT__S2+40(a2) + ld s8, OFFSETOF__CONTEXT__S2+48(a2) + ld s9, OFFSETOF__CONTEXT__S2+56(a2) + ld s10, OFFSETOF__CONTEXT__S2+64(a2) + ld s11, OFFSETOF__CONTEXT__S2+72(a2) // Invoke the funclet jalr a1