]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: rename getcallerfp to getfp
authorFelix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Mon, 3 Apr 2023 23:10:55 +0000 (01:10 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Mon, 22 May 2023 10:04:13 +0000 (10:04 +0000)
The previous name was wrong due to the mistaken assumption that calling
f->g->getcallerpc and f->g->getcallersp would respectively return the
pc/sp at g. However, they are actually referring to their caller's
caller, i.e. f.

Rename getcallerfp to getfp in order to stay consistent with this
naming convention.

Also see discussion on CL 463835.

For #16638

This is a redo of CL 481617 that became necessary because CL 461738
added another call site for getcallerfp().

Change-Id: If0b536e85a6c26061b65e7b5c2859fc31385d025
Reviewed-on: https://go-review.googlesource.com/c/go/+/494857
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>

16 files changed:
src/runtime/asm_amd64.s
src/runtime/asm_arm64.s
src/runtime/export_test.go
src/runtime/export_windows_test.go
src/runtime/os_wasm.go
src/runtime/stubs_386.go
src/runtime/stubs_amd64.go
src/runtime/stubs_arm.go
src/runtime/stubs_arm64.go
src/runtime/stubs_loong64.go
src/runtime/stubs_mips64x.go
src/runtime/stubs_mipsx.go
src/runtime/stubs_ppc64x.go
src/runtime/stubs_riscv64.go
src/runtime/stubs_s390x.go
src/runtime/trace.go

index 7fe8528d19b6991eb993ea40c138911153119325..4ba2333f559f4bf611cf2940e1f0ff2a6665becc 100644 (file)
@@ -2088,6 +2088,6 @@ TEXT runtime·retpolineR13(SB),NOSPLIT|NOFRAME,$0; RETPOLINE(13)
 TEXT runtime·retpolineR14(SB),NOSPLIT|NOFRAME,$0; RETPOLINE(14)
 TEXT runtime·retpolineR15(SB),NOSPLIT|NOFRAME,$0; RETPOLINE(15)
 
-TEXT ·getcallerfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
+TEXT ·getfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
        MOVQ BP, AX
        RET
index 5cce33d7fec66c5427ea562e6e1c47b393751b58..bd736ca8d22d77aece41aa5cd3e65159e7cf650c 100644 (file)
@@ -1568,6 +1568,6 @@ TEXT runtime·panicSliceConvert<ABIInternal>(SB),NOSPLIT,$0-16
        MOVD    R3, R1
        JMP     runtime·goPanicSliceConvert<ABIInternal>(SB)
 
-TEXT ·getcallerfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
+TEXT ·getfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
        MOVD R29, R0
        RET
index db91bc650d4d7f53c677dc0cc9a11f26ca9d66fd..5dc32ac5f77b79793c2b2ed65aa7bc83c963b1c5 100644 (file)
@@ -1826,7 +1826,7 @@ func PersistentAlloc(n uintptr) unsafe.Pointer {
 // FPCallers works like Callers and uses frame pointer unwinding to populate
 // pcBuf with the return addresses of the physical frames on the stack.
 func FPCallers(pcBuf []uintptr) int {
-       return fpTracebackPCs(unsafe.Pointer(getcallerfp()), pcBuf)
+       return fpTracebackPCs(unsafe.Pointer(getfp()), pcBuf)
 }
 
 var (
index 5b9f08fb798c3a1f6e5f65c8d091761e41185019..8e7662da6e793c05f24ee3d9c812ae64480d1320 100644 (file)
@@ -33,6 +33,6 @@ func NewContextStub() ContextStub {
        var ctx context
        ctx.set_ip(getcallerpc())
        ctx.set_sp(getcallersp())
-       ctx.set_fp(getcallerfp())
+       ctx.set_fp(getfp())
        return ContextStub{ctx}
 }
index 1a6f7d802ff7f9b2a8bd3b30e44b278a0beef8e4..bf78dfb5f9f275042c6c9fccbd9c2e99cea00d21 100644 (file)
@@ -137,8 +137,9 @@ func preemptM(mp *m) {
        // No threads, so nothing to do.
 }
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
 
 func setProcessCPUProfiler(hz int32) {}
 func setThreadCPUProfiler(hz int32)  {}
index ef531367c9b8baa3fb4b71e5b9a723c25511c344..a1dd023974a0c6fc41159a759ead4b5ed8ab84c6 100644 (file)
@@ -19,5 +19,6 @@ func emptyfunc()
 //go:noescape
 func asmcgocall_no_g(fn, arg unsafe.Pointer)
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index 3e7cf4f38375e15999cc9b74c2821746d57a81cd..a86a4964579e36e603969ac2ef7e4b56d166dc70 100644 (file)
@@ -48,6 +48,6 @@ func asmcgocall_no_g(fn, arg unsafe.Pointer)
 func spillArgs()
 func unspillArgs()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
 // TODO: Make this a compiler intrinsic
-func getcallerfp() uintptr
+func getfp() uintptr
index be40a2b06ad1f98d2085d360dba0b2f6833bad85..e19f1a87b2526a817e78661bd18e22a8e838df34 100644 (file)
@@ -24,5 +24,6 @@ func read_tls_fallback()
 //go:noescape
 func asmcgocall_no_g(fn, arg unsafe.Pointer)
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index 723337ce52ae088ff84969b97928794486d89f23..df04e64291321588e38d2410fe2a4f67d2088390 100644 (file)
@@ -22,6 +22,6 @@ func emptyfunc()
 func spillArgs()
 func unspillArgs()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
 // TODO: Make this a compiler intrinsic
-func getcallerfp() uintptr
+func getfp() uintptr
index 0575c3093d1d985b8dd5cf14a816c57325416a0e..556983cad1fbf6152a6f2ca064c72030ca0eb69f 100644 (file)
@@ -10,5 +10,6 @@ package runtime
 func load_g()
 func save_g()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index dbc4424f6c2d939cb04661b6559bd6382526676f..f0cf0886203d139e9809d4f61899832728437d2f 100644 (file)
@@ -15,5 +15,6 @@ func save_g()
 //go:noescape
 func asmcgocall_no_g(fn, arg unsafe.Pointer)
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index abae8418a1d9914f2e54f59fa2d1d2d3007d2627..84ba147b85c58cca662c68de5a2b9e3f1996699a 100644 (file)
@@ -10,5 +10,6 @@ package runtime
 func load_g()
 func save_g()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index 67035eb7e8c8fb0b0bf593507e372241e47ef9f7..0b7771ef03006e00249aa89ae8c9bb3c2be2d660 100644 (file)
@@ -16,5 +16,6 @@ func reginit()
 func spillArgs()
 func unspillArgs()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index 0df1659c4a59688c9cbb68b2a9e3a2623e050580..b07d7f8746cd0c872fe5f93dc5e18da54646ee4b 100644 (file)
@@ -15,5 +15,6 @@ func save_g()
 func spillArgs()
 func unspillArgs()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index 799f4e948fc0c92d9346d001a7868008f0455e70..a2b07ff8aa8e6bbc989201c254039f806a00082f 100644 (file)
@@ -8,5 +8,6 @@ package runtime
 func load_g()
 func save_g()
 
-// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
-func getcallerfp() uintptr { return 0 }
+// getfp returns the frame pointer register of its caller or 0 if not implemented.
+// TODO: Make this a compiler intrinsic
+func getfp() uintptr { return 0 }
index 378cd7bb08f0db7cbce1e27f9d4980955567ced5..2f9e141b09ed216023ecc228a764dc90e6f2051f 100644 (file)
@@ -970,7 +970,7 @@ func traceStackID(mp *m, pcBuf []uintptr, skip int) uint64 {
                // Fast path: Unwind using frame pointers.
                pcBuf[0] = uintptr(skip)
                if curgp == gp {
-                       nstk += fpTracebackPCs(unsafe.Pointer(getcallerfp()), pcBuf[1:])
+                       nstk += fpTracebackPCs(unsafe.Pointer(getfp()), pcBuf[1:])
                } else if curgp != nil {
                        // We're called on the g0 stack through mcall(fn) or systemstack(fn). To
                        // behave like gcallers above, we start unwinding from sched.bp, which