Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I assume there are tradeoffs? Or are precise garbage collectors simply better everywhere (except maybe complexity)?


They're better everywhere except complexity. The two main things that add to the complexity in Go's case are:

1) Existing compilers. Both GCC and LLVM don't precisely track object pointers throughout code generation.

2) Existing FFIs. If you expose an FFI that allows object pointers leak to C code without anything to anchor them as a root then you lock yourself into a conservative GC.


I'm pretty sure that the existing conservative GC in cgo doesn't even scan the C part of the heap, so if you try to use unanchored pointers to Go objects, you will crash. More details here, in the comments: https://code.google.com/p/go/source/browse/misc/cgo/gmp/gmp....

I'm not sure how gccgo does it. There may be some limitations there based on the gcc internals, but I don't see why that would prevent cgo from developing a precise collector.


It wasn't obvious to me looking at the source of te actual GC implementatiob whether it avoids the C stack frames between Go frames. If it does then they don't have much to worry about.


I'm not sure about stack frames, but I do remember a lot of discussion about golang using a single contiguous area of virtual memory for its heap. Since C wouldn't be using that same address range, there would be no potential issues where someone would put a Go object on the C heap for a long time and have that result in implicit GC pinning. C stack frames may be an issue (I haven't checked either) but only for upcalls from C, which seem rare.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: