algsym = dalgsym(t)
}
- var sptr *Sym
tptr := Ptrto(t)
if !Isptr[t.Etype] && (t.Sym != nil || methods(tptr) != nil) {
- sptr = dtypesym(tptr)
- } else {
- sptr = weaktypesym(tptr)
+ sptr := dtypesym(tptr)
+ r := obj.Addrel(Linksym(s))
+ r.Off = 0
+ r.Siz = 0
+ r.Sym = sptr.Lsym
+ r.Type = obj.R_USETYPE
}
gcsym, useGCProg, ptrdata := dgcsym(t)
// gcdata *byte
// string *string
// *uncommonType
- // ptrToThis *rtype
// }
ot = duintptr(s, ot, uint64(t.Width))
ot = duintptr(s, ot, uint64(ptrdata))
// otherwise linker will assume 0.
ot += Widthptr
- ot = dsymptr(s, ot, sptr, 0) // ptrto type
return ot
}
switch t.Etype {
default:
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
case TARRAY:
if t.Bound >= 0 {
t2.Bound = -1 // slice
s2 := dtypesym(t2)
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s1, 0)
ot = dsymptr(s, ot, s2, 0)
ot = duintptr(s, ot, uint64(t.Bound))
s1 := dtypesym(t.Type)
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s1, 0)
}
s1 := dtypesym(t.Type)
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s1, 0)
ot = duintptr(s, ot, uint64(t.Chan))
}
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = duint8(s, ot, uint8(obj.Bool2int(isddd)))
// two slice headers: in and out.
// ../../../../runtime/type.go:/interfaceType
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s, ot+Widthptr+2*Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
s3 := dtypesym(mapbucket(t))
s4 := dtypesym(hmap(t))
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s1, 0)
ot = dsymptr(s, ot, s2, 0)
ot = dsymptr(s, ot, s3, 0)
s1 := dtypesym(t.Type)
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s1, 0)
// ../../../../runtime/type.go:/structType
}
ot = dcommontype(s, ot, t)
- xt = ot - 2*Widthptr
+ xt = ot - 1*Widthptr
ot = dsymptr(s, ot, s, ot+Widthptr+2*Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
ot = duintxx(s, ot, uint64(n), Widthint)
// we want be able to find.
if t.Sym == nil {
switch t.Etype {
- case TPTR32, TPTR64:
- // The ptrto field of the type data cannot be relied on when
- // dynamic linking: a type T may be defined in a module that makes
- // no use of pointers to that type, but another module can contain
- // a package that imports the first one and does use *T pointers.
- // The second module will end up defining type data for *T and a
- // type.*T symbol pointing at it. It's important that calling
- // .PtrTo() on the reflect.Type for T returns this type data and
- // not some synthesized object, so we need reflect to be able to
- // find it!
- if !Ctxt.Flag_dynlink {
- break
- }
- fallthrough
- case TARRAY, TCHAN, TFUNC, TMAP:
+ case TPTR32, TPTR64, TARRAY, TCHAN, TFUNC, TMAP:
slink := typelinksym(t)
dsymptr(slink, 0, s, 0)
ggloblsym(slink, int32(Widthptr), int16(dupok|obj.RODATA))
gcdata *byte // garbage collection data
string string // string form; unnecessary but undeniably useful
*uncommonType // (relatively) uncommon fields
- ptrToThis *rtype // type for pointer to this type, if used in binary or has methods
}
// a copy of runtime.typeAlg
}
func (t *rtype) ptrTo() *rtype {
- if p := t.ptrToThis; p != nil {
- return p
- }
-
- // Otherwise, synthesize one.
- // This only happens for pointers with no methods.
- // We keep the mapping in a map on the side, because
- // this operation is rare and a separate map lets us keep
- // the type structures in read-only memory.
+ // Check the cache.
ptrMap.RLock()
if m := ptrMap.m; m != nil {
if p := m[t]; p != nil {
}
}
ptrMap.RUnlock()
+
ptrMap.Lock()
if ptrMap.m == nil {
ptrMap.m = make(map[*rtype]*ptrType)
p.hash = fnv1(t.hash, '*')
p.uncommonType = nil
- p.ptrToThis = nil
p.elem = t
ptrMap.m[t] = p
// Note that strings are not unique identifiers for types:
// there can be more than one with a given string.
// Only types we might want to look up are included:
-// channels, maps, slices, and arrays.
+// pointers, channels, maps, slices, and arrays.
func typelinks() [][]*rtype
// typesByString returns the subslice of typelinks() whose elements have
ch.hash = fnv1(typ.hash, 'c', byte(dir))
ch.elem = typ
ch.uncommonType = nil
- ch.ptrToThis = nil
return cachePut(ckey, &ch.rtype)
}
mt.reflexivekey = isReflexive(ktyp)
mt.needkeyupdate = needKeyUpdate(ktyp)
mt.uncommonType = nil
- mt.ptrToThis = nil
return cachePut(ckey, &mt.rtype)
}
// Populate the remaining fields of ft and store in cache.
ft.string = str
ft.uncommonType = nil
- ft.ptrToThis = nil
funcLookupCache.m[hash] = append(funcLookupCache.m[hash], &ft.rtype)
return &ft.rtype
slice.hash = fnv1(typ.hash, '[')
slice.elem = typ
slice.uncommonType = nil
- slice.ptrToThis = nil
return cachePut(ckey, &slice.rtype)
}
array.align = typ.align
array.fieldAlign = typ.fieldAlign
array.uncommonType = nil
- array.ptrToThis = nil
array.len = uintptr(count)
array.slice = slice.(*rtype)
func itab_callback(tab *itab) {
t := tab._type
- // Dump a map from itab* to the type of its data field.
- // We want this map so we can deduce types of interface referents.
- if t.kind&kindDirectIface == 0 {
- // indirect - data slot is a pointer to t.
- dumptype(t.ptrto)
- dumpint(tagItab)
- dumpint(uint64(uintptr(unsafe.Pointer(tab))))
- dumpint(uint64(uintptr(unsafe.Pointer(t.ptrto))))
- } else if t.kind&kindNoPointers == 0 {
- // t is pointer-like - data slot is a t.
- dumptype(t)
- dumpint(tagItab)
- dumpint(uint64(uintptr(unsafe.Pointer(tab))))
- dumpint(uint64(uintptr(unsafe.Pointer(t))))
- } else {
- // Data slot is a scalar. Dump type just for fun.
- // With pointer-only interfaces, this shouldn't happen.
- dumptype(t)
- dumpint(tagItab)
- dumpint(uint64(uintptr(unsafe.Pointer(tab))))
- dumpint(uint64(uintptr(unsafe.Pointer(t))))
- }
+ dumptype(t)
+ dumpint(tagItab)
+ dumpint(uint64(uintptr(unsafe.Pointer(tab))))
+ dumpint(uint64(uintptr(unsafe.Pointer(t))))
}
func dumpitabs() {
}
}
-var dumphdr = []byte("go1.6 heap dump\n")
+var dumphdr = []byte("go1.7 heap dump\n")
func mdump() {
// make sure we're done sweeping