1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:50:22 -07:00

cmd/internal/obj: remove Link.Plan9privates

Move it to the x86 package, matching our handling
of deferreturn in x86 and arm.
While we're here, improve the concurrency safety
of both Plan9privates and deferreturn
by eagerly initializing them in instinit.

Updates #15756

Change-Id: If3b1995c1e4ec816a5443a18f8d715631967a8b1
Reviewed-on: https://go-review.googlesource.com/40408
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2017-04-12 06:11:08 -07:00
parent b8d327a438
commit 49f4b5a4f5
3 changed files with 14 additions and 17 deletions

View File

@ -725,7 +725,6 @@ type Link struct {
PosTable src.PosTable
InlTree InlTree // global inlining tree used by gc/inl.go
Imports []string
Plan9privates *LSym
DiagFunc func(string, ...interface{})
DebugInfo func(fn *LSym, curfn interface{}) []*dwarf.Var // if non-nil, curfn is a *gc.Node
Errors int

View File

@ -39,6 +39,11 @@ import (
"strings"
)
var (
plan9privates *obj.LSym
deferreturn *obj.LSym
)
// Instruction layout.
const (
@ -1830,10 +1835,6 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
n := 0
var c int32
errors := ctxt.Errors
var deferreturn *obj.LSym
if ctxt.Headtype == obj.Hnacl {
deferreturn = ctxt.Lookup("runtime.deferreturn", 0)
}
for {
loop := int32(0)
for i := range s.R {
@ -1973,6 +1974,13 @@ func instinit(ctxt *obj.Link) {
return
}
switch ctxt.Headtype {
case obj.Hplan9:
plan9privates = ctxt.Lookup("_privates", 0)
case obj.Hnacl:
deferreturn = ctxt.Lookup("runtime.deferreturn", 0)
}
for i := 1; optab[i].as != 0; i++ {
c := optab[i].as
if opindex[c&obj.AMask] != nil {
@ -4108,13 +4116,10 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
}
case obj.Hplan9:
if ctxt.Plan9privates == nil {
ctxt.Plan9privates = ctxt.Lookup("_privates", 0)
}
pp.From = obj.Addr{}
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_EXTERN
pp.From.Sym = ctxt.Plan9privates
pp.From.Sym = plan9privates
pp.From.Offset = 0
pp.From.Index = REG_NONE
asmbuf.Put1(0x8B)
@ -4164,13 +4169,10 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.PutInt32(0)
case obj.Hplan9:
if ctxt.Plan9privates == nil {
ctxt.Plan9privates = ctxt.Lookup("_privates", 0)
}
pp.From = obj.Addr{}
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_EXTERN
pp.From.Sym = ctxt.Plan9privates
pp.From.Sym = plan9privates
pp.From.Offset = 0
pp.From.Index = REG_NONE
asmbuf.rexflag |= Pw

View File

@ -589,10 +589,6 @@ func nacladdr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
}
func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
if ctxt.Headtype == obj.Hplan9 && ctxt.Plan9privates == nil {
ctxt.Plan9privates = ctxt.Lookup("_privates", 0)
}
if cursym.Text == nil || cursym.Text.Link == nil {
return
}