// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Garbage collector (GC) enum { ScanStackByFrames = 1, // TODO(rsc): Half the code in the garbage collector // now accesses the bitmap as an array of bytes // instead of as an array of uintptrs. // This is tricky to do correctly in a portable fashion. // (It breaks on big-endian systems.) // Should we just make the bitmap a byte array? // Four bits per word (see #defines below). gcBits = 4, wordsPerBitmapByte = 8/gcBits, // GC type info programs. // The programs allow to store type info required for GC in a compact form. // Most importantly arrays take O(1) space instead of O(n). // The program grammar is: // // Program = {Block} "insEnd" // Block = Data | Array // Data = "insData" DataSize DataBlock // DataSize = int // size of the DataBlock in bit pairs, 1 byte // DataBlock = binary // dense GC mask (2 bits per word) of size ]DataSize/4[ bytes // Array = "insArray" ArrayLen Block "insArrayEnd" // ArrayLen = int // length of the array, 8 bytes (4 bytes for 32-bit arch) // // Each instruction (insData, insArray, etc) is 1 byte. // For example, for type struct { x []byte; y [20]struct{ z int; w *byte }; } // the program looks as: // // insData 3 (BitsMultiWord BitsSlice BitsScalar) // insArray 20 insData 2 (BitsScalar BitsPointer) insArrayEnd insEnd // // Total size of the program is 17 bytes (13 bytes on 32-bits). // The corresponding GC mask would take 43 bytes (it would be repeated // because the type has odd number of words). insData = 1, insArray, insArrayEnd, insEnd, // Pointer map BitsPerPointer = 2, BitsMask = (1<