]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: flag static variables as no-pointers
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Mon, 27 May 2013 06:11:59 +0000 (08:11 +0200)
committerJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Mon, 27 May 2013 06:11:59 +0000 (08:11 +0200)
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

src/pkg/runtime/hashmap.c
src/pkg/runtime/os_darwin.c
src/pkg/runtime/os_freebsd.c
src/pkg/runtime/os_linux.c
src/pkg/runtime/os_netbsd.c
src/pkg/runtime/os_openbsd.c
src/pkg/runtime/os_plan9.c
src/pkg/runtime/os_windows.c
src/pkg/runtime/symtab.c

index 959d6bc760236e671383293a8c7cae671f4bd925..2e61bcfe8fad8ae707272162ede4861b7370a9d2 100644 (file)
@@ -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.
index 276362a97f6d094e51cb23e8f72974d4b310d8a5..deb1c556a922cf0b43e9cded882ee49f7ab683b7 100644 (file)
@@ -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.
index f454ab3497725ddef5f946eb79fb13d973a3df92..8c6e1b24964c780720e8e9dbda30bc34bcaecb01 100644 (file)
@@ -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.
index 6b86d2b1777a29f8efb4a031c17b141eb1eeadd5..6bb376a7e9539280722b4eb6abc89f04d56d8fc0 100644 (file)
@@ -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.
index 7679ec2552e20d66cb07e05269c473c68c7fe239..3355208133956273a11773209aea4144848347ae 100644 (file)
@@ -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.
index 4ce102ec2cb64df6f0419981949e11e36e116514..898dca9b6ac591802e59b1000b0fc5d3b351133d 100644 (file)
@@ -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.
index 53ec4ae176ffe6e231f8635fbced46b65f337231..dd02eb878245c6bbf56b8575e3a1da1a6a990233 100644 (file)
@@ -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.
index b28affe31b66593792368e843d24eb4c519cb712..9b8e3e363a2e4dadca95cb3dc33d138a5f1cd619 100644 (file)
@@ -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;
 
index 578406247e3cdbec0c6301731faa03d0705b99de..5edcb49bda8c5ed35affbb31264874099bd7a630 100644 (file)
@@ -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");