]> git.ipfire.org Git - thirdparty/gcc.git/commit
compiler, runtime, reflect: generate unique type descriptors
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Jun 2019 23:37:04 +0000 (23:37 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Jun 2019 23:37:04 +0000 (23:37 +0000)
commit03f42d617c877bb2846e10bdef25687b7f55cdf1
tree19c16f5db5a78699200253d35ce390c429f76126
parent32fdeb30ccc7527b8dfad15c10015942dec6fef1
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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@271894 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc
gcc/go/gofrontend/gogo.h
gcc/go/gofrontend/names.cc
gcc/go/gofrontend/runtime.def
gcc/go/gofrontend/types.cc
libgo/go/reflect/type.go
libgo/go/runtime/type.go