Re: [Gc] Determining if pointer GC allocated
ivmai at mail.ru
Wed Dec 21 23:47:01 PST 2011
Of course, not a problem to add it to public API (for gc7.3) in case it would be really useful.
22 12 2011, 04:13 "Boehm, Hans" <hans.boehm at hp.com>:
> IIRC, GC_base() is avoided on the most frequently exercised paths in the collector, though those do very similar things using essentially the same data structures. But it is essentially a short piece of straight-line code, so it should indeed be quite fast. Slight improvements are probably possible if you know that the argument is a base pointer. If you assume the argument is a pointer to a valid object, GC_find_header() != 0 might be a bit faster, though it uses an interface that's not currently exported.
> > -----Original Message-----
> > From: gc-bounces at linux.hpl.hp.com [mailto:gc-bounces at linux.hpl.hp.com]
> > On Behalf Of Hans Aberg
> > Sent: Wednesday, December 21, 2011 5:23 AM
> > To: Bruce Hoult
> > Cc: gc at linux.hpl.hp.com; Henning Makholm
> > Subject: Re: [Gc] Determining if pointer GC allocated
> > 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
> > _______________________________________________
> > Gc mailing list
> > Gc at linux.hpl.hp.com
> > https://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> Gc mailing list
> Gc at linux.hpl.hp.com
More information about the Gc