[Gc] Determining if pointer GC allocated

Hans Aberg haberg-1 at telia.com
Wed Dec 21 05:22:45 PST 2011


On 21 Dec 2011, at 13:00, Bruce Hoult wrote:

>>>> Is there a function to check if a pointer has been allocated by the
>>>> GC? That is, something like
>>>>   bool is_on_heap(void* p);
>>>> that returns true exactly when p has been allocated by the GC.
>>>> And would such a function be time consuming?
>>> 
>>> Check whether GC_base(p) returns 0.
>> 
>> Thanks! I saw this function, but did not realize it could be used.
>> 
>> How time-consuming is this call?
> 
> It's used in the inner loop of the marking phase in the GC, so much
> effort is made to make it fast!
> 
> Without actually reading the source code right now, I'd guess it is on
> the order of 10 memory references.

Would it be possible to implement a significantly faster function that just checks if the pointer is GC allocated, rather than finding the base?

Hans





More information about the Gc mailing list