]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: implement getcallersp in Go
authorAustin Clements <austin@google.com>
Thu, 22 Sep 2016 21:02:22 +0000 (17:02 -0400)
committerAustin Clements <austin@google.com>
Mon, 26 Sep 2016 22:01:32 +0000 (22:01 +0000)
This makes it possible to inline getcallersp. getcallersp is on the
hot path of defers, so this slightly speeds up defer:

name           old time/op  new time/op  delta
Defer-4        78.3ns ± 2%  75.1ns ± 1%  -4.00%   (p=0.000 n=9+8)

Updates #14939.

Change-Id: Icc1cc4cd2f0a81fc4c8344432d0b2e783accacdd
Reviewed-on: https://go-review.googlesource.com/29655
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_amd64p32.s
src/runtime/asm_arm.s
src/runtime/asm_arm64.s
src/runtime/asm_mips64x.s
src/runtime/asm_ppc64x.s
src/runtime/asm_s390x.s
src/runtime/stubs.go

index 12038220ac494c2f3cddda366985a2c62cee503a..56d495aede6f4b739372ea164cac3e6c9138536a 100644 (file)
@@ -808,11 +808,6 @@ setbar:
        CALL    runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB), NOSPLIT, $0-8
-       MOVL    argp+0(FP), AX
-       MOVL    AX, ret+4(FP)
-       RET
-
 // func cputicks() int64
 TEXT runtime·cputicks(SB),NOSPLIT,$0-8
        TESTL   $0x4000000, runtime·cpuid_edx(SB) // no sse2, no mfence
index 488c34a2338d8b4036d17f35afe23b5a3e62d5a8..8d992188de545536a868103100c1253ddc58ff23 100644 (file)
@@ -825,11 +825,6 @@ setbar:
        CALL    runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$0-16
-       MOVQ    argp+0(FP), AX
-       MOVQ    AX, ret+8(FP)
-       RET
-
 // func cputicks() int64
 TEXT runtime·cputicks(SB),NOSPLIT,$0-0
        CMPB    runtime·lfenceBeforeRdtsc(SB), $1
index 6aa230841e03361b21b6835ebe5fea7456b19ea9..0b42c666ae5bc71da2bca09541d0ef546c47cb3f 100644 (file)
@@ -521,11 +521,6 @@ setbar:
        CALL    runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$0-12
-       MOVL    argp+0(FP), AX
-       MOVL    AX, ret+8(FP)
-       RET
-
 // int64 runtime·cputicks(void)
 TEXT runtime·cputicks(SB),NOSPLIT,$0-0
        RDTSC
index 29f39cf15d050f3fa309c914efb4aec95487f214..d768060af206c632afefe6a59b678411e117c1ef 100644 (file)
@@ -695,12 +695,6 @@ setbar:
        BL      runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$-4-8
-       MOVW    argp+0(FP), R0
-       MOVW    $-4(R0), R0
-       MOVW    R0, ret+4(FP)
-       RET
-
 TEXT runtime·emptyfunc(SB),0,$0-0
        RET
 
index 066b534900bcd082aede7241e0ebf99efe2c54b9..c46569f68ca700221aa91d0042226b24e7dc8329 100644 (file)
@@ -731,12 +731,6 @@ setbar:
        BL      runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$0-16
-       MOVD    argp+0(FP), R0
-       SUB     $8, R0
-       MOVD    R0, ret+8(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT,$-8-0
        B       (ZR)
        UNDEF
index 15105b90c3810aad887bdca45c3aefcfea8540d2..138181833cb39945b6a3c2ad484a97f691afe619 100644 (file)
@@ -643,12 +643,6 @@ setbar:
        JAL     runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$0-16
-       MOVV    argp+0(FP), R1
-       ADDV    $-8, R1
-       MOVV    R1, ret+8(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT,$-8-0
        MOVW    (R0), R0
        UNDEF
index 67b3d5069197dcfb0c6171dd3d59707e92179681..b5cd12bb3c6e348fe02a59f235102e76aab6824f 100644 (file)
@@ -742,12 +742,6 @@ setbar:
        BL      runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$0-16
-       MOVD    argp+0(FP), R3
-       SUB     $FIXED_FRAME, R3
-       MOVD    R3, ret+8(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    (R0), R0
        UNDEF
index 3fe224df37a136fb45c7668a22bafb846f1175a2..6d0533a3dc8f8609b554440ee2bd22c7ef1af90b 100644 (file)
@@ -715,12 +715,6 @@ setbar:
        BL      runtime·setNextBarrierPC(SB)
        RET
 
-TEXT runtime·getcallersp(SB),NOSPLIT,$0-16
-       MOVD    argp+0(FP), R3
-       SUB     $8, R3
-       MOVD    R3, ret+8(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    (R0), R0
        UNDEF
index f6bb2fba16daa17a254368a55adb2491257df3b9..88f4139ba33651b5f6f88c97b7a6cd4e83af40be 100644 (file)
@@ -4,7 +4,10 @@
 
 package runtime
 
-import "unsafe"
+import (
+       "runtime/internal/sys"
+       "unsafe"
+)
 
 // Should be a built-in for unsafe.Pointer?
 //go:nosplit
@@ -196,8 +199,10 @@ func setcallerpc(argp unsafe.Pointer, pc uintptr)
 //go:noescape
 func getcallerpc(argp unsafe.Pointer) uintptr
 
-//go:noescape
-func getcallersp(argp unsafe.Pointer) uintptr
+//go:nosplit
+func getcallersp(argp unsafe.Pointer) uintptr {
+       return uintptr(argp) - sys.MinFrameSize
+}
 
 //go:noescape
 func asmcgocall(fn, arg unsafe.Pointer) int32