mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add go:nowritebarrierrec annotation
This introduces a recursive variant of the go:nowritebarrier annotation that prohibits write barriers not only in the annotated function, but in all functions it calls, recursively. The error message gives the shortest call stack from the annotated function to the function containing the prohibited write barrier, including the names of the functions and the line numbers of the calls. To demonstrate the annotation, we apply it to gcmarkwb_m, the write barrier itself. This is a new annotation rather than a modification of the existing go:nowritebarrier annotation because, for better or worse, there are many go:nowritebarrier functions that do call functions with write barriers. In most of these cases this is benign because the annotation was conservative, but it prohibits simply coopting the existing annotation. Change-Id: I225ca483c8f699e8436373ed96349e80ca2c2479 Reviewed-on: https://go-review.googlesource.com/16554 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
2780abd645
commit
3a765430c1
7 changed files with 161 additions and 19 deletions
|
|
@ -479,6 +479,10 @@ func Main() {
|
|||
fninit(xtop)
|
||||
}
|
||||
|
||||
if compiling_runtime != 0 {
|
||||
checknowritebarrierrec()
|
||||
}
|
||||
|
||||
// Phase 9: Check external declarations.
|
||||
for i, n := range externdcl {
|
||||
if n.Op == ONAME {
|
||||
|
|
@ -1682,6 +1686,15 @@ func getlinepragma() int {
|
|||
nowritebarrier = true
|
||||
return c
|
||||
}
|
||||
|
||||
if verb == "go:nowritebarrierrec" {
|
||||
if compiling_runtime == 0 {
|
||||
Yyerror("//go:nowritebarrierrec only allowed in runtime")
|
||||
}
|
||||
nowritebarrierrec = true
|
||||
nowritebarrier = true // Implies nowritebarrier
|
||||
return c
|
||||
}
|
||||
return c
|
||||
}
|
||||
if c != 'l' {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue