Leandro Lucarella wrote:
Walter Bright, el 18 de agosto a las 10:08 me escribiste:
bearophile wrote:
Currently in the D2 GC there is no notion of pinned/unpinned class instances,
but eventually an attribute as @pinned may be added to D3, plus its related
semantics. It adds complexity to the language and it needs to interact with
the GC, so it will get useful as the D GC becomes more modern (with different
zones for newly allocated objects, etc).
There is no need for a pin attribute, the gc can determine if a
class needs pinning or not.
As long as the precise heap scanning patch is applied (and much better
if we can manage to scan the static data precisely too). Otherwise you
simply just can't move stuff around because you don't know what is
a pointer and what is not (thus you can't update pointer that point to
moved stuff).
Hence the objects with ambiguous references to them get automatically pinned by
the gc. I've implemented such a gc before, it works fine. It's called a "mostly
copying collector".
Besides, any scheme where you have to manually mark pinnable objects is doomed
to have disastrously subtle and hard-to-find bugs.