Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3b25b3c

Browse files
committedFeb 20, 2025
cmd/compile: remove residual register GC map code
We used to generate register GC maps as an experimental approach for asynchronous preemption, which later we chose not to take. Most of the register GC map code are already removed. One exception is that the ssa.Register type still contains a field for the register map index. Remove it. Change-Id: Ib177ebce9548aa5ffbcaedd4b507240ea7df8afe Reviewed-on: https://go-review.googlesource.com/c/go/+/651076 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 266b0cf commit 3b25b3c

File tree

4 files changed

+551
-586
lines changed

4 files changed

+551
-586
lines changed
 

Diff for: ‎src/cmd/compile/internal/ssa/_gen/main.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ func genOp() {
426426
continue
427427
}
428428
fmt.Fprintf(w, "var registers%s = [...]Register {\n", a.name)
429-
var gcRegN int
430429
num := map[string]int8{}
431430
for i, r := range a.regnames {
432431
num[r] = int8(i)
@@ -443,14 +442,7 @@ func genOp() {
443442
default:
444443
objname = pkg + ".REG_" + r
445444
}
446-
// Assign a GC register map index to registers
447-
// that may contain pointers.
448-
gcRegIdx := -1
449-
if a.gpregmask&(1<<uint(i)) != 0 {
450-
gcRegIdx = gcRegN
451-
gcRegN++
452-
}
453-
fmt.Fprintf(w, " {%d, %s, %d, \"%s\"},\n", i, objname, gcRegIdx, r)
445+
fmt.Fprintf(w, " {%d, %s, \"%s\"},\n", i, objname, r)
454446
}
455447
parameterRegisterList := func(paramNamesString string) []int8 {
456448
paramNamesString = strings.TrimSpace(paramNamesString)
@@ -477,10 +469,6 @@ func genOp() {
477469
paramIntRegs := parameterRegisterList(a.ParamIntRegNames)
478470
paramFloatRegs := parameterRegisterList(a.ParamFloatRegNames)
479471

480-
if gcRegN > 32 {
481-
// Won't fit in a uint32 mask.
482-
log.Fatalf("too many GC registers (%d > 32) on %s", gcRegN, a.name)
483-
}
484472
fmt.Fprintln(w, "}")
485473
fmt.Fprintf(w, "var paramIntReg%s = %#v\n", a.name, paramIntRegs)
486474
fmt.Fprintf(w, "var paramFloatReg%s = %#v\n", a.name, paramFloatRegs)

Diff for: ‎src/cmd/compile/internal/ssa/config.go

+17-33
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,23 @@ type Config struct {
3737
floatParamRegs []int8 // register numbers of floating param (in/out) registers
3838
ABI1 *abi.ABIConfig // "ABIInternal" under development // TODO change comment when this becomes current
3939
ABI0 *abi.ABIConfig
40-
GCRegMap []*Register // garbage collector register map, by GC register index
41-
FPReg int8 // register number of frame pointer, -1 if not used
42-
LinkReg int8 // register number of link register if it is a general purpose register, -1 if not used
43-
hasGReg bool // has hardware g register
44-
ctxt *obj.Link // Generic arch information
45-
optimize bool // Do optimization
46-
noDuffDevice bool // Don't use Duff's device
47-
useSSE bool // Use SSE for non-float operations
48-
useAvg bool // Use optimizations that need Avg* operations
49-
useHmul bool // Use optimizations that need Hmul* operations
50-
SoftFloat bool //
51-
Race bool // race detector enabled
52-
BigEndian bool //
53-
UseFMA bool // Use hardware FMA operation
54-
unalignedOK bool // Unaligned loads/stores are ok
55-
haveBswap64 bool // architecture implements Bswap64
56-
haveBswap32 bool // architecture implements Bswap32
57-
haveBswap16 bool // architecture implements Bswap16
40+
FPReg int8 // register number of frame pointer, -1 if not used
41+
LinkReg int8 // register number of link register if it is a general purpose register, -1 if not used
42+
hasGReg bool // has hardware g register
43+
ctxt *obj.Link // Generic arch information
44+
optimize bool // Do optimization
45+
noDuffDevice bool // Don't use Duff's device
46+
useSSE bool // Use SSE for non-float operations
47+
useAvg bool // Use optimizations that need Avg* operations
48+
useHmul bool // Use optimizations that need Hmul* operations
49+
SoftFloat bool //
50+
Race bool // race detector enabled
51+
BigEndian bool //
52+
UseFMA bool // Use hardware FMA operation
53+
unalignedOK bool // Unaligned loads/stores are ok
54+
haveBswap64 bool // architecture implements Bswap64
55+
haveBswap32 bool // architecture implements Bswap32
56+
haveBswap16 bool // architecture implements Bswap16
5857
}
5958

6059
type (
@@ -385,21 +384,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize, softfloat boo
385384
opcodeTable[Op386LoweredWB].reg.clobbers |= 1 << 3 // BX
386385
}
387386

388-
// Create the GC register map index.
389-
// TODO: This is only used for debug printing. Maybe export config.registers?
390-
gcRegMapSize := int16(0)
391-
for _, r := range c.registers {
392-
if r.gcNum+1 > gcRegMapSize {
393-
gcRegMapSize = r.gcNum + 1
394-
}
395-
}
396-
c.GCRegMap = make([]*Register, gcRegMapSize)
397-
for i, r := range c.registers {
398-
if r.gcNum != -1 {
399-
c.GCRegMap[r.gcNum] = &c.registers[i]
400-
}
401-
}
402-
403387
return c
404388
}
405389

Diff for: ‎src/cmd/compile/internal/ssa/location.go

-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type Location interface {
2020
type Register struct {
2121
num int32 // dense numbering
2222
objNum int16 // register number from cmd/internal/obj/$ARCH
23-
gcNum int16 // GC register map number (dense numbering of registers that can contain pointers)
2423
name string
2524
}
2625

@@ -34,12 +33,6 @@ func (r *Register) ObjNum() int16 {
3433
return r.objNum
3534
}
3635

37-
// GCNum returns the runtime GC register index of r, or -1 if this
38-
// register can't contain pointers.
39-
func (r *Register) GCNum() int16 {
40-
return r.gcNum
41-
}
42-
4336
// A LocalSlot is a location in the stack frame, which identifies and stores
4437
// part or all of a PPARAM, PPARAMOUT, or PAUTO ONAME node.
4538
// It can represent a whole variable, part of a larger stack slot, or part of a

Diff for: ‎src/cmd/compile/internal/ssa/opGen.go

+533-533
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.