Commit 157f0698 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: call missing popdcl in various genxxx functions

Not calling popdcl doesn't have an impact on generated code but
the result is a growing (rather than empty) stack of symbols,
possibly causing more data to remain alive than necessary.

Also: minor cleanups.

Change-Id: Ic4fdbcd8843637d69ab1aa15e896a7e6339bc990
Reviewed-on: https://go-review.googlesource.com/20554Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
parent 88a21ebb
......@@ -280,6 +280,8 @@ func genhash(sym *Sym, t *Type) {
typecheck(&fn, Etop)
typechecklist(fn.Nbody.Slice(), Etop)
Curfn = nil
popdcl()
testdclstack()
// Disable safemode while compiling this code: the code we
// generate internally can refer to unsafe.Pointer.
......@@ -472,6 +474,8 @@ func geneq(sym *Sym, t *Type) {
typecheck(&fn, Etop)
typechecklist(fn.Nbody.Slice(), Etop)
Curfn = nil
popdcl()
testdclstack()
// Disable safemode while compiling this code: the code we
// generate internally can refer to unsafe.Pointer.
......
......@@ -76,9 +76,10 @@ type Sym struct {
Pkg *Pkg
Name string // variable name
Def *Node // definition: ONAME OTYPE OPACK or OLITERAL
Label *Label // corresponding label (ephemeral)
Block int32 // blocknumber to catch redeclaration
Lastlineno int32 // last declaration for diagnostic
Label *Label // corresponding label (ephemeral)
Origpkg *Pkg // original package for . import
Lsym *obj.LSym
Fsym *Sym // funcsym
......
......@@ -2142,8 +2142,8 @@ func (p *parser) structdcl() []*Node {
typ := p.ntype()
tag := p.oliteral()
if l := fields; len(l) == 0 || l[0].Sym.Name == "?" {
// ? symbol, during import (list1(nil) == nil)
if len(fields) == 0 || fields[0].Sym.Name == "?" {
// ? symbol, during import
n := typ
if n.Op == OIND {
n = n.Left
......
......@@ -2030,6 +2030,8 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
funcbody(fn)
Curfn = fn
popdcl()
testdclstack()
// wrappers where T is anonymous (struct or interface) can be duplicated.
if rcvr.Etype == TSTRUCT || rcvr.Etype == TINTER || Isptr[rcvr.Etype] && rcvr.Type.Etype == TSTRUCT {
......
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