9
9
"internal/abi"
10
10
"internal/goarch"
11
11
"internal/itoa"
12
+ "internal/runtime/itab"
12
13
"internal/unsafeheader"
13
14
"math"
14
15
"runtime"
@@ -208,14 +209,7 @@ type emptyInterface struct {
208
209
209
210
// nonEmptyInterface is the header for an interface value with methods.
210
211
type nonEmptyInterface struct {
211
- // see ../runtime/iface.go:/Itab
212
- itab * struct {
213
- ityp * abi.Type // static interface type
214
- typ * abi.Type // dynamic concrete type
215
- hash uint32 // copy of typ.hash
216
- _ [4 ]byte
217
- fun [100000 ]unsafe.Pointer // method table
218
- }
212
+ itab * itab.Itab
219
213
word unsafe.Pointer
220
214
}
221
215
@@ -883,7 +877,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
883
877
// The return value t gives the method type signature (without the receiver).
884
878
// The return value fn is a pointer to the method code.
885
879
func methodReceiver (op string , v Value , methodIndex int ) (rcvrtype * abi.Type , t * funcType , fn unsafe.Pointer ) {
886
- i := methodIndex
880
+ i := uintptr ( methodIndex )
887
881
if v .typ ().Kind () == abi .Interface {
888
882
tt := (* interfaceType )(unsafe .Pointer (v .typ ()))
889
883
if uint (i ) >= uint (len (tt .Methods )) {
@@ -897,8 +891,8 @@ func methodReceiver(op string, v Value, methodIndex int) (rcvrtype *abi.Type, t
897
891
if iface .itab == nil {
898
892
panic ("reflect: " + op + " of method on nil interface value" )
899
893
}
900
- rcvrtype = iface .itab .typ
901
- fn = unsafe .Pointer (& iface .itab .fun [ i ] )
894
+ rcvrtype = iface .itab .Type
895
+ fn = unsafe .Add ( unsafe . Pointer (& iface .itab .Fun [ 0 ]), unsafe . Sizeof ( iface . itab . Fun [ 0 ]) * i )
902
896
t = (* funcType )(unsafe .Pointer (tt .typeOff (m .Typ )))
903
897
} else {
904
898
rcvrtype = v .typ ()
0 commit comments