]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] reflect: use internal/abi.FuncPCABI0 to take address of assembly...
authorCherry Mui <cherryyz@google.com>
Fri, 21 May 2021 22:28:25 +0000 (18:28 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 24 May 2021 21:05:34 +0000 (21:05 +0000)
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>
src/reflect/asm_amd64.s
src/reflect/makefunc.go

index 86d3f4e4bf77075e53ed7c0975cc6653bd79bb64..7491c772acd9f99504724a9d897dc756d144b704 100644 (file)
 // 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.
index d53e68a3594a66de2fddde11860279931d1106f5..588be8bcc155602cdad79e7f4b7003444fbe7772 100644 (file)
@@ -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)