Reduces binary size of cmd/go by 1%.
For #6853.
Change-Id: I6f2992a4dd3699db1b532ab08683e82741b9c2e4
Reviewed-on: https://go-review.googlesource.com/19692
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
} else {
ot = dsymptr(s, ot, algsym, 0)
}
- ot = dsymptr(s, ot, gcsym, 0)
+ ot = dsymptr(s, ot, gcsym, 0) // gcdata
p := Tconv(t, obj.FmtLeft|obj.FmtUnsigned)
- //print("dcommontype: %s\n", p);
- ot = dgostringptr(s, ot, p) // string
+ _, symdata := stringsym(p) // string
+ ot = dsymptr(s, ot, symdata, 0)
+ ot = duintxx(s, ot, uint64(len(p)), Widthint)
+ //fmt.Printf("dcommontype: %s\n", p)
// skip pointer to extraType,
// which follows the rest of this type structure.
// commonsize returns the size of the common prefix for all type
// structures (runtime._type).
func commonsize() int {
- return 7*Thearch.Ptrsize + 8
+ return 8*Thearch.Ptrsize + 8
}
// Type.commonType.kind
var r []string
for _, m := range typelinks() {
for _, t := range m {
- r = append(r, *t.string)
+ r = append(r, t.string)
}
}
return r
kind uint8 // enumeration for C
alg *typeAlg // algorithm table
gcdata *byte // garbage collection data
- string *string // string form; unnecessary but undeniably useful
+ 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
}
return *t.name
}
-func (t *rtype) String() string { return *t.string }
+func (t *rtype) String() string { return t.string }
func (t *rtype) Size() uintptr { return t.size }
}
// Look in known types.
- s := "*" + *t.string
+ s := "*" + t.string
for _, tt := range typesByString(s) {
p = (*ptrType)(unsafe.Pointer(tt))
if p.elem == t {
prototype := *(**ptrType)(unsafe.Pointer(&iptr))
*p = *prototype
- p.string = &s
+ p.string = s
// For the type structures linked into the binary, the
// compiler provides a good hash of the string.
for i < j {
h := i + (j-i)/2 // avoid overflow when computing h
// i ≤ h < j
- if !(*typ[h].string >= s) {
+ if !(typ[h].string >= s) {
i = h + 1 // preserves f(i-1) == false
} else {
j = h // preserves f(j) == true
// We could do a second binary search, but the caller is going
// to do a linear scan anyway.
j = i
- for j < len(typ) && *typ[j].string == s {
+ for j < len(typ) && typ[j].string == s {
j++
}
lookupCache.Unlock()
panic("reflect.ChanOf: invalid dir")
case SendDir:
- s = "chan<- " + *typ.string
+ s = "chan<- " + typ.string
case RecvDir:
- s = "<-chan " + *typ.string
+ s = "<-chan " + typ.string
case BothDir:
- s = "chan " + *typ.string
+ s = "chan " + typ.string
}
for _, tt := range typesByString(s) {
ch := (*chanType)(unsafe.Pointer(tt))
ch := new(chanType)
*ch = *prototype
ch.dir = uintptr(dir)
- ch.string = &s
+ ch.string = s
ch.hash = fnv1(typ.hash, 'c', byte(dir))
ch.elem = typ
ch.uncommonType = nil
}
// Look in known types.
- s := "map[" + *ktyp.string + "]" + *etyp.string
+ s := "map[" + ktyp.string + "]" + etyp.string
for _, tt := range typesByString(s) {
mt := (*mapType)(unsafe.Pointer(tt))
if mt.key == ktyp && mt.elem == etyp {
var imap interface{} = (map[unsafe.Pointer]unsafe.Pointer)(nil)
mt := new(mapType)
*mt = **(**mapType)(unsafe.Pointer(&imap))
- mt.string = &s
+ mt.string = s
mt.hash = fnv1(etyp.hash, 'm', byte(ktyp.hash>>24), byte(ktyp.hash>>16), byte(ktyp.hash>>8), byte(ktyp.hash))
mt.key = ktyp
mt.elem = etyp
}
// Populate the remaining fields of ft and store in cache.
- ft.string = &str
+ ft.string = str
ft.uncommonType = nil
ft.ptrToThis = nil
funcLookupCache.m[hash] = append(funcLookupCache.m[hash], &ft.rtype)
}
if ft.dotdotdot && i == len(ft.in)-1 {
repr = append(repr, "..."...)
- repr = append(repr, *(*sliceType)(unsafe.Pointer(t)).elem.string...)
+ repr = append(repr, (*sliceType)(unsafe.Pointer(t)).elem.string...)
} else {
- repr = append(repr, *t.string...)
+ repr = append(repr, t.string...)
}
}
repr = append(repr, ')')
if i > 0 {
repr = append(repr, ", "...)
}
- repr = append(repr, *t.string...)
+ repr = append(repr, t.string...)
}
if len(ft.out) > 1 {
repr = append(repr, ')')
b.ptrdata = ptrdata
b.kind = kind
b.gcdata = gcdata
- s := "bucket(" + *ktyp.string + "," + *etyp.string + ")"
- b.string = &s
+ s := "bucket(" + ktyp.string + "," + etyp.string + ")"
+ b.string = s
return b
}
}
// Look in known types.
- s := "[]" + *typ.string
+ s := "[]" + typ.string
for _, tt := range typesByString(s) {
slice := (*sliceType)(unsafe.Pointer(tt))
if slice.elem == typ {
prototype := *(**sliceType)(unsafe.Pointer(&islice))
slice := new(sliceType)
*slice = *prototype
- slice.string = &s
+ slice.string = s
slice.hash = fnv1(typ.hash, '[')
slice.elem = typ
slice.uncommonType = nil
}
// Look in known types.
- s := "[" + strconv.Itoa(count) + "]" + *typ.string
+ s := "[" + strconv.Itoa(count) + "]" + typ.string
for _, tt := range typesByString(s) {
array := (*arrayType)(unsafe.Pointer(tt))
if array.elem == typ {
prototype := *(**arrayType)(unsafe.Pointer(&iarray))
array := new(arrayType)
*array = *prototype
- array.string = &s
+ array.string = s
array.hash = fnv1(typ.hash, '[')
for n := uint32(count); n > 0; n >>= 8 {
array.hash = fnv1(array.hash, byte(n))
var s string
if rcvr != nil {
- s = "methodargs(" + *rcvr.string + ")(" + *t.string + ")"
+ s = "methodargs(" + rcvr.string + ")(" + t.string + ")"
} else {
- s = "funcargs(" + *t.string + ")"
+ s = "funcargs(" + t.string + ")"
}
- x.string = &s
+ x.string = s
// cache result for future callers
if layoutCache.m == nil {
t := tab._type
fn := t.alg.hash
if fn == nil {
- panic(errorString("hash of unhashable type " + *t._string))
+ panic(errorString("hash of unhashable type " + t._string))
}
if isDirectIface(t) {
return c1 * fn(unsafe.Pointer(&a.data), h^c0)
}
fn := t.alg.hash
if fn == nil {
- panic(errorString("hash of unhashable type " + *t._string))
+ panic(errorString("hash of unhashable type " + t._string))
}
if isDirectIface(t) {
return c1 * fn(unsafe.Pointer(&a.data), h^c0)
}
eq := t.alg.equal
if eq == nil {
- panic(errorString("comparing uncomparable type " + *t._string))
+ panic(errorString("comparing uncomparable type " + t._string))
}
if isDirectIface(t) {
return eq(noescape(unsafe.Pointer(&x.data)), noescape(unsafe.Pointer(&y.data)))
t := xtab._type
eq := t.alg.equal
if eq == nil {
- panic(errorString("comparing uncomparable type " + *t._string))
+ panic(errorString("comparing uncomparable type " + t._string))
}
if isDirectIface(t) {
return eq(noescape(unsafe.Pointer(&x.data)), noescape(unsafe.Pointer(&y.data)))
func typestring(x interface{}) string {
e := efaceOf(&x)
- return *e._type._string
+ return e._type._string
}
// For calling from C.
dumpint(uint64(uintptr(unsafe.Pointer(t))))
dumpint(uint64(t.size))
if t.x == nil || t.x.pkgpath == nil || t.x.name == nil {
- dumpstr(*t._string)
+ dumpstr(t._string)
} else {
pkgpath := stringStructOf(t.x.pkgpath)
name := stringStructOf(t.x.name)
if canfail {
return nil
}
- panic(&TypeAssertionError{"", *typ._string, *inter.typ._string, *inter.mhdr[0].name})
+ panic(&TypeAssertionError{"", typ._string, inter.typ._string, *inter.mhdr[0].name})
}
// compiler has provided some good hash codes for us.
if locked != 0 {
unlock(&ifaceLock)
}
- panic(&TypeAssertionError{"", *typ._string, *inter.typ._string, *iname})
+ panic(&TypeAssertionError{"", typ._string, inter.typ._string, *iname})
}
m.bad = 1
break
func panicdottype(have, want, iface *_type) {
haveString := ""
if have != nil {
- haveString = *have._string
+ haveString = have._string
}
- panic(&TypeAssertionError{*iface._string, haveString, *want._string, ""})
+ panic(&TypeAssertionError{iface._string, haveString, want._string, ""})
}
func assertI2T(t *_type, i iface, r unsafe.Pointer) {
tab := i.tab
if tab == nil {
- panic(&TypeAssertionError{"", "", *t._string, ""})
+ panic(&TypeAssertionError{"", "", t._string, ""})
}
if tab._type != t {
- panic(&TypeAssertionError{*tab.inter.typ._string, *tab._type._string, *t._string, ""})
+ panic(&TypeAssertionError{tab.inter.typ._string, tab._type._string, t._string, ""})
}
if r != nil {
if isDirectIface(t) {
func assertE2T(t *_type, e eface, r unsafe.Pointer) {
if e._type == nil {
- panic(&TypeAssertionError{"", "", *t._string, ""})
+ panic(&TypeAssertionError{"", "", t._string, ""})
}
if e._type != t {
- panic(&TypeAssertionError{"", *e._type._string, *t._string, ""})
+ panic(&TypeAssertionError{"", e._type._string, t._string, ""})
}
if r != nil {
if isDirectIface(t) {
tab := i.tab
if tab == nil {
// explicit conversions require non-nil interface value.
- panic(&TypeAssertionError{"", "", *inter.typ._string, ""})
+ panic(&TypeAssertionError{"", "", inter.typ._string, ""})
}
r._type = tab._type
r.data = i.data
tab := i.tab
if tab == nil {
// explicit conversions require non-nil interface value.
- panic(&TypeAssertionError{"", "", *inter.typ._string, ""})
+ panic(&TypeAssertionError{"", "", inter.typ._string, ""})
}
if tab.inter == inter {
r.tab = tab
t := e._type
if t == nil {
// explicit conversions require non-nil interface value.
- panic(&TypeAssertionError{"", "", *inter.typ._string, ""})
+ panic(&TypeAssertionError{"", "", inter.typ._string, ""})
}
r.tab = getitab(inter, t, false)
r.data = e.data
func assertE2E(inter *interfacetype, e eface, r *eface) {
if e._type == nil {
// explicit conversions require non-nil interface value.
- panic(&TypeAssertionError{"", "", *inter.typ._string, ""})
+ panic(&TypeAssertionError{"", "", inter.typ._string, ""})
}
*r = e
}
throw("runtime: typeBitsBulkBarrier without type")
}
if typ.size != size {
- println("runtime: typeBitsBulkBarrier with type ", *typ._string, " of size ", typ.size, " but memory size", size)
+ println("runtime: typeBitsBulkBarrier with type ", typ._string, " of size ", typ.size, " but memory size", size)
throw("runtime: invalid typeBitsBulkBarrier")
}
if typ.kind&kindGCProg != 0 {
- println("runtime: typeBitsBulkBarrier with type ", *typ._string, " with GC prog")
+ println("runtime: typeBitsBulkBarrier with type ", typ._string, " with GC prog")
throw("runtime: invalid typeBitsBulkBarrier")
}
if !writeBarrier.needed {
}
if nw == 0 {
// No pointers! Caller was supposed to check.
- println("runtime: invalid type ", *typ._string)
+ println("runtime: invalid type ", typ._string)
throw("heapBitsSetType: called with non-pointer type")
return
}
if doubleCheck {
end := heapBitsForAddr(x + size)
if typ.kind&kindGCProg == 0 && (hbitp != end.bitp || (w == nw+2) != (end.shift == 2)) {
- println("ended at wrong bitmap byte for", *typ._string, "x", dataSize/typ.size)
+ println("ended at wrong bitmap byte for", typ._string, "x", dataSize/typ.size)
print("typ.size=", typ.size, " typ.ptrdata=", typ.ptrdata, " dataSize=", dataSize, " size=", size, "\n")
print("w=", w, " nw=", nw, " b=", hex(b), " nb=", nb, " hb=", hex(hb), "\n")
h0 := heapBitsForAddr(x)
}
}
if have != want {
- println("mismatch writing bits for", *typ._string, "x", dataSize/typ.size)
+ println("mismatch writing bits for", typ._string, "x", dataSize/typ.size)
print("typ.size=", typ.size, " typ.ptrdata=", typ.ptrdata, " dataSize=", dataSize, " size=", size, "\n")
print("kindGCProg=", typ.kind&kindGCProg != 0, "\n")
print("w=", w, " nw=", nw, " b=", hex(b), " nb=", nb, " hb=", hex(hb), "\n")
throw("runtime.SetFinalizer: first argument is nil")
}
if etyp.kind&kindMask != kindPtr {
- throw("runtime.SetFinalizer: first argument is " + *etyp._string + ", not pointer")
+ throw("runtime.SetFinalizer: first argument is " + etyp._string + ", not pointer")
}
ot := (*ptrtype)(unsafe.Pointer(etyp))
if ot.elem == nil {
}
if ftyp.kind&kindMask != kindFunc {
- 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))
if ft.dotdotdot || len(ft.in) != 1 {
- throw("runtime.SetFinalizer: cannot pass " + *etyp._string + " to finalizer " + *ftyp._string)
+ throw("runtime.SetFinalizer: cannot pass " + etyp._string + " to finalizer " + ftyp._string)
}
fint := ft.in[0]
switch {
goto okarg
}
}
- throw("runtime.SetFinalizer: cannot pass " + *etyp._string + " to finalizer " + *ftyp._string)
+ throw("runtime.SetFinalizer: cannot pass " + etyp._string + " to finalizer " + ftyp._string)
okarg:
// compute size needed for return parameters
nret := uintptr(0)
if typ == nil {
print("tracealloc(", p, ", ", hex(size), ")\n")
} else {
- print("tracealloc(", p, ", ", hex(size), ", ", *typ._string, ")\n")
+ print("tracealloc(", p, ", ", hex(size), ", ", typ._string, ")\n")
}
if gp.m.curg == nil || gp == gp.m.curg {
goroutineheader(gp)
// If the KindGCProg bit is set in kind, gcdata is a GC program.
// Otherwise it is a ptrmask bitmap. See mbitmap.go for details.
gcdata *byte
- _string *string
+ _string string
x *uncommontype
ptrto *_type
}