Commit 758b5b32 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: make Stksize local

Passes toolstash -cmp. No compiler performance impact.

Updates #15756

Change-Id: I85b45244453ae28d4da76be4313badddcbf3f5dc
Reviewed-on: https://go-review.googlesource.com/38330
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent e0a5e69b
...@@ -1199,8 +1199,6 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) { ...@@ -1199,8 +1199,6 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
} }
func funccompile(n *Node) { func funccompile(n *Node) {
Stksize = BADWIDTH
if n.Type == nil { if n.Type == nil {
if nerrors == 0 { if nerrors == 0 {
Fatalf("funccompile missing type") Fatalf("funccompile missing type")
...@@ -1215,7 +1213,6 @@ func funccompile(n *Node) { ...@@ -1215,7 +1213,6 @@ func funccompile(n *Node) {
Fatalf("funccompile %v inside %v", n.Func.Nname.Sym, Curfn.Func.Nname.Sym) Fatalf("funccompile %v inside %v", n.Func.Nname.Sym, Curfn.Func.Nname.Sym)
} }
Stksize = 0
dclcontext = PAUTO dclcontext = PAUTO
funcdepth = n.Func.Depth + 1 funcdepth = n.Func.Depth + 1
compile(n) compile(n)
......
...@@ -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 Stksize int64 // stack size for current frame
var stkptrsize int64 // prefix of stack containing pointers var stkptrsize int64 // prefix of stack containing pointers
var Curfn *Node var Curfn *Node
......
...@@ -221,7 +221,7 @@ func (s byStackVar) Swap(i, j int) { s[i], s[j] = s[j], s[i] } ...@@ -221,7 +221,7 @@ func (s byStackVar) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
var scratchFpMem *Node var scratchFpMem *Node
func (s *ssafn) AllocFrame(f *ssa.Func) { func (s *ssafn) AllocFrame(f *ssa.Func) {
Stksize = 0 s.stksize = 0
stkptrsize = 0 stkptrsize = 0
fn := s.curfn.Func fn := s.curfn.Func
...@@ -277,22 +277,22 @@ func (s *ssafn) AllocFrame(f *ssa.Func) { ...@@ -277,22 +277,22 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
if w >= thearch.MAXWIDTH || w < 0 { if w >= thearch.MAXWIDTH || w < 0 {
Fatalf("bad width") Fatalf("bad width")
} }
Stksize += w s.stksize += w
Stksize = Rnd(Stksize, int64(n.Type.Align)) s.stksize = Rnd(s.stksize, int64(n.Type.Align))
if haspointers(n.Type) { if haspointers(n.Type) {
stkptrsize = Stksize 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) {
Stksize = Rnd(Stksize, int64(Widthptr)) s.stksize = Rnd(s.stksize, int64(Widthptr))
} }
if Stksize >= 1<<31 { if s.stksize >= 1<<31 {
yyerrorl(s.curfn.Pos, "stack frame too large (>2GB)") yyerrorl(s.curfn.Pos, "stack frame too large (>2GB)")
} }
n.Xoffset = -Stksize n.Xoffset = -s.stksize
} }
Stksize = Rnd(Stksize, int64(Widthreg)) s.stksize = Rnd(s.stksize, int64(Widthreg))
stkptrsize = Rnd(stkptrsize, int64(Widthreg)) stkptrsize = Rnd(stkptrsize, int64(Widthreg))
} }
......
...@@ -4357,7 +4357,7 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) { ...@@ -4357,7 +4357,7 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) {
liveness(e.curfn, ptxt, gcargs, gclocals) liveness(e.curfn, ptxt, gcargs, gclocals)
// Add frame prologue. Zero ambiguously live variables. // Add frame prologue. Zero ambiguously live variables.
thearch.Defframe(ptxt, e.curfn, Stksize+s.maxarg) thearch.Defframe(ptxt, e.curfn, e.stksize+s.maxarg)
if Debug['f'] != 0 { if Debug['f'] != 0 {
frame(0) frame(0)
} }
...@@ -4668,6 +4668,7 @@ func fieldIdx(n *Node) int { ...@@ -4668,6 +4668,7 @@ func fieldIdx(n *Node) int {
// It also exports a bunch of compiler services for the ssa backend. // It also exports a bunch of compiler services for the ssa backend.
type ssafn struct { type ssafn struct {
curfn *Node curfn *Node
stksize int64 // stack size for current frame
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