mirror of
https://github.com/golang/go
synced 2024-11-19 10:44:47 -07:00
cmd/compile: emit string symbols during walk
This avoids needing a mutex to protect stringsym, and preserves a consistent ctxt.Data ordering in the face of a concurrent backend. Updates #15756 Change-Id: I775daae11db5db1269533a00f5249e3a03086ffc Reviewed-on: https://go-review.googlesource.com/40509 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
b0e5a0c93c
commit
16df2ccded
@ -502,6 +502,8 @@ opswitch:
|
|||||||
case OTYPE, ONAME, OLITERAL:
|
case OTYPE, ONAME, OLITERAL:
|
||||||
// TODO(mdempsky): Just return n; see discussion on CL 38655.
|
// TODO(mdempsky): Just return n; see discussion on CL 38655.
|
||||||
// Perhaps refactor to use Node.mayBeShared for these instead.
|
// Perhaps refactor to use Node.mayBeShared for these instead.
|
||||||
|
// If these return early, make sure to still call
|
||||||
|
// stringsym for constant strings.
|
||||||
|
|
||||||
case ONOT, OMINUS, OPLUS, OCOM, OREAL, OIMAG, ODOTMETH, ODOTINTER,
|
case ONOT, OMINUS, OPLUS, OCOM, OREAL, OIMAG, ODOTMETH, ODOTINTER,
|
||||||
OIND, OSPTR, OITAB, OIDATA, OADDR:
|
OIND, OSPTR, OITAB, OIDATA, OADDR:
|
||||||
@ -1653,6 +1655,11 @@ opswitch:
|
|||||||
}
|
}
|
||||||
if n.Op == OLITERAL {
|
if n.Op == OLITERAL {
|
||||||
n = typecheck(n, Erv)
|
n = typecheck(n, Erv)
|
||||||
|
// Emit string symbol now to avoid emitting
|
||||||
|
// any concurrently during the backend.
|
||||||
|
if s, ok := n.Val().U.(string); ok {
|
||||||
|
_ = stringsym(s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHasCall(n)
|
updateHasCall(n)
|
||||||
|
Loading…
Reference in New Issue
Block a user