Commit 35724c1a authored by Jan Ziak's avatar Jan Ziak Committed by Russ Cox

runtime: hide the semaphore table from garbage collector

R=rsc, dvyukov, dave
CC=golang-dev
https://golang.org/cl/6528043
parent 8c058b32
...@@ -43,11 +43,13 @@ struct SemaRoot ...@@ -43,11 +43,13 @@ struct SemaRoot
// Prime to not correlate with any user patterns. // Prime to not correlate with any user patterns.
#define SEMTABLESZ 251 #define SEMTABLESZ 251
static union union semtable
{ {
SemaRoot; SemaRoot;
uint8 pad[CacheLineSize]; uint8 pad[CacheLineSize];
} semtable[SEMTABLESZ]; };
#pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage collector */
static union semtable semtable[SEMTABLESZ];
static SemaRoot* static SemaRoot*
semroot(uint32 *addr) semroot(uint32 *addr)
...@@ -98,7 +100,7 @@ cansemacquire(uint32 *addr) ...@@ -98,7 +100,7 @@ cansemacquire(uint32 *addr)
void void
runtime·semacquire(uint32 volatile *addr) runtime·semacquire(uint32 volatile *addr)
{ {
Sema s; Sema s; // Needs to be allocated on stack, otherwise garbage collector could deallocate it
SemaRoot *root; SemaRoot *root;
// Easy case. // Easy case.
......
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