Skip to content

Commit a6deafa

Browse files
committed
cmd/compile: rename issafepoint -> hasStackMap
Currently, this function conflates two (easily conflated!) concepts: whether a Value is a safe-point and whether it has a stack map. In particular, call Values may not be a safe-point, but may need a stack map anyway in case the called function grows the stack. Hence, rename this function to "hasStackMap", since that's really what it represents. For #36365. Change-Id: I89839de0be8db3be3f0d3a7fb5fcf0b0b6ebc98a Reviewed-on: https://go-review.googlesource.com/c/go/+/230540 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
1 parent 2bad2f7 commit a6deafa

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/cmd/compile/internal/gc/plive.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ func (lv *Liveness) pointerMap(liveout bvec, vars []*Node, args, locals bvec) {
646646
func (lv *Liveness) markUnsafePoints() {
647647
if compiling_runtime || lv.f.NoSplit {
648648
// No complex analysis necessary. Do this on the fly
649-
// in issafepoint.
649+
// in hasStackMap.
650650
return
651651
}
652652

@@ -801,9 +801,12 @@ func (lv *Liveness) markUnsafePoints() {
801801
}
802802
}
803803

804-
// Returns true for instructions that are safe points that must be annotated
805-
// with liveness information.
806-
func (lv *Liveness) issafepoint(v *ssa.Value) bool {
804+
// Returns true for instructions that must have a stack map.
805+
//
806+
// This does not necessarily mean the instruction is a safe-point. In
807+
// particular, call Values can have a stack map in case the callee
808+
// grows the stack, but not themselves be a safe-point.
809+
func (lv *Liveness) hasStackMap(v *ssa.Value) bool {
807810
// The runtime was written with the assumption that
808811
// safe-points only appear at call sites (because that's how
809812
// it used to be). We could and should improve that, but for
@@ -1049,7 +1052,7 @@ func (lv *Liveness) epilogue() {
10491052
// Walk forward through the basic block instructions and
10501053
// allocate liveness maps for those instructions that need them.
10511054
for _, v := range b.Values {
1052-
if !lv.issafepoint(v) {
1055+
if !lv.hasStackMap(v) {
10531056
continue
10541057
}
10551058

@@ -1064,7 +1067,7 @@ func (lv *Liveness) epilogue() {
10641067
for i := len(b.Values) - 1; i >= 0; i-- {
10651068
v := b.Values[i]
10661069

1067-
if lv.issafepoint(v) {
1070+
if lv.hasStackMap(v) {
10681071
// Found an interesting instruction, record the
10691072
// corresponding liveness information.
10701073

@@ -1113,7 +1116,7 @@ func (lv *Liveness) epilogue() {
11131116
// of the context register, so it's dead after the call.
11141117
index = int32(firstBitmapIndex)
11151118
for _, v := range b.Values {
1116-
if lv.issafepoint(v) {
1119+
if lv.hasStackMap(v) {
11171120
live := lv.livevars[index]
11181121
if v.Op.IsCall() && live.regs != 0 {
11191122
lv.printDebug()
@@ -1185,7 +1188,7 @@ func (lv *Liveness) compact(b *ssa.Block) {
11851188
pos++
11861189
}
11871190
for _, v := range b.Values {
1188-
if lv.issafepoint(v) {
1191+
if lv.hasStackMap(v) {
11891192
lv.livenessMap.set(v, add(lv.livevars[pos]))
11901193
pos++
11911194
}
@@ -1360,7 +1363,7 @@ func (lv *Liveness) printDebug() {
13601363
fmt.Printf("\n")
13611364
}
13621365

1363-
if !lv.issafepoint(v) {
1366+
if !lv.hasStackMap(v) {
13641367
continue
13651368
}
13661369

0 commit comments

Comments
 (0)