]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: keep pointer input arguments live throughout function
authorKeith Randall <khr@golang.org>
Fri, 22 Apr 2016 02:28:28 +0000 (19:28 -0700)
committerKeith Randall <khr@golang.org>
Wed, 18 May 2016 19:25:27 +0000 (19:25 +0000)
commit3572c6418b5032fbd7e888e14fd9ad5afac85dfc
treef35b61226320fbee9b50dde209307dad97e0604b
parentd52022676da939cb183083da4ee0b614f86ac3b0
cmd/compile: keep pointer input arguments live throughout function

Introduce a KeepAlive op which makes sure that its argument is kept
live until the KeepAlive.  Use KeepAlive to mark pointer input
arguments as live after each function call and at each return.

We do this change only for pointer arguments.  Those are the
critical ones to handle because they might have finalizers.
Doing compound arguments (slices, structs, ...) is more complicated
because we would need to track field liveness individually (we do
that for auto variables now, but inputs requires extra trickery).

Turn off the automatic marking of args as live.  That way, when args
are explicitly nulled, plive will know that the original argument is
dead.

The KeepAlive op will be the eventual implementation of
runtime.KeepAlive.

Fixes #15277

Change-Id: I5f223e65d99c9f8342c03fbb1512c4d363e903e5
Reviewed-on: https://go-review.googlesource.com/22365
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/gc/plive.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/lower.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/regalloc.go
test/fixedbugs/issue15277.go [new file with mode: 0644]