]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: replace unions with structs
authorDmitriy Vyukov <dvyukov@google.com>
Sun, 7 Apr 2013 03:02:49 +0000 (20:02 -0700)
committerDmitriy Vyukov <dvyukov@google.com>
Sun, 7 Apr 2013 03:02:49 +0000 (20:02 -0700)
Unions can break precise GC.
Update #5193.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/8456043

src/pkg/runtime/atomic_arm.c
src/pkg/runtime/sema.goc

index 9193d599d36fb047684dc25f4941d0b793b878ae..a78b1dfe2ce80740dece04abedc1db2f64ffb2d6 100644 (file)
@@ -5,9 +5,9 @@
 #include "runtime.h"
 #include "arch_GOARCH.h"
 
-static union {
+static struct {
        Lock l;
-       byte pad [CacheLineSize];
+       byte pad[CacheLineSize-sizeof(Lock)];
 } locktab[57];
 
 #define LOCK(addr) (&locktab[((uintptr)(addr)>>3)%nelem(locktab)].l)
index c4b5247b3da0e33982569e5a8a38cea4e2e1a4a7..4df01fc4e497b6531247db1ed61224cb6234190f 100644 (file)
@@ -44,13 +44,13 @@ struct SemaRoot
 // Prime to not correlate with any user patterns.
 #define SEMTABLESZ 251
 
-union semtable
+struct semtable
 {
        SemaRoot;
-       uint8 pad[CacheLineSize];
+       uint8 pad[CacheLineSize-sizeof(SemaRoot)];
 };
 #pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage collector */
-static union semtable semtable[SEMTABLESZ];
+static struct semtable semtable[SEMTABLESZ];
 
 static SemaRoot*
 semroot(uint32 *addr)