]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't emit stack maps for write barrier calls
authorAustin Clements <austin@google.com>
Tue, 28 Apr 2020 00:42:00 +0000 (20:42 -0400)
committerAustin Clements <austin@google.com>
Wed, 29 Apr 2020 21:29:18 +0000 (21:29 +0000)
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 #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>
src/cmd/compile/internal/gc/plive.go
src/cmd/compile/internal/gc/ssa.go

index 61c01f5b9d5331a8d4a72e20d7e32ca89d8c106c..707ceca33a367d3df074cdb0d2769dcaaf73a2a3 100644 (file)
@@ -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 {
index e99221c2171c37631d467b5c7e27c91ef02bfa71..70f6dd6e18f4f4a5c0c1fcec9733406d73539f70 100644 (file)
@@ -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())
                }