• Russ Cox's avatar
    reflect: add ArrayOf, ChanOf, MapOf, SliceOf · 11209825
    Russ Cox authored
    In order to add these, we need to be able to find references
    to such types that already exist in the binary. To do that, introduce
    a new linker section holding a list of the types corresponding to
    arrays, chans, maps, and slices.
    
    To offset the storage cost of this list, and to simplify the code,
    remove the interface{} header from the representation of a
    runtime type. It was used in early versions of the code but was
    made obsolete by the kind field: a switch on kind is more efficient
    than a type switch.
    
    In the godoc binary, removing the interface{} header cuts two
    words from each of about 10,000 types. Adding back the list of pointers
    to array, chan, map, and slice types reintroduces one word for
    each of about 500 types. On a 64-bit machine, then, this CL *removes*
    a net 156 kB of read-only data from the binary.
    
    This CL does not include the needed support for precise garbage
    collection. I have created issue 4375 to track that.
    
    This CL also does not set the 'algorithm' - specifically the equality
    and copy functions - for a new array correctly, so I have unexported
    ArrayOf for now. That is also part of issue 4375.
    
    Fixes #2339.
    
    R=r, remyoudompheng, mirtchovski, iant
    CC=golang-dev
    https://golang.org/cl/6572043
    11209825
decodesym.c 3.92 KB