Skip to content

Commit ff97962

Browse files
committed
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 <[email protected]>
1 parent 03d6637 commit ff97962

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/cmd/gc/walk.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,7 +2800,21 @@ appendslice(Node *n, NodeList **init)
28002800

28012801
l = list(l, nif);
28022802

2803-
if(flag_race) {
2803+
if(haspointers(l1->type->type)) {
2804+
// copy(s[len(l1):len(l1)+len(l2)], l2)
2805+
nptr1 = nod(OSLICE, s, nod(OKEY,
2806+
nod(OLEN, l1, N),
2807+
nod(OADD, nod(OLEN, l1, N), nod(OLEN, l2, N))));
2808+
nptr1->etype = 1;
2809+
nptr2 = l2;
2810+
fn = syslook("typedslicecopy", 1);
2811+
argtype(fn, l1->type);
2812+
argtype(fn, l2->type);
2813+
nt = mkcall1(fn, types[TINT], &l,
2814+
typename(l1->type->type),
2815+
nptr1, nptr2);
2816+
l = list(l, nt);
2817+
} else if(flag_race) {
28042818
// rely on runtime to instrument copy.
28052819
// copy(s[len(l1):len(l1)+len(l2)], l2)
28062820
nptr1 = nod(OSLICE, s, nod(OKEY,

0 commit comments

Comments
 (0)