On Wednesday, 14 May 2014 at 19:45:20 UTC, Marc Schütz wrote:
- We have external code programmed in languages other than D, most prominently C and C++. These don't provide any type information, therefore the GC needs to handle their memory conservatively, which means there can be false pointers => no deterministic destruction.

Oh yes, I agree.

However, you could have rules for collection and FFI (calling C). Like only allowing collection if all C parameters that point to GC memory have a shorter life span than other D pointers to the same memory (kind of like borrowed pointers in Rust).

- Variables on the stack and in registers. In theory, the compiler could generate that information, or existing debug information might be used, but that's complicated for the GC to handle and will probably have runtime costs.

The easy solution is to use something that is to define safe zones where you can freeze (kind of like rendezvous semaphores, but not quite).

- Untagged unions. The GC has no way to figure out which of the union fields is currently valid. If any of them is a pointer, it needs to treat them conservatively.

So you need a function that can help the GC if the pointer fields of the union don't match up or don't point to class instances.

Ola.

Reply via email to