public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Threadsafe Garbage Collection allocation
@ 2019-06-28 20:48 Giuliano Belinassi
  2019-06-28 21:20 ` Jeff Law
  2019-06-29  6:31 ` Richard Biener
  0 siblings, 2 replies; 3+ messages in thread
From: Giuliano Belinassi @ 2019-06-28 20:48 UTC (permalink / raw)
  To: gcc, richard.guenther

Hi,

***
Question: What are all the possible ways to allocate and deallocate memory
through the Garbage Collector?
***

Context: I am parallelizing GCC internals and I am facing problems with the GCC
Garbage Collector, and therefore I need to make it threadsafe to continue with
the project.

Currently, I want to do a palliative solution to this, which is locking a mutex
every time a chunk of memory is allocated or deallocated. For this, I need to
know all the possibilities to allocate and deallocate memory and lock/unlock
the mutex there.

As far as I have seen, there are the macros XALLOC, XNEW, XNEWVEC... defined in
libiberty.h which are called everywhere in GCC, but I don't know if these are
the only ways to allocate memory in GCC through the Garbage Collector.

Thank you for your support,
Giuliano.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Threadsafe Garbage Collection allocation
  2019-06-28 20:48 Threadsafe Garbage Collection allocation Giuliano Belinassi
@ 2019-06-28 21:20 ` Jeff Law
  2019-06-29  6:31 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2019-06-28 21:20 UTC (permalink / raw)
  To: Giuliano Belinassi, gcc, richard.guenther

On 6/28/19 2:48 PM, Giuliano Belinassi wrote:
> Hi,
> 
> ***
> Question: What are all the possible ways to allocate and deallocate memory
> through the Garbage Collector?
> ***
> 
> Context: I am parallelizing GCC internals and I am facing problems with the GCC
> Garbage Collector, and therefore I need to make it threadsafe to continue with
> the project.
> 
> Currently, I want to do a palliative solution to this, which is locking a mutex
> every time a chunk of memory is allocated or deallocated. For this, I need to
> know all the possibilities to allocate and deallocate memory and lock/unlock
> the mutex there.
> 
> As far as I have seen, there are the macros XALLOC, XNEW, XNEWVEC... defined in
> libiberty.h which are called everywhere in GCC, but I don't know if these are
> the only ways to allocate memory in GCC through the Garbage Collector.
Those allocate via malloc, not the GC system.

ggc_alloc is where you want to be looking.

jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Threadsafe Garbage Collection allocation
  2019-06-28 20:48 Threadsafe Garbage Collection allocation Giuliano Belinassi
  2019-06-28 21:20 ` Jeff Law
@ 2019-06-29  6:31 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2019-06-29  6:31 UTC (permalink / raw)
  To: Giuliano Belinassi, gcc

On June 28, 2019 10:48:51 PM GMT+02:00, Giuliano Belinassi <giuliano.belinassi@usp.br> wrote:
>Hi,
>
>***
>Question: What are all the possible ways to allocate and deallocate
>memory
>through the Garbage Collector?
>***
>
>Context: I am parallelizing GCC internals and I am facing problems with
>the GCC
>Garbage Collector, and therefore I need to make it threadsafe to
>continue with
>the project.
>
>Currently, I want to do a palliative solution to this, which is locking
>a mutex
>every time a chunk of memory is allocated or deallocated. For this, I
>need to
>know all the possibilities to allocate and deallocate memory and
>lock/unlock
>the mutex there.
>
>As far as I have seen, there are the macros XALLOC, XNEW, XNEWVEC...
>defined in
>libiberty.h which are called everywhere in GCC, but I don't know if
>these are
>the only ways to allocate memory in GCC through the Garbage Collector.

GC allocation will eventually call ggc_alloc_internal and manual freeing ggc_free. Collection goes via ggc_collect and is done only at specific points triggered from the pass manager. 

Richard. 

>Thank you for your support,
>Giuliano.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-29  6:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28 20:48 Threadsafe Garbage Collection allocation Giuliano Belinassi
2019-06-28 21:20 ` Jeff Law
2019-06-29  6:31 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).