]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: make HasHeapPointer recursive
authorAustin Clements <austin@google.com>
Tue, 24 Oct 2017 20:34:33 +0000 (16:34 -0400)
committerAustin Clements <austin@google.com>
Sun, 29 Oct 2017 20:21:47 +0000 (20:21 +0000)
commit316e3036a7dda449ed9e64b3ab86ef686080a343
tree1d2a5761c25d9837f998e386ca88c2e25fcba7a9
parentafbe646ab4480696d61462e9cab2ad048b5c1b6c
cmd/compile: make HasHeapPointer recursive

Currently (*Type).HasHeapPointer only ignores pointers go:notinheap
types if the type itself is a pointer to a go:notinheap type. However,
if it's some other type that contains pointers where all of those
pointers are go:notinheap, it will conservatively return true. As a
result, we'll use write barriers where they aren't needed, for example
calling typedmemmove instead of just memmove on structs that contain
only go:notinheap pointers.

Fix this by making HasHeapPointer walk the whole type looking for
pointers that aren't marked go:notinheap.

Change-Id: Ib8c6abf6f7a20f34969d1d402c5498e0b990be59
Reviewed-on: https://go-review.googlesource.com/73412
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/types/type.go
test/notinheap3.go [new file with mode: 0644]