]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: make Stksize local
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 17 Mar 2017 16:10:57 +0000 (09:10 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 17 Mar 2017 23:57:15 +0000 (23:57 +0000)
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: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/ssa.go

index e47cf194a1f6fb3a738b6b783e89d7371e230622..94d18e2256ac29c5794508e413d30eaff7e959cb 100644 (file)
@@ -1199,8 +1199,6 @@ func addmethod(msym *Sym, t *Type, local, nointerface bool) {
 }
 
 func funccompile(n *Node) {
-       Stksize = BADWIDTH
-
        if n.Type == nil {
                if nerrors == 0 {
                        Fatalf("funccompile missing type")
@@ -1215,7 +1213,6 @@ func funccompile(n *Node) {
                Fatalf("funccompile %v inside %v", n.Func.Nname.Sym, Curfn.Func.Nname.Sym)
        }
 
-       Stksize = 0
        dclcontext = PAUTO
        funcdepth = n.Func.Depth + 1
        compile(n)
index 57408e665de0ed3ecaf8bcf628cff63511e8895c..c9fe228feb6680fb2173db6dc1465211f1f27b4c 100644 (file)
@@ -245,8 +245,6 @@ var dclcontext Class // PEXTERN/PAUTO
 
 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 Curfn *Node
index be3b8ac36912c43e73ef8ec8d6b70beba42cbc97..c1cda86ed07df9009cad45321d04b2c8c7bf90d3 100644 (file)
@@ -221,7 +221,7 @@ func (s byStackVar) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
 var scratchFpMem *Node
 
 func (s *ssafn) AllocFrame(f *ssa.Func) {
-       Stksize = 0
+       s.stksize = 0
        stkptrsize = 0
        fn := s.curfn.Func
 
@@ -277,22 +277,22 @@ func (s *ssafn) AllocFrame(f *ssa.Func) {
                if w >= thearch.MAXWIDTH || w < 0 {
                        Fatalf("bad width")
                }
-               Stksize += w
-               Stksize = Rnd(Stksize, int64(n.Type.Align))
+               s.stksize += w
+               s.stksize = Rnd(s.stksize, int64(n.Type.Align))
                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) {
-                       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)")
                }
 
-               n.Xoffset = -Stksize
+               n.Xoffset = -s.stksize
        }
 
-       Stksize = Rnd(Stksize, int64(Widthreg))
+       s.stksize = Rnd(s.stksize, int64(Widthreg))
        stkptrsize = Rnd(stkptrsize, int64(Widthreg))
 }
 
index 29a2728caf9f7a8e98af46112430a54085f88766..dff0d664acf4c2ef6a435b5ddaf42f57775b0ada 100644 (file)
@@ -4357,7 +4357,7 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) {
        liveness(e.curfn, ptxt, gcargs, gclocals)
 
        // 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 {
                frame(0)
        }
@@ -4667,8 +4667,9 @@ 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
-       log   bool
+       curfn   *Node
+       stksize int64 // stack size for current frame
+       log     bool
 }
 
 func (s *ssafn) TypeBool() ssa.Type    { return Types[TBOOL] }