cmd/internal/obj: Use bitfield for LSym attributes

Reduces the size of LSym struct.

On 32bit: before 84  after 76
On 64bit: before 136 after 128

name       old time/op     new time/op     delta
Template       182ms ± 3%      182ms ± 3%    ~           (p=0.607 n=19+20)
Unicode       93.5ms ± 4%     94.2ms ± 3%    ~           (p=0.141 n=20+19)
GoTypes        608ms ± 1%      605ms ± 2%    ~           (p=0.056 n=20+20)

name       old user-ns/op  new user-ns/op  delta
Template        249M ± 7%       249M ± 4%    ~           (p=0.605 n=18+19)
Unicode         149M ±14%       151M ± 5%    ~           (p=0.724 n=20+17)
GoTypes         855M ± 4%       853M ± 3%    ~           (p=0.537 n=19+19)

name       old alloc/op    new alloc/op    delta
Template      40.3MB ± 0%     40.3MB ± 0%  -0.11%        (p=0.000 n=19+20)
Unicode       33.8MB ± 0%     33.8MB ± 0%  -0.08%        (p=0.000 n=20+20)
GoTypes        119MB ± 0%      119MB ± 0%  -0.10%        (p=0.000 n=19+20)

name       old allocs/op   new allocs/op   delta
Template        383k ± 0%       383k ± 0%    ~           (p=0.703 n=20+20)
Unicode         317k ± 0%       317k ± 0%    ~           (p=0.982 n=19+18)
GoTypes        1.14M ± 0%      1.14M ± 0%    ~           (p=0.086 n=20+20)

Change-Id: Id6ba0db3ecc4503a4e9af3ed0d5884d4366e8bf9
Reviewed-on: https://go-review.googlesource.com/31870
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Shahar Kohanim <skohanim@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
shaharko 2016-10-24 23:15:41 +03:00 committed by Shahar Kohanim
parent 2ee82edfc2
commit d391dc260a
16 changed files with 134 additions and 109 deletions

View file

@ -320,19 +320,19 @@ func (w *objWriter) writeSymDebug(s *LSym) {
if s.Type != 0 {
fmt.Fprintf(ctxt.Bso, "t=%d ", s.Type)
}
if s.Dupok {
if s.DuplicateOK() {
fmt.Fprintf(ctxt.Bso, "dupok ")
}
if s.Cfunc {
if s.CFunc() {
fmt.Fprintf(ctxt.Bso, "cfunc ")
}
if s.Nosplit {
if s.NoSplit() {
fmt.Fprintf(ctxt.Bso, "nosplit ")
}
fmt.Fprintf(ctxt.Bso, "size=%d", s.Size)
if s.Type == STEXT {
fmt.Fprintf(ctxt.Bso, " args=%#x locals=%#x", uint64(s.Args), uint64(s.Locals))
if s.Leaf {
if s.Leaf() {
fmt.Fprintf(ctxt.Bso, " leaf")
}
}
@ -391,13 +391,13 @@ func (w *objWriter) writeSym(s *LSym) {
w.writeInt(int64(s.Type))
w.writeRefIndex(s)
flags := int64(0)
if s.Dupok {
if s.DuplicateOK() {
flags |= 1
}
if s.Local {
if s.Local() {
flags |= 1 << 1
}
if s.MakeTypelink {
if s.MakeTypelink() {
flags |= 1 << 2
}
w.writeInt(flags)
@ -422,19 +422,19 @@ func (w *objWriter) writeSym(s *LSym) {
w.writeInt(int64(s.Args))
w.writeInt(int64(s.Locals))
if s.Nosplit {
if s.NoSplit() {
w.writeInt(1)
} else {
w.writeInt(0)
}
flags = int64(0)
if s.Leaf {
if s.Leaf() {
flags |= 1
}
if s.Cfunc {
if s.CFunc() {
flags |= 1 << 1
}
if s.ReflectMethod {
if s.ReflectMethod() {
flags |= 1 << 2
}
w.writeInt(flags)
@ -560,7 +560,7 @@ func gendwarf(ctxt *Link, text []*LSym) []*LSym {
}
dw = append(dw, dsym)
dsym.Type = SDWARFINFO
dsym.Dupok = s.Dupok
dsym.Set(AttrDuplicateOK, s.DuplicateOK())
var vars dwarf.Var
var abbrev int
var offs int32