Skip to content
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
12 changes: 11 additions & 1 deletion internal/fakecgo/trampolines_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ return value will be in AX
*/
#include "textflag.h"
#include "go_asm.h"
#include "abi_amd64.h"

// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions.

Expand Down Expand Up @@ -73,11 +74,20 @@ TEXT ·setg_trampoline(SB), NOSPLIT, $0-16
CALL BX
RET

TEXT threadentry_trampoline(SB), NOSPLIT, $16
TEXT threadentry_trampoline(SB), NOSPLIT, $0
// See crosscall2.
PUSH_REGS_HOST_TO_ABI0()

// X15 is designated by Go as a fixed zero register.
// Calling directly into ABIInternal, ensure it is zero.
PXOR X15, X15

MOVQ DI, AX
MOVQ ·threadentry_call(SB), DX
MOVQ (DX), CX
CALL CX

POP_REGS_HOST_TO_ABI0()
RET

TEXT ·call5(SB), NOSPLIT, $0-56
Expand Down
17 changes: 16 additions & 1 deletion internal/fakecgo/trampolines_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "textflag.h"
#include "go_asm.h"
#include "abi_arm64.h"

// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions.

Expand Down Expand Up @@ -53,11 +54,25 @@ TEXT ·setg_trampoline(SB), NOSPLIT, $0-16
RET

TEXT threadentry_trampoline(SB), NOSPLIT, $0-0
MOVD R0, 8(RSP)
// See crosscall2.
SUB $(8*24), RSP
STP (R0, R1), (8*1)(RSP)
MOVD R3, (8*3)(RSP)

SAVE_R19_TO_R28(8*4)
SAVE_F8_TO_F15(8*14)
STP (R29, R30), (8*22)(RSP)

MOVD ·threadentry_call(SB), R26
MOVD (R26), R2
CALL (R2)
MOVD $0, R0 // TODO: get the return value from threadentry

RESTORE_R19_TO_R28(8*4)
RESTORE_F8_TO_F15(8*14)
LDP (8*22)(RSP), (R29, R30)

ADD $(8*24), RSP
RET

TEXT ·call5(SB), NOSPLIT, $0-0
Expand Down
20 changes: 18 additions & 2 deletions internal/fakecgo/trampolines_loong64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "textflag.h"
#include "go_asm.h"
#include "abi_loong64.h"

// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions.

Expand Down Expand Up @@ -52,11 +53,26 @@ TEXT ·setg_trampoline(SB), NOSPLIT, $0
CALL (R5)
RET

TEXT threadentry_trampoline(SB), NOSPLIT, $16
MOVV R4, 8(R3)
TEXT threadentry_trampoline(SB), NOSPLIT, $0
// See crosscall2.
ADDV $(-23*8), R3
MOVV R4, (1*8)(R3) // fn unsafe.Pointer
MOVV R5, (2*8)(R3) // a unsafe.Pointer
MOVV R7, (3*8)(R3) // ctxt uintptr

SAVE_R22_TO_R31((4*8))
SAVE_F24_TO_F31((14*8))
MOVV R1, (22*8)(R3)

MOVV ·threadentry_call(SB), R5
MOVV (R5), R6
CALL (R6)

RESTORE_R22_TO_R31((4*8))
RESTORE_F24_TO_F31((14*8))
MOVV (22*8)(R3), R1

ADDV $(23*8), R3
RET

TEXT ·call5(SB), NOSPLIT, $0-0
Expand Down