]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: use go:notinheap for anonymous structs
authorKeith Randall <khr@golang.org>
Wed, 26 Aug 2020 21:17:35 +0000 (14:17 -0700)
committerKeith Randall <khr@golang.org>
Wed, 16 Sep 2020 17:26:46 +0000 (17:26 +0000)
commit42b023d7b9cb8229e3035fa3d36bce41a1ef0c43
tree9aab593bbf7bf04bdafe9298280130e0ee21f570
parent4f915911e84819b69329a224d5b646983ac9fed7
cmd/cgo: use go:notinheap for anonymous structs

They can't reasonably be allocated on the heap. Not a huge deal, but
it has an interesting and useful side effect.

After CL 249917, the compiler and runtime treat pointers to
go:notinheap types as uintptrs instead of real pointers (no write
barrier, not processed during stack scanning, ...). That feature is
exactly what we want for cgo to fix #40954. All the cases we have of
pointers declared in C, but which might actually be filled with
non-pointer data, are of this form (JNI's jobject heirarch, Darwin's
CFType heirarchy, ...).

Fixes #40954

Change-Id: I44a3b9bc2513d4287107e39d0cbbd0efd46a3aae
Reviewed-on: https://go-review.googlesource.com/c/go/+/250940
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go
src/cmd/cgo/out.go
test/fixedbugs/issue40954.go [new file with mode: 0644]