mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile, runtime: add go:yeswritebarrierrec pragma
This pragma cancels the effect of go:nowritebarrierrec. This is useful in the scheduler because there are places where we enter a function without a valid P (and hence cannot have write barriers), but then obtain a P. This allows us to annotate the function with go:nowritebarrierrec and split out the part after we've obtained a P into a go:yeswritebarrierrec function. Change-Id: Ic8ce4b6d3c074a1ecd8280ad90eaf39f0ffbcc2a Reviewed-on: https://go-review.googlesource.com/30938 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
6347367be3
commit
a9e6cebde2
6 changed files with 194 additions and 34 deletions
|
|
@ -1317,7 +1317,7 @@ func checknowritebarrierrec() {
|
|||
visitBottomUp(xtop, func(list []*Node, recursive bool) {
|
||||
// Functions with write barriers have depth 0.
|
||||
for _, n := range list {
|
||||
if n.Func.WBLineno != 0 {
|
||||
if n.Func.WBLineno != 0 && n.Func.Pragma&Yeswritebarrierrec == 0 {
|
||||
c.best[n] = nowritebarrierrecCall{target: nil, depth: 0, lineno: n.Func.WBLineno}
|
||||
}
|
||||
}
|
||||
|
|
@ -1329,6 +1329,12 @@ func checknowritebarrierrec() {
|
|||
for _ = range list {
|
||||
c.stable = false
|
||||
for _, n := range list {
|
||||
if n.Func.Pragma&Yeswritebarrierrec != 0 {
|
||||
// Don't propagate write
|
||||
// barrier up to a
|
||||
// yeswritebarrierrec function.
|
||||
continue
|
||||
}
|
||||
if n.Func.WBLineno == 0 {
|
||||
c.curfn = n
|
||||
c.visitcodelist(n.Nbody)
|
||||
|
|
@ -1393,9 +1399,6 @@ func (c *nowritebarrierrecChecker) visitcall(n *Node) {
|
|||
if fn == nil || fn.Op != ONAME || fn.Class != PFUNC || fn.Name.Defn == nil {
|
||||
return
|
||||
}
|
||||
if (compiling_runtime || fn.Sym.Pkg == Runtimepkg) && fn.Sym.Name == "allocm" {
|
||||
return
|
||||
}
|
||||
defn := fn.Name.Defn
|
||||
|
||||
fnbest, ok := c.best[defn]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue