Unreviewed changes
12 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: src/cmd/compile/internal/types2/named.go
Insertions: 1, Deletions: 2.
@@ -587,6 +587,7 @@
func (n *Named) under() Type {
assert(n.stateHas(resolved))
+ // optimization for likely case
if n.stateHas(underlying) {
return n.underlying
}
@@ -613,8 +614,6 @@
}
// acquire the lock without checking; performance is probably fine
-
- // else, we must also lock t and calculate t.underlying
t.resolve()
t.mu.Lock()
defer t.mu.Unlock()
```
```
The name of the file: src/go/types/named.go
Insertions: 1, Deletions: 2.
@@ -590,6 +590,7 @@
func (n *Named) under() Type {
assert(n.stateHas(resolved))
+ // optimization for likely case
if n.stateHas(underlying) {
return n.underlying
}
@@ -616,8 +617,6 @@
}
// acquire the lock without checking; performance is probably fine
-
- // else, we must also lock t and calculate t.underlying
t.resolve()
t.mu.Lock()
defer t.mu.Unlock()
```
Change information
Commit message:
go/types, types2: guard Named.underlying with Named.mu
It appears that CL 695977 introduced a data race on Named.underlying.
This fixes that race by specifying a new namedState called underlying,
which, perhaps unsurprisingly, signals that Named.underlying is populated.
Unfortunately, the underlying namedState is independent of the complete
namedState (unsurprising since methods and the underlying type are not related).
Hence, they cannot be ordered and thus do not fit the current integer-based
state representation. To account for combinations of states, we introduce a
bit set representation for namedState instead. The namedState field is also
renamed to stateMask to reflect this new representation.
Methods that operate on the stateMask are adjusted and exposition is added
throughout.
Fixes #75963
Change-Id: Icfa188ea2fa7916804c06f80668e99176bf4e978
Files:
- M src/cmd/compile/internal/types2/named.go
- M src/go/types/named.go
Change size: L
Delta: 2 files changed, 184 insertions(+), 90 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Robert Griesemer
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI