aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/reflectdata/reflect.go
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2021-06-08 19:28:45 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2021-08-19 16:10:32 +0000
commit91e2e3b9030440713b59dcc7dd9deae71b18d9fc (patch)
tree4f96a7b3d7d9a2cc4c4a39619dbf3786c44696f7 /src/cmd/compile/internal/reflectdata/reflect.go
parent9871726c72af7009aa73be33edfa06a8d9e5965e (diff)
downloadgo-91e2e3b9030440713b59dcc7dd9deae71b18d9fc.tar.gz
go-91e2e3b9030440713b59dcc7dd9deae71b18d9fc.zip
cmd/compile: prevent duplicated works in WriteRuntimeTypes
While processing signatset, the entry is deleted immediately after being pushed to signatslice. Then calling writeType may add the same type to signatset again. That would add more works, though not a big impact to the performace, since when writeType is guarded by s.Siggen() check. Instead, we should keep the entry in signatset, so written type will never be added again. This change does not affect compiler performace, but help debugging issue like one in #46386 easier. Change-Id: Iddafe773885fa21cb7003ba27ddf9554fc3f297d Reviewed-on: https://go-review.googlesource.com/c/go/+/326029 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/reflect.go')
-rw-r--r--src/cmd/compile/internal/reflectdata/reflect.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go
index b04e4d684f..3db6585894 100644
--- a/src/cmd/compile/internal/reflectdata/reflect.go
+++ b/src/cmd/compile/internal/reflectdata/reflect.go
@@ -39,8 +39,11 @@ func CountPTabs() int {
// runtime interface and reflection data structures
var (
- signatmu sync.Mutex // protects signatset and signatslice
- signatset = make(map[*types.Type]struct{})
+ // protects signatset and signatslice
+ signatmu sync.Mutex
+ // Tracking which types need runtime type descriptor
+ signatset = make(map[*types.Type]struct{})
+ // Queue of types wait to be generated runtime type descriptor
signatslice []*types.Type
gcsymmu sync.Mutex // protects gcsymset and gcsymslice
@@ -1248,7 +1251,6 @@ func WriteRuntimeTypes() {
// Transfer entries to a slice and sort, for reproducible builds.
for _, t := range signatslice {
signats = append(signats, typeAndStr{t: t, short: types.TypeSymName(t), regular: t.String()})
- delete(signatset, t)
}
signatslice = signatslice[:0]
sort.Sort(typesByString(signats))