]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: add write barrier in copy of function parameters to heap
authorRuss Cox <rsc@golang.org>
Mon, 29 Dec 2014 16:47:04 +0000 (11:47 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 6 Jan 2015 00:27:49 +0000 (00:27 +0000)
Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: I1320d5340a9e421c779f24f3b170e33974e56e4f
Reviewed-on: https://go-review.googlesource.com/2278
Reviewed-by: Rick Hudson <rlh@golang.org>
src/cmd/gc/typecheck.c
src/cmd/gc/walk.c

index 4512767c38fd3114a8d1de86e664faa50a9430ca..aa693aff7f914525f377c6bc8f28a205d0b6d8ad 100644 (file)
@@ -2786,6 +2786,7 @@ islvalue(Node *n)
        case OIND:
        case ODOTPTR:
        case OCLOSUREVAR:
+       case OPARAM:
                return 1;
        case ODOT:
                return islvalue(n->left);
index df97f17670a0086582333137689a9a7cb6e4c2a0..99611efce8907410b79675a0dfbf0fd317e650e5 100644 (file)
@@ -462,6 +462,7 @@ walkexpr(Node **np, NodeList **init)
        case ONONAME:
        case OINDREG:
        case OEMPTY:
+       case OPARAM:
                goto ret;
 
        case ONOT:
@@ -2519,7 +2520,7 @@ paramstoheap(Type **argin, int out)
 {
        Type *t;
        Iter savet;
-       Node *v;
+       Node *v, *as;
        NodeList *nn;
 
        nn = nil;
@@ -2544,8 +2545,13 @@ paramstoheap(Type **argin, int out)
                if(v->alloc == nil)
                        v->alloc = callnew(v->type);
                nn = list(nn, nod(OAS, v->heapaddr, v->alloc));
-               if((v->class & ~PHEAP) != PPARAMOUT)
-                       nn = list(nn, nod(OAS, v, v->stackparam));
+               if((v->class & ~PHEAP) != PPARAMOUT) {
+                       as = nod(OAS, v, v->stackparam);
+                       v->stackparam->typecheck = 1;
+                       typecheck(&as, Etop);
+                       as = applywritebarrier(as, &nn);
+                       nn = list(nn, as);
+               }
        }
        return nn;
 }