]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: add write barrier for append(slice, slice...)
authorRuss Cox <rsc@golang.org>
Mon, 29 Dec 2014 21:26:25 +0000 (16:26 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 6 Jan 2015 14:41:45 +0000 (14:41 +0000)
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>
src/cmd/gc/walk.c

index 956b57d28b558168f0b243d023b607dfa47b8230..ed0cb1425a345c6526375ebfca7dc77c068e6c58 100644 (file)
@@ -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,