github.com/notti/go-dynamic@v0.0.0-20190619201224-fc443047424c/internal/fakecgo/trampoline_386.s (about) 1 /* 2 See trampoline_amd64.s for explanations. 3 4 => we can use SI, DI, BX instead of the stack 5 6 C Calling convention cdecl used here (we only need integer args): 7 Pass values on the stack in right to left order 8 return value will be in AX 9 10 If there are no return values calling conventions are the same -> NOFRAME + JMP 11 */ 12 #include "textflag.h" 13 14 TEXT x_cgo_init_trampoline(SB),NOSPLIT|NOFRAME,$0 15 JMP ·x_cgo_init(SB) 16 RET 17 18 TEXT x_cgo_thread_start_trampoline(SB),NOSPLIT|NOFRAME,$0 19 JMP ·x_cgo_thread_start(SB) 20 RET 21 22 TEXT ·threadentry_trampoline(SB),NOSPLIT,$8 23 MOVL arg0+0(FP), AX 24 MOVL AX, 0(SP) 25 CALL ·threadentry(SB) 26 MOVL 4(SP), AX 27 RET 28 29 // func setg_trampoline(setg uintptr, g uintptr) 30 TEXT ·setg_trampoline(SB),NOSPLIT,$4-8 31 MOVL g+4(FP), AX 32 MOVL AX, 0(SP) 33 MOVL setg+0(FP), AX 34 CALL AX 35 RET 36 37 TEXT x_cgo_notify_runtime_init_done_trampoline(SB),NOSPLIT|NOFRAME,$0 38 JMP ·x_cgo_notify_runtime_init_done(SB) 39 RET 40 41 TEXT x_cgo_setenv_trampoline(SB),NOSPLIT|NOFRAME,$0 42 JMP ·x_cgo_setenv(SB) 43 RET 44 45 TEXT x_cgo_unsetenv_trampoline(SB),NOSPLIT|NOFRAME,$0 46 JMP ·x_cgo_unsetenv(SB) 47 RET 48 49 // func asmlibccall6(fn, n, args uintptr) uintptr 50 TEXT ·asmlibccall6(SB),NOSPLIT,$0-16 51 MOVL SP, DI 52 MOVL n+4(FP), AX 53 MOVL args+8(FP), BX 54 MOVL fn+0(FP), DX 55 56 TESTL AX, AX 57 JZ finished 58 59 next: 60 DECL AX 61 MOVL (BX)(AX*4), CX 62 SUBL $4, SP 63 MOVL CX, 0(SP) 64 65 TESTL AX, AX 66 JZ finished 67 JMP next 68 69 finished: 70 CALL DX 71 72 MOVL DI, SP 73 74 MOVL AX, ret+12(FP) 75 76 RET