Skip to content

Commit 4d514c8

Browse files
committed
[x64] Remove hardcoded stack layout offsets
Use offsets from the StackLayout::Thunk structure, instead of hardcoded offset values. No functional change.
1 parent 9171169 commit 4d514c8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/xenia/cpu/backend/x64/x64_backend.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ HostToGuestThunk X64ThunkEmitter::EmitHostToGuestThunk() {
434434
code_offsets.prolog = getSize();
435435

436436
// rsp + 0 = return address
437-
mov(qword[rsp + 8 * 3], GetNativeReg(2));
438-
mov(qword[rsp + 8 * 2], GetNativeReg(1));
439-
mov(qword[rsp + 8 * 1], GetNativeReg(0));
437+
mov(qword[rsp + offsetof(StackLayout::Thunk, arg_temp[2])], GetNativeReg(2));
438+
mov(qword[rsp + offsetof(StackLayout::Thunk, arg_temp[1])], GetNativeReg(1));
439+
mov(qword[rsp + offsetof(StackLayout::Thunk, arg_temp[0])], GetNativeReg(0));
440440
sub(rsp, stack_size);
441441

442442
code_offsets.prolog_stack_alloc = getSize();
@@ -455,9 +455,9 @@ HostToGuestThunk X64ThunkEmitter::EmitHostToGuestThunk() {
455455
code_offsets.epilog = getSize();
456456

457457
add(rsp, stack_size);
458-
mov(GetNativeReg(0), qword[rsp + 8 * 1]);
459-
mov(GetNativeReg(1), qword[rsp + 8 * 2]);
460-
mov(GetNativeReg(2), qword[rsp + 8 * 3]);
458+
mov(GetNativeReg(0), qword[rsp + offsetof(StackLayout::Thunk, arg_temp[0])]);
459+
mov(GetNativeReg(1), qword[rsp + offsetof(StackLayout::Thunk, arg_temp[1])]);
460+
mov(GetNativeReg(2), qword[rsp + offsetof(StackLayout::Thunk, arg_temp[2])]);
461461
ret();
462462

463463
code_offsets.tail = getSize();

0 commit comments

Comments
 (0)