• Austin Clements's avatar
    cmd/compile: elide write barriers for copy of notinheap pointers · b78b54ff
    Austin Clements authored
    Currently copy and append for types containing only scalars and
    notinheap pointers still get compiled to have write barriers, even
    though those write barriers are unnecessary. Fix these to use
    HasHeapPointer instead of just Haspointer so that they elide write
    barriers when possible.
    
    This fixes the unnecessary write barrier in runtime.recordspan when it
    grows the h.allspans slice. This is important because recordspan gets
    called (*very* indirectly) from (*gcWork).tryGet, which is
    go:nowritebarrierrec. Unfortunately, the compiler's analysis has no
    hope of seeing this because it goes through the indirect call
    fixalloc.first, but I saw it happen.
    
    Change-Id: Ieba3abc555a45f573705eab780debcfe5c4f5dd1
    Reviewed-on: https://go-review.googlesource.com/73413
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    b78b54ff
notinheap3.go 936 Bytes