On 11/3/2011 8:14 PM, bearophile wrote:
Mark-compact (aka moving) collectors, where live objects are moved together
to make allocated memory more compact. Note that doing this involves
updating pointers’ values on the fly. This category includes semispace
collectors as well as the more efficient modern ones like the .NET CLR’s
that don’t use up half your memory or address space. C++ cannot support
this without at least a new pointer type, because C/C++ pointer values are
required to be stable (not change their values), so that you can cast them
to an int and back, or write them to a file and back; this is why we
created the ^ pointer type for C++/CLI which can safely point into #3-style
compacting GC heaps. See section 3.3 of my paper
(http://www.gotw.ca/publications/C++CLIRationale.pdf ) A Design Rationale
for C++/CLI for more rationale about ^ and gcnew.<

Tell me if I am wrong still.

You're wrong still :-)

How do you implement a moving GC in D if D has
raw pointers?

It can be done if the D compiler emits full runtime type info. It's a solved problem with GCs.

D semantics doesn't allow the GC to automatically modify those
pointers when the GC moves the data.

Yes, it does. I've implemented a moving collector before designing D, and I carefully defined the semantics so that it could be done for D.

Besides, having two pointer types in D would be disastrously complex. C++/CLI does, and C++/CLI is a failure in the marketplace. (I've dealt with multiple pointer types from the DOS daze, and believe me it is a BAD BAD BAD idea.)

Reply via email to