detached b178e75

internal/fakecgo: match Go's implementation (#142)

This code inlined the macros to avoid copying the header. However, the header was copied into the project for other reasons and this code never got updated to match the Go implementation.
commit
b178e7518254895d38a88b4bcdbc02cda4221263
author
TotallyGamerJet · · 2023-07-04 12:19 UTC
committer
GitHub · · 2023-07-04 12:19 UTC
parent
08ca952
signature
GPG Unverified4AEE18F83AFDEB23 The key is unknown
refs
tag: v0.4.0-alpha.5
1 file · +15 -52
M internal/fakecgo/asm_amd64.s +15 -52
@@ -3,74 +3,37 @@
33 // license that can be found in the LICENSE file.
44
55 #include "textflag.h"
6+#include "../abi/abi_amd64.h"
67
78 // Called by C code generated by cmd/cgo.
89 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
910 // Saves C callee-saved registers and calls cgocallback with three arguments.
1011 // fn is the PC of a func(a unsafe.Pointer) function.
1112 // This signature is known to SWIG, so we can't change it.
12-#ifndef GOOS_windows
13-TEXT crosscall2(SB), NOSPLIT, $0x50-0 // keeps stack pointer 32-byte aligned
14-#else
15-TEXT crosscall2(SB), NOSPLIT, $0x110-0 // also need to save xmm6 - xmm15
16-#endif
17- MOVQ BX, 0x18(SP)
18- MOVQ R12, 0x28(SP)
19- MOVQ R13, 0x30(SP)
20- MOVQ R14, 0x38(SP)
21- MOVQ R15, 0x40(SP)
22-
23-#ifdef GOOS_windows
24- // Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15 and XMM6 -- XMM15.
25- MOVQ DI, 0x48(SP)
26- MOVQ SI, 0x50(SP)
27- MOVUPS X6, 0x60(SP)
28- MOVUPS X7, 0x70(SP)
29- MOVUPS X8, 0x80(SP)
30- MOVUPS X9, 0x90(SP)
31- MOVUPS X10, 0xa0(SP)
32- MOVUPS X11, 0xb0(SP)
33- MOVUPS X12, 0xc0(SP)
34- MOVUPS X13, 0xd0(SP)
35- MOVUPS X14, 0xe0(SP)
36- MOVUPS X15, 0xf0(SP)
37-
38- MOVQ CX, 0x0(SP) // fn
39- MOVQ DX, 0x8(SP) // arg
40-
41- // Skip n in R8.
42- MOVQ R9, 0x10(SP) // ctxt
43-
44- CALL runtime·cgocallback(SB)
13+TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0-0
14+ PUSH_REGS_HOST_TO_ABI0()
4515
46- MOVQ 0x48(SP), DI
47- MOVQ 0x50(SP), SI
48- MOVUPS 0x60(SP), X6
49- MOVUPS 0x70(SP), X7
50- MOVUPS 0x80(SP), X8
51- MOVUPS 0x90(SP), X9
52- MOVUPS 0xa0(SP), X10
53- MOVUPS 0xb0(SP), X11
54- MOVUPS 0xc0(SP), X12
55- MOVUPS 0xd0(SP), X13
56- MOVUPS 0xe0(SP), X14
57- MOVUPS 0xf0(SP), X15
16+ // Make room for arguments to cgocallback.
17+ ADJSP $0x18
5818
59-#else
19+#ifndef GOOS_windows
6020 MOVQ DI, 0x0(SP) // fn
6121 MOVQ SI, 0x8(SP) // arg
6222
6323 // Skip n in DX.
6424 MOVQ CX, 0x10(SP) // ctxt
6525
66- CALL runtime·cgocallback(SB)
26+#else
27+ MOVQ CX, 0x0(SP) // fn
28+ MOVQ DX, 0x8(SP) // arg
29+
30+ // Skip n in R8.
31+ MOVQ R9, 0x10(SP) // ctxt
6732
6833 #endif
6934
70- MOVQ 0x18(SP), BX
71- MOVQ 0x28(SP), R12
72- MOVQ 0x30(SP), R13
73- MOVQ 0x38(SP), R14
74- MOVQ 0x40(SP), R15
35+ CALL runtime·cgocallback(SB)
7536
37+ ADJSP $-0x18
38+ POP_REGS_HOST_TO_ABI0()
7639 RET
@@ -3,74 +3,37 @@
3 // license that can be found in the LICENSE file.3 // license that can be found in the LICENSE file.
4 4
5 #include "textflag.h"5 #include "textflag.h"
6+#include "../abi/abi_amd64.h"
6 7
7 // Called by C code generated by cmd/cgo.8 // Called by C code generated by cmd/cgo.
8 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)9 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
9 // Saves C callee-saved registers and calls cgocallback with three arguments.10 // Saves C callee-saved registers and calls cgocallback with three arguments.
10 // fn is the PC of a func(a unsafe.Pointer) function.11 // fn is the PC of a func(a unsafe.Pointer) function.
11 // This signature is known to SWIG, so we can't change it.12 // This signature is known to SWIG, so we can't change it.
12-#ifndef GOOS_windows13+TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0-0
13-TEXT crosscall2(SB), NOSPLIT, $0x50-0 // keeps stack pointer 32-byte aligned14+ PUSH_REGS_HOST_TO_ABI0()
14-#else
15-TEXT crosscall2(SB), NOSPLIT, $0x110-0 // also need to save xmm6 - xmm15
16-#endif
17- MOVQ BX, 0x18(SP)
18- MOVQ R12, 0x28(SP)
19- MOVQ R13, 0x30(SP)
20- MOVQ R14, 0x38(SP)
21- MOVQ R15, 0x40(SP)
22-
23-#ifdef GOOS_windows
24- // Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15 and XMM6 -- XMM15.
25- MOVQ DI, 0x48(SP)
26- MOVQ SI, 0x50(SP)
27- MOVUPS X6, 0x60(SP)
28- MOVUPS X7, 0x70(SP)
29- MOVUPS X8, 0x80(SP)
30- MOVUPS X9, 0x90(SP)
31- MOVUPS X10, 0xa0(SP)
32- MOVUPS X11, 0xb0(SP)
33- MOVUPS X12, 0xc0(SP)
34- MOVUPS X13, 0xd0(SP)
35- MOVUPS X14, 0xe0(SP)
36- MOVUPS X15, 0xf0(SP)
37-
38- MOVQ CX, 0x0(SP) // fn
39- MOVQ DX, 0x8(SP) // arg
40-
41- // Skip n in R8.
42- MOVQ R9, 0x10(SP) // ctxt
43-
44- CALL runtime·cgocallback(SB)
45 15
46- MOVQ 0x48(SP), DI16+ // Make room for arguments to cgocallback.
47- MOVQ 0x50(SP), SI17+ ADJSP $0x18
48- MOVUPS 0x60(SP), X6
49- MOVUPS 0x70(SP), X7
50- MOVUPS 0x80(SP), X8
51- MOVUPS 0x90(SP), X9
52- MOVUPS 0xa0(SP), X10
53- MOVUPS 0xb0(SP), X11
54- MOVUPS 0xc0(SP), X12
55- MOVUPS 0xd0(SP), X13
56- MOVUPS 0xe0(SP), X14
57- MOVUPS 0xf0(SP), X15
58 18
59-#else19+#ifndef GOOS_windows
60 MOVQ DI, 0x0(SP) // fn20 MOVQ DI, 0x0(SP) // fn
61 MOVQ SI, 0x8(SP) // arg21 MOVQ SI, 0x8(SP) // arg
62 22
63 // Skip n in DX.23 // Skip n in DX.
64 MOVQ CX, 0x10(SP) // ctxt24 MOVQ CX, 0x10(SP) // ctxt
65 25
66- CALL runtime·cgocallback(SB)26+#else
27+ MOVQ CX, 0x0(SP) // fn
28+ MOVQ DX, 0x8(SP) // arg
29+
30+ // Skip n in R8.
31+ MOVQ R9, 0x10(SP) // ctxt
67 32
68 #endif33 #endif
69 34
70- MOVQ 0x18(SP), BX35+ CALL runtime·cgocallback(SB)
71- MOVQ 0x28(SP), R12
72- MOVQ 0x30(SP), R13
73- MOVQ 0x38(SP), R14
74- MOVQ 0x40(SP), R15
75 36
37+ ADJSP $-0x18
38+ POP_REGS_HOST_TO_ABI0()
76 RET39 RET

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close