]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: hide the semaphore table from garbage collector
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Tue, 18 Sep 2012 18:30:01 +0000 (14:30 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 18 Sep 2012 18:30:01 +0000 (14:30 -0400)
R=rsc, dvyukov, dave
CC=golang-dev
https://golang.org/cl/6528043

src/pkg/runtime/sema.goc

index 8b9cef4b37d546c91e470cf9ed2e2a2e27ca4c5a..5fac830fcf5a7c637759f7521a21b95a7f29cb1e 100644 (file)
@@ -43,11 +43,13 @@ struct SemaRoot
 // Prime to not correlate with any user patterns.
 #define SEMTABLESZ 251
 
-static union
+union semtable
 {
        SemaRoot;
        uint8 pad[CacheLineSize];
-} semtable[SEMTABLESZ];
+};
+#pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage collector */
+static union semtable semtable[SEMTABLESZ];
 
 static SemaRoot*
 semroot(uint32 *addr)
@@ -98,7 +100,7 @@ cansemacquire(uint32 *addr)
 void
 runtime·semacquire(uint32 volatile *addr)
 {
-       Sema s;
+       Sema s; // Needs to be allocated on stack, otherwise garbage collector could deallocate it
        SemaRoot *root;
 
        // Easy case.