]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: hide mheap from race detector
authorDmitriy Vyukov <dvyukov@google.com>
Fri, 16 Nov 2012 16:06:11 +0000 (20:06 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Fri, 16 Nov 2012 16:06:11 +0000 (20:06 +0400)
This significantly decreases amount of shadow memory
mapped by race detector.
I haven't tested on Windows, but on Linux it reduces
virtual memory size from 1351m to 330m for fmt.test.
Fixes #4379.

R=golang-dev, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6849057

src/pkg/runtime/race.c

index 23866f01d1a814310b613151d32fcf2539e2fad0..aae43852a3b6f195e562708ef4d28335cd5e27e6 100644 (file)
@@ -34,9 +34,16 @@ static bool onstack(uintptr argp);
 void
 runtime·raceinit(void)
 {
+       uintptr sz;
+
        m->racecall = true;
        runtime∕race·Initialize();
-       runtime∕race·MapShadow(noptrdata, enoptrbss - noptrdata);
+       sz = (byte*)&runtime·mheap - noptrdata;
+       if(sz)
+               runtime∕race·MapShadow(noptrdata, sz);
+       sz = enoptrbss - (byte*)(&runtime·mheap+1);
+       if(sz)
+               runtime∕race·MapShadow(&runtime·mheap+1, sz);
        m->racecall = false;
 }