@@ -31,71 +31,190 @@ var asmsysvicall6 libcFunc
31
31
32
32
//go:nosplit
33
33
func sysvicall0 (fn * libcFunc ) uintptr {
34
+ // Leave caller's PC/SP around for traceback.
35
+ gp := getg ()
36
+ var mp * m
37
+ if gp != nil {
38
+ mp = gp .m
39
+ }
40
+ if mp != nil {
41
+ mp .libcallg .set (gp )
42
+ mp .libcallpc = getcallerpc ()
43
+ // sp must be the last, because once async cpu profiler finds
44
+ // all three values to be non-zero, it will use them
45
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
46
+ }
47
+
34
48
var libcall libcall
35
49
libcall .fn = uintptr (unsafe .Pointer (fn ))
36
50
libcall .n = 0
37
51
libcall .args = uintptr (unsafe .Pointer (fn )) // it's unused but must be non-nil, otherwise crashes
38
52
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
53
+ if mp != nil {
54
+ mp .libcallsp = 0
55
+ }
39
56
return libcall .r1
40
57
}
41
58
42
59
//go:nosplit
43
60
func sysvicall1 (fn * libcFunc , a1 uintptr ) uintptr {
61
+ // Leave caller's PC/SP around for traceback.
62
+ gp := getg ()
63
+ var mp * m
64
+ if gp != nil {
65
+ mp = gp .m
66
+ }
67
+ if mp != nil {
68
+ mp .libcallg .set (gp )
69
+ mp .libcallpc = getcallerpc ()
70
+ // sp must be the last, because once async cpu profiler finds
71
+ // all three values to be non-zero, it will use them
72
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
73
+ }
74
+
44
75
var libcall libcall
45
76
libcall .fn = uintptr (unsafe .Pointer (fn ))
46
77
libcall .n = 1
47
78
// TODO(rsc): Why is noescape necessary here and below?
48
79
libcall .args = uintptr (noescape (unsafe .Pointer (& a1 )))
49
80
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
81
+ if mp != nil {
82
+ mp .libcallsp = 0
83
+ }
50
84
return libcall .r1
51
85
}
52
86
53
87
//go:nosplit
54
88
func sysvicall2 (fn * libcFunc , a1 , a2 uintptr ) uintptr {
89
+ // Leave caller's PC/SP around for traceback.
90
+ gp := getg ()
91
+ var mp * m
92
+ if gp != nil {
93
+ mp = gp .m
94
+ }
95
+ if mp != nil {
96
+ mp .libcallg .set (gp )
97
+ mp .libcallpc = getcallerpc ()
98
+ // sp must be the last, because once async cpu profiler finds
99
+ // all three values to be non-zero, it will use them
100
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
101
+ }
102
+
55
103
var libcall libcall
56
104
libcall .fn = uintptr (unsafe .Pointer (fn ))
57
105
libcall .n = 2
58
106
libcall .args = uintptr (noescape (unsafe .Pointer (& a1 )))
59
107
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
108
+ if mp != nil {
109
+ mp .libcallsp = 0
110
+ }
60
111
return libcall .r1
61
112
}
62
113
63
114
//go:nosplit
64
115
func sysvicall3 (fn * libcFunc , a1 , a2 , a3 uintptr ) uintptr {
116
+ // Leave caller's PC/SP around for traceback.
117
+ gp := getg ()
118
+ var mp * m
119
+ if gp != nil {
120
+ mp = gp .m
121
+ }
122
+ if mp != nil {
123
+ mp .libcallg .set (gp )
124
+ mp .libcallpc = getcallerpc ()
125
+ // sp must be the last, because once async cpu profiler finds
126
+ // all three values to be non-zero, it will use them
127
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
128
+ }
129
+
65
130
var libcall libcall
66
131
libcall .fn = uintptr (unsafe .Pointer (fn ))
67
132
libcall .n = 3
68
133
libcall .args = uintptr (noescape (unsafe .Pointer (& a1 )))
69
134
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
135
+ if mp != nil {
136
+ mp .libcallsp = 0
137
+ }
70
138
return libcall .r1
71
139
}
72
140
73
141
//go:nosplit
74
142
func sysvicall4 (fn * libcFunc , a1 , a2 , a3 , a4 uintptr ) uintptr {
143
+ // Leave caller's PC/SP around for traceback.
144
+ gp := getg ()
145
+ var mp * m
146
+ if gp != nil {
147
+ mp = gp .m
148
+ }
149
+ if mp != nil {
150
+ mp .libcallg .set (gp )
151
+ mp .libcallpc = getcallerpc ()
152
+ // sp must be the last, because once async cpu profiler finds
153
+ // all three values to be non-zero, it will use them
154
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
155
+ }
156
+
75
157
var libcall libcall
76
158
libcall .fn = uintptr (unsafe .Pointer (fn ))
77
159
libcall .n = 4
78
160
libcall .args = uintptr (noescape (unsafe .Pointer (& a1 )))
79
161
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
162
+ if mp != nil {
163
+ mp .libcallsp = 0
164
+ }
80
165
return libcall .r1
81
166
}
82
167
83
168
//go:nosplit
84
169
func sysvicall5 (fn * libcFunc , a1 , a2 , a3 , a4 , a5 uintptr ) uintptr {
170
+ // Leave caller's PC/SP around for traceback.
171
+ gp := getg ()
172
+ var mp * m
173
+ if gp != nil {
174
+ mp = gp .m
175
+ }
176
+ if mp != nil {
177
+ mp .libcallg .set (gp )
178
+ mp .libcallpc = getcallerpc ()
179
+ // sp must be the last, because once async cpu profiler finds
180
+ // all three values to be non-zero, it will use them
181
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
182
+ }
183
+
85
184
var libcall libcall
86
185
libcall .fn = uintptr (unsafe .Pointer (fn ))
87
186
libcall .n = 5
88
187
libcall .args = uintptr (noescape (unsafe .Pointer (& a1 )))
89
188
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
189
+ if mp != nil {
190
+ mp .libcallsp = 0
191
+ }
90
192
return libcall .r1
91
193
}
92
194
93
195
//go:nosplit
94
196
func sysvicall6 (fn * libcFunc , a1 , a2 , a3 , a4 , a5 , a6 uintptr ) uintptr {
197
+ // Leave caller's PC/SP around for traceback.
198
+ gp := getg ()
199
+ var mp * m
200
+ if gp != nil {
201
+ mp = gp .m
202
+ }
203
+ if mp != nil {
204
+ mp .libcallg .set (gp )
205
+ mp .libcallpc = getcallerpc ()
206
+ // sp must be the last, because once async cpu profiler finds
207
+ // all three values to be non-zero, it will use them
208
+ mp .libcallsp = getcallersp (unsafe .Pointer (& fn ))
209
+ }
210
+
95
211
var libcall libcall
96
212
libcall .fn = uintptr (unsafe .Pointer (fn ))
97
213
libcall .n = 6
98
214
libcall .args = uintptr (noescape (unsafe .Pointer (& a1 )))
99
215
asmcgocall (unsafe .Pointer (& asmsysvicall6 ), unsafe .Pointer (& libcall ))
216
+ if mp != nil {
217
+ mp .libcallsp = 0
218
+ }
100
219
return libcall .r1
101
220
}
0 commit comments