Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Ian Lance Taylor
On Wed, Dec 20, 2017 at 2:45 AM, Xuanyi Chew wrote: > > I'm guessing also, that a "true" pointer has to be byte aligned - no pointer > tagging shennanigans with unsafe.Pointer You can do all the pointer tagging you like as long as the final bits can not be interpreted as a pointer into the Go hea

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Ian Lance Taylor
On Wed, Dec 20, 2017 at 1:54 AM, Jan Mercl <0xj...@gmail.com> wrote: > > On Wed, Dec 20, 2017 at 12:57 AM 'Keith Randall' via golang-nuts > wrote: > >> Pointers that point from a Go object to somewhere outside the Go heap are >> perfectly fine. > > Can you please specify the exact mechanism used b

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Xuanyi Chew
I'm guessing also, that a "true" pointer has to be byte aligned - no pointer tagging shennanigans with unsafe.Pointer On Wednesday, 20 December 2017 21:42:49 UTC+11, Xuanyi Chew wrote: > > I echo this. > > On Wednesday, 20 December 2017 20:55:03 UTC+11, Jan Mercl wrote: >> >> >> On Wed, Dec 20, 2

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Xuanyi Chew
I echo this. On Wednesday, 20 December 2017 20:55:03 UTC+11, Jan Mercl wrote: > > > On Wed, Dec 20, 2017 at 12:57 AM 'Keith Randall' via golang-nuts < > golan...@googlegroups.com > wrote: > > > Pointers that point from a Go object to somewhere outside the Go heap > are perfectly fine. > > Can you

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Jan Mercl
On Wed, Dec 20, 2017 at 12:57 AM 'Keith Randall' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Pointers that point from a Go object to somewhere outside the Go heap are perfectly fine. Can you please specify the exact mechanism used by the runtime to determine "is outside the Go heap"?

Re: [go-nuts] GC Internals Questions

2017-12-19 Thread 'Keith Randall' via golang-nuts
Pointers that point from a Go object to somewhere outside the Go heap are perfectly fine. The Go runtime will not try to dereference them. unsafe.Pointer is ok, but so are concrete types, like *byte. One caveat: the pointer must be a real pointer. Don't store a bunch of bitfields in a Go pointer

Re: [go-nuts] GC Internals Questions

2017-12-19 Thread Xuanyi Chew
I've partially remembered why I used unsafe.Pointer instead of uintptr. In cases where the tensor was built from an existing memory (i.e building a tensor with Go allocated slice backing), I wanted the slice to not be GC'd away On Wednesday, 20 December 2017 00:00:10 UTC+11, Jan Mercl wrote: >

Re: [go-nuts] GC Internals Questions

2017-12-19 Thread Jan Mercl
On Tue, Dec 19, 2017 at 1:50 PM Xuanyi Chew wrote: > As such I have no idea what would happen if the GC scanner hits a unsafe.Pointer that it cannot access. Will the pointer be marked as unaccessible? Does it panic with SIGBUS? I think the GC will not try to dereference a pointer that is known t