Commit 60682c4f authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: replace unions with structs

Unions can break precise GC.
Update #5193.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/8456043
parent cfe33677
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include "runtime.h" #include "runtime.h"
#include "arch_GOARCH.h" #include "arch_GOARCH.h"
static union { static struct {
Lock l; Lock l;
byte pad [CacheLineSize]; byte pad[CacheLineSize-sizeof(Lock)];
} locktab[57]; } locktab[57];
#define LOCK(addr) (&locktab[((uintptr)(addr)>>3)%nelem(locktab)].l) #define LOCK(addr) (&locktab[((uintptr)(addr)>>3)%nelem(locktab)].l)
......
...@@ -44,13 +44,13 @@ struct SemaRoot ...@@ -44,13 +44,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
union semtable struct semtable
{ {
SemaRoot; SemaRoot;
uint8 pad[CacheLineSize]; uint8 pad[CacheLineSize-sizeof(SemaRoot)];
}; };
#pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage collector */ #pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage collector */
static union semtable semtable[SEMTABLESZ]; static struct semtable semtable[SEMTABLESZ];
static SemaRoot* static SemaRoot*
semroot(uint32 *addr) semroot(uint32 *addr)
......
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