diff options
author | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2013-03-27 20:33:17 +0100 |
---|---|---|
committer | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2013-03-27 20:33:17 +0100 |
commit | e6a05d41e3f7eec8e46e8d1c2feb3b151c688f85 (patch) | |
tree | 4971f7559f6bc1d063bf59a69509449e241ac1a7 /src/cmd/gc | |
parent | 291530efde59fa68fa42870282fd6eeb831f95a6 (diff) | |
download | go-e6a05d41e3f7eec8e46e8d1c2feb3b151c688f85.tar.gz |
cmd/gc: fix race instrumentation of append and type switches.
The remaining issues are about runtime and sync package
instrumentation.
Update issue 4228
R=dvyukov, bradfitz
CC=golang-dev
https://codereview.appspot.com/8041043
Diffstat (limited to 'src/cmd/gc')
-rw-r--r-- | src/cmd/gc/racewalk.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/cmd/gc/racewalk.c b/src/cmd/gc/racewalk.c index fee5cf422..5d4f62e76 100644 --- a/src/cmd/gc/racewalk.c +++ b/src/cmd/gc/racewalk.c @@ -133,7 +133,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) case OASOP: case OAS: case OAS2: - case OAS2DOTTYPE: case OAS2RECV: case OAS2FUNC: case OAS2MAPR: @@ -186,12 +185,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) racewalknode(&n->left, init, 0, 0); goto ret; - case OSWITCH: - if(n->ntest->op == OTYPESW) - // TODO(dvyukov): the expression can contain calls or reads. - return; - goto ret; - case ONOT: case OMINUS: case OPLUS: @@ -317,6 +310,10 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) racewalknode(&n->left, init, 0, 0); goto ret; + case OTYPESW: + racewalknode(&n->right, init, 0, 0); + goto ret; + // should not appear in AST by now case OSEND: case ORECV: @@ -334,6 +331,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) case OMAKESLICE: case OCALL: case OCOPY: + case OAPPEND: case ORUNESTR: case OARRAYBYTESTR: case OARRAYRUNESTR: @@ -344,6 +342,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) case OADDSTR: case ODOTTYPE: case ODOTTYPE2: + case OAS2DOTTYPE: case OCALLPART: // lowered to PTRLIT case OCLOSURE: // lowered to PTRLIT case ORANGE: // lowered to ordinary for loop @@ -364,6 +363,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) case OIF: case OCALLMETH: case ORETURN: + case OSWITCH: case OSELECT: case OEMPTY: case OBREAK: @@ -389,10 +389,6 @@ racewalknode(Node **np, NodeList **init, int wr, int skip) case OLITERAL: case OSLICESTR: // always preceded by bounds checking, avoid double instrumentation. goto ret; - - // unimplemented - case OAPPEND: - goto ret; } ret: @@ -448,6 +444,7 @@ callinstr(Node **np, NodeList **init, int wr, int skip) if(isartificial(n)) return 0; if(t->etype == TSTRUCT) { + // TODO: instrument arrays similarly. // PARAMs w/o PHEAP are not interesting. if(n->class == PPARAM || n->class == PPARAMOUT) return 0; @@ -484,7 +481,7 @@ callinstr(Node **np, NodeList **init, int wr, int skip) // that has got a pointer inside. Whether it points to // the heap or not is impossible to know at compile time if((class&PHEAP) || class == PPARAMREF || class == PEXTERN - || b->type->etype == TARRAY || b->op == ODOTPTR || b->op == OIND || b->op == OXDOT) { + || b->op == OINDEX || b->op == ODOTPTR || b->op == OIND || b->op == OXDOT) { hascalls = 0; foreach(n, hascallspred, &hascalls); if(hascalls) { @@ -510,6 +507,8 @@ uintptraddr(Node *n) return r; } +// basenod returns the simplest child node of n pointing to the same +// memory area. static Node* basenod(Node *n) { @@ -518,7 +517,7 @@ basenod(Node *n) n = n->left; continue; } - if(n->op == OINDEX) { + if(n->op == OINDEX && isfixedarray(n->type)) { n = n->left; continue; } |