Commit 3431d911 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: add global autogeneratedPos

We use an "autogenerated" position in several places.
Rather than recreate it each time, make one early on and reuse it.
This removes the creation of new positions during the backend,
which was not concurrency-safe.

Updates #15756

Change-Id: Ic116b2e60f0e99de1a2ea87fe763831b50b645f8
Reviewed-on: https://go-review.googlesource.com/38915
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent b28f2f73
...@@ -186,7 +186,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -186,7 +186,7 @@ func genhash(sym *Sym, t *Type) {
fmt.Printf("genhash %v %v\n", sym, t) fmt.Printf("genhash %v %v\n", sym, t)
} }
lineno = makePos(nil, 1, 0) // less confusing than end of input lineno = autogeneratedPos // less confusing than end of input
dclcontext = PEXTERN dclcontext = PEXTERN
markdcl() markdcl()
...@@ -364,7 +364,7 @@ func geneq(sym *Sym, t *Type) { ...@@ -364,7 +364,7 @@ func geneq(sym *Sym, t *Type) {
fmt.Printf("geneq %v %v\n", sym, t) fmt.Printf("geneq %v %v\n", sym, t)
} }
lineno = makePos(nil, 1, 0) // less confusing than end of input lineno = autogeneratedPos // less confusing than end of input
dclcontext = PEXTERN dclcontext = PEXTERN
markdcl() markdcl()
......
...@@ -286,6 +286,8 @@ var nodfp *Node ...@@ -286,6 +286,8 @@ var nodfp *Node
var disable_checknil int var disable_checknil int
var autogeneratedPos src.XPos
// interface to back end // interface to back end
type Arch struct { type Arch struct {
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
package gc package gc
import "cmd/internal/src"
// a function named init is a special case. // a function named init is a special case.
// it is called by the initialization before // it is called by the initialization before
// main is run. to make it unique within a // main is run. to make it unique within a
...@@ -77,7 +75,7 @@ func anyinit(n []*Node) bool { ...@@ -77,7 +75,7 @@ func anyinit(n []*Node) bool {
} }
func fninit(n []*Node) { func fninit(n []*Node) {
lineno = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0) lineno = autogeneratedPos
nf := initfix(n) nf := initfix(n)
if !anyinit(nf) { if !anyinit(nf) {
return return
......
...@@ -351,6 +351,8 @@ func Main(archInit func(*Arch)) { ...@@ -351,6 +351,8 @@ func Main(archInit func(*Arch)) {
dclcontext = PEXTERN dclcontext = PEXTERN
nerrors = 0 nerrors = 0
autogeneratedPos = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
timings.Start("fe", "loadsys") timings.Start("fe", "loadsys")
loadsys() loadsys()
......
...@@ -1717,7 +1717,7 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) { ...@@ -1717,7 +1717,7 @@ func genwrapper(rcvr *Type, method *Field, newnam *Sym, iface int) {
fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam) fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam)
} }
lineno = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0) lineno = autogeneratedPos
dclcontext = PEXTERN dclcontext = PEXTERN
markdcl() markdcl()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment