Skip to content

Commit 49f4b5a

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent b8d327a commit 49f4b5a

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/cmd/internal/obj/link.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ type Link struct {
725725
PosTable src.PosTable
726726
InlTree InlTree // global inlining tree used by gc/inl.go
727727
Imports []string
728-
Plan9privates *LSym
729728
DiagFunc func(string, ...interface{})
730729
DebugInfo func(fn *LSym, curfn interface{}) []*dwarf.Var // if non-nil, curfn is a *gc.Node
731730
Errors int

src/cmd/internal/obj/x86/asm6.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ import (
3939
"strings"
4040
)
4141

42+
var (
43+
plan9privates *obj.LSym
44+
deferreturn *obj.LSym
45+
)
46+
4247
// Instruction layout.
4348

4449
const (
@@ -1830,10 +1835,6 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
18301835
n := 0
18311836
var c int32
18321837
errors := ctxt.Errors
1833-
var deferreturn *obj.LSym
1834-
if ctxt.Headtype == obj.Hnacl {
1835-
deferreturn = ctxt.Lookup("runtime.deferreturn", 0)
1836-
}
18371838
for {
18381839
loop := int32(0)
18391840
for i := range s.R {
@@ -1973,6 +1974,13 @@ func instinit(ctxt *obj.Link) {
19731974
return
19741975
}
19751976

1977+
switch ctxt.Headtype {
1978+
case obj.Hplan9:
1979+
plan9privates = ctxt.Lookup("_privates", 0)
1980+
case obj.Hnacl:
1981+
deferreturn = ctxt.Lookup("runtime.deferreturn", 0)
1982+
}
1983+
19761984
for i := 1; optab[i].as != 0; i++ {
19771985
c := optab[i].as
19781986
if opindex[c&obj.AMask] != nil {
@@ -4108,13 +4116,10 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
41084116
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
41094117
}
41104118
case obj.Hplan9:
4111-
if ctxt.Plan9privates == nil {
4112-
ctxt.Plan9privates = ctxt.Lookup("_privates", 0)
4113-
}
41144119
pp.From = obj.Addr{}
41154120
pp.From.Type = obj.TYPE_MEM
41164121
pp.From.Name = obj.NAME_EXTERN
4117-
pp.From.Sym = ctxt.Plan9privates
4122+
pp.From.Sym = plan9privates
41184123
pp.From.Offset = 0
41194124
pp.From.Index = REG_NONE
41204125
asmbuf.Put1(0x8B)
@@ -4164,13 +4169,10 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
41644169
asmbuf.PutInt32(0)
41654170

41664171
case obj.Hplan9:
4167-
if ctxt.Plan9privates == nil {
4168-
ctxt.Plan9privates = ctxt.Lookup("_privates", 0)
4169-
}
41704172
pp.From = obj.Addr{}
41714173
pp.From.Type = obj.TYPE_MEM
41724174
pp.From.Name = obj.NAME_EXTERN
4173-
pp.From.Sym = ctxt.Plan9privates
4175+
pp.From.Sym = plan9privates
41744176
pp.From.Offset = 0
41754177
pp.From.Index = REG_NONE
41764178
asmbuf.rexflag |= Pw

src/cmd/internal/obj/x86/obj6.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ func nacladdr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
589589
}
590590

591591
func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
592-
if ctxt.Headtype == obj.Hplan9 && ctxt.Plan9privates == nil {
593-
ctxt.Plan9privates = ctxt.Lookup("_privates", 0)
594-
}
595-
596592
if cursym.Text == nil || cursym.Text.Link == nil {
597593
return
598594
}

0 commit comments

Comments
 (0)