aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/gc
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-16 19:22:58 -0500
committerRuss Cox <rsc@golang.org>2015-01-21 00:44:18 +0000
commitdba9eb336930ccddafb4bec2ca67d6ea125b1f02 (patch)
treecfcbc7b73287ac5f120ca5538b46e6b8f8be486b /src/cmd/gc
parent8bf6e09f4cbb0242039dd4602f1f2d58e30e0f26 (diff)
downloadgo-dba9eb336930ccddafb4bec2ca67d6ea125b1f02.tar.xz
build: implement GOEXPERIMENT again in runtime, and add to liblink
For Austin's framepointer experiment. Change-Id: I81b6f414943b3578924f853300b9193684f79bf4 Reviewed-on: https://go-review.googlesource.com/2994 Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/cmd/gc')
-rw-r--r--src/cmd/gc/go.h2
-rw-r--r--src/cmd/gc/lex.c69
-rw-r--r--src/cmd/gc/plive.c34
-rw-r--r--src/cmd/gc/walk.c4
4 files changed, 21 insertions, 88 deletions
diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h
index 21cf8b894d..5a2b774316 100644
--- a/src/cmd/gc/go.h
+++ b/src/cmd/gc/go.h
@@ -994,8 +994,6 @@ EXTERN int debuglive;
EXTERN Link* ctxt;
EXTERN int nointerface;
-EXTERN int fieldtrack_enabled;
-EXTERN int precisestack_enabled;
EXTERN int writearchive;
EXTERN Biobuf bstdout;
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index 006ded20e8..29fb2e1603 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -33,19 +33,6 @@ static char *goos, *goarch, *goroot;
#define BOM 0xFEFF
-// Compiler experiments.
-// These are controlled by the GOEXPERIMENT environment
-// variable recorded when the compiler is built.
-static struct {
- char *name;
- int *val;
-} exper[] = {
-// {"rune32", &rune32},
- {"fieldtrack", &fieldtrack_enabled},
- {"precisestack", &precisestack_enabled},
- {nil, nil},
-};
-
// Debug arguments.
// These can be specified with the -d flag, as in "-d nil"
// to set the debug_checknil variable. In general the list passed
@@ -55,55 +42,8 @@ static struct {
int *val;
} debugtab[] = {
{"nil", &debug_checknil},
- {nil, nil},
};
-static void
-addexp(char *s)
-{
- int i;
-
- for(i=0; exper[i].name != nil; i++) {
- if(strcmp(exper[i].name, s) == 0) {
- *exper[i].val = 1;
- return;
- }
- }
-
- print("unknown experiment %s\n", s);
- exits("unknown experiment");
-}
-
-static void
-setexp(void)
-{
- char *f[20];
- int i, nf;
-
- precisestack_enabled = 1; // on by default
-
- // cmd/dist #defines GOEXPERIMENT for us.
- nf = getfields(GOEXPERIMENT, f, nelem(f), 1, ",");
- for(i=0; i<nf; i++)
- addexp(f[i]);
-}
-
-char*
-expstring(void)
-{
- int i;
- static char buf[512];
-
- strcpy(buf, "X");
- for(i=0; exper[i].name != nil; i++)
- if(*exper[i].val)
- seprint(buf+strlen(buf), buf+sizeof buf, ",%s", exper[i].name);
- if(strlen(buf) == 1)
- strcpy(buf, "X,none");
- buf[1] = ':';
- return buf;
-}
-
// Our own isdigit, isspace, isalpha, isalnum that take care
// of EOF and other out of range arguments.
static int
@@ -272,8 +212,6 @@ main(int argc, char *argv[])
if(nacl)
flag_largemodel = 1;
- setexp();
-
fmtstrinit(&pragcgobuf);
quotefmtinstall();
@@ -344,13 +282,14 @@ main(int argc, char *argv[])
nf = getfields(debugstr, f, nelem(f), 1, ",");
for(i=0; i<nf; i++) {
- for(j=0; debugtab[j].name != nil; j++) {
+ for(j=0; j<nelem(debugtab); j++) {
if(strcmp(debugtab[j].name, f[i]) == 0) {
- *debugtab[j].val = 1;
+ if(debugtab[j].val != nil)
+ *debugtab[j].val = 1;
break;
}
}
- if(debugtab[j].name == nil)
+ if(j >= nelem(debugtab))
sysfatal("unknown debug information -d '%s'\n", f[i]);
}
}
diff --git a/src/cmd/gc/plive.c b/src/cmd/gc/plive.c
index 3bfa69b1f0..e22d756ced 100644
--- a/src/cmd/gc/plive.c
+++ b/src/cmd/gc/plive.c
@@ -1487,25 +1487,21 @@ livenessepilogue(Liveness *lv)
// Annotate ambiguously live variables so that they can
// be zeroed at function entry.
// livein and liveout are dead here and used as temporaries.
- // For now, only enabled when using GOEXPERIMENT=precisestack
- // during make.bash / all.bash.
- if(precisestack_enabled) {
- bvresetall(livein);
- bvandnot(liveout, any, all);
- if(!bvisempty(liveout)) {
- for(pos = 0; pos < liveout->n; pos++) {
- if(!bvget(liveout, pos))
- continue;
- bvset(all, pos); // silence future warnings in this block
- n = *(Node**)arrayget(lv->vars, pos);
- if(!n->needzero) {
- n->needzero = 1;
- if(debuglive >= 1)
- warnl(p->lineno, "%N: %lN is ambiguously live", curfn->nname, n);
- // Record in 'ambiguous' bitmap.
- xoffset = n->xoffset + stkptrsize;
- twobitwalktype1(n->type, &xoffset, ambig);
- }
+ bvresetall(livein);
+ bvandnot(liveout, any, all);
+ if(!bvisempty(liveout)) {
+ for(pos = 0; pos < liveout->n; pos++) {
+ if(!bvget(liveout, pos))
+ continue;
+ bvset(all, pos); // silence future warnings in this block
+ n = *(Node**)arrayget(lv->vars, pos);
+ if(!n->needzero) {
+ n->needzero = 1;
+ if(debuglive >= 1)
+ warnl(p->lineno, "%N: %lN is ambiguously live", curfn->nname, n);
+ // Record in 'ambiguous' bitmap.
+ xoffset = n->xoffset + stkptrsize;
+ twobitwalktype1(n->type, &xoffset, ambig);
}
}
}
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c
index 48dd17a6af..1d2dcf7447 100644
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -2521,9 +2521,9 @@ paramstoheap(Type **argin, int out)
v = t->nname;
if(v && v->sym && v->sym->name[0] == '~' && v->sym->name[1] == 'r') // unnamed result
v = N;
- // In precisestack mode, the garbage collector assumes results
+ // For precise stacks, the garbage collector assumes results
// are always live, so zero them always.
- if(out && (precisestack_enabled || (v == N && hasdefer))) {
+ if(out) {
// Defer might stop a panic and show the
// return values as they exist at the time of panic.
// Make sure to zero them on entry to the function.