r271894 - in /trunk: gcc/go/gofrontend/MERGE gc...

ian@gcc.gnu.org ian@gcc.gnu.org
Mon Jun 3 23:37:00 GMT 2019


Author: ian
Date: Mon Jun  3 23:37:04 2019
New Revision: 271894

URL: https://gcc.gnu.org/viewcvs?rev=271894&root=gcc&view=rev
Log:
    compiler, runtime, reflect: generate unique type descriptors
    
    Currently, the compiler already generates common symbols for type
    descriptors, so the type descriptors are unique. However, when a
    type is created through reflection, it is not deduplicated with
    compiler-generated types. As a consequence, we cannot assume type
    descriptors are unique, and cannot use pointer equality to
    compare them. Also, when constructing a reflect.Type, it has to
    go through a canonicalization map, which introduces overhead to
    reflect.TypeOf, and lock contentions in concurrent programs.
    
    In order for the reflect package to deduplicate types with
    compiler-created types, we register all the compiler-created type
    descriptors at startup time. The reflect package, when it needs
    to create a type, looks up the registry of compiler-created types
    before creates a new one. There is no lock contention since the
    registry is read-only after initialization.
    
    This lets us get rid of the canonicalization map, and also makes
    it possible to compare type descriptors with pointer equality.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179598

Modified:
    trunk/gcc/go/gofrontend/MERGE
    trunk/gcc/go/gofrontend/gogo.cc
    trunk/gcc/go/gofrontend/gogo.h
    trunk/gcc/go/gofrontend/names.cc
    trunk/gcc/go/gofrontend/runtime.def
    trunk/gcc/go/gofrontend/types.cc
    trunk/libgo/go/reflect/type.go
    trunk/libgo/go/runtime/type.go



More information about the Gcc-cvs mailing list