Skip to content

Commit 22f4280

Browse files
committed
runtime: remove the dummy arg of getcallersp
getcallersp is intrinsified, and so the dummy arg is no longer needed. Remove it, as well as a few dummy args that are solely to feed getcallersp. Change-Id: Ibb6c948ff9c56537042b380ac3be3a91b247aaa6 Reviewed-on: https://go-review.googlesource.com/109596 Run-TryBot: Cherry Zhang <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent a3bafcf commit 22f4280

15 files changed

+54
-57
lines changed

src/runtime/cgocall.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func cgocall(fn, arg unsafe.Pointer) int32 {
125125
// "system call", run the Go code (which may grow the stack),
126126
// and then re-enter the "system call" reusing the PC and SP
127127
// saved by entersyscall here.
128-
entersyscall(0)
128+
entersyscall()
129129

130130
mp.incgo = true
131131
errno := asmcgocall(fn, arg)
@@ -134,7 +134,7 @@ func cgocall(fn, arg unsafe.Pointer) int32 {
134134
// reschedule us on to a different M.
135135
endcgo(mp)
136136

137-
exitsyscall(0)
137+
exitsyscall()
138138

139139
// From the garbage collector's perspective, time can move
140140
// backwards in the sequence above. If there's a callback into
@@ -188,7 +188,7 @@ func cgocallbackg(ctxt uintptr) {
188188
// save syscall* and let reentersyscall restore them.
189189
savedsp := unsafe.Pointer(gp.syscallsp)
190190
savedpc := gp.syscallpc
191-
exitsyscall(0) // coming out of cgo call
191+
exitsyscall() // coming out of cgo call
192192
gp.m.incgo = false
193193

194194
cgocallbackg1(ctxt)

src/runtime/export_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func LockOSCounts() (external, internal uint32) {
403403
//go:noinline
404404
func TracebackSystemstack(stk []uintptr, i int) int {
405405
if i == 0 {
406-
pc, sp := getcallerpc(), getcallersp(unsafe.Pointer(&stk))
406+
pc, sp := getcallerpc(), getcallersp()
407407
return gentraceback(pc, sp, 0, getg(), 0, &stk[0], len(stk), nil, nil, _TraceJumpStack)
408408
}
409409
n := 0

src/runtime/futex_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ func TestFutexsleep(t *testing.T) {
5151
tt.ch = make(chan *futexsleepTest, 1)
5252
wg.Add(1)
5353
go func(tt *futexsleepTest) {
54-
runtime.Entersyscall(0)
54+
runtime.Entersyscall()
5555
runtime.Futexsleep(&tt.mtx, 0, tt.ns)
56-
runtime.Exitsyscall(0)
56+
runtime.Exitsyscall()
5757
tt.ch <- tt
5858
wg.Done()
5959
}(tt)

src/runtime/lock_futex.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ func notetsleepg(n *note, ns int64) bool {
224224
throw("notetsleepg on g0")
225225
}
226226

227-
entersyscallblock(0)
227+
entersyscallblock()
228228
ok := notetsleep_internal(n, ns)
229-
exitsyscall(0)
229+
exitsyscall()
230230
return ok
231231
}

src/runtime/lock_sema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ func notetsleepg(n *note, ns int64) bool {
277277
throw("notetsleepg on g0")
278278
}
279279
semacreate(gp.m)
280-
entersyscallblock(0)
280+
entersyscallblock()
281281
ok := notetsleep_internal(n, ns, nil, 0)
282-
exitsyscall(0)
282+
exitsyscall()
283283
return ok
284284
}

src/runtime/mprof.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ func GoroutineProfile(p []StackRecord) (n int, ok bool) {
740740
r := p
741741

742742
// Save current goroutine.
743-
sp := getcallersp(unsafe.Pointer(&p))
743+
sp := getcallersp()
744744
pc := getcallerpc()
745745
systemstack(func() {
746746
saveg(pc, sp, gp, &r[0])
@@ -785,7 +785,7 @@ func Stack(buf []byte, all bool) int {
785785
n := 0
786786
if len(buf) > 0 {
787787
gp := getg()
788-
sp := getcallersp(unsafe.Pointer(&buf))
788+
sp := getcallersp()
789789
pc := getcallerpc()
790790
systemstack(func() {
791791
g0 := getg()
@@ -827,7 +827,7 @@ func tracealloc(p unsafe.Pointer, size uintptr, typ *_type) {
827827
if gp.m.curg == nil || gp == gp.m.curg {
828828
goroutineheader(gp)
829829
pc := getcallerpc()
830-
sp := getcallersp(unsafe.Pointer(&p))
830+
sp := getcallersp()
831831
systemstack(func() {
832832
traceback(pc, sp, 0, gp)
833833
})
@@ -847,7 +847,7 @@ func tracefree(p unsafe.Pointer, size uintptr) {
847847
print("tracefree(", p, ", ", hex(size), ")\n")
848848
goroutineheader(gp)
849849
pc := getcallerpc()
850-
sp := getcallersp(unsafe.Pointer(&p))
850+
sp := getcallersp()
851851
systemstack(func() {
852852
traceback(pc, sp, 0, gp)
853853
})

src/runtime/norace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func benchmarkSyscall(b *testing.B, work, excess int) {
3434
b.RunParallel(func(pb *testing.PB) {
3535
foo := 42
3636
for pb.Next() {
37-
runtime.Entersyscall(0)
37+
runtime.Entersyscall()
3838
for i := 0; i < work; i++ {
3939
foo *= 2
4040
foo /= 2
4141
}
42-
runtime.Exitsyscall(0)
42+
runtime.Exitsyscall()
4343
}
4444
_ = foo
4545
})

src/runtime/os_solaris.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func sysvicall0(fn *libcFunc) uintptr {
4242
mp.libcallpc = getcallerpc()
4343
// sp must be the last, because once async cpu profiler finds
4444
// all three values to be non-zero, it will use them
45-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
45+
mp.libcallsp = getcallersp()
4646
}
4747

4848
var libcall libcall
@@ -69,7 +69,7 @@ func sysvicall1(fn *libcFunc, a1 uintptr) uintptr {
6969
mp.libcallpc = getcallerpc()
7070
// sp must be the last, because once async cpu profiler finds
7171
// all three values to be non-zero, it will use them
72-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
72+
mp.libcallsp = getcallersp()
7373
}
7474

7575
var libcall libcall
@@ -97,7 +97,7 @@ func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr {
9797
mp.libcallpc = getcallerpc()
9898
// sp must be the last, because once async cpu profiler finds
9999
// all three values to be non-zero, it will use them
100-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
100+
mp.libcallsp = getcallersp()
101101
}
102102

103103
var libcall libcall
@@ -124,7 +124,7 @@ func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr {
124124
mp.libcallpc = getcallerpc()
125125
// sp must be the last, because once async cpu profiler finds
126126
// all three values to be non-zero, it will use them
127-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
127+
mp.libcallsp = getcallersp()
128128
}
129129

130130
var libcall libcall
@@ -151,7 +151,7 @@ func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr {
151151
mp.libcallpc = getcallerpc()
152152
// sp must be the last, because once async cpu profiler finds
153153
// all three values to be non-zero, it will use them
154-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
154+
mp.libcallsp = getcallersp()
155155
}
156156

157157
var libcall libcall
@@ -178,7 +178,7 @@ func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
178178
mp.libcallpc = getcallerpc()
179179
// sp must be the last, because once async cpu profiler finds
180180
// all three values to be non-zero, it will use them
181-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
181+
mp.libcallsp = getcallersp()
182182
}
183183

184184
var libcall libcall
@@ -205,7 +205,7 @@ func sysvicall6(fn *libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
205205
mp.libcallpc = getcallerpc()
206206
// sp must be the last, because once async cpu profiler finds
207207
// all three values to be non-zero, it will use them
208-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
208+
mp.libcallsp = getcallersp()
209209
}
210210

211211
var libcall libcall

src/runtime/os_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ func stdcall(fn stdFunction) uintptr {
711711
mp.libcallpc = getcallerpc()
712712
// sp must be the last, because once async cpu profiler finds
713713
// all three values to be non-zero, it will use them
714-
mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
714+
mp.libcallsp = getcallersp()
715715
}
716716
asmcgocall(asmstdcallAddr, unsafe.Pointer(&mp.libcall))
717717
mp.libcallsp = 0

src/runtime/panic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func deferproc(siz int32, fn *funcval) { // arguments of fn follow fn
8181
// collection or stack copying trigger until we've copied them out
8282
// to somewhere safe. The memmove below does that.
8383
// Until the copy completes, we can only call nosplit routines.
84-
sp := getcallersp(unsafe.Pointer(&siz))
84+
sp := getcallersp()
8585
argp := uintptr(unsafe.Pointer(&fn)) + unsafe.Sizeof(fn)
8686
callerpc := getcallerpc()
8787

@@ -320,7 +320,7 @@ func deferreturn(arg0 uintptr) {
320320
if d == nil {
321321
return
322322
}
323-
sp := getcallersp(unsafe.Pointer(&arg0))
323+
sp := getcallersp()
324324
if d.sp != sp {
325325
return
326326
}
@@ -637,7 +637,7 @@ func recovery(gp *g) {
637637
//go:nosplit
638638
func fatalpanic(msgs *_panic) {
639639
pc := getcallerpc()
640-
sp := getcallersp(unsafe.Pointer(&msgs))
640+
sp := getcallersp()
641641
gp := getg()
642642
// Switch to the system stack to avoid any stack growth, which
643643
// may make things worse if the runtime is in a bad state.

src/runtime/proc.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ func mstart() {
11921192
// both Go and C functions with stack growth prologues.
11931193
_g_.stackguard0 = _g_.stack.lo + _StackGuard
11941194
_g_.stackguard1 = _g_.stackguard0
1195-
mstart1(0)
1195+
mstart1()
11961196

11971197
// Exit this thread.
11981198
if GOOS == "windows" || GOOS == "solaris" || GOOS == "plan9" {
@@ -1204,7 +1204,7 @@ func mstart() {
12041204
mexit(osStack)
12051205
}
12061206

1207-
func mstart1(dummy int32) {
1207+
func mstart1() {
12081208
_g_ := getg()
12091209

12101210
if _g_ != _g_.m.g0 {
@@ -1215,7 +1215,7 @@ func mstart1(dummy int32) {
12151215
// for terminating the thread.
12161216
// We're never coming back to mstart1 after we call schedule,
12171217
// so other calls can reuse the current frame.
1218-
save(getcallerpc(), getcallersp(unsafe.Pointer(&dummy)))
1218+
save(getcallerpc(), getcallersp())
12191219
asminit()
12201220
minit()
12211221

@@ -2836,8 +2836,8 @@ func reentersyscall(pc, sp uintptr) {
28362836

28372837
// Standard syscall entry used by the go syscall library and normal cgo calls.
28382838
//go:nosplit
2839-
func entersyscall(dummy int32) {
2840-
reentersyscall(getcallerpc(), getcallersp(unsafe.Pointer(&dummy)))
2839+
func entersyscall() {
2840+
reentersyscall(getcallerpc(), getcallersp())
28412841
}
28422842

28432843
func entersyscall_sysmon() {
@@ -2869,7 +2869,7 @@ func entersyscall_gcwait() {
28692869

28702870
// The same as entersyscall(), but with a hint that the syscall is blocking.
28712871
//go:nosplit
2872-
func entersyscallblock(dummy int32) {
2872+
func entersyscallblock() {
28732873
_g_ := getg()
28742874

28752875
_g_.m.locks++ // see comment in entersyscall
@@ -2881,7 +2881,7 @@ func entersyscallblock(dummy int32) {
28812881

28822882
// Leave SP around for GC and traceback.
28832883
pc := getcallerpc()
2884-
sp := getcallersp(unsafe.Pointer(&dummy))
2884+
sp := getcallersp()
28852885
save(pc, sp)
28862886
_g_.syscallsp = _g_.sched.sp
28872887
_g_.syscallpc = _g_.sched.pc
@@ -2905,7 +2905,7 @@ func entersyscallblock(dummy int32) {
29052905
systemstack(entersyscallblock_handoff)
29062906

29072907
// Resave for traceback during blocked call.
2908-
save(getcallerpc(), getcallersp(unsafe.Pointer(&dummy)))
2908+
save(getcallerpc(), getcallersp())
29092909

29102910
_g_.m.locks--
29112911
}
@@ -2927,11 +2927,11 @@ func entersyscallblock_handoff() {
29272927
//
29282928
//go:nosplit
29292929
//go:nowritebarrierrec
2930-
func exitsyscall(dummy int32) {
2930+
func exitsyscall() {
29312931
_g_ := getg()
29322932

29332933
_g_.m.locks++ // see comment in entersyscall
2934-
if getcallersp(unsafe.Pointer(&dummy)) > _g_.syscallsp {
2934+
if getcallersp() > _g_.syscallsp {
29352935
throw("exitsyscall: syscall frame is no longer valid")
29362936
}
29372937

src/runtime/signal_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
316316
st := stackt{ss_size: g.m.g0.stack.hi - g.m.g0.stack.lo}
317317
setSignalstackSP(&st, g.m.g0.stack.lo)
318318
setGsignalStack(&st, &gsignalStack)
319-
g.m.gsignal.stktopsp = getcallersp(unsafe.Pointer(&sig))
319+
g.m.gsignal.stktopsp = getcallersp()
320320
setStack = true
321321
} else {
322322
var st stackt
@@ -335,7 +335,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
335335
dropm()
336336
}
337337
setGsignalStack(&st, &gsignalStack)
338-
g.m.gsignal.stktopsp = getcallersp(unsafe.Pointer(&sig))
338+
g.m.gsignal.stktopsp = getcallersp()
339339
setStack = true
340340
}
341341
}

src/runtime/stubs.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,14 @@ func publicationBarrier()
199199

200200
// getcallerpc returns the program counter (PC) of its caller's caller.
201201
// getcallersp returns the stack pointer (SP) of its caller's caller.
202-
// argp must be a pointer to the caller's first function argument.
203-
// The implementation may or may not use argp, depending on
204-
// the architecture. The implementation may be a compiler
205-
// intrinsic; there is not necessarily code implementing this
206-
// on every platform.
202+
// The implementation may be a compiler intrinsic; there is not
203+
// necessarily code implementing this on every platform.
207204
//
208205
// For example:
209206
//
210207
// func f(arg1, arg2, arg3 int) {
211208
// pc := getcallerpc()
212-
// sp := getcallersp(unsafe.Pointer(&arg1))
209+
// sp := getcallersp()
213210
// }
214211
//
215212
// These two lines find the PC and SP immediately following
@@ -231,7 +228,7 @@ func publicationBarrier()
231228
func getcallerpc() uintptr
232229

233230
//go:noescape
234-
func getcallersp(argp unsafe.Pointer) uintptr // implemented as an intrinsic on all platforms
231+
func getcallersp() uintptr // implemented as an intrinsic on all platforms
235232

236233
// getclosureptr returns the pointer to the current closure.
237234
// getclosureptr can only be used in an assignment statement

0 commit comments

Comments
 (0)