aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/mips
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2017-04-19 11:19:53 -0700
committerKeith Randall <khr@golang.org>2017-04-20 23:47:43 +0000
commit38dee12dea062337a9591b49a9525d85afedc09c (patch)
treef841123575aa8604a67b8a5baa0b1902600ef3f6 /src/cmd/compile/internal/mips
parent7bd1c210858f308ee9a73b6a3b953c477ebb294e (diff)
downloadgo-38dee12dea062337a9591b49a9525d85afedc09c.tar.gz
go-38dee12dea062337a9591b49a9525d85afedc09c.zip
cmd/compile: zero ambiguously live variables at VARKILLs
At VARKILLs, zero a variable if it is ambiguously live. After the VARKILL anything this variable references might be collected. If it were to become live again later, the GC will see references to already-collected objects. We don't know a variable is ambiguously live until very late in compilation (after lowering, register allocation, ...), so it is hard to generate the code in an arch-independent way. We also have to be careful not to clobber any registers. Fortunately, this almost never happens so performance is ~irrelevant. There are only 2 instances where this triggers in the stdlib. Fixes #20029 Change-Id: Ia9585a91d7b823fad4a9d141d954464cc7af31f4 Reviewed-on: https://go-review.googlesource.com/41076 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/mips')
-rw-r--r--src/cmd/compile/internal/mips/galign.go1
-rw-r--r--src/cmd/compile/internal/mips/ggen.go16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/mips/galign.go b/src/cmd/compile/internal/mips/galign.go
index f0ef6cd100..77ec78aabf 100644
--- a/src/cmd/compile/internal/mips/galign.go
+++ b/src/cmd/compile/internal/mips/galign.go
@@ -19,6 +19,7 @@ func Init(arch *gc.Arch) {
arch.REGSP = mips.REGSP
arch.MAXWIDTH = (1 << 31) - 1
arch.ZeroRange = zerorange
+ arch.ZeroAuto = zeroAuto
arch.Ginsnop = ginsnop
arch.SSAMarkMoves = func(s *gc.SSAGenState, b *ssa.Block) {}
arch.SSAGenValue = ssaGenValue
diff --git a/src/cmd/compile/internal/mips/ggen.go b/src/cmd/compile/internal/mips/ggen.go
index dafa341a13..5a9f590763 100644
--- a/src/cmd/compile/internal/mips/ggen.go
+++ b/src/cmd/compile/internal/mips/ggen.go
@@ -43,6 +43,22 @@ func zerorange(pp *gc.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog {
return p
}
+func zeroAuto(pp *gc.Progs, n *gc.Node) {
+ // Note: this code must not clobber any registers.
+ sym := gc.Linksym(n.Sym)
+ size := n.Type.Size()
+ for i := int64(0); i < size; i += 4 {
+ p := pp.Prog(mips.AMOVW)
+ p.From.Type = obj.TYPE_REG
+ p.From.Reg = mips.REGZERO
+ p.To.Type = obj.TYPE_MEM
+ p.To.Name = obj.NAME_AUTO
+ p.To.Reg = mips.REGSP
+ p.To.Offset = n.Xoffset + i
+ p.To.Sym = sym
+ }
+}
+
func ginsnop(pp *gc.Progs) {
p := pp.Prog(mips.ANOR)
p.From.Type = obj.TYPE_REG