Commit ff979626 authored by Russ Cox's avatar Russ Cox

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/2310Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent 03d6637d
...@@ -2800,7 +2800,21 @@ appendslice(Node *n, NodeList **init) ...@@ -2800,7 +2800,21 @@ appendslice(Node *n, NodeList **init)
l = list(l, nif); 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. // rely on runtime to instrument copy.
// copy(s[len(l1):len(l1)+len(l2)], l2) // copy(s[len(l1):len(l1)+len(l2)], l2)
nptr1 = nod(OSLICE, s, nod(OKEY, nptr1 = nod(OSLICE, s, nod(OKEY,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment