]> Cypherpunks repositories - gostls13.git/commitdiff
runtime, reflect: access runtime.reflectcall directly
authorAustin Clements <austin@google.com>
Thu, 8 Nov 2018 15:34:19 +0000 (10:34 -0500)
committerAustin Clements <austin@google.com>
Mon, 12 Nov 2018 20:27:14 +0000 (20:27 +0000)
Currently, package runtime contains the definition of reflect.call,
even though it's just a jump to runtime.reflectcall. This "push"
symbol is confusing, since it's not clear where the definition of
reflect.call comes from when you're in the reflect package.

Replace this with a "pull" symbol: the runtime now defines only
runtime.reflectcall and package reflect uses a go:linkname to access
this symbol directly. This makes it clear where reflect.call is coming
from without any spooky action at a distance and eliminates all of the
definitions of reflect.call in the runtime.

Change-Id: I3ec73cd394efe9df8d3061a57c73aece2e7048dd
Reviewed-on: https://go-review.googlesource.com/c/148657
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
13 files changed:
src/cmd/vet/all/whitelist/all.txt
src/reflect/value.go
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_mipsx.s
src/runtime/asm_ppc64x.s
src/runtime/asm_s390x.s
src/runtime/asm_wasm.s
src/runtime/stubs.go

index c2dabeece423e6f2de3b018752a758b9832b89c6..761f4ced4e46d5e9146a882a4568170a8031b548 100644 (file)
@@ -10,7 +10,6 @@ go/types/scope.go: method WriteTo(w io.Writer, n int, recurse bool) should have
 // False positives.
 
 // Nothing much to do about cross-package assembly. Unfortunate.
-runtime/asm_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: call is in package reflect
 internal/bytealg/equal_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: memequal is in package runtime
 internal/bytealg/equal_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: memequal_varlen is in package runtime
 
index 6d2862dbab713ff097a64f590b1d59e3a388bc7d..8906febb9bf1a41ca56e7a0717ab662e80442f7f 100644 (file)
@@ -2667,6 +2667,8 @@ func maplen(m unsafe.Pointer) int
 // back into arg+retoffset before returning. If copying result bytes back,
 // the caller must pass the argument frame type as argtype, so that
 // call can execute appropriate write barriers during the copy.
+//
+//go:linkname call runtime.reflectcall
 func call(argtype *rtype, fn, arg unsafe.Pointer, n uint32, retoffset uint32)
 
 func ifaceE2I(t *rtype, src interface{}, dst unsafe.Pointer)
index 5bc2063bed47298bfc12899092b855317e9936a7..48a959aad108107be57bdb7f26c3d7099036ee6c 100644 (file)
@@ -493,9 +493,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0
        JMP     AX
 // Note: can't just "JMP NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       JMP     ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT, $0-20
        MOVL    argsize+12(FP), CX
        DISPATCH(runtime·call16, 16)
index ab891154c8d005c99c91e437585d3cb93ae40f25..6339dc000022cdb5dcea40527c4b8ab5041cb1a9 100644 (file)
@@ -448,9 +448,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0
        JMP     AX
 // Note: can't just "JMP NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       JMP     ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT, $0-32
        MOVLQZX argsize+24(FP), CX
        DISPATCH(runtime·call32, 32)
index 7f194d24034acffbe2293d68776881eccb9c9961..7b57fc78d6b8ed124d4f463a5f643d7370dff045 100644 (file)
@@ -318,9 +318,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0
        JMP     AX
 // Note: can't just "JMP NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       JMP     ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT, $0-20
        MOVLQZX argsize+12(FP), CX
        DISPATCH(runtime·call16, 16)
index 174dc463892451a78312f3ef26a14691e14f6c8e..745aceaaff6c32f17dd0488161bb349e1c59f653 100644 (file)
@@ -439,9 +439,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    $NAME(SB), R1;          \
        B       (R1)
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       B       ·reflectcall(SB)
-
 TEXT ·reflectcall(SB),NOSPLIT|NOFRAME,$0-20
        MOVW    argsize+12(FP), R0
        DISPATCH(runtime·call16, 16)
index 6a6a699241dc582112137eaec6d89e0c240043f0..2248cec13252038e4d923596c1f3ec84685449fa 100644 (file)
@@ -330,9 +330,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
        B       (R27)
 // Note: can't just "B NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       B       ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT|NOFRAME, $0-32
        MOVWU argsize+24(FP), R16
        DISPATCH(runtime·call32, 32)
index 4b842ff0f221ec3703710f6f2ddf7d5ef4f638cb..ef45ab137880e6949e94f7cf70603cc35eac9363 100644 (file)
@@ -292,9 +292,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
        JMP     (R4)
 // Note: can't just "BR NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       JMP     ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT|NOFRAME, $0-32
        MOVWU argsize+24(FP), R1
        DISPATCH(runtime·call32, 32)
index 654eb6572c5bf8dfe68fc60806851adc826727bb..6ef4507ee1168aa54a1d33a93e85fbfaa4642c00 100644 (file)
@@ -291,9 +291,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0
        MOVW    $NAME(SB), R4;  \
        JMP     (R4)
 
-TEXT reflect·call(SB),NOSPLIT,$0-20
-       JMP     ·reflectcall(SB)
-
 TEXT ·reflectcall(SB),NOSPLIT|NOFRAME,$0-20
        MOVW    argsize+12(FP), R1
 
index 21ed2bfcfdb3433d92de2da4213fc4d7e0be634b..fb0003c9b2f92833bfefaeebc1c9fdd024bc2eca 100644 (file)
@@ -355,9 +355,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
        BR      (CTR)
 // Note: can't just "BR NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       BR      ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT|NOFRAME, $0-32
        MOVWZ argsize+24(FP), R3
        DISPATCH(runtime·call32, 32)
index 9ef1b8a4c8dce33416d9f70a4fd788d3168d8327..566c3e923645dc2118573b4598540108ec66529f 100644 (file)
@@ -381,9 +381,6 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
        BR      (R5)
 // Note: can't just "BR NAME(SB)" - bad inlining results.
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       BR      ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT, $-8-32
        MOVWZ argsize+24(FP), R3
        DISPATCH(runtime·call32, 32)
index baf840d0cf5fb2e95cdeec89a0e85833c466634e..374b9f73dbf3ec0463bcb20c7e16fb31d46ff4f1 100644 (file)
@@ -293,9 +293,6 @@ TEXT ·cgocallback_gofunc(SB), NOSPLIT, $16-32
                JMP NAME(SB); \
        End
 
-TEXT reflect·call(SB), NOSPLIT, $0-0
-       JMP ·reflectcall(SB)
-
 TEXT ·reflectcall(SB), NOSPLIT, $0-32
        I64Load fn+8(FP)
        I64Eqz
index 632b1e2293f881bb826ace2686f57f9133a58a55..bb4fd2cc832c6ba2412edf1e46d54d4edb64b1bb 100644 (file)
@@ -154,6 +154,8 @@ func breakpoint()
 // one call that copies results back, in cgocallbackg1, and it does NOT pass a
 // frame type, meaning there are no write barriers invoked. See that call
 // site for justification.
+//
+// Package reflect accesses this symbol through a linkname.
 func reflectcall(argtype *_type, fn, arg unsafe.Pointer, argsize uint32, retoffset uint32)
 
 func procyield(cycles uint32)