aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2017-04-13 06:11:36 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2017-04-13 16:37:04 +0000
commit16df2ccdedec47d0be940702bb064f656091bd28 (patch)
tree71a1fc78b924bdced12b6bf9e7b2c9767e542b47
parentb0e5a0c93ccf5166dab30864df7e5632a5973447 (diff)
downloadgo-16df2ccdedec47d0be940702bb064f656091bd28.tar.xz
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>
-rw-r--r--src/cmd/compile/internal/gc/walk.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 7cdc56d05c..954433c447 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -502,6 +502,8 @@ opswitch:
case OTYPE, ONAME, OLITERAL:
// TODO(mdempsky): Just return n; see discussion on CL 38655.
// 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,
OIND, OSPTR, OITAB, OIDATA, OADDR:
@@ -1653,6 +1655,11 @@ opswitch:
}
if n.Op == OLITERAL {
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)