Skip to content

Commit 3b251e6

Browse files
committed
cmd/internal/obj: eagerly initialize x86 assembler
Prior to this CL, instinit was called as needed. This does not work well in a concurrent backend. Initialization is very cheap; do it on startup instead. Passes toolstash-check -all. No compiler performance impact. Updates #15756 Change-Id: Ifa5e82e8abf4504435e1b28766f5703a0555f42d Reviewed-on: https://go-review.googlesource.com/38662 Run-TryBot: Josh Bleecher Snyder <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent e76d6a4 commit 3b251e6

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/cmd/asm/internal/arch/arch.go

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ func archX86(linkArch *obj.LinkArch) *Arch {
171171
instructions["PSRLDQ"] = x86.APSRLO
172172
instructions["PADDD"] = x86.APADDL
173173

174+
x86.InstInit()
175+
174176
return &Arch{
175177
LinkArch: linkArch,
176178
Instructions: instructions,

src/cmd/compile/internal/amd64/galign.go

+2
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ func Init(arch *gc.Arch) {
2727
arch.SSAMarkMoves = ssaMarkMoves
2828
arch.SSAGenValue = ssaGenValue
2929
arch.SSAGenBlock = ssaGenBlock
30+
31+
x86.InstInit()
3032
}

src/cmd/compile/internal/x86/galign.go

+2
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ func Init(arch *gc.Arch) {
3333
arch.Ginsnop = ginsnop
3434

3535
arch.SSAMarkMoves = ssaMarkMoves
36+
37+
x86.InstInit()
3638
}

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ var ymmxmm0f38 = []ytab{
883883
* two values match the Ytypes of the p->from and p->to operands. The function
884884
* oclass in span.c computes the specific Ytype of an operand and then the set
885885
* of more general Ytypes that it satisfies is implied by the ycover table, set
886-
* up in instinit. For example, oclass distinguishes the constants 0 and 1
887-
* from the more general 8-bit constants, but instinit says
886+
* up in InstInit. For example, oclass distinguishes the constants 0 and 1
887+
* from the more general 8-bit constants, but InstInit says
888888
*
889889
* ycover[Yi0*Ymax + Ys32] = 1;
890890
* ycover[Yi1*Ymax + Ys32] = 1;
@@ -1770,7 +1770,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
17701770
}
17711771

17721772
if ycover[0] == 0 {
1773-
instinit()
1773+
ctxt.Diag("x86 tables not initialized, call x86.InstInit first")
17741774
}
17751775

17761776
for p := ctxt.Cursym.Text; p != nil; p = p.Link {
@@ -1965,7 +1965,14 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
19651965
}
19661966
}
19671967

1968-
func instinit() {
1968+
func InstInit() {
1969+
if ycover[0] != 0 {
1970+
// Already initialized; stop now.
1971+
// This happens in the cmd/asm tests,
1972+
// each of which re-initializes the arch.
1973+
return
1974+
}
1975+
19691976
for i := 1; optab[i].as != 0; i++ {
19701977
c := optab[i].as
19711978
if opindex[c&obj.AMask] != nil {

0 commit comments

Comments
 (0)