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

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

src/pkg/runtime/malloc.h
src/pkg/runtime/mprof.goc

index 38122bf8a5e8b8f3d00ad2a1f7329f47b8a5ad13..4635e53e096a2f6bae88f176d6fc3f130c78f590 100644 (file)
@@ -416,10 +416,10 @@ struct MHeap
        byte *arena_end;
 
        // central free lists for small size classes.
-       // the union makes sure that the MCentrals are
+       // the padding makes sure that the MCentrals are
        // spaced CacheLineSize bytes apart, so that each MCentral.Lock
        // gets its own cache line.
-       union {
+       struct {
                MCentral;
                byte pad[CacheLineSize];
        } central[NumSizeClasses];
index 707e505ba74041ec16de6e5d44c96bc453a3e924..63334e704e3d32cb266950cc03cda9ed95801cac 100644 (file)
@@ -61,6 +61,8 @@ struct Bucket
        Bucket  *next;  // next in hash list
        Bucket  *allnext;       // next in list of all mbuckets/bbuckets
        int32   typ;
+       // Generally unions can break precise GC,
+       // this one is fine because it does not contain pointers.
        union
        {
                struct  // typ == MProf