Skip to content

Commit

Permalink
Save rax in pre stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch committed Mar 21, 2024
1 parent df7558f commit 5e72f8d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/coreclr/pal/inc/unixasmmacrosamd64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ C_FUNC(\Name\()_End):

.macro PUSH_ARGUMENT_REGISTERS

push_argument_register rax
push_argument_register r9
push_argument_register r8
push_argument_register rcx
Expand Down Expand Up @@ -217,6 +218,7 @@ C_FUNC(\Name\()_End):
pop_argument_register rcx
pop_argument_register r8
pop_argument_register r9
pop_argument_register rax

.endm

Expand Down Expand Up @@ -257,6 +259,7 @@ C_FUNC(\Name\()_End):
// CalleeSavedRegisters::r14
// CalleeSavedRegisters::r13
// CalleeSavedRegisters::r12
// TransitionBlock::m_raxSwiftRetBufReg
// ArgumentRegisters::r9
// ArgumentRegisters::r8
// ArgumentRegisters::rcx
Expand All @@ -283,7 +286,7 @@ C_FUNC(\Name\()_End):
__PWTB_FloatArgumentRegisters = __PWTB_FloatArgumentRegisters + 8
.endif

__PWTB_StackAlloc = __PWTB_FloatArgumentRegisters + 8 * 16 + 8 // 8 floating point registers
__PWTB_StackAlloc = __PWTB_FloatArgumentRegisters + 8 * 16 // 8 floating point registers
__PWTB_TransitionBlock = __PWTB_StackAlloc

.if \stackAllocOnEntry >= 4*8
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/amd64/theprestubamd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ NESTED_ENTRY ThePreStub, _TEXT, NoHandler
lea rdi, [rsp + __PWTB_TransitionBlock] // pTransitionBlock*
mov rsi, METHODDESC_REGISTER
call C_FUNC(PreStubWorker)
mov r10, rax

EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
TAILJMP_RAX
jmp r10

NESTED_END ThePreStub, _TEXT

Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/vm/amd64/umthunkstub.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
//
NESTED_ENTRY TheUMEntryPrestub, _TEXT, UnhandledExceptionHandlerUnix
PUSH_ARGUMENT_REGISTERS
// +8 for alignment
alloc_stack (SIZEOF_MAX_FP_ARG_SPILL + 8)
alloc_stack (SIZEOF_MAX_FP_ARG_SPILL)
SAVE_FLOAT_ARGUMENT_REGISTERS 0
END_PROLOGUE

Expand All @@ -21,7 +20,7 @@ NESTED_ENTRY TheUMEntryPrestub, _TEXT, UnhandledExceptionHandlerUnix
// we're going to tail call to the exec stub that we just setup

RESTORE_FLOAT_ARGUMENT_REGISTERS 0
free_stack (SIZEOF_MAX_FP_ARG_SPILL + 8)
free_stack (SIZEOF_MAX_FP_ARG_SPILL)
POP_ARGUMENT_REGISTERS
TAILJMP_RAX

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/amd64/unixasmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler
//
PUSH_ARGUMENT_REGISTERS
push_register r11
push_register rax

//
// Allocate space for XMM parameter registers and alignment
Expand Down Expand Up @@ -103,7 +102,6 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler
//
// Restore integer parameter registers, r11 and rax
//
pop_register rax
pop_register r11
POP_ARGUMENT_REGISTERS

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct TransitionBlock
#elif defined(TARGET_AMD64)
#ifdef UNIX_AMD64_ABI
ArgumentRegisters m_argumentRegisters;
INT64 m_raxSwiftRetBufReg;
#endif
CalleeSavedRegisters m_calleeSavedRegisters;
TADDR m_ReturnAddress;
Expand Down

0 comments on commit 5e72f8d

Please sign in to comment.