mirror of
https://github.com/golang/go
synced 2024-11-11 21:30:23 -07:00
cmd/gc: add write barrier for append(slice, slice...)
Found with GODEBUG=wbshadow=2 mode. Eventually that will run automatically, but right now it still detects other missing write barriers. Change-Id: I5624b509a36650bce6834cf394b9da163abbf8c0 Reviewed-on: https://go-review.googlesource.com/2310 Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
03d6637dbb
commit
ff979626fc
@ -2800,7 +2800,21 @@ appendslice(Node *n, NodeList **init)
|
||||
|
||||
l = list(l, nif);
|
||||
|
||||
if(flag_race) {
|
||||
if(haspointers(l1->type->type)) {
|
||||
// copy(s[len(l1):len(l1)+len(l2)], l2)
|
||||
nptr1 = nod(OSLICE, s, nod(OKEY,
|
||||
nod(OLEN, l1, N),
|
||||
nod(OADD, nod(OLEN, l1, N), nod(OLEN, l2, N))));
|
||||
nptr1->etype = 1;
|
||||
nptr2 = l2;
|
||||
fn = syslook("typedslicecopy", 1);
|
||||
argtype(fn, l1->type);
|
||||
argtype(fn, l2->type);
|
||||
nt = mkcall1(fn, types[TINT], &l,
|
||||
typename(l1->type->type),
|
||||
nptr1, nptr2);
|
||||
l = list(l, nt);
|
||||
} else if(flag_race) {
|
||||
// rely on runtime to instrument copy.
|
||||
// copy(s[len(l1):len(l1)+len(l2)], l2)
|
||||
nptr1 = nod(OSLICE, s, nod(OKEY,
|
||||
|
Loading…
Reference in New Issue
Block a user