Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize on using code location for interior asm code references #97853

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 10 additions & 28 deletions src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,28 @@
#if !defined(USE_PORTABLE_HELPERS) // @TODO: these are (currently) only implemented in assembly helpers

#if defined(FEATURE_DYNAMIC_CODE)
EXTERN_C void * RhpUniversalTransition();
GPTR_IMPL_INIT(PTR_VOID, g_RhpUniversalTransitionAddr, (void**)&RhpUniversalTransition);

EXTERN_C PTR_VOID PointerToReturnFromUniversalTransition;
GVAL_IMPL_INIT(PTR_VOID, g_ReturnFromUniversalTransitionAddr, PointerToReturnFromUniversalTransition);

EXTERN_C PTR_VOID PointerToReturnFromUniversalTransition_DebugStepTailCall;
GVAL_IMPL_INIT(PTR_VOID, g_ReturnFromUniversalTransition_DebugStepTailCallAddr, PointerToReturnFromUniversalTransition_DebugStepTailCall);
EXTERN_C CODE_LOCATION ReturnFromUniversalTransition;
EXTERN_C CODE_LOCATION ReturnFromUniversalTransition_DebugStepTailCall;
#endif

#ifdef TARGET_X86
EXTERN_C void * PointerToRhpCallFunclet2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpCallFunclet2Addr, PointerToRhpCallFunclet2);
EXTERN_C CODE_LOCATION RhpCallFunclet2;
#endif
EXTERN_C void * PointerToRhpCallCatchFunclet2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpCallCatchFunclet2Addr, PointerToRhpCallCatchFunclet2);
EXTERN_C void * PointerToRhpCallFinallyFunclet2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpCallFinallyFunclet2Addr, PointerToRhpCallFinallyFunclet2);
EXTERN_C void * PointerToRhpCallFilterFunclet2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpCallFilterFunclet2Addr, PointerToRhpCallFilterFunclet2);
EXTERN_C void * PointerToRhpThrowEx2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpThrowEx2Addr, PointerToRhpThrowEx2);
EXTERN_C void * PointerToRhpThrowHwEx2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpThrowHwEx2Addr, PointerToRhpThrowHwEx2);
EXTERN_C void * PointerToRhpRethrow2;
GVAL_IMPL_INIT(PTR_VOID, g_RhpRethrow2Addr, PointerToRhpRethrow2);
EXTERN_C CODE_LOCATION RhpCallCatchFunclet2;
EXTERN_C CODE_LOCATION RhpCallFinallyFunclet2;
EXTERN_C CODE_LOCATION RhpCallFilterFunclet2;
EXTERN_C CODE_LOCATION RhpThrowEx2;
EXTERN_C CODE_LOCATION RhpThrowHwEx2;
EXTERN_C CODE_LOCATION RhpRethrow2;
#endif // !defined(USE_PORTABLE_HELPERS)

// Addresses of functions in the DAC won't match their runtime counterparts so we
// assign them to globals. However it is more performant in the runtime to compare
// against immediates than to fetch the global. This macro hides the difference.
//
// We use a special code path for the return address from thunks as
// having the return address public confuses today DIA stackwalker. Before we can
// ingest the updated DIA, we're instead exposing a global void * variable
// holding the return address.
#ifdef DACCESS_COMPILE
#define EQUALS_RETURN_ADDRESS(x, func_name) ((x) == g_ ## func_name ## Addr)
#else
#define EQUALS_RETURN_ADDRESS(x, func_name) (((x)) == (PointerTo ## func_name))
#define EQUALS_RETURN_ADDRESS(x, func_name) ((x) == &func_name)
#endif

#ifdef DACCESS_COMPILE
Expand Down
18 changes: 0 additions & 18 deletions src/coreclr/nativeaot/Runtime/amd64/AsmMacros.inc
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,6 @@ Name label proc
PUBLIC Name
endm

EXPORT_POINTER_TO_ADDRESS macro Name

local AddressToExport

AddressToExport label proc

.const

align 8

Name dq offset AddressToExport

public Name

.code

endm

_tls_array equ 58h ;; offsetof(TEB, ThreadLocalStoragePointer)

;;
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/amd64/ExceptionHandling.S
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ NESTED_ENTRY RhpThrowHwEx, _TEXT, NoHandler
// rsi contains the address of the ExInfo
call EXTERNAL_C_FUNC(RhThrowHwEx)

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowHwEx2
ALTERNATE_ENTRY RhpThrowHwEx2

// no return
int 3
Expand Down Expand Up @@ -151,7 +151,7 @@ NESTED_ENTRY RhpThrowEx, _TEXT, NoHandler
// rsi contains the address of the ExInfo
call EXTERNAL_C_FUNC(RhThrowEx)

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowEx2
ALTERNATE_ENTRY RhpThrowEx2

// no return
int 3
Expand Down Expand Up @@ -222,7 +222,7 @@ NESTED_ENTRY RhpRethrow, _TEXT, NoHandler
// rsi contains the address of the new ExInfo
call EXTERNAL_C_FUNC(RhRethrow)

EXPORT_POINTER_TO_ADDRESS PointerToRhpRethrow2
ALTERNATE_ENTRY RhpRethrow2

// no return
int 3
Expand Down Expand Up @@ -334,7 +334,7 @@ NESTED_ENTRY RhpCallCatchFunclet, _TEXT, NoHandler
mov rsi, [rsp + locArg0] // rsi <- exception object
call qword ptr [rsp + locArg1] // call handler funclet

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallCatchFunclet2
ALTERNATE_ENTRY RhpCallCatchFunclet2

mov rdx, [rsp + locArg2] // rdx <- dispatch context

Expand Down Expand Up @@ -473,7 +473,7 @@ NESTED_ENTRY RhpCallFinallyFunclet, _TEXT, NoHandler
mov rdi, [rsi + OFFSETOF__REGDISPLAY__SP] // rdi <- establisher frame
call qword ptr [rsp + locArg0] // handler funclet address

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFinallyFunclet2
ALTERNATE_ENTRY RhpCallFinallyFunclet2

mov rsi, [rsp + locArg1] // rsi <- regdisplay

Expand Down Expand Up @@ -523,7 +523,7 @@ NESTED_ENTRY RhpCallFilterFunclet, _TEXT, NoHandler
mov rdi, [rdx + OFFSETOF__REGDISPLAY__SP] // rdi <- establisher frame
call rax

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFilterFunclet2
ALTERNATE_ENTRY RhpCallFilterFunclet2

// RAX contains the result of the filter execution

Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/amd64/ExceptionHandling.asm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ NESTED_ENTRY RhpThrowHwEx, _TEXT
;; rdx contains the address of the ExInfo
call RhThrowHwEx

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowHwEx2
ALTERNATE_ENTRY RhpThrowHwEx2

;; no return
int 3
Expand Down Expand Up @@ -184,7 +184,7 @@ NESTED_ENTRY RhpThrowEx, _TEXT
;; rdx contains the address of the ExInfo
call RhThrowEx

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowEx2
ALTERNATE_ENTRY RhpThrowEx2

;; no return
int 3
Expand Down Expand Up @@ -269,7 +269,7 @@ NESTED_ENTRY RhpRethrow, _TEXT
;; rdx contains the address of the new ExInfo
call RhRethrow

EXPORT_POINTER_TO_ADDRESS PointerToRhpRethrow2
ALTERNATE_ENTRY RhpRethrow2

;; no return
int 3
Expand Down Expand Up @@ -428,7 +428,7 @@ endif
mov rdx, [rsp + rsp_offsetof_arguments + 0h] ;; rdx <- exception object
call qword ptr [rsp + rsp_offsetof_arguments + 8h] ;; call handler funclet

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallCatchFunclet2
ALTERNATE_ENTRY RhpCallCatchFunclet2

mov r8, [rsp + rsp_offsetof_arguments + 10h] ;; r8 <- dispatch context

Expand Down Expand Up @@ -601,7 +601,7 @@ endif
mov rcx, [rdx + OFFSETOF__REGDISPLAY__SP] ;; rcx <- establisher frame
call qword ptr [rsp + rsp_offsetof_arguments + 0h] ;; handler funclet address

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFinallyFunclet2
ALTERNATE_ENTRY RhpCallFinallyFunclet2

mov rdx, [rsp + rsp_offsetof_arguments + 8h] ;; rdx <- regdisplay

Expand Down Expand Up @@ -666,7 +666,7 @@ NESTED_ENTRY RhpCallFilterFunclet, _TEXT
mov rcx, [r8 + OFFSETOF__REGDISPLAY__SP] ;; rcx <- establisher frame
call rax

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFilterFunclet2
ALTERNATE_ENTRY RhpCallFilterFunclet2

;; RAX contains the result of the filter execution

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ NESTED_ENTRY Rhp\FunctionName, _TEXT, NoHandler
lea rdi, [rsp + DISTANCE_FROM_CHILDSP_TO_RETURN_BLOCK]
call r10

EXPORT_POINTER_TO_ADDRESS PointerToReturnFrom\FunctionName
ALTERNATE_ENTRY ReturnFrom\FunctionName

// restore fp argument registers
movdqa xmm0, [rsp + DISTANCE_FROM_CHILDSP_TO_FP_REGS + 0x00]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ endif ; TRASH_SAVED_ARGUMENT_REGISTERS
lea rcx, [rsp + DISTANCE_FROM_CHILDSP_TO_RETURN_BLOCK]
call r10

EXPORT_POINTER_TO_ADDRESS PointerToReturnFrom&FunctionName
ALTERNATE_ENTRY ReturnFrom&FunctionName

; We cannot make the label public as that tricks DIA stackwalker into thinking
; it's the beginning of a method. For this reason we export the address
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/arm/ExceptionHandling.S
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ NESTED_ENTRY RhpThrowHwEx, _TEXT, NoHandler
// r1 contains the address of the ExInfo
bl C_FUNC(RhThrowHwEx)

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowHwEx2
GLOBAL_LABEL RhpThrowHwEx2

// no return
EMIT_BREAKPOINT
Expand Down Expand Up @@ -176,7 +176,7 @@ LOCAL_LABEL(NotHiJacked):
// r1 contains the address of the new ExInfo
bl C_FUNC(RhThrowEx)

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowEx2
GLOBAL_LABEL RhpThrowEx2

// no return
EMIT_BREAKPOINT
Expand Down Expand Up @@ -237,7 +237,7 @@ NESTED_ENTRY RhpRethrow, _TEXT, NoHandler
// r1 contains the address of the new ExInfo
blx C_FUNC(RhRethrow)

EXPORT_POINTER_TO_ADDRESS PointerToRhpRethrow2
GLOBAL_LABEL RhpRethrow2

// no return
EMIT_BREAKPOINT
Expand Down Expand Up @@ -320,7 +320,7 @@ LOCAL_LABEL(ClearSuccess_Catch):
// r0 <- exception object
blx r3 // call handler funclet

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallCatchFunclet2
GLOBAL_LABEL RhpCallCatchFunclet2

str r0, [sp, #rsp_offset_r0] // Save the result

Expand Down Expand Up @@ -421,7 +421,7 @@ LOCAL_LABEL(ClearSuccess):

blx r2 // handler funclet address

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFinallyFunclet2
GLOBAL_LABEL RhpCallFinallyFunclet2

ldr r1, [sp, #rsp_offset_r1] // reload REGDISPLAY pointer

Expand Down Expand Up @@ -497,7 +497,7 @@ NESTED_ENTRY RhpCallFilterFunclet, _TEXT, NoHandler
// r1 = establisher frame
blx r12

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFilterFunclet2
GLOBAL_LABEL RhpCallFilterFunclet2

// R0 contains the result of the filter execution

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/arm/UniversalTransition.S
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ NESTED_ENTRY Rhp\FunctionName, _TEXT, NoHandler
add r0, sp, #DISTANCE_FROM_CHILDSP_TO_RETURN_BLOCK // First parameter to target function is a pointer to the return block
blx r12

EXPORT_POINTER_TO_ADDRESS PointerToReturnFrom\FunctionName
GLOBAL_LABEL ReturnFrom\FunctionName

// We cannot make the label public as that tricks DIA stackwalker into thinking
// it's the beginning of a method. For this reason we export an auxiliary variable
Expand Down
19 changes: 0 additions & 19 deletions src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,6 @@ MovInstr SETS "movk"
ldr w$RegNum, [x$RegNum, $Name]
MEND


;; -----------------------------------------------------------------------------
;;
;; Macro to export a pointer to an address inside a stub as a 64-bit variable
;;
MACRO
EXPORT_POINTER_TO_ADDRESS $Name
LCLS CodeLbl
CodeLbl SETS "$Name":CC:"Lbl"
$CodeLbl
AREA | .rdata | , ALIGN = 8, DATA, READONLY
$Name
DCQ $CodeLbl
EXPORT $Name
TEXTAREA
ROUT

MEND

jkotas marked this conversation as resolved.
Show resolved Hide resolved
;; -----------------------------------------------------------------------------
;;
;; Macro for indicating an alternate entry point into a function.
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.S
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
// x1: ExInfo*
bl C_FUNC(RhThrowHwEx)

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowHwEx2
ALTERNATE_ENTRY RhpThrowHwEx2

// no return
EMIT_BREAKPOINT
Expand Down Expand Up @@ -332,7 +332,7 @@ LOCAL_LABEL(NotHijacked):
// x1: ExInfo*
bl C_FUNC(RhThrowEx)

EXPORT_POINTER_TO_ADDRESS PointerToRhpThrowEx2
ALTERNATE_ENTRY RhpThrowEx2

// no return
EMIT_BREAKPOINT
Expand Down Expand Up @@ -377,7 +377,7 @@ LOCAL_LABEL(NotHijacked):
// x1 contains the address of the new ExInfo
bl C_FUNC(RhRethrow)

EXPORT_POINTER_TO_ADDRESS PointerToRhpRethrow2
ALTERNATE_ENTRY RhpRethrow2

// no return
EMIT_BREAKPOINT
Expand Down Expand Up @@ -452,7 +452,7 @@ LOCAL_LABEL(ClearSuccess_Catch):
// x0 still contains the exception object
blr x1

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallCatchFunclet2
ALTERNATE_ENTRY RhpCallCatchFunclet2

// x0 contains resume IP

Expand Down Expand Up @@ -586,7 +586,7 @@ LOCAL_LABEL(ClearSuccess):
//
blr x0

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFinallyFunclet2
ALTERNATE_ENTRY RhpCallFinallyFunclet2

ldr x1, [sp, #rsp_offset_x1] // reload REGDISPLAY pointer

Expand Down Expand Up @@ -650,7 +650,7 @@ LOCAL_LABEL(SetSuccess):
// x0 still contains the exception object
blr x1

EXPORT_POINTER_TO_ADDRESS PointerToRhpCallFilterFunclet2
ALTERNATE_ENTRY RhpCallFilterFunclet2

ldp d8, d9, [sp, #0x00]
ldp d10, d11, [sp, #0x10]
Expand Down
Loading
Loading