aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-11-08 10:34:19 -0500
committerAustin Clements <austin@google.com>2018-11-12 20:27:14 +0000
commit4f3604d3f2b25905907742f48cd0feeec5b458e1 (patch)
tree393a6f20d5d07b39e23eb547bb767c1b9aceb5ca
parentf58b02a29c395b5ec28bb548b1fd3ca18e2b3a4f (diff)
downloadgo-4f3604d3f2b25905907742f48cd0feeec5b458e1.tar.gz
go-4f3604d3f2b25905907742f48cd0feeec5b458e1.zip
runtime, reflect: access runtime.reflectcall directly
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>
-rw-r--r--src/cmd/vet/all/whitelist/all.txt1
-rw-r--r--src/reflect/value.go2
-rw-r--r--src/runtime/asm_386.s3
-rw-r--r--src/runtime/asm_amd64.s3
-rw-r--r--src/runtime/asm_amd64p32.s3
-rw-r--r--src/runtime/asm_arm.s3
-rw-r--r--src/runtime/asm_arm64.s3
-rw-r--r--src/runtime/asm_mips64x.s3
-rw-r--r--src/runtime/asm_mipsx.s3
-rw-r--r--src/runtime/asm_ppc64x.s3
-rw-r--r--src/runtime/asm_s390x.s3
-rw-r--r--src/runtime/asm_wasm.s3
-rw-r--r--src/runtime/stubs.go2
13 files changed, 4 insertions, 31 deletions
diff --git a/src/cmd/vet/all/whitelist/all.txt b/src/cmd/vet/all/whitelist/all.txt
index c2dabeece4..761f4ced4e 100644
--- a/src/cmd/vet/all/whitelist/all.txt
+++ b/src/cmd/vet/all/whitelist/all.txt
@@ -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
diff --git a/src/reflect/value.go b/src/reflect/value.go
index 6d2862dbab..8906febb9b 100644
--- a/src/reflect/value.go
+++ b/src/reflect/value.go
@@ -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)
diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s
index 5bc2063bed..48a959aad1 100644
--- a/src/runtime/asm_386.s
+++ b/src/runtime/asm_386.s
@@ -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)
diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s
index ab891154c8..6339dc0000 100644
--- a/src/runtime/asm_amd64.s
+++ b/src/runtime/asm_amd64.s
@@ -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)
diff --git a/src/runtime/asm_amd64p32.s b/src/runtime/asm_amd64p32.s
index 7f194d2403..7b57fc78d6 100644
--- a/src/runtime/asm_amd64p32.s
+++ b/src/runtime/asm_amd64p32.s
@@ -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)
diff --git a/src/runtime/asm_arm.s b/src/runtime/asm_arm.s
index 174dc46389..745aceaaff 100644
--- a/src/runtime/asm_arm.s
+++ b/src/runtime/asm_arm.s
@@ -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)
diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s
index 6a6a699241..2248cec132 100644
--- a/src/runtime/asm_arm64.s
+++ b/src/runtime/asm_arm64.s
@@ -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)
diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s
index 4b842ff0f2..ef45ab1378 100644
--- a/src/runtime/asm_mips64x.s
+++ b/src/runtime/asm_mips64x.s
@@ -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)
diff --git a/src/runtime/asm_mipsx.s b/src/runtime/asm_mipsx.s
index 654eb6572c..6ef4507ee1 100644
--- a/src/runtime/asm_mipsx.s
+++ b/src/runtime/asm_mipsx.s
@@ -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
diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s
index 21ed2bfcfd..fb0003c9b2 100644
--- a/src/runtime/asm_ppc64x.s
+++ b/src/runtime/asm_ppc64x.s
@@ -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)
diff --git a/src/runtime/asm_s390x.s b/src/runtime/asm_s390x.s
index 9ef1b8a4c8..566c3e9236 100644
--- a/src/runtime/asm_s390x.s
+++ b/src/runtime/asm_s390x.s
@@ -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)
diff --git a/src/runtime/asm_wasm.s b/src/runtime/asm_wasm.s
index baf840d0cf..374b9f73db 100644
--- a/src/runtime/asm_wasm.s
+++ b/src/runtime/asm_wasm.s
@@ -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
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index 632b1e2293..bb4fd2cc83 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -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)