Commit 2326c24c authored by Marvin Stenger's avatar Marvin Stenger Committed by David Crawshaw

cmd/internal/obj: convert fields of LSym from uint8 to bool

No performance regression measurable:

name      old time/op    new time/op    delta
Template     432ms ± 3%     422ms ± 2%  -2.34%   (p=0.010 n=10+9)
GoTypes      1.46s ± 1%     1.46s ± 1%    ~     (p=0.796 n=10+10)
Compiler     7.15s ± 1%     7.14s ± 1%    ~      (p=0.447 n=10+9)

Change-Id: I21b93cb989017b6fec2215de2423d87f25cf538c
Reviewed-on: https://go-review.googlesource.com/21220Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 8eec2bbf
...@@ -135,7 +135,7 @@ func gcsymdup(s *Sym) { ...@@ -135,7 +135,7 @@ func gcsymdup(s *Sym) {
Fatalf("cannot rosymdup %s with relocations", ls.Name) Fatalf("cannot rosymdup %s with relocations", ls.Name)
} }
ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P)) ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P))
ls.Dupok = 1 ls.Dupok = true
} }
func emitptrargsmap() { func emitptrargsmap() {
...@@ -442,7 +442,7 @@ func compile(fn *Node) { ...@@ -442,7 +442,7 @@ func compile(fn *Node) {
ptxt.From3.Offset |= obj.REFLECTMETHOD ptxt.From3.Offset |= obj.REFLECTMETHOD
} }
if fn.Func.Pragma&Systemstack != 0 { if fn.Func.Pragma&Systemstack != 0 {
ptxt.From.Sym.Cfunc = 1 ptxt.From.Sym.Cfunc = true
} }
// Clumsy but important. // Clumsy but important.
......
...@@ -367,7 +367,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -367,7 +367,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
if cursym.Text.Mark&LEAF != 0 { if cursym.Text.Mark&LEAF != 0 {
cursym.Leaf = 1 cursym.Leaf = true
if autosize == 0 { if autosize == 0 {
break break
} }
...@@ -709,7 +709,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -709,7 +709,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_MEM p.From.Type = obj.TYPE_MEM
p.From.Reg = REGG p.From.Reg = REGG
p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
...@@ -822,7 +822,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -822,7 +822,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
call.To.Type = obj.TYPE_BRANCH call.To.Type = obj.TYPE_BRANCH
morestack := "runtime.morestack" morestack := "runtime.morestack"
switch { switch {
case ctxt.Cursym.Cfunc != 0: case ctxt.Cursym.Cfunc:
morestack = "runtime.morestackc" morestack = "runtime.morestackc"
case ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0: case ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0:
morestack = "runtime.morestack_noctxt" morestack = "runtime.morestack_noctxt"
......
...@@ -57,7 +57,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -57,7 +57,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_MEM p.From.Type = obj.TYPE_MEM
p.From.Reg = REGG p.From.Reg = REGG
p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
...@@ -193,7 +193,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -193,7 +193,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
call.To.Type = obj.TYPE_BRANCH call.To.Type = obj.TYPE_BRANCH
morestack := "runtime.morestack" morestack := "runtime.morestack"
switch { switch {
case ctxt.Cursym.Cfunc != 0: case ctxt.Cursym.Cfunc:
morestack = "runtime.morestackc" morestack = "runtime.morestackc"
case ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0: case ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0:
morestack = "runtime.morestack_noctxt" morestack = "runtime.morestack_noctxt"
...@@ -718,7 +718,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -718,7 +718,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
aoffset = 0xF0 aoffset = 0xF0
} }
if cursym.Text.Mark&LEAF != 0 { if cursym.Text.Mark&LEAF != 0 {
cursym.Leaf = 1 cursym.Leaf = true
if ctxt.Autosize == 0 { if ctxt.Autosize == 0 {
break break
} }
......
...@@ -309,12 +309,12 @@ type LSym struct { ...@@ -309,12 +309,12 @@ type LSym struct {
Name string Name string
Type int16 Type int16
Version int16 Version int16
Dupok uint8 Dupok bool
Cfunc uint8 Cfunc bool
Nosplit uint8 Nosplit bool
Leaf uint8 Leaf bool
Seenglobl uint8 Seenglobl bool
Onlist uint8 Onlist bool
// ReflectMethod means the function may call reflect.Type.Method or // ReflectMethod means the function may call reflect.Type.Method or
// reflect.Type.MethodByName. Matching is imprecise (as reflect.Type // reflect.Type.MethodByName. Matching is imprecise (as reflect.Type
......
...@@ -302,7 +302,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -302,7 +302,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
if cursym.Text.Mark&LEAF != 0 { if cursym.Text.Mark&LEAF != 0 {
cursym.Leaf = 1 cursym.Leaf = true
break break
} }
...@@ -560,7 +560,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -560,7 +560,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_MEM p.From.Type = obj.TYPE_MEM
p.From.Reg = REGG p.From.Reg = REGG
p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
...@@ -690,7 +690,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -690,7 +690,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
p.As = AJAL p.As = AJAL
p.To.Type = obj.TYPE_BRANCH p.To.Type = obj.TYPE_BRANCH
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.To.Sym = obj.Linklookup(ctxt, "runtime.morestackc", 0) p.To.Sym = obj.Linklookup(ctxt, "runtime.morestackc", 0)
} else if ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0 { } else if ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0 {
p.To.Sym = obj.Linklookup(ctxt, "runtime.morestack_noctxt", 0) p.To.Sym = obj.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
......
...@@ -170,15 +170,14 @@ func flushplist(ctxt *Link, freeProgs bool) { ...@@ -170,15 +170,14 @@ func flushplist(ctxt *Link, freeProgs bool) {
case AGLOBL: case AGLOBL:
s := p.From.Sym s := p.From.Sym
tmp6 := s.Seenglobl if s.Seenglobl {
s.Seenglobl++
if tmp6 != 0 {
fmt.Printf("duplicate %v\n", p) fmt.Printf("duplicate %v\n", p)
} }
if s.Onlist != 0 { s.Seenglobl = true
if s.Onlist {
log.Fatalf("symbol %s listed multiple times", s.Name) log.Fatalf("symbol %s listed multiple times", s.Name)
} }
s.Onlist = 1 s.Onlist = true
ctxt.Data = append(ctxt.Data, s) ctxt.Data = append(ctxt.Data, s)
s.Size = p.To.Offset s.Size = p.To.Offset
if s.Type == 0 || s.Type == SXREF { if s.Type == 0 || s.Type == SXREF {
...@@ -186,7 +185,7 @@ func flushplist(ctxt *Link, freeProgs bool) { ...@@ -186,7 +185,7 @@ func flushplist(ctxt *Link, freeProgs bool) {
} }
flag := int(p.From3.Offset) flag := int(p.From3.Offset)
if flag&DUPOK != 0 { if flag&DUPOK != 0 {
s.Dupok = 1 s.Dupok = true
} }
if flag&RODATA != 0 { if flag&RODATA != 0 {
s.Type = SRODATA s.Type = SRODATA
...@@ -209,17 +208,17 @@ func flushplist(ctxt *Link, freeProgs bool) { ...@@ -209,17 +208,17 @@ func flushplist(ctxt *Link, freeProgs bool) {
if s.Text != nil { if s.Text != nil {
log.Fatalf("duplicate TEXT for %s", s.Name) log.Fatalf("duplicate TEXT for %s", s.Name)
} }
if s.Onlist != 0 { if s.Onlist {
log.Fatalf("symbol %s listed multiple times", s.Name) log.Fatalf("symbol %s listed multiple times", s.Name)
} }
s.Onlist = 1 s.Onlist = true
text = append(text, s) text = append(text, s)
flag := int(p.From3Offset()) flag := int(p.From3Offset())
if flag&DUPOK != 0 { if flag&DUPOK != 0 {
s.Dupok = 1 s.Dupok = true
} }
if flag&NOSPLIT != 0 { if flag&NOSPLIT != 0 {
s.Nosplit = 1 s.Nosplit = true
} }
if flag&REFLECTMETHOD != 0 { if flag&REFLECTMETHOD != 0 {
s.ReflectMethod = true s.ReflectMethod = true
...@@ -437,19 +436,19 @@ func writesym(ctxt *Link, b *Biobuf, s *LSym) { ...@@ -437,19 +436,19 @@ func writesym(ctxt *Link, b *Biobuf, s *LSym) {
if s.Type != 0 { if s.Type != 0 {
fmt.Fprintf(ctxt.Bso, "t=%d ", s.Type) fmt.Fprintf(ctxt.Bso, "t=%d ", s.Type)
} }
if s.Dupok != 0 { if s.Dupok {
fmt.Fprintf(ctxt.Bso, "dupok ") fmt.Fprintf(ctxt.Bso, "dupok ")
} }
if s.Cfunc != 0 { if s.Cfunc {
fmt.Fprintf(ctxt.Bso, "cfunc ") fmt.Fprintf(ctxt.Bso, "cfunc ")
} }
if s.Nosplit != 0 { if s.Nosplit {
fmt.Fprintf(ctxt.Bso, "nosplit ") fmt.Fprintf(ctxt.Bso, "nosplit ")
} }
fmt.Fprintf(ctxt.Bso, "size=%d", s.Size) fmt.Fprintf(ctxt.Bso, "size=%d", s.Size)
if s.Type == STEXT { if s.Type == STEXT {
fmt.Fprintf(ctxt.Bso, " args=%#x locals=%#x", uint64(s.Args), uint64(s.Locals)) fmt.Fprintf(ctxt.Bso, " args=%#x locals=%#x", uint64(s.Args), uint64(s.Locals))
if s.Leaf != 0 { if s.Leaf {
fmt.Fprintf(ctxt.Bso, " leaf") fmt.Fprintf(ctxt.Bso, " leaf")
} }
} }
...@@ -499,9 +498,12 @@ func writesym(ctxt *Link, b *Biobuf, s *LSym) { ...@@ -499,9 +498,12 @@ func writesym(ctxt *Link, b *Biobuf, s *LSym) {
Bputc(b, 0xfe) Bputc(b, 0xfe)
wrint(b, int64(s.Type)) wrint(b, int64(s.Type))
wrsym(b, s) wrsym(b, s)
flags := int64(s.Dupok) flags := int64(0)
if s.Dupok {
flags |= 1
}
if s.Local { if s.Local {
flags |= 2 flags |= 1 << 1
} }
wrint(b, flags) wrint(b, flags)
wrint(b, s.Size) wrint(b, s.Size)
...@@ -522,8 +524,18 @@ func writesym(ctxt *Link, b *Biobuf, s *LSym) { ...@@ -522,8 +524,18 @@ func writesym(ctxt *Link, b *Biobuf, s *LSym) {
if s.Type == STEXT { if s.Type == STEXT {
wrint(b, int64(s.Args)) wrint(b, int64(s.Args))
wrint(b, int64(s.Locals)) wrint(b, int64(s.Locals))
wrint(b, int64(s.Nosplit)) if s.Nosplit {
flags := int64(s.Leaf) | int64(s.Cfunc)<<1 wrint(b, 1)
} else {
wrint(b, 0)
}
flags := int64(0)
if s.Leaf {
flags |= 1
}
if s.Cfunc {
flags |= 1 << 1
}
if s.ReflectMethod { if s.ReflectMethod {
flags |= 1 << 2 flags |= 1 << 2
} }
......
...@@ -534,7 +534,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -534,7 +534,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
if cursym.Text.Mark&LEAF != 0 { if cursym.Text.Mark&LEAF != 0 {
cursym.Leaf = 1 cursym.Leaf = true
break break
} }
...@@ -828,7 +828,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -828,7 +828,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_MEM p.From.Type = obj.TYPE_MEM
p.From.Reg = REGG p.From.Reg = REGG
p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
...@@ -943,7 +943,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog { ...@@ -943,7 +943,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
} }
var morestacksym *obj.LSym var morestacksym *obj.LSym
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
morestacksym = obj.Linklookup(ctxt, "runtime.morestackc", 0) morestacksym = obj.Linklookup(ctxt, "runtime.morestackc", 0)
} else if ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0 { } else if ctxt.Cursym.Text.From3.Offset&obj.NEEDCTXT == 0 {
morestacksym = obj.Linklookup(ctxt, "runtime.morestack_noctxt", 0) morestacksym = obj.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
......
...@@ -985,7 +985,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob ...@@ -985,7 +985,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob
p.From.Reg = REG_SP p.From.Reg = REG_SP
indir_cx(ctxt, p, &p.To) indir_cx(ctxt, p, &p.To)
p.To.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.To.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.To.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.To.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
} else if framesize <= obj.StackBig { } else if framesize <= obj.StackBig {
...@@ -1007,7 +1007,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob ...@@ -1007,7 +1007,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob
p.From.Reg = REG_AX p.From.Reg = REG_AX
indir_cx(ctxt, p, &p.To) indir_cx(ctxt, p, &p.To)
p.To.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.To.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.To.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.To.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
} else { } else {
...@@ -1031,7 +1031,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob ...@@ -1031,7 +1031,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob
p.As = mov p.As = mov
indir_cx(ctxt, p, &p.From) indir_cx(ctxt, p, &p.From)
p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0 p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
if ctxt.Cursym.Cfunc != 0 { if ctxt.Cursym.Cfunc {
p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1 p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
} }
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
...@@ -1095,7 +1095,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob ...@@ -1095,7 +1095,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob
call.To.Type = obj.TYPE_BRANCH call.To.Type = obj.TYPE_BRANCH
morestack := "runtime.morestack" morestack := "runtime.morestack"
switch { switch {
case ctxt.Cursym.Cfunc != 0: case ctxt.Cursym.Cfunc:
morestack = "runtime.morestackc" morestack = "runtime.morestackc"
case ctxt.Cursym.Text.From3Offset()&obj.NEEDCTXT == 0: case ctxt.Cursym.Text.From3Offset()&obj.NEEDCTXT == 0:
morestack = "runtime.morestack_noctxt" morestack = "runtime.morestack_noctxt"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment