]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove the dummy arg of getcallersp
authorCherry Zhang <cherryyz@google.com>
Thu, 26 Apr 2018 18:06:08 +0000 (14:06 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 26 Apr 2018 18:57:20 +0000 (18:57 +0000)
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 <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

15 files changed:
src/runtime/cgocall.go
src/runtime/export_test.go
src/runtime/futex_test.go
src/runtime/lock_futex.go
src/runtime/lock_sema.go
src/runtime/mprof.go
src/runtime/norace_test.go
src/runtime/os_solaris.go
src/runtime/os_windows.go
src/runtime/panic.go
src/runtime/proc.go
src/runtime/signal_unix.go
src/runtime/stubs.go
src/runtime/syscall_solaris.go
src/runtime/traceback.go

index a06bed20f50a0262d81332648491602b06158993..c85033f4bccff682a7cbec7fe4f8e9be63118f2f 100644 (file)
@@ -125,7 +125,7 @@ func cgocall(fn, arg unsafe.Pointer) int32 {
        // "system call", run the Go code (which may grow the stack),
        // and then re-enter the "system call" reusing the PC and SP
        // saved by entersyscall here.
-       entersyscall(0)
+       entersyscall()
 
        mp.incgo = true
        errno := asmcgocall(fn, arg)
@@ -134,7 +134,7 @@ func cgocall(fn, arg unsafe.Pointer) int32 {
        // reschedule us on to a different M.
        endcgo(mp)
 
-       exitsyscall(0)
+       exitsyscall()
 
        // From the garbage collector's perspective, time can move
        // backwards in the sequence above. If there's a callback into
@@ -188,7 +188,7 @@ func cgocallbackg(ctxt uintptr) {
        // save syscall* and let reentersyscall restore them.
        savedsp := unsafe.Pointer(gp.syscallsp)
        savedpc := gp.syscallpc
-       exitsyscall(0) // coming out of cgo call
+       exitsyscall() // coming out of cgo call
        gp.m.incgo = false
 
        cgocallbackg1(ctxt)
index 51a0ea26fea082e243b79ba05ce70b5c7c7ed896..2575df1e3999a13ebaed614875d6f6c97a92b295 100644 (file)
@@ -403,7 +403,7 @@ func LockOSCounts() (external, internal uint32) {
 //go:noinline
 func TracebackSystemstack(stk []uintptr, i int) int {
        if i == 0 {
-               pc, sp := getcallerpc(), getcallersp(unsafe.Pointer(&stk))
+               pc, sp := getcallerpc(), getcallersp()
                return gentraceback(pc, sp, 0, getg(), 0, &stk[0], len(stk), nil, nil, _TraceJumpStack)
        }
        n := 0
index 0738f8f23b061f4ee1726e632ab0953eff6302f3..3051bd58801a1e91bd03ca0d68bef83b90a49421 100644 (file)
@@ -51,9 +51,9 @@ func TestFutexsleep(t *testing.T) {
                tt.ch = make(chan *futexsleepTest, 1)
                wg.Add(1)
                go func(tt *futexsleepTest) {
-                       runtime.Entersyscall(0)
+                       runtime.Entersyscall()
                        runtime.Futexsleep(&tt.mtx, 0, tt.ns)
-                       runtime.Exitsyscall(0)
+                       runtime.Exitsyscall()
                        tt.ch <- tt
                        wg.Done()
                }(tt)
index 9d55bd129c992188122ce536df593f209c06b527..18dd4629a0cd03c3ac0b620ac60432b325e52d73 100644 (file)
@@ -224,8 +224,8 @@ func notetsleepg(n *note, ns int64) bool {
                throw("notetsleepg on g0")
        }
 
-       entersyscallblock(0)
+       entersyscallblock()
        ok := notetsleep_internal(n, ns)
-       exitsyscall(0)
+       exitsyscall()
        return ok
 }
index b41f805cee57ee996cd3768ce6cb9eb782949569..4cb0e84db3888997b15fd632287a9b191cdeb815 100644 (file)
@@ -277,8 +277,8 @@ func notetsleepg(n *note, ns int64) bool {
                throw("notetsleepg on g0")
        }
        semacreate(gp.m)
-       entersyscallblock(0)
+       entersyscallblock()
        ok := notetsleep_internal(n, ns, nil, 0)
-       exitsyscall(0)
+       exitsyscall()
        return ok
 }
index 0455fe86acb83aaf24ee006d0af2b3da4200fd90..43e4810d978786c00f0bcb1d99ab9e14770137bc 100644 (file)
@@ -740,7 +740,7 @@ func GoroutineProfile(p []StackRecord) (n int, ok bool) {
                r := p
 
                // Save current goroutine.
-               sp := getcallersp(unsafe.Pointer(&p))
+               sp := getcallersp()
                pc := getcallerpc()
                systemstack(func() {
                        saveg(pc, sp, gp, &r[0])
@@ -785,7 +785,7 @@ func Stack(buf []byte, all bool) int {
        n := 0
        if len(buf) > 0 {
                gp := getg()
-               sp := getcallersp(unsafe.Pointer(&buf))
+               sp := getcallersp()
                pc := getcallerpc()
                systemstack(func() {
                        g0 := getg()
@@ -827,7 +827,7 @@ func tracealloc(p unsafe.Pointer, size uintptr, typ *_type) {
        if gp.m.curg == nil || gp == gp.m.curg {
                goroutineheader(gp)
                pc := getcallerpc()
-               sp := getcallersp(unsafe.Pointer(&p))
+               sp := getcallersp()
                systemstack(func() {
                        traceback(pc, sp, 0, gp)
                })
@@ -847,7 +847,7 @@ func tracefree(p unsafe.Pointer, size uintptr) {
        print("tracefree(", p, ", ", hex(size), ")\n")
        goroutineheader(gp)
        pc := getcallerpc()
-       sp := getcallersp(unsafe.Pointer(&p))
+       sp := getcallersp()
        systemstack(func() {
                traceback(pc, sp, 0, gp)
        })
index e9b39b2f4553fa0d3dc1dde971654d0996958e54..e90128bb6d412a866656713b42a949c28f186583 100644 (file)
@@ -34,12 +34,12 @@ func benchmarkSyscall(b *testing.B, work, excess int) {
        b.RunParallel(func(pb *testing.PB) {
                foo := 42
                for pb.Next() {
-                       runtime.Entersyscall(0)
+                       runtime.Entersyscall()
                        for i := 0; i < work; i++ {
                                foo *= 2
                                foo /= 2
                        }
-                       runtime.Exitsyscall(0)
+                       runtime.Exitsyscall()
                }
                _ = foo
        })
index d698e09e7d5fa2dd3ce62bbefe182ef196f646fd..703a2e54301e92cc482e646e1b4ee8fe44b562ee 100644 (file)
@@ -42,7 +42,7 @@ func sysvicall0(fn *libcFunc) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
@@ -69,7 +69,7 @@ func sysvicall1(fn *libcFunc, a1 uintptr) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
@@ -97,7 +97,7 @@ func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
@@ -124,7 +124,7 @@ func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
@@ -151,7 +151,7 @@ func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
@@ -178,7 +178,7 @@ func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
@@ -205,7 +205,7 @@ func sysvicall6(fn *libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
 
        var libcall libcall
index 415ec0cb903b98d46c3d36e32ed3c2623bd5ca89..01f46e163cca4799f533e34fefa4fc9a1adf73cb 100644 (file)
@@ -711,7 +711,7 @@ func stdcall(fn stdFunction) uintptr {
                mp.libcallpc = getcallerpc()
                // sp must be the last, because once async cpu profiler finds
                // all three values to be non-zero, it will use them
-               mp.libcallsp = getcallersp(unsafe.Pointer(&fn))
+               mp.libcallsp = getcallersp()
        }
        asmcgocall(asmstdcallAddr, unsafe.Pointer(&mp.libcall))
        mp.libcallsp = 0
index 6a889a1ee6ad1472a2bbddfaba223ec99126caf3..3abcf9045bec77eff89f5a2084af82ec08ee6dea 100644 (file)
@@ -81,7 +81,7 @@ func deferproc(siz int32, fn *funcval) { // arguments of fn follow fn
        // collection or stack copying trigger until we've copied them out
        // to somewhere safe. The memmove below does that.
        // Until the copy completes, we can only call nosplit routines.
-       sp := getcallersp(unsafe.Pointer(&siz))
+       sp := getcallersp()
        argp := uintptr(unsafe.Pointer(&fn)) + unsafe.Sizeof(fn)
        callerpc := getcallerpc()
 
@@ -320,7 +320,7 @@ func deferreturn(arg0 uintptr) {
        if d == nil {
                return
        }
-       sp := getcallersp(unsafe.Pointer(&arg0))
+       sp := getcallersp()
        if d.sp != sp {
                return
        }
@@ -637,7 +637,7 @@ func recovery(gp *g) {
 //go:nosplit
 func fatalpanic(msgs *_panic) {
        pc := getcallerpc()
-       sp := getcallersp(unsafe.Pointer(&msgs))
+       sp := getcallersp()
        gp := getg()
        // Switch to the system stack to avoid any stack growth, which
        // may make things worse if the runtime is in a bad state.
index b67d67a6f79eefaac198653fbf17089b13a4845b..33845ae6e01cee65afd8352c7530798402c42483 100644 (file)
@@ -1192,7 +1192,7 @@ func mstart() {
        // both Go and C functions with stack growth prologues.
        _g_.stackguard0 = _g_.stack.lo + _StackGuard
        _g_.stackguard1 = _g_.stackguard0
-       mstart1(0)
+       mstart1()
 
        // Exit this thread.
        if GOOS == "windows" || GOOS == "solaris" || GOOS == "plan9" {
@@ -1204,7 +1204,7 @@ func mstart() {
        mexit(osStack)
 }
 
-func mstart1(dummy int32) {
+func mstart1() {
        _g_ := getg()
 
        if _g_ != _g_.m.g0 {
@@ -1215,7 +1215,7 @@ func mstart1(dummy int32) {
        // for terminating the thread.
        // We're never coming back to mstart1 after we call schedule,
        // so other calls can reuse the current frame.
-       save(getcallerpc(), getcallersp(unsafe.Pointer(&dummy)))
+       save(getcallerpc(), getcallersp())
        asminit()
        minit()
 
@@ -2836,8 +2836,8 @@ func reentersyscall(pc, sp uintptr) {
 
 // Standard syscall entry used by the go syscall library and normal cgo calls.
 //go:nosplit
-func entersyscall(dummy int32) {
-       reentersyscall(getcallerpc(), getcallersp(unsafe.Pointer(&dummy)))
+func entersyscall() {
+       reentersyscall(getcallerpc(), getcallersp())
 }
 
 func entersyscall_sysmon() {
@@ -2869,7 +2869,7 @@ func entersyscall_gcwait() {
 
 // The same as entersyscall(), but with a hint that the syscall is blocking.
 //go:nosplit
-func entersyscallblock(dummy int32) {
+func entersyscallblock() {
        _g_ := getg()
 
        _g_.m.locks++ // see comment in entersyscall
@@ -2881,7 +2881,7 @@ func entersyscallblock(dummy int32) {
 
        // Leave SP around for GC and traceback.
        pc := getcallerpc()
-       sp := getcallersp(unsafe.Pointer(&dummy))
+       sp := getcallersp()
        save(pc, sp)
        _g_.syscallsp = _g_.sched.sp
        _g_.syscallpc = _g_.sched.pc
@@ -2905,7 +2905,7 @@ func entersyscallblock(dummy int32) {
        systemstack(entersyscallblock_handoff)
 
        // Resave for traceback during blocked call.
-       save(getcallerpc(), getcallersp(unsafe.Pointer(&dummy)))
+       save(getcallerpc(), getcallersp())
 
        _g_.m.locks--
 }
@@ -2927,11 +2927,11 @@ func entersyscallblock_handoff() {
 //
 //go:nosplit
 //go:nowritebarrierrec
-func exitsyscall(dummy int32) {
+func exitsyscall() {
        _g_ := getg()
 
        _g_.m.locks++ // see comment in entersyscall
-       if getcallersp(unsafe.Pointer(&dummy)) > _g_.syscallsp {
+       if getcallersp() > _g_.syscallsp {
                throw("exitsyscall: syscall frame is no longer valid")
        }
 
index 0d8caae7a068b90751b9e0c58cfcdfb77da90a10..4981c1f615827081192f9192ef377e7e90764e00 100644 (file)
@@ -316,7 +316,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
                        st := stackt{ss_size: g.m.g0.stack.hi - g.m.g0.stack.lo}
                        setSignalstackSP(&st, g.m.g0.stack.lo)
                        setGsignalStack(&st, &gsignalStack)
-                       g.m.gsignal.stktopsp = getcallersp(unsafe.Pointer(&sig))
+                       g.m.gsignal.stktopsp = getcallersp()
                        setStack = true
                } else {
                        var st stackt
@@ -335,7 +335,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
                                dropm()
                        }
                        setGsignalStack(&st, &gsignalStack)
-                       g.m.gsignal.stktopsp = getcallersp(unsafe.Pointer(&sig))
+                       g.m.gsignal.stktopsp = getcallersp()
                        setStack = true
                }
        }
index 7818fd36839a624bc28e4e8ca375556d63b630fc..d1cdf5fa5d94f0a9a80524507548d0e23c5f3ede 100644 (file)
@@ -199,17 +199,14 @@ func publicationBarrier()
 
 // getcallerpc returns the program counter (PC) of its caller's caller.
 // getcallersp returns the stack pointer (SP) of its caller's caller.
-// argp must be a pointer to the caller's first function argument.
-// The implementation may or may not use argp, depending on
-// the architecture. The implementation may be a compiler
-// intrinsic; there is not necessarily code implementing this
-// on every platform.
+// The implementation may be a compiler intrinsic; there is not
+// necessarily code implementing this on every platform.
 //
 // For example:
 //
 //     func f(arg1, arg2, arg3 int) {
 //             pc := getcallerpc()
-//             sp := getcallersp(unsafe.Pointer(&arg1))
+//             sp := getcallersp()
 //     }
 //
 // These two lines find the PC and SP immediately following
@@ -231,7 +228,7 @@ func publicationBarrier()
 func getcallerpc() uintptr
 
 //go:noescape
-func getcallersp(argp unsafe.Pointer) uintptr // implemented as an intrinsic on all platforms
+func getcallersp() uintptr // implemented as an intrinsic on all platforms
 
 // getclosureptr returns the pointer to the current closure.
 // getclosureptr can only be used in an assignment statement
index 12afca17bb7aeaa4576c4b6df5a166cc75144b83..9f05a47892916f4861097a64af0f437fa115262f 100644 (file)
@@ -34,9 +34,9 @@ func syscall_sysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err
                n:    nargs,
                args: uintptr(unsafe.Pointer(&a1)),
        }
-       entersyscallblock(0)
+       entersyscallblock()
        asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
-       exitsyscall(0)
+       exitsyscall()
        return call.r1, call.r2, call.err
 }
 
@@ -130,9 +130,9 @@ func syscall_gethostname() (name string, err uintptr) {
                n:    2,
                args: uintptr(unsafe.Pointer(&args[0])),
        }
-       entersyscallblock(0)
+       entersyscallblock()
        asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
-       exitsyscall(0)
+       exitsyscall()
        if call.r1 != 0 {
                return "", call.err
        }
@@ -168,9 +168,9 @@ func syscall_pipe() (r, w, err uintptr) {
                n:    0,
                args: uintptr(unsafe.Pointer(&pipe1)), // it's unused but must be non-nil, otherwise crashes
        }
-       entersyscallblock(0)
+       entersyscallblock()
        asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
-       exitsyscall(0)
+       exitsyscall()
        return call.r1, call.r2, call.err
 }
 
@@ -247,9 +247,9 @@ func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
                n:    4,
                args: uintptr(unsafe.Pointer(&trap)),
        }
-       entersyscallblock(0)
+       entersyscallblock()
        asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
-       exitsyscall(0)
+       exitsyscall()
        return call.r1, call.r2, call.err
 }
 
@@ -259,9 +259,9 @@ func syscall_wait4(pid uintptr, wstatus *uint32, options uintptr, rusage unsafe.
                n:    4,
                args: uintptr(unsafe.Pointer(&pid)),
        }
-       entersyscallblock(0)
+       entersyscallblock()
        asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
-       exitsyscall(0)
+       exitsyscall()
        return int(call.r1), call.err
 }
 
index 0f392a50fdd65a8e7e35f516d74a0af6341bfdb4..2fb8aea59d5d2d65d97f87a2001d17fb0d70c7f6 100644 (file)
@@ -761,7 +761,7 @@ func printAncestorTracebackFuncInfo(f funcInfo, pc uintptr) bool {
 }
 
 func callers(skip int, pcbuf []uintptr) int {
-       sp := getcallersp(unsafe.Pointer(&skip))
+       sp := getcallersp()
        pc := getcallerpc()
        gp := getg()
        var n int