]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: add a writebarrier phase in SSA
authorCherry Zhang <cherryyz@google.com>
Thu, 13 Oct 2016 10:57:00 +0000 (06:57 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 25 Oct 2016 21:53:40 +0000 (21:53 +0000)
commitf6aec889e1c880316b1989bdc6ce3b926cbe5fe4
tree93e8be5693e528cfc887be1c647504349ce07669
parent698bfa17a842890043098b972446e9b8dbc20841
cmd/compile: add a writebarrier phase in SSA

When the compiler insert write barriers, the frontend makes
conservative decisions at an early stage. This may have false
positives which result in write barriers for stack writes.

A new phase, writebarrier, is added to the SSA backend, to delay
the decision and eliminate false positives. The frontend still
makes conservative decisions. When building SSA, instead of
emitting runtime calls directly, it emits WB ops (StoreWB,
MoveWB, etc.), which will be expanded to branches and runtime
calls in writebarrier phase. Writes to static locations on stack
are detected and write barriers are removed.

All write barriers of stack writes found by the script from
issue #17330 are eliminated (except two false positives).

Fixes #17330.

Change-Id: I9bd66333da9d0ceb64dcaa3c6f33502798d1a0f8
Reviewed-on: https://go-review.googlesource.com/31131
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/check.go
src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/config.go
src/cmd/compile/internal/ssa/export_test.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/op.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/value.go
src/cmd/compile/internal/ssa/writebarrier.go [new file with mode: 0644]
test/writebarrier.go