Commit dc4434a0 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: make stkptrsize local

While we're here, also eliminate a few more Curfn uses.

Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: Ib8db9e23467bbaf16cc44bf62d604910f733d6b8
Reviewed-on: https://go-review.googlesource.com/38331
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 758b5b32
...@@ -245,8 +245,6 @@ var dclcontext Class // PEXTERN/PAUTO ...@@ -245,8 +245,6 @@ var dclcontext Class // PEXTERN/PAUTO
var statuniqgen int // name generator for static temps var statuniqgen int // name generator for static temps
var stkptrsize int64 // prefix of stack containing pointers
var Curfn *Node var Curfn *Node
var Widthptr int var Widthptr int
......
...@@ -222,7 +222,7 @@ var scratchFpMem *Node ...@@ -222,7 +222,7 @@ var scratchFpMem *Node
func (s *ssafn) AllocFrame(f *ssa.Func) { func (s *ssafn) AllocFrame(f *ssa.Func) {
s.stksize = 0 s.stksize = 0
stkptrsize = 0 s.stkptrsize = 0
fn := s.curfn.Func fn := s.curfn.Func
// Mark the PAUTO's unused. // Mark the PAUTO's unused.
...@@ -280,7 +280,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) { ...@@ -280,7 +280,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
s.stksize += w s.stksize += w
s.stksize = Rnd(s.stksize, int64(n.Type.Align)) s.stksize = Rnd(s.stksize, int64(n.Type.Align))
if haspointers(n.Type) { if haspointers(n.Type) {
stkptrsize = s.stksize s.stkptrsize = s.stksize
} }
if thearch.LinkArch.InFamily(sys.MIPS, sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) { if thearch.LinkArch.InFamily(sys.MIPS, sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) {
s.stksize = Rnd(s.stksize, int64(Widthptr)) s.stksize = Rnd(s.stksize, int64(Widthptr))
...@@ -293,7 +293,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) { ...@@ -293,7 +293,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
} }
s.stksize = Rnd(s.stksize, int64(Widthreg)) s.stksize = Rnd(s.stksize, int64(Widthreg))
stkptrsize = Rnd(stkptrsize, int64(Widthreg)) s.stkptrsize = Rnd(s.stkptrsize, int64(Widthreg))
} }
func compile(fn *Node) { func compile(fn *Node) {
......
...@@ -89,6 +89,7 @@ type Liveness struct { ...@@ -89,6 +89,7 @@ type Liveness struct {
ptxt *obj.Prog ptxt *obj.Prog
vars []*Node vars []*Node
cfg []*BasicBlock cfg []*BasicBlock
stkptrsize int64
// An array with a bit vector for each safe point tracking // An array with a bit vector for each safe point tracking
// live variables, indexed by bb.rpo. // live variables, indexed by bb.rpo.
...@@ -601,12 +602,13 @@ func liveIndex(n *Node, vars []*Node) int32 { ...@@ -601,12 +602,13 @@ func liveIndex(n *Node, vars []*Node) int32 {
// Constructs a new liveness structure used to hold the global state of the // Constructs a new liveness structure used to hold the global state of the
// liveness computation. The cfg argument is a slice of *BasicBlocks and the // liveness computation. The cfg argument is a slice of *BasicBlocks and the
// vars argument is a slice of *Nodes. // vars argument is a slice of *Nodes.
func newliveness(fn *Node, ptxt *obj.Prog, cfg []*BasicBlock, vars []*Node) *Liveness { func newliveness(fn *Node, ptxt *obj.Prog, cfg []*BasicBlock, vars []*Node, stkptrsize int64) *Liveness {
result := Liveness{ result := Liveness{
fn: fn, fn: fn,
ptxt: ptxt, ptxt: ptxt,
cfg: cfg, cfg: cfg,
vars: vars, vars: vars,
stkptrsize: stkptrsize,
} }
nblocks := int32(len(cfg)) nblocks := int32(len(cfg))
...@@ -872,8 +874,8 @@ func onebitwalktype1(t *Type, xoffset *int64, bv bvec) { ...@@ -872,8 +874,8 @@ func onebitwalktype1(t *Type, xoffset *int64, bv bvec) {
} }
// Returns the number of words of local variables. // Returns the number of words of local variables.
func localswords() int32 { func localswords(lv *Liveness) int32 {
return int32(stkptrsize / int64(Widthptr)) return int32(lv.stkptrsize / int64(Widthptr))
} }
// Returns the number of words of in and out arguments. // Returns the number of words of in and out arguments.
...@@ -895,7 +897,7 @@ func onebitlivepointermap(lv *Liveness, liveout bvec, vars []*Node, args bvec, l ...@@ -895,7 +897,7 @@ func onebitlivepointermap(lv *Liveness, liveout bvec, vars []*Node, args bvec, l
node := vars[i] node := vars[i]
switch node.Class { switch node.Class {
case PAUTO: case PAUTO:
xoffset = node.Xoffset + stkptrsize xoffset = node.Xoffset + lv.stkptrsize
onebitwalktype1(node.Type, &xoffset, locals) onebitwalktype1(node.Type, &xoffset, locals)
case PPARAM, PPARAMOUT: case PPARAM, PPARAMOUT:
...@@ -1581,7 +1583,7 @@ func livenessemit(lv *Liveness, argssym, livesym *Sym) { ...@@ -1581,7 +1583,7 @@ func livenessemit(lv *Liveness, argssym, livesym *Sym) {
aoff := duint32(argssym, 0, uint32(len(lv.livevars))) // number of bitmaps aoff := duint32(argssym, 0, uint32(len(lv.livevars))) // number of bitmaps
aoff = duint32(argssym, aoff, uint32(args.n)) // number of bits in each bitmap aoff = duint32(argssym, aoff, uint32(args.n)) // number of bits in each bitmap
locals := bvalloc(localswords()) locals := bvalloc(localswords(lv))
loff := duint32(livesym, 0, uint32(len(lv.livevars))) // number of bitmaps loff := duint32(livesym, 0, uint32(len(lv.livevars))) // number of bitmaps
loff = duint32(livesym, loff, uint32(locals.n)) // number of bits in each bitmap loff = duint32(livesym, loff, uint32(locals.n)) // number of bits in each bitmap
...@@ -1609,21 +1611,21 @@ func printprog(p *obj.Prog) { ...@@ -1609,21 +1611,21 @@ func printprog(p *obj.Prog) {
// Entry pointer for liveness analysis. Constructs a complete CFG, solves for // Entry pointer for liveness analysis. Constructs a complete CFG, solves for
// the liveness of pointer variables in the function, and emits a runtime data // the liveness of pointer variables in the function, and emits a runtime data
// structure read by the garbage collector. // structure read by the garbage collector.
func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) { func liveness(e *ssafn, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
// Change name to dump debugging information only for a specific function. // Change name to dump debugging information only for a specific function.
debugdelta := 0 debugdelta := 0
if Curfn.Func.Nname.Sym.Name == "!" { if e.curfn.Func.Nname.Sym.Name == "!" {
debugdelta = 2 debugdelta = 2
} }
debuglive += debugdelta debuglive += debugdelta
if debuglive >= 3 { if debuglive >= 3 {
fmt.Printf("liveness: %s\n", Curfn.Func.Nname.Sym.Name) fmt.Printf("liveness: %s\n", e.curfn.Func.Nname.Sym.Name)
printprog(firstp) printprog(firstp)
} }
checkptxt(fn, firstp) checkptxt(e.curfn, firstp)
// Construct the global liveness state. // Construct the global liveness state.
cfg := newcfg(firstp) cfg := newcfg(firstp)
...@@ -1631,8 +1633,8 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) { ...@@ -1631,8 +1633,8 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
if debuglive >= 3 { if debuglive >= 3 {
printcfg(cfg) printcfg(cfg)
} }
vars := getvariables(fn) vars := getvariables(e.curfn)
lv := newliveness(fn, firstp, cfg, vars) lv := newliveness(e.curfn, firstp, cfg, vars, e.stkptrsize)
// Run the dataflow framework. // Run the dataflow framework.
livenessprologue(lv) livenessprologue(lv)
...@@ -1658,7 +1660,7 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) { ...@@ -1658,7 +1660,7 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
livenessemit(lv, argssym, livesym) livenessemit(lv, argssym, livesym)
// Free everything. // Free everything.
for _, ln := range fn.Func.Dcl { for _, ln := range e.curfn.Func.Dcl {
if ln != nil { if ln != nil {
ln.SetOpt(nil) ln.SetOpt(nil)
} }
......
...@@ -4354,7 +4354,7 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) { ...@@ -4354,7 +4354,7 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) {
} }
// Generate gc bitmaps. // Generate gc bitmaps.
liveness(e.curfn, ptxt, gcargs, gclocals) liveness(e, ptxt, gcargs, gclocals)
// Add frame prologue. Zero ambiguously live variables. // Add frame prologue. Zero ambiguously live variables.
thearch.Defframe(ptxt, e.curfn, e.stksize+s.maxarg) thearch.Defframe(ptxt, e.curfn, e.stksize+s.maxarg)
...@@ -4669,6 +4669,7 @@ func fieldIdx(n *Node) int { ...@@ -4669,6 +4669,7 @@ func fieldIdx(n *Node) int {
type ssafn struct { type ssafn struct {
curfn *Node curfn *Node
stksize int64 // stack size for current frame stksize int64 // stack size for current frame
stkptrsize int64 // prefix of stack containing pointers
log bool log bool
} }
......
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