Skip to content

Commit 3afbca5

Browse files
felixgeqmuntal
authored andcommitted
runtime: rename getcallerfp to getfp
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Felix Geisendörfer <[email protected]>
1 parent d75cc4b commit 3afbca5

16 files changed

+36
-27
lines changed

src/runtime/asm_amd64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,6 @@ TEXT runtime·retpolineR13(SB),NOSPLIT|NOFRAME,$0; RETPOLINE(13)
20882088
TEXT runtime·retpolineR14(SB),NOSPLIT|NOFRAME,$0; RETPOLINE(14)
20892089
TEXT runtime·retpolineR15(SB),NOSPLIT|NOFRAME,$0; RETPOLINE(15)
20902090

2091-
TEXT ·getcallerfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
2091+
TEXT ·getfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
20922092
MOVQ BP, AX
20932093
RET

src/runtime/asm_arm64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,6 @@ TEXT runtime·panicSliceConvert<ABIInternal>(SB),NOSPLIT,$0-16
15681568
MOVD R3, R1
15691569
JMP runtime·goPanicSliceConvert<ABIInternal>(SB)
15701570

1571-
TEXT ·getcallerfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
1571+
TEXT ·getfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
15721572
MOVD R29, R0
15731573
RET

src/runtime/export_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ func PersistentAlloc(n uintptr) unsafe.Pointer {
18261826
// FPCallers works like Callers and uses frame pointer unwinding to populate
18271827
// pcBuf with the return addresses of the physical frames on the stack.
18281828
func FPCallers(pcBuf []uintptr) int {
1829-
return fpTracebackPCs(unsafe.Pointer(getcallerfp()), pcBuf)
1829+
return fpTracebackPCs(unsafe.Pointer(getfp()), pcBuf)
18301830
}
18311831

18321832
var (

src/runtime/export_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ func NewContextStub() ContextStub {
3333
var ctx context
3434
ctx.set_ip(getcallerpc())
3535
ctx.set_sp(getcallersp())
36-
ctx.set_fp(getcallerfp())
36+
ctx.set_fp(getfp())
3737
return ContextStub{ctx}
3838
}

src/runtime/os_wasm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ func preemptM(mp *m) {
137137
// No threads, so nothing to do.
138138
}
139139

140-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
141-
func getcallerfp() uintptr { return 0 }
140+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
141+
// TODO: Make this a compiler intrinsic
142+
func getfp() uintptr { return 0 }
142143

143144
func setProcessCPUProfiler(hz int32) {}
144145
func setThreadCPUProfiler(hz int32) {}

src/runtime/stubs_386.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ func emptyfunc()
1919
//go:noescape
2020
func asmcgocall_no_g(fn, arg unsafe.Pointer)
2121

22-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
23-
func getcallerfp() uintptr { return 0 }
22+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
23+
// TODO: Make this a compiler intrinsic
24+
func getfp() uintptr { return 0 }

src/runtime/stubs_amd64.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ func asmcgocall_no_g(fn, arg unsafe.Pointer)
4848
func spillArgs()
4949
func unspillArgs()
5050

51-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
51+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
5252
// TODO: Make this a compiler intrinsic
53-
func getcallerfp() uintptr
53+
func getfp() uintptr

src/runtime/stubs_arm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ func read_tls_fallback()
2424
//go:noescape
2525
func asmcgocall_no_g(fn, arg unsafe.Pointer)
2626

27-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
28-
func getcallerfp() uintptr { return 0 }
27+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
28+
// TODO: Make this a compiler intrinsic
29+
func getfp() uintptr { return 0 }

src/runtime/stubs_arm64.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ func emptyfunc()
2222
func spillArgs()
2323
func unspillArgs()
2424

25-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
25+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
2626
// TODO: Make this a compiler intrinsic
27-
func getcallerfp() uintptr
27+
func getfp() uintptr

src/runtime/stubs_loong64.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ package runtime
1010
func load_g()
1111
func save_g()
1212

13-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
14-
func getcallerfp() uintptr { return 0 }
13+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
14+
// TODO: Make this a compiler intrinsic
15+
func getfp() uintptr { return 0 }

src/runtime/stubs_mips64x.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ func save_g()
1515
//go:noescape
1616
func asmcgocall_no_g(fn, arg unsafe.Pointer)
1717

18-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
19-
func getcallerfp() uintptr { return 0 }
18+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
19+
// TODO: Make this a compiler intrinsic
20+
func getfp() uintptr { return 0 }

src/runtime/stubs_mipsx.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ package runtime
1010
func load_g()
1111
func save_g()
1212

13-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
14-
func getcallerfp() uintptr { return 0 }
13+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
14+
// TODO: Make this a compiler intrinsic
15+
func getfp() uintptr { return 0 }

src/runtime/stubs_ppc64x.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ func reginit()
1616
func spillArgs()
1717
func unspillArgs()
1818

19-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
20-
func getcallerfp() uintptr { return 0 }
19+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
20+
// TODO: Make this a compiler intrinsic
21+
func getfp() uintptr { return 0 }

src/runtime/stubs_riscv64.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ func save_g()
1515
func spillArgs()
1616
func unspillArgs()
1717

18-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
19-
func getcallerfp() uintptr { return 0 }
18+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
19+
// TODO: Make this a compiler intrinsic
20+
func getfp() uintptr { return 0 }

src/runtime/stubs_s390x.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ package runtime
88
func load_g()
99
func save_g()
1010

11-
// getcallerfp returns the address of the frame pointer in the callers frame or 0 if not implemented.
12-
func getcallerfp() uintptr { return 0 }
11+
// getfp returns the frame pointer register of its caller or 0 if not implemented.
12+
// TODO: Make this a compiler intrinsic
13+
func getfp() uintptr { return 0 }

src/runtime/trace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ func traceStackID(mp *m, pcBuf []uintptr, skip int) uint64 {
970970
// Fast path: Unwind using frame pointers.
971971
pcBuf[0] = uintptr(skip)
972972
if curgp == gp {
973-
nstk += fpTracebackPCs(unsafe.Pointer(getcallerfp()), pcBuf[1:])
973+
nstk += fpTracebackPCs(unsafe.Pointer(getfp()), pcBuf[1:])
974974
} else if curgp != nil {
975975
// We're called on the g0 stack through mcall(fn) or systemstack(fn). To
976976
// behave like gcallers above, we start unwinding from sched.bp, which

0 commit comments

Comments
 (0)