From 6cac100eefbe07ffd2c9bf64c9a782bf93d79081 Mon Sep 17 00:00:00 2001 From: David Chase Date: Mon, 24 Oct 2016 10:25:05 -0400 Subject: cmd/compile: add intrinsic for reading caller's pc First step towards removing the mandatory argument for getcallerpc, which solves certain problems for the runtime. This might also slightly improve performance. Intrinsic enabled on 386, amd64, amd64p32, runtime asm implementation removed on those architectures. Now-superfluous argument remains in getcallerpc signature (for a future CL; non-386/amd64 asm funcs ignore it). Added getcallerpc to the "not a real function" test in dcl.go, that story is a little odd with respect to unexported functions but that is not this CL. Fixes #17327. Change-Id: I5df1ad91f27ee9ac1f0dd88fa48f1329d6306c3e Reviewed-on: https://go-review.googlesource.com/31851 Run-TryBot: David Chase TryBot-Result: Gobot Gobot Reviewed-by: Austin Clements --- src/runtime/asm_386.s | 6 ------ src/runtime/asm_amd64.s | 6 ------ src/runtime/asm_amd64p32.s | 6 ------ src/runtime/stubs.go | 4 +++- 4 files changed, 3 insertions(+), 19 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s index 76758686e5..f3b927f0b7 100644 --- a/src/runtime/asm_386.s +++ b/src/runtime/asm_386.s @@ -849,12 +849,6 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0 INT $3 RET -TEXT runtime·getcallerpc(SB),NOSPLIT,$4-8 - MOVL argp+0(FP),AX // addr of first arg - MOVL -4(AX),AX // get calling pc - MOVL AX, ret+4(FP) - RET - // func cputicks() int64 TEXT runtime·cputicks(SB),NOSPLIT,$0-8 CMPB runtime·support_sse2(SB), $1 diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index f992276794..d87f454e03 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -833,12 +833,6 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0 INT $3 RET -TEXT runtime·getcallerpc(SB),NOSPLIT,$8-16 - MOVQ argp+0(FP),AX // addr of first arg - MOVQ -8(AX),AX // get calling pc - MOVQ AX, ret+8(FP) - RET - // func cputicks() int64 TEXT runtime·cputicks(SB),NOSPLIT,$0-0 CMPB runtime·lfenceBeforeRdtsc(SB), $1 diff --git a/src/runtime/asm_amd64p32.s b/src/runtime/asm_amd64p32.s index 6777ad03b9..c80a563bda 100644 --- a/src/runtime/asm_amd64p32.s +++ b/src/runtime/asm_amd64p32.s @@ -559,12 +559,6 @@ TEXT runtime·stackcheck(SB), NOSPLIT, $0-0 MOVL 0, AX RET -TEXT runtime·getcallerpc(SB),NOSPLIT,$8-12 - MOVL argp+0(FP),AX // addr of first arg - MOVL -8(AX),AX // get calling pc - MOVL AX, ret+8(FP) - RET - // int64 runtime·cputicks(void) TEXT runtime·cputicks(SB),NOSPLIT,$0-0 RDTSC diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go index 331fc0d518..65f1695ec4 100644 --- a/src/runtime/stubs.go +++ b/src/runtime/stubs.go @@ -200,7 +200,9 @@ func publicationBarrier() // getcallersp returns the stack pointer (SP) of its caller's caller. // For both, the 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 architecture. The implementation may be a compiler +// intrinsic; there is not necessarily code implementing this +// on every platform. // // For example: // -- cgit v1.3