Skip to content

Commit

Permalink
Replace absolute labels with #define in assembly code (dotnet#106225)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed Aug 13, 2024
1 parent 47af310 commit d101ebb
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 54 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/nativeaot/Runtime/arm64/AllocFast.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "AsmOffsets.inc"

// GC type flags
GC_ALLOC_FINALIZE = 1
#define GC_ALLOC_FINALIZE 1

//
// Rename fields of nested structs
//
OFFSETOF__Thread__m_alloc_context__alloc_ptr = OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_ptr
OFFSETOF__Thread__m_alloc_context__alloc_limit = OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_limit
#define OFFSETOF__Thread__m_alloc_context__alloc_ptr (OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_ptr)
#define OFFSETOF__Thread__m_alloc_context__alloc_limit (OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_limit)



Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/arm64/GcProbe.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <unixasmmacros.inc>
#include "AsmOffsets.inc"

PROBE_FRAME_SIZE = 0xD0 // 4 * 8 for fixed part of PInvokeTransitionFrame (fp, lr, m_pThread, m_Flags) +
// 10 * 8 for callee saved registers +
// 1 * 8 for caller SP +
// 2 * 8 for int returns +
// 1 * 8 for alignment padding +
// 4 * 16 for FP/HFA/HVA returns
#define PROBE_FRAME_SIZE 0xD0 // 4 * 8 for fixed part of PInvokeTransitionFrame (fp, lr, m_pThread, m_Flags) +
// 10 * 8 for callee saved registers +
// 1 * 8 for caller SP +
// 2 * 8 for int returns +
// 1 * 8 for alignment padding +
// 4 * 16 for FP/HFA/HVA returns

// See PUSH_COOP_PINVOKE_FRAME, this macro is very similar, but also saves return registers
// and accepts the register bitmask
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/arm64/InteropThunksHelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

POINTER_SIZE = 0x08
#define POINTER_SIZE 0x08

//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interop Thunks Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand Down
11 changes: 0 additions & 11 deletions src/coreclr/nativeaot/Runtime/arm64/PInvoke.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@

.global RhpTrapThreads

// Note: these must match the defs in PInvokeTransitionFrameFlags defined in rhbinder.h
PTFF_SAVE_SP = 0x00000400

// Bit position for the flags above, to be used with tbz / tbnz instructions
PTFF_THREAD_ABORT_BIT = 36

// Bit position for the flags above, to be used with tbz/tbnz instructions
TSF_Attached_Bit = 0
TSF_SuppressGcStress_Bit = 3
TSF_DoNotTriggerGc_Bit = 4

//
// RhpPInvoke
//
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/nativeaot/Runtime/loongarch64/AllocFast.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "AsmOffsets.inc"

// GC type flags
GC_ALLOC_FINALIZE = 1
#define GC_ALLOC_FINALIZE 1

//
// Rename fields of nested structs
//
OFFSETOF__Thread__m_alloc_context__alloc_ptr = OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_ptr
OFFSETOF__Thread__m_alloc_context__alloc_limit = OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_limit
#define OFFSETOF__Thread__m_alloc_context__alloc_ptr (OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_ptr)
#define OFFSETOF__Thread__m_alloc_context__alloc_limit (OFFSETOF__Thread__m_rgbAllocContextBuffer + OFFSETOF__gc_alloc_context__alloc_limit)



Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/loongarch64/GcProbe.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <unixasmmacros.inc>
#include "AsmOffsets.inc"

PROBE_FRAME_SIZE = 0xD0 // 4 * 8 for fixed part of PInvokeTransitionFrame (fp, ra, m_pThread, m_Flags) +
// 10 * 8 for callee saved registers +
// 1 * 8 for caller SP +
// 2 * 8 for int returns +
// 1 * 8 for alignment padding +
// 4 * 16 for FP returns
#define PROBE_FRAME_SIZE 0xD0 // 4 * 8 for fixed part of PInvokeTransitionFrame (fp, ra, m_pThread, m_Flags) +
// 10 * 8 for callee saved registers +
// 1 * 8 for caller SP +
// 2 * 8 for int returns +
// 1 * 8 for alignment padding +
// 4 * 16 for FP returns

// See PUSH_COOP_PINVOKE_FRAME, this macro is very similar, but also saves return registers
// and accepts the register bitmask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

POINTER_SIZE = 0x08
#define POINTER_SIZE 0x08

//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interop Thunks Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/nativeaot/Runtime/loongarch64/PInvoke.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

.global RhpTrapThreads

// Note: these must match the defs in PInvokeTransitionFrameFlags defined in rhbinder.h
PTFF_SAVE_SP = 0x00000200

// Bit position for the flags above, to be used with andi+beq/bne instructions
PTFF_THREAD_ABORT_BIT = 36

//
// RhpPInvoke
//
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/unix/unixasmmacrosamd64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ C_FUNC(\Name):
1:
.endm

DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_RSP
#define DEFAULT_FRAME_SAVE_FLAGS (PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_RSP)

.macro PUSH_COOP_PINVOKE_FRAME trashReg
push_nonvol_reg rbp // push RBP frame
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/nativeaot/Runtime/unix/unixasmmacrosarm64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ C_FUNC(\Name):
.endm

// Note: these must match the defs in PInvokeTransitionFrameFlags
PTFF_SAVE_SP = 0x00000400
PTFF_SAVE_X0 = 0x00000800
PTFF_SAVE_X1 = 0x00001000
PTFF_SAVE_ALL_PRESERVED = 0x000003FF // NOTE: x19-x28
#define PTFF_SAVE_SP 0x00000400
#define PTFF_SAVE_X0 0x00000800
#define PTFF_SAVE_X1 0x00001000
#define PTFF_SAVE_ALL_PRESERVED 0x000003FF // NOTE: x19-x28

DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP
#define DEFAULT_FRAME_SAVE_FLAGS (PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP)

.macro PUSH_COOP_PINVOKE_FRAME trashReg

Expand Down Expand Up @@ -342,7 +342,7 @@ DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP
.endm

// Bit position for the flags above, to be used with tbz / tbnz instructions
PTFF_THREAD_ABORT_BIT = 36
#define PTFF_THREAD_ABORT_BIT 36

//
// CONSTANTS -- INTEGER
Expand All @@ -353,8 +353,8 @@ PTFF_THREAD_ABORT_BIT = 36
#define TSF_SuppressGcStress__OR__TSF_DoNotTriggerGC 0x18

// Bit position for the flags above, to be used with tbz / tbnz instructions
TrapThreadsFlags_AbortInProgress_Bit = 0
TrapThreadsFlags_TrapThreads_Bit = 1
#define TrapThreadsFlags_AbortInProgress_Bit 0
#define TrapThreadsFlags_TrapThreads_Bit 1

// These must match the TrapThreadsFlags enum
#define TrapThreadsFlags_None 0
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ C_FUNC(\Name):
.endm

// Note: these must match the defs in PInvokeTransitionFrameFlags
PTFF_SAVE_SP = 0x00000200
PTFF_SAVE_R4 = 0x00001000
PTFF_SAVE_R5 = 0x00002000
PTFF_SAVE_ALL_PRESERVED = 0x000001FF // NOTE: r23-r31
#define PTFF_SAVE_SP 0x00000200
#define PTFF_SAVE_R4 0x00001000
#define PTFF_SAVE_R5 0x00002000
#define PTFF_SAVE_ALL_PRESERVED 0x000001FF // NOTE: r23-r31

DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP
#define DEFAULT_FRAME_SAVE_FLAGS (PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP)

.macro PUSH_COOP_PINVOKE_FRAME trashReg

Expand Down Expand Up @@ -309,7 +309,7 @@ DEFAULT_FRAME_SAVE_FLAGS = PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP
.endm

// Bit position for the flags above, to be used with andi+beq/bne instructions
PTFF_THREAD_ABORT_BIT = 36
#define PTFF_THREAD_ABORT_BIT 36

//
// CONSTANTS -- INTEGER
Expand All @@ -320,8 +320,8 @@ PTFF_THREAD_ABORT_BIT = 36
#define TSF_SuppressGcStress__OR__TSF_DoNotTriggerGC 0x18

// Bit position for the flags above, to be used with andi+beq/bne instructions
TrapThreadsFlags_AbortInProgress_Bit = 0
TrapThreadsFlags_TrapThreads_Bit = 1
#define TrapThreadsFlags_AbortInProgress_Bit 0
#define TrapThreadsFlags_TrapThreads_Bit 1

// These must match the TrapThreadsFlags enum
#define TrapThreadsFlags_None 0
Expand Down

0 comments on commit d101ebb

Please sign in to comment.