GC/non-GC memory as part of data type?

Gregor Mückl gregormueckl at gmx.de
Thu Nov 14 20:42:14 UTC 2019


On Wednesday, 13 November 2019 at 15:25:46 UTC, James Lu wrote:
> On Wednesday, 13 November 2019 at 15:19:38 UTC, Gregor Mückl 
> wrote:
>> Hi!
>>
>> This is an attempt to follow up on the DIP1025 discussion: 
>> what happens if all pointers/arrays/references carry the 
>> origin of the pointed to memory region as part of their type? 
>> The goal is to have a cleaner, more explicit separation of GC 
>> and non-GC heaps.
>>
>> [...]
>
> We could add @nogc types. That indicates to the implementation
> that the memory held by that type MAY be ignored by the GC and 
> that
> that any pointers held in that type MUST NOT be moved by a 
> moving
> GC.
>
> Alternatively, "special" pointers could have a .toPointer 
> function
> that converts itself into the memory address they mean. 
> Applications
> include XOR pointers.

Haven't thought about moving GC allocated memory yet. Does the 
current D spec even allow this? The way you're allowed to take 
pointers to GC memory and store them in places unknown to the GC 
should prevent it.


More information about the Digitalmars-d mailing list