diff options
Diffstat (limited to 'src/cmd/compile/internal/ssa/cache.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/cache.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/cache.go b/src/cmd/compile/internal/ssa/cache.go index f1018da497..8434084bde 100644 --- a/src/cmd/compile/internal/ssa/cache.go +++ b/src/cmd/compile/internal/ssa/cache.go @@ -14,6 +14,11 @@ type Cache struct { blocks [200]Block locs [2000]Location + // Storage for DWARF variable locations. Lazily allocated + // since location lists are off by default. + varLocs []VarLoc + curVarLoc int + // Reusable stackAllocState. // See stackalloc.go's {new,put}StackAllocState. stackAllocState *stackAllocState @@ -38,4 +43,21 @@ func (c *Cache) Reset() { for i := range xl { xl[i] = nil } + xvl := c.varLocs[:c.curVarLoc] + for i := range xvl { + xvl[i] = VarLoc{} + } + c.curVarLoc = 0 +} + +func (c *Cache) NewVarLoc() *VarLoc { + if c.varLocs == nil { + c.varLocs = make([]VarLoc, 4000) + } + if c.curVarLoc == len(c.varLocs) { + return &VarLoc{} + } + vl := &c.varLocs[c.curVarLoc] + c.curVarLoc++ + return vl } |