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
From-SVN: r271894
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| config | Loading commit data... | |
| go | Loading commit data... | |
| misc/cgo | Loading commit data... | |
| runtime | Loading commit data... | |
| testsuite | Loading commit data... | |
| LICENSE | Loading commit data... | |
| MERGE | Loading commit data... | |
| Makefile.am | Loading commit data... | |
| Makefile.in | Loading commit data... | |
| PATENTS | Loading commit data... | |
| README | Loading commit data... | |
| README.gcc | Loading commit data... | |
| VERSION | Loading commit data... | |
| aclocal.m4 | Loading commit data... | |
| check-packages.txt | Loading commit data... | |
| config.h.in | Loading commit data... | |
| configure | Loading commit data... | |
| configure.ac | Loading commit data... | |
| goarch.sh | Loading commit data... | |
| godeps.sh | Loading commit data... | |
| gotool-packages.txt | Loading commit data... | |
| libgo-packages.txt | Loading commit data... | |
| libgo.imp | Loading commit data... | |
| match.sh | Loading commit data... | |
| merge.sh | Loading commit data... | |
| mkrsysinfo.sh | Loading commit data... | |
| mkruntimeinc.sh | Loading commit data... | |
| mksigtab.sh | Loading commit data... | |
| mksysinfo.sh | Loading commit data... | |
| mvifdiff.sh | Loading commit data... | |
| sysinfo.c | Loading commit data... |