October 30, 2021
On 10/30/21 3:47 PM, Elronnd wrote:

> If the GC were moving, it would also have to move the pointers you took
> to AA elements.

I doubt D's GC can ever change pointer values because the values may be hiding inside e.g. ulong variables. And we would definitely not want the GC to change ulong values just because it thought they were familiar pointer values in disguise. :)

Ali

October 31, 2021
On Sunday, 31 October 2021 at 02:56:35 UTC, Ali Çehreli wrote:
> On 10/30/21 3:47 PM, Elronnd wrote:
>
> > If the GC were moving, it would also have to move the
> pointers you took
> > to AA elements.
>
> I doubt D's GC can ever change pointer values because the values may be hiding inside e.g. ulong variables. And we would definitely not want the GC to change ulong values just because it thought they were familiar pointer values in disguise. :)

Precise GC exists now.
October 31, 2021
On Sat, Oct 30, 2021 at 07:56:35PM -0700, Ali Çehreli via Digitalmars-d-learn wrote:
> On 10/30/21 3:47 PM, Elronnd wrote:
> 
> > If the GC were moving, it would also have to move the pointers you took to AA elements.
> 
> I doubt D's GC can ever change pointer values because the values may be hiding inside e.g. ulong variables. And we would definitely not want the GC to change ulong values just because it thought they were familiar pointer values in disguise. :)
[...]

The current spec explicitly states that masking pointers this way is UB.


T

-- 
Без труда не выловишь и рыбку из пруда.
October 31, 2021
On 10/31/21 9:49 AM, H. S. Teoh wrote:

> The current spec explicitly states that masking pointers this way is UB.

Ok. :) What about unions?

union U {
  ulong u;
  void* p;
}

Can the GC deal with that?

Or other smart ways where I store the pointer in two parts as page+offset? (Perhaps that's UB as well.)

Ali

October 31, 2021
On Sun, Oct 31, 2021 at 09:54:23AM -0700, Ali Çehreli via Digitalmars-d-learn wrote:
> On 10/31/21 9:49 AM, H. S. Teoh wrote:
> 
> > The current spec explicitly states that masking pointers this way is UB.
> 
> Ok. :) What about unions?
> 
> union U {
>   ulong u;
>   void* p;
> }
> 
> Can the GC deal with that?

https://dlang.org/spec/garbage.html#obj_pinning_and_gc


Though I have to say, object pinning does impose restrictions on a moving GC implementation that may negate some of its benefits.


T

-- 
Never criticize a man until you've walked a mile in his shoes. Then when you do criticize him, you'll be a mile away and he won't have his shoes.
October 31, 2021
On 10/31/21 9:54 AM, Ali Çehreli wrote:

> Or other smart ways where I store the pointer in two parts as page+offset?

Ok, that was silly. There would be no reference to the GC memory if I chopped off a pointer. :/

Ali

1 2 3
Next ›   Last »