mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime, cmd/compile: rename memclr -> memclrNoHeapPointers
Since barrier-less memclr is only safe in very narrow circumstances, this commit renames memclr to avoid accidentally calling memclr on typed memory. This can cause subtle, non-deterministic bugs, so it's worth some effort to prevent. In the near term, this will also prevent bugs creeping in from any concurrent CLs that add calls to memclr; if this happens, whichever patch hits master second will fail to compile. This also adds the other new memclr variants to the compiler's builtin.go to minimize the churn on that binary blob. We'll use these in future commits. Updates #17503. Change-Id: I00eead049f5bd35ca107ea525966831f3d1ed9ca Reviewed-on: https://go-review.googlesource.com/31369 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
ae3bb4a537
commit
87e48c5afd
33 changed files with 154 additions and 139 deletions
|
|
@ -393,11 +393,13 @@ func memclrrange(n, v1, v2, a *Node) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// TODO: Use memclrHasPointers if there are pointers.
|
||||
|
||||
// Convert to
|
||||
// if len(a) != 0 {
|
||||
// hp = &a[0]
|
||||
// hn = len(a)*sizeof(elem(a))
|
||||
// memclr(hp, hn)
|
||||
// memclrNoHeapPointers(hp, hn)
|
||||
// i = len(a) - 1
|
||||
// }
|
||||
n.Op = OIF
|
||||
|
|
@ -423,8 +425,8 @@ func memclrrange(n, v1, v2, a *Node) bool {
|
|||
tmp = conv(tmp, Types[TUINTPTR])
|
||||
n.Nbody.Append(nod(OAS, hn, tmp))
|
||||
|
||||
// memclr(hp, hn)
|
||||
fn := mkcall("memclr", nil, nil, hp, hn)
|
||||
// memclrNoHeapPointers(hp, hn)
|
||||
fn := mkcall("memclrNoHeapPointers", nil, nil, hp, hn)
|
||||
|
||||
n.Nbody.Append(fn)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue