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