Commit e017e0cb authored by Jan Ziak's avatar Jan Ziak

runtime: flag static variables as no-pointers

Variables in data sections of 32-bit executables interfere with
garbage collector's ability to free objects and/or unnecessarily
slow down the garbage collector.

This changeset moves some static variables to .noptr sections.
'files' in symtab.c is now allocated dynamically.

R=golang-dev, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/9786044
parent 20c524c5
......@@ -524,6 +524,7 @@ hash_lookup(MapType *t, Hmap *h, byte **keyp)
}
// When an item is not found, fast versions return a pointer to this zeroed memory.
#pragma dataflag 16 // no pointers
static uint8 empty_value[MAXVALUESIZE];
// Specialized versions of mapaccess1 for specific types.
......
......@@ -523,6 +523,7 @@ runtime·setprof(bool on)
runtime·sigprocmask(SIG_BLOCK, &sigset_prof, nil);
}
#pragma dataflag 16 // no pointers
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......@@ -533,6 +534,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1);
}
#pragma dataflag 16 // no pointers
static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split.
......
......@@ -235,6 +235,7 @@ runtime·setprof(bool on)
USED(on);
}
#pragma dataflag 16 // no pointers
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......@@ -245,6 +246,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1);
}
#pragma dataflag 16 // no pointers
static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split.
......
......@@ -172,6 +172,7 @@ runtime·get_random_data(byte **rnd, int32 *rnd_len)
*rnd = runtime·startup_random_data;
*rnd_len = runtime·startup_random_data_len;
} else {
#pragma dataflag 16 // no pointers
static byte urandom_data[HashRandomBytes];
int32 fd;
fd = runtime·open("/dev/urandom", 0 /* O_RDONLY */, 0);
......@@ -283,6 +284,7 @@ runtime·setprof(bool on)
USED(on);
}
#pragma dataflag 16 // no pointers
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......@@ -293,6 +295,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1);
}
#pragma dataflag 16 // no pointers
static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split.
......
......@@ -275,6 +275,7 @@ runtime·setprof(bool on)
USED(on);
}
#pragma dataflag 16 // no pointers
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......@@ -285,6 +286,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1);
}
#pragma dataflag 16 // no pointers
static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split.
......
......@@ -257,6 +257,7 @@ runtime·setprof(bool on)
USED(on);
}
#pragma dataflag 16 // no pointers
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......@@ -267,6 +268,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1);
}
#pragma dataflag 16 // no pointers
static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split.
......
......@@ -330,6 +330,7 @@ runtime·setprof(bool on)
USED(on);
}
#pragma dataflag 16 // no pointers
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......@@ -340,6 +341,7 @@ runtime·badcallback(void)
runtime·pwrite(2, badcallback, sizeof badcallback - 1, -1LL);
}
#pragma dataflag 16 // no pointers
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
// This runs on a foreign stack, without an m or a g. No stack split.
......
......@@ -450,9 +450,11 @@ runtime·setprof(bool on)
USED(on);
}
#pragma dataflag 16 // no pointers
int8 runtime·badcallbackmsg[] = "runtime: cgo callback on thread not created by Go.\n";
int32 runtime·badcallbacklen = sizeof runtime·badcallbackmsg - 1;
#pragma dataflag 16 // no pointers
int8 runtime·badsignalmsg[] = "runtime: signal received on thread not created by Go.\n";
int32 runtime·badsignallen = sizeof runtime·badsignalmsg - 1;
......
......@@ -307,6 +307,15 @@ gostringn(byte *p, int32 l)
return s;
}
static struct
{
String srcstring;
int32 aline;
int32 delta;
} *files;
enum { maxfiles = 200 };
// walk symtab accumulating path names for use by pc/ln table.
// don't need the full generality of the z entry history stack because
// there are no includes in go (and only sensible includes in our c);
......@@ -314,12 +323,8 @@ gostringn(byte *p, int32 l)
static void
dosrcline(Sym *sym)
{
#pragma dataflag 16 // no pointers
static byte srcbuf[1000];
static struct {
String srcstring;
int32 aline;
int32 delta;
} files[200];
static int32 incstart;
static int32 nfunc, nfile, nhist;
Func *f;
......@@ -347,7 +352,7 @@ dosrcline(Sym *sym)
l = makepath(srcbuf, sizeof srcbuf, sym->name+1);
nhist = 0;
nfile = 0;
if(nfile == nelem(files))
if(nfile == maxfiles)
return;
files[nfile].srcstring = gostringn(srcbuf, l);
files[nfile].aline = 0;
......@@ -358,7 +363,7 @@ dosrcline(Sym *sym)
if(srcbuf[0] != '\0') {
if(nhist++ == 0)
incstart = sym->value;
if(nhist == 0 && nfile < nelem(files)) {
if(nhist == 0 && nfile < maxfiles) {
// new top-level file
files[nfile].srcstring = gostringn(srcbuf, l);
files[nfile].aline = sym->value;
......@@ -567,10 +572,12 @@ buildfuncs(void)
splitpcln();
// record src file and line info for each func
files = runtime·malloc(maxfiles * sizeof(files[0]));
walksymtab(dosrcline); // pass 1: determine hugestring_len
hugestring.str = runtime·mallocgc(hugestring_len, FlagNoPointers, 0, 0);
hugestring.len = 0;
walksymtab(dosrcline); // pass 2: fill and use hugestring
files = nil;
if(hugestring.len != hugestring_len)
runtime·throw("buildfunc: problem in initialization procedure");
......
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