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: 's avatarMatthew Dempsky <mdempsky@google.com>
parent 758b5b32
......@@ -245,8 +245,6 @@ var dclcontext Class // PEXTERN/PAUTO
var statuniqgen int // name generator for static temps
var stkptrsize int64 // prefix of stack containing pointers
var Curfn *Node
var Widthptr int
......
......@@ -222,7 +222,7 @@ var scratchFpMem *Node
func (s *ssafn) AllocFrame(f *ssa.Func) {
s.stksize = 0
stkptrsize = 0
s.stkptrsize = 0
fn := s.curfn.Func
// Mark the PAUTO's unused.
......@@ -280,7 +280,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
s.stksize += w
s.stksize = Rnd(s.stksize, int64(n.Type.Align))
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) {
s.stksize = Rnd(s.stksize, int64(Widthptr))
......@@ -293,7 +293,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
}
s.stksize = Rnd(s.stksize, int64(Widthreg))
stkptrsize = Rnd(stkptrsize, int64(Widthreg))
s.stkptrsize = Rnd(s.stkptrsize, int64(Widthreg))
}
func compile(fn *Node) {
......
......@@ -85,10 +85,11 @@ type BasicBlock struct {
// A collection of global state used by liveness analysis.
type Liveness struct {
fn *Node
ptxt *obj.Prog
vars []*Node
cfg []*BasicBlock
fn *Node
ptxt *obj.Prog
vars []*Node
cfg []*BasicBlock
stkptrsize int64
// An array with a bit vector for each safe point tracking
// live variables, indexed by bb.rpo.
......@@ -601,12 +602,13 @@ func liveIndex(n *Node, vars []*Node) int32 {
// 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
// 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{
fn: fn,
ptxt: ptxt,
cfg: cfg,
vars: vars,
fn: fn,
ptxt: ptxt,
cfg: cfg,
vars: vars,
stkptrsize: stkptrsize,
}
nblocks := int32(len(cfg))
......@@ -872,8 +874,8 @@ func onebitwalktype1(t *Type, xoffset *int64, bv bvec) {
}
// Returns the number of words of local variables.
func localswords() int32 {
return int32(stkptrsize / int64(Widthptr))
func localswords(lv *Liveness) int32 {
return int32(lv.stkptrsize / int64(Widthptr))
}
// 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
node := vars[i]
switch node.Class {
case PAUTO:
xoffset = node.Xoffset + stkptrsize
xoffset = node.Xoffset + lv.stkptrsize
onebitwalktype1(node.Type, &xoffset, locals)
case PPARAM, PPARAMOUT:
......@@ -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, 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, loff, uint32(locals.n)) // number of bits in each bitmap
......@@ -1609,21 +1611,21 @@ func printprog(p *obj.Prog) {
// Entry pointer for liveness analysis. Constructs a complete CFG, solves for
// the liveness of pointer variables in the function, and emits a runtime data
// 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.
debugdelta := 0
if Curfn.Func.Nname.Sym.Name == "!" {
if e.curfn.Func.Nname.Sym.Name == "!" {
debugdelta = 2
}
debuglive += debugdelta
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)
}
checkptxt(fn, firstp)
checkptxt(e.curfn, firstp)
// Construct the global liveness state.
cfg := newcfg(firstp)
......@@ -1631,8 +1633,8 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
if debuglive >= 3 {
printcfg(cfg)
}
vars := getvariables(fn)
lv := newliveness(fn, firstp, cfg, vars)
vars := getvariables(e.curfn)
lv := newliveness(e.curfn, firstp, cfg, vars, e.stkptrsize)
// Run the dataflow framework.
livenessprologue(lv)
......@@ -1658,7 +1660,7 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
livenessemit(lv, argssym, livesym)
// Free everything.
for _, ln := range fn.Func.Dcl {
for _, ln := range e.curfn.Func.Dcl {
if ln != nil {
ln.SetOpt(nil)
}
......
......@@ -4354,7 +4354,7 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) {
}
// Generate gc bitmaps.
liveness(e.curfn, ptxt, gcargs, gclocals)
liveness(e, ptxt, gcargs, gclocals)
// Add frame prologue. Zero ambiguously live variables.
thearch.Defframe(ptxt, e.curfn, e.stksize+s.maxarg)
......@@ -4667,9 +4667,10 @@ func fieldIdx(n *Node) int {
// ssafn holds frontend information about a function that the backend is processing.
// It also exports a bunch of compiler services for the ssa backend.
type ssafn struct {
curfn *Node
stksize int64 // stack size for current frame
log bool
curfn *Node
stksize int64 // stack size for current frame
stkptrsize int64 // prefix of stack containing pointers
log bool
}
func (s *ssafn) TypeBool() ssa.Type { return Types[TBOOL] }
......
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