mirror of
https://github.com/golang/go
synced 2024-11-20 06:14:53 -07:00
cmd/gc: racewalk: fix a bunch of minor issues
1. Prepend racefuncenter() to fn->enter -- fn->enter can contain new() calls, and we want them to be in the scope of the function. 2. Dump fn->enter and fn->exit. 3. Add TODO that OTYPESW expression can contain interesting memory accesses. 4. Ignore only _ names instead of all names starting with _. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6822048
This commit is contained in:
parent
4094c1bae7
commit
de10a23db1
@ -43,6 +43,13 @@ racewalk(Node *fn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< local
|
||||||
|
// TODO(dvyukov): ideally this should be:
|
||||||
|
// racefuncenter(getreturnaddress())
|
||||||
|
// because it's much more costly to obtain from runtime library.
|
||||||
|
nd = mkcall("racefuncenter", T, nil);
|
||||||
|
fn->enter = concat(list1(nd), fn->enter);
|
||||||
|
=======
|
||||||
// nodpc is the PC of the caller as extracted by
|
// nodpc is the PC of the caller as extracted by
|
||||||
// getcallerpc. We use -widthptr(FP) for x86.
|
// getcallerpc. We use -widthptr(FP) for x86.
|
||||||
// BUG: this will not work on arm.
|
// BUG: this will not work on arm.
|
||||||
@ -52,13 +59,18 @@ racewalk(Node *fn)
|
|||||||
nodpc->xoffset = -widthptr;
|
nodpc->xoffset = -widthptr;
|
||||||
nd = mkcall("racefuncenter", T, nil, nodpc);
|
nd = mkcall("racefuncenter", T, nil, nodpc);
|
||||||
fn->enter = list(fn->enter, nd);
|
fn->enter = list(fn->enter, nd);
|
||||||
|
>>>>>>> other
|
||||||
nd = mkcall("racefuncexit", T, nil);
|
nd = mkcall("racefuncexit", T, nil);
|
||||||
fn->exit = list(fn->exit, nd); // works fine if (!fn->exit)
|
fn->exit = list(fn->exit, nd);
|
||||||
racewalklist(curfn->nbody, nil);
|
racewalklist(curfn->nbody, nil);
|
||||||
|
|
||||||
if(debug['W']) {
|
if(debug['W']) {
|
||||||
snprint(s, sizeof(s), "after racewalk %S", curfn->nname->sym);
|
snprint(s, sizeof(s), "after racewalk %S", curfn->nname->sym);
|
||||||
dumplist(s, curfn->nbody);
|
dumplist(s, curfn->nbody);
|
||||||
|
snprint(s, sizeof(s), "after walk %S", curfn->nname->sym);
|
||||||
|
dumplist(s, curfn->nbody);
|
||||||
|
snprint(s, sizeof(s), "enter %S", curfn->nname->sym);
|
||||||
|
dumplist(s, curfn->enter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +175,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
|
|||||||
|
|
||||||
case OSWITCH:
|
case OSWITCH:
|
||||||
if(n->ntest->op == OTYPESW)
|
if(n->ntest->op == OTYPESW)
|
||||||
// don't bother, we have static typization
|
// TODO(dvyukov): the expression can contain calls or reads.
|
||||||
return;
|
return;
|
||||||
racewalknode(&n->ntest, &n->ninit, 0, 0);
|
racewalknode(&n->ntest, &n->ninit, 0, 0);
|
||||||
racewalklist(n->nbody, nil);
|
racewalklist(n->nbody, nil);
|
||||||
@ -369,7 +381,7 @@ callinstr(Node *n, NodeList **init, int wr, int skip)
|
|||||||
if(n->op == ONAME) {
|
if(n->op == ONAME) {
|
||||||
if(n->sym != S) {
|
if(n->sym != S) {
|
||||||
if(n->sym->name != nil) {
|
if(n->sym->name != nil) {
|
||||||
if(strncmp(n->sym->name, "_", sizeof("_")-1) == 0)
|
if(strcmp(n->sym->name, "_") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if(strncmp(n->sym->name, "autotmp_", sizeof("autotmp_")-1) == 0)
|
if(strncmp(n->sym->name, "autotmp_", sizeof("autotmp_")-1) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -381,7 +393,7 @@ callinstr(Node *n, NodeList **init, int wr, int skip)
|
|||||||
if(t->etype == TSTRUCT) {
|
if(t->etype == TSTRUCT) {
|
||||||
res = 0;
|
res = 0;
|
||||||
for(t1=t->type; t1; t1=t1->down) {
|
for(t1=t->type; t1; t1=t1->down) {
|
||||||
if(t1->sym && strncmp(t1->sym->name, "_", sizeof("_")-1)) {
|
if(t1->sym && strcmp(t1->sym->name, "_")) {
|
||||||
n = treecopy(n);
|
n = treecopy(n);
|
||||||
f = nod(OXDOT, n, newname(t1->sym));
|
f = nod(OXDOT, n, newname(t1->sym));
|
||||||
if(callinstr(f, init, wr, 0)) {
|
if(callinstr(f, init, wr, 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user