]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.15] cmd/cgo: use go:notinheap for anonymous structs
authorKeith Randall <khr@golang.org>
Wed, 26 Aug 2020 21:17:35 +0000 (14:17 -0700)
committerDmitri Shuralyov <dmitshur@golang.org>
Fri, 9 Oct 2020 17:25:11 +0000 (17:25 +0000)
commit96983721d42e9e238ea9fec720849ab7bb616122
tree1664581ba93f3ffb6401e7cd90d0ff9f41ee7280
parent142027888a7d3da0494d77581166f1d120317864
[release-branch.go1.15] 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>
Reviewed-on: https://go-review.googlesource.com/c/go/+/255321
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go
src/cmd/cgo/out.go
test/fixedbugs/issue40954.go [new file with mode: 0644]