aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/reflect/makefunc.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-09-27 17:53:46 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-09-27 17:53:46 +0000
commit8bcd5487e589c17afc77c982589247b106caba73 (patch)
tree133857cd0c49e652d0d0f10641c67369221de3f9 /libgo/go/reflect/makefunc.go
parentf6113c278ac0953abf9d8d2bdbed8fcc240cf352 (diff)
downloadgcc-8bcd5487e589c17afc77c982589247b106caba73.zip
gcc-8bcd5487e589c17afc77c982589247b106caba73.tar.gz
gcc-8bcd5487e589c17afc77c982589247b106caba73.tar.bz2
reflect: Implement MakeFunc for amd64.
From-SVN: r202982
Diffstat (limited to 'libgo/go/reflect/makefunc.go')
-rw-r--r--libgo/go/reflect/makefunc.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/libgo/go/reflect/makefunc.go b/libgo/go/reflect/makefunc.go
index f03beb3..7253a63 100644
--- a/libgo/go/reflect/makefunc.go
+++ b/libgo/go/reflect/makefunc.go
@@ -7,6 +7,7 @@
package reflect
import (
+ "runtime"
"unsafe"
)
@@ -45,14 +46,33 @@ func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value {
panic("reflect: call of MakeFunc with non-Func type")
}
+ switch runtime.GOARCH {
+ case "amd64":
+ default:
+ panic("reflect.MakeFunc not implemented for " + runtime.GOARCH)
+ }
+
t := typ.common()
ftyp := (*funcType)(unsafe.Pointer(t))
- _, _ = t, ftyp
+ // Indirect Go func value (dummy) to obtain
+ // actual code address. (A Go func value is a pointer
+ // to a C function pointer. http://golang.org/s/go11func.)
+ dummy := makeFuncStub
+ code := **(**uintptr)(unsafe.Pointer(&dummy))
- panic("reflect MakeFunc not implemented")
+ impl := &makeFuncImpl{code: code, typ: ftyp, fn: fn}
+
+ return Value{t, unsafe.Pointer(impl), flag(Func) << flagKindShift}
}
+// makeFuncStub is an assembly function that is the code half of
+// the function returned from MakeFunc. It expects a *callReflectFunc
+// as its context register, and its job is to invoke callReflect(ctxt, frame)
+// where ctxt is the context register and frame is a pointer to the first
+// word in the passed-in argument frame.
+func makeFuncStub()
+
// makeMethodValue converts v from the rcvr+method index representation
// of a method value to an actual method func value, which is
// basically the receiver value with a special bit set, into a true