mirror of
https://github.com/golang/go
synced 2024-09-30 20:38:32 -06:00
runtime: change functype's in and out fields to []*_type
Allows removing a few gratuitous unsafe.Pointer conversions and parallels the type of reflect.funcType's in and out fields ([]*rtype). Change-Id: Ie5ca230a94407301a854dfd8782a3180d5054bc4 Reviewed-on: https://go-review.googlesource.com/16163 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
163653eeaa
commit
c279250946
@ -327,11 +327,10 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
|
|||||||
throw("runtime.SetFinalizer: second argument is " + *ftyp._string + ", not a function")
|
throw("runtime.SetFinalizer: second argument is " + *ftyp._string + ", not a function")
|
||||||
}
|
}
|
||||||
ft := (*functype)(unsafe.Pointer(ftyp))
|
ft := (*functype)(unsafe.Pointer(ftyp))
|
||||||
ins := *(*[]*_type)(unsafe.Pointer(&ft.in))
|
if ft.dotdotdot || len(ft.in) != 1 {
|
||||||
if ft.dotdotdot || len(ins) != 1 {
|
|
||||||
throw("runtime.SetFinalizer: cannot pass " + *etyp._string + " to finalizer " + *ftyp._string)
|
throw("runtime.SetFinalizer: cannot pass " + *etyp._string + " to finalizer " + *ftyp._string)
|
||||||
}
|
}
|
||||||
fint := ins[0]
|
fint := ft.in[0]
|
||||||
switch {
|
switch {
|
||||||
case fint == etyp:
|
case fint == etyp:
|
||||||
// ok - same type
|
// ok - same type
|
||||||
@ -356,7 +355,7 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
|
|||||||
okarg:
|
okarg:
|
||||||
// compute size needed for return parameters
|
// compute size needed for return parameters
|
||||||
nret := uintptr(0)
|
nret := uintptr(0)
|
||||||
for _, t := range *(*[]*_type)(unsafe.Pointer(&ft.out)) {
|
for _, t := range ft.out {
|
||||||
nret = round(nret, uintptr(t.align)) + uintptr(t.size)
|
nret = round(nret, uintptr(t.align)) + uintptr(t.size)
|
||||||
}
|
}
|
||||||
nret = round(nret, ptrSize)
|
nret = round(nret, ptrSize)
|
||||||
|
@ -45,16 +45,16 @@ func compileCallback(fn eface, cleanstack bool) (code uintptr) {
|
|||||||
panic("compileCallback: not a function")
|
panic("compileCallback: not a function")
|
||||||
}
|
}
|
||||||
ft := (*functype)(unsafe.Pointer(fn._type))
|
ft := (*functype)(unsafe.Pointer(fn._type))
|
||||||
if ft.out.len != 1 {
|
if len(ft.out) != 1 {
|
||||||
panic("compileCallback: function must have one output parameter")
|
panic("compileCallback: function must have one output parameter")
|
||||||
}
|
}
|
||||||
uintptrSize := unsafe.Sizeof(uintptr(0))
|
uintptrSize := unsafe.Sizeof(uintptr(0))
|
||||||
if t := (**_type)(unsafe.Pointer(ft.out.array)); (*t).size != uintptrSize {
|
if ft.out[0].size != uintptrSize {
|
||||||
panic("compileCallback: output parameter size is wrong")
|
panic("compileCallback: output parameter size is wrong")
|
||||||
}
|
}
|
||||||
argsize := uintptr(0)
|
argsize := uintptr(0)
|
||||||
for _, t := range (*[1024](*_type))(unsafe.Pointer(ft.in.array))[:ft.in.len] {
|
for _, t := range ft.in {
|
||||||
if (*t).size > uintptrSize {
|
if t.size > uintptrSize {
|
||||||
panic("compileCallback: input parameter size is wrong")
|
panic("compileCallback: input parameter size is wrong")
|
||||||
}
|
}
|
||||||
argsize += uintptrSize
|
argsize += uintptrSize
|
||||||
|
@ -84,8 +84,8 @@ type slicetype struct {
|
|||||||
type functype struct {
|
type functype struct {
|
||||||
typ _type
|
typ _type
|
||||||
dotdotdot bool
|
dotdotdot bool
|
||||||
in slice
|
in []*_type
|
||||||
out slice
|
out []*_type
|
||||||
}
|
}
|
||||||
|
|
||||||
type ptrtype struct {
|
type ptrtype struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user