Commit e5ef6572 authored by Russ Cox's avatar Russ Cox

cmd/gc: add write barrier in copy of function parameters to heap

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/2278Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent 54bb4dc3
...@@ -2786,6 +2786,7 @@ islvalue(Node *n) ...@@ -2786,6 +2786,7 @@ islvalue(Node *n)
case OIND: case OIND:
case ODOTPTR: case ODOTPTR:
case OCLOSUREVAR: case OCLOSUREVAR:
case OPARAM:
return 1; return 1;
case ODOT: case ODOT:
return islvalue(n->left); return islvalue(n->left);
......
...@@ -462,6 +462,7 @@ walkexpr(Node **np, NodeList **init) ...@@ -462,6 +462,7 @@ walkexpr(Node **np, NodeList **init)
case ONONAME: case ONONAME:
case OINDREG: case OINDREG:
case OEMPTY: case OEMPTY:
case OPARAM:
goto ret; goto ret;
case ONOT: case ONOT:
...@@ -2519,7 +2520,7 @@ paramstoheap(Type **argin, int out) ...@@ -2519,7 +2520,7 @@ paramstoheap(Type **argin, int out)
{ {
Type *t; Type *t;
Iter savet; Iter savet;
Node *v; Node *v, *as;
NodeList *nn; NodeList *nn;
nn = nil; nn = nil;
...@@ -2544,8 +2545,13 @@ paramstoheap(Type **argin, int out) ...@@ -2544,8 +2545,13 @@ paramstoheap(Type **argin, int out)
if(v->alloc == nil) if(v->alloc == nil)
v->alloc = callnew(v->type); v->alloc = callnew(v->type);
nn = list(nn, nod(OAS, v->heapaddr, v->alloc)); nn = list(nn, nod(OAS, v->heapaddr, v->alloc));
if((v->class & ~PHEAP) != PPARAMOUT) if((v->class & ~PHEAP) != PPARAMOUT) {
nn = list(nn, nod(OAS, v, v->stackparam)); as = nod(OAS, v, v->stackparam);
v->stackparam->typecheck = 1;
typecheck(&as, Etop);
as = applywritebarrier(as, &nn);
nn = list(nn, as);
}
} }
return nn; return nn;
} }
......
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