@@ -22,6 +22,7 @@ import (
22
22
"cmd/compile/internal/liveness"
23
23
"cmd/compile/internal/objw"
24
24
"cmd/compile/internal/reflectdata"
25
+ "cmd/compile/internal/rttype"
25
26
"cmd/compile/internal/ssa"
26
27
"cmd/compile/internal/staticdata"
27
28
"cmd/compile/internal/typecheck"
@@ -5537,7 +5538,7 @@ func (s *state) getClosureAndRcvr(fn *ir.SelectorExpr) (*ssa.Value, *ssa.Value)
5537
5538
i := s .expr (fn .X )
5538
5539
itab := s .newValue1 (ssa .OpITab , types .Types [types .TUINTPTR ], i )
5539
5540
s .nilCheck (itab )
5540
- itabidx := fn .Offset () + 2 * int64 ( types . PtrSize ) + 8 // offset of fun field in runtime.itab
5541
+ itabidx := fn .Offset () + rttype . ITab . OffsetOf ( "Fun" )
5541
5542
closure := s .newValue1I (ssa .OpOffPtr , s .f .Config .Types .UintptrPtr , itabidx , itab )
5542
5543
rcvr := s .newValue1 (ssa .OpIData , s .f .Config .Types .BytePtr , i )
5543
5544
return closure , rcvr
@@ -6522,7 +6523,7 @@ func (s *state) dynamicDottype(n *ir.DynamicTypeAssertExpr, commaok bool) (res,
6522
6523
targetItab = s .expr (n .ITab )
6523
6524
// TODO(mdempsky): Investigate whether compiling n.RType could be
6524
6525
// better than loading itab.typ.
6525
- target = s .load (byteptr , s .newValue1I (ssa .OpOffPtr , byteptr , int64 ( types . PtrSize ), targetItab )) // itab.typ
6526
+ target = s .load (byteptr , s .newValue1I (ssa .OpOffPtr , byteptr , rttype . ITab . OffsetOf ( "Type" ), targetItab ))
6526
6527
} else {
6527
6528
target = s .expr (n .RType )
6528
6529
}
@@ -6580,7 +6581,7 @@ func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, targ
6580
6581
return
6581
6582
}
6582
6583
// Load type out of itab, build interface with existing idata.
6583
- off := s .newValue1I (ssa .OpOffPtr , byteptr , int64 ( types . PtrSize ), itab )
6584
+ off := s .newValue1I (ssa .OpOffPtr , byteptr , rttype . ITab . OffsetOf ( "Type" ), itab )
6584
6585
typ := s .load (byteptr , off )
6585
6586
idata := s .newValue1 (ssa .OpIData , byteptr , iface )
6586
6587
res = s .newValue2 (ssa .OpIMake , dst , typ , idata )
@@ -6590,7 +6591,7 @@ func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, targ
6590
6591
s .startBlock (bOk )
6591
6592
// nonempty -> empty
6592
6593
// Need to load type from itab
6593
- off := s .newValue1I (ssa .OpOffPtr , byteptr , int64 ( types . PtrSize ), itab )
6594
+ off := s .newValue1I (ssa .OpOffPtr , byteptr , rttype . ITab . OffsetOf ( "Type" ), itab )
6594
6595
s .vars [typVar ] = s .load (byteptr , off )
6595
6596
s .endBlock ()
6596
6597
@@ -6644,7 +6645,7 @@ func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, targ
6644
6645
s .startBlock (bNonNil )
6645
6646
typ := itab
6646
6647
if ! src .IsEmptyInterface () {
6647
- typ = s .load (byteptr , s .newValue1I (ssa .OpOffPtr , byteptr , int64 ( types . PtrSize ), itab ))
6648
+ typ = s .load (byteptr , s .newValue1I (ssa .OpOffPtr , byteptr , rttype . ITab . OffsetOf ( "Type" ), itab ))
6648
6649
}
6649
6650
6650
6651
// Check the cache first.
@@ -6685,9 +6686,9 @@ func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, targ
6685
6686
// Load hash from type or itab.
6686
6687
var hash * ssa.Value
6687
6688
if src .IsEmptyInterface () {
6688
- hash = s .newValue2 (ssa .OpLoad , typs .UInt32 , s .newValue1I (ssa .OpOffPtr , typs .UInt32Ptr , 2 * s . config . PtrSize , typ ), s .mem ())
6689
+ hash = s .newValue2 (ssa .OpLoad , typs .UInt32 , s .newValue1I (ssa .OpOffPtr , typs .UInt32Ptr , rttype . Type . OffsetOf ( "Hash" ) , typ ), s .mem ())
6689
6690
} else {
6690
- hash = s .newValue2 (ssa .OpLoad , typs .UInt32 , s .newValue1I (ssa .OpOffPtr , typs .UInt32Ptr , 2 * s . config . PtrSize , itab ), s .mem ())
6691
+ hash = s .newValue2 (ssa .OpLoad , typs .UInt32 , s .newValue1I (ssa .OpOffPtr , typs .UInt32Ptr , rttype . ITab . OffsetOf ( "Hash" ) , itab ), s .mem ())
6691
6692
}
6692
6693
hash = s .newValue1 (zext , typs .Uintptr , hash )
6693
6694
s .vars [hashVar ] = hash
0 commit comments