aboutsummaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-05-21 18:28:25 -0400
committerCherry Mui <cherryyz@google.com>2021-05-24 21:05:34 +0000
commitf6427426787b292ec28cfd826615e3ae9a66b54a (patch)
tree3739c072ffe88a2c083dc04bffbde57a0bf1dbbb /src/reflect
parente0844acfc8baa57541a8efef723937c2733e0c99 (diff)
downloadgo-f6427426787b292ec28cfd826615e3ae9a66b54a.tar.gz
go-f6427426787b292ec28cfd826615e3ae9a66b54a.zip
[dev.typeparams] reflect: use internal/abi.FuncPCABI0 to take address of assembly functions
makeFuncStub and methodValueCall on AMD64 are marked as ABIInternal, so Go code can get their (unwrapped) addresses (using open-coded funcPC). Ues internal/abi.FuncPCABI0 instead, and un-mark the functions. Change-Id: Id28b6101ec7e55bc5a357d4236482cec70cd7e5d Reviewed-on: https://go-review.googlesource.com/c/go/+/322350 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/asm_amd64.s8
-rw-r--r--src/reflect/makefunc.go12
2 files changed, 4 insertions, 16 deletions
diff --git a/src/reflect/asm_amd64.s b/src/reflect/asm_amd64.s
index 86d3f4e4bf..7491c772ac 100644
--- a/src/reflect/asm_amd64.s
+++ b/src/reflect/asm_amd64.s
@@ -24,10 +24,8 @@
// See the comment on the declaration of makeFuncStub in makefunc.go
// for more details.
// No arg size here; runtime pulls arg map out of the func value.
-// makeFuncStub must be ABIInternal because it is placed directly
-// in function values.
// This frame contains two locals. See the comment above LOCAL_RETVALID.
-TEXT ·makeFuncStub<ABIInternal>(SB),(NOSPLIT|WRAPPER),$312
+TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$312
NO_LOCAL_POINTERS
// NO_LOCAL_POINTERS is a lie. The stack map for the two locals in this
// frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
@@ -55,10 +53,8 @@ TEXT ·makeFuncStub<ABIInternal>(SB),(NOSPLIT|WRAPPER),$312
// See the comment on the declaration of methodValueCall in makefunc.go
// for more details.
// No arg size here; runtime pulls arg map out of the func value.
-// methodValueCall must be ABIInternal because it is placed directly
-// in function values.
// This frame contains two locals. See the comment above LOCAL_RETVALID.
-TEXT ·methodValueCall<ABIInternal>(SB),(NOSPLIT|WRAPPER),$312
+TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$312
NO_LOCAL_POINTERS
// NO_LOCAL_POINTERS is a lie. The stack map for the two locals in this
// frame is specially handled in the runtime. See the comment above LOCAL_RETVALID.
diff --git a/src/reflect/makefunc.go b/src/reflect/makefunc.go
index d53e68a359..588be8bcc1 100644
--- a/src/reflect/makefunc.go
+++ b/src/reflect/makefunc.go
@@ -52,11 +52,7 @@ func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value {
t := typ.common()
ftyp := (*funcType)(unsafe.Pointer(t))
- // Indirect Go func value (dummy) to obtain
- // actual code address. (A Go func value is a pointer
- // to a C function pointer. https://golang.org/s/go11func.)
- dummy := makeFuncStub
- code := **(**uintptr)(unsafe.Pointer(&dummy))
+ code := abi.FuncPCABI0(makeFuncStub)
// makeFuncImpl contains a stack map for use by the runtime
_, _, abi := funcLayout(ftyp, nil)
@@ -111,11 +107,7 @@ func makeMethodValue(op string, v Value) Value {
// v.Type returns the actual type of the method value.
ftyp := (*funcType)(unsafe.Pointer(v.Type().(*rtype)))
- // Indirect Go func value (dummy) to obtain
- // actual code address. (A Go func value is a pointer
- // to a C function pointer. https://golang.org/s/go11func.)
- dummy := methodValueCall
- code := **(**uintptr)(unsafe.Pointer(&dummy))
+ code := abi.FuncPCABI0(methodValueCall)
// methodValue contains a stack map for use by the runtime
_, _, abi := funcLayout(ftyp, nil)