Question about garbage collection specification

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 14 04:58:50 PDT 2015


On Sunday, 14 June 2015 at 11:57:35 UTC, rsw0x wrote:
> On Sunday, 14 June 2015 at 11:36:59 UTC, Paulo Pinto wrote:
>> On Sunday, 14 June 2015 at 11:03:00 UTC, Marc Schütz wrote:
>>> On Saturday, 13 June 2015 at 22:07:26 UTC, deadalnix wrote:
>>>> On Saturday, 13 June 2015 at 11:32:20 UTC, rsw0x wrote:
>>>>> http://dlang.org/garbage.html
>>>>>
>>>>> Do not take advantage of alignment of pointers to store bit 
>>>>> flags in the low order bits:
>>>>> p = cast(void*)(cast(int)p | 1);  // error: undefined 
>>>>> behavior
>>>>>
>>>>> if this restriction is actually imposed - why does 
>>>>> std.bitmanip.tagged{ClassRef,Pointer} even exist?
>>>>
>>>> That seems like an arbitrary limitation. This will create an 
>>>> interior pointer, which the GC needs to recognize anyway.
>>>>
>>>> The doc need to be updated.
>>>
>>> I see David Nadlinger already said so in the PR, but that's 
>>> how I understand it:
>>>
>>> AFAIU the purpose of this restriction is to allow the GC to 
>>> take advantage of alignment: a pointer with the lowest bit 
>>> set cannot point to a 4-byte aligned struct, for example. The 
>>> GC doc [1] mentions alignment several times, among them:
>>> "Do not misalign pointers if those pointers may point into 
>>> the GC heap"
>>>
>>> As for arbitrary pointer arithmetic being allowed, I guess 
>>> that's because the language doesn't distinguish between GC 
>>> and non-GC pointers. And note that it is un- at safe anyway.
>>>
>>> [1] http://dlang.org/garbage.html
>>
>> Wouldn't it make sense to do so?
>>
>> Active Oberon, Modula-3 and .NET make such difference in their 
>> pointer types.
>>
>> I would imagine it could help in terms of what is possible for 
>> GC improvements.
>>
>> --
>> Paulo
>
> But a pointer can already point to a one byte aligned part of 
> an object and keep it alive because internal pointers must be 
> supported. The only alignment enforced is that pointers must be 
> aligned. This is an arbitrary restriction.

Woops, replied to the wrong person. My bad.


And yes, you're right that the GC could improve if we went 
towards "d pointers" like Go did.


More information about the Digitalmars-d mailing list