Skip to content

Commit

Permalink
cmd/compile: don't emit stack maps for write barrier calls
Browse files Browse the repository at this point in the history
These are necessarily deeply non-preemptible, so there's no point in
emitting stack maps for them. We already mark them as unsafe points,
so this only affects the runtime, since user code does not emit stack
maps at unsafe points. SSAGenState.PrepareCall also excludes them when
it's sanity checking call stack maps.

Right now this only drops a handful of unnecessary stack maps from the
runtime, but we're about to start emitting stack maps only at calls
for user code, too. At that point, this will matter much more.

For golang#36365.

Change-Id: Ib3abfedfddc8e724d933a064fa4d573500627990
Reviewed-on: https://go-review.googlesource.com/c/go/+/230542
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
  • Loading branch information
aclements authored and xujianhai666 committed May 21, 2020
1 parent 31743ad commit 6bb52b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/cmd/compile/internal/gc/plive.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,16 @@ func (lv *Liveness) hasStackMap(v *ssa.Value) bool {
// we only need stack maps at call sites. go:nosplit functions
// are similar.
if compiling_runtime || lv.f.NoSplit {
return v.Op.IsCall()
if !v.Op.IsCall() {
return false
}
// typedmemclr and typedmemmove are write barriers and
// deeply non-preemptible. They are unsafe points and
// hence should not have liveness maps.
if sym, _ := v.Aux.(*obj.LSym); sym == typedmemclr || sym == typedmemmove {
return false
}
return true
}

switch v.Op {
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -6572,9 +6572,7 @@ func (s *SSAGenState) Call(v *ssa.Value) *obj.Prog {
func (s *SSAGenState) PrepareCall(v *ssa.Value) {
idx := s.livenessMap.Get(v)
if !idx.StackMapValid() {
// typedmemclr and typedmemmove are write barriers and
// deeply non-preemptible. They are unsafe points and
// hence should not have liveness maps.
// See Liveness.hasStackMap.
if sym, _ := v.Aux.(*obj.LSym); !(sym == typedmemclr || sym == typedmemmove) {
Fatalf("missing stack map index for %v", v.LongString())
}
Expand Down

0 comments on commit 6bb52b4

Please sign in to comment.