* Garbage Collector interface - GTY
@ 2003-02-22 12:09 Josef Zlomek
2003-02-22 23:02 ` Geoff Keating
0 siblings, 1 reply; 6+ messages in thread
From: Josef Zlomek @ 2003-02-22 12:09 UTC (permalink / raw)
To: gcc
Hi,
Although I know how to tell garbage collector to mark simple
datastructures, I have a problem with the following one which is more
complicated. I have read the documentation but it is too brief for me.
The data structure is a dynamic array, each element is a struct of
two members - the first and the last element of the chained list. The
nodes (and their internals) of the chained list should be garbage
collected I do not know how to tell GC not to mark the struct itself.
Currently I have the following structures:
--------------------------------------------------------------
/* Node of the variable location list. */
struct var_loc_node GTY ((chain_next ("%h.next")))
{
rtx GTY (()) var_loc_note;
const char * GTY (()) label;
struct var_loc_node * GTY (()) next;
};
/* Variable location list. */
struct var_loc_list_def GTY (())
{
struct var_loc_node * GTY (()) first;
struct var_loc_node * GTY ((skip ("%h"))) last;
/* "skip" is there because the last element will be marked through the chain.*/
};
typedef struct var_loc_list_def var_loc_list;
/* Table of decl location linked lists. */
static GTY ((length ("decl_loc_table_allocated"))) var_loc_list *decl_loc_table;
/* Number of elements in the decl_loc_table that are allocated. */
static unsigned decl_loc_table_allocated;
---------------------------------------------------------------------
In the generated file, I see that var_loc_list_def is being marked too.
Although it bootstraps I do not think it is completelly correct, because
the struct var_loc_list_def is not dynamically allocated.
void
gt_ggc_mx_var_loc_list_def (x_p)
void *x_p;
{
struct var_loc_list_def * const x = (struct var_loc_list_def *)x_p;
if (ggc_test_and_set_mark (x))
{
gt_ggc_m_12var_loc_node ((*x).first);
}
}
Josef
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Garbage Collector interface - GTY
2003-02-22 12:09 Garbage Collector interface - GTY Josef Zlomek
@ 2003-02-22 23:02 ` Geoff Keating
2003-02-22 23:09 ` Josef Zlomek
0 siblings, 1 reply; 6+ messages in thread
From: Geoff Keating @ 2003-02-22 23:02 UTC (permalink / raw)
To: Josef Zlomek; +Cc: gcc
Josef Zlomek <zlomj9am@artax.karlin.mff.cuni.cz> writes:
> Hi,
>
> Although I know how to tell garbage collector to mark simple
> datastructures, I have a problem with the following one which is more
> complicated. I have read the documentation but it is too brief for me.
>
> The data structure is a dynamic array, each element is a struct of
> two members - the first and the last element of the chained list. The
> nodes (and their internals) of the chained list should be garbage
> collected I do not know how to tell GC not to mark the struct itself.
This is not supported, by design. Anything that refers to a GCed
object must be either a global variable or must be GCed itself; you
can't have references to GCed objects in malloced memory.
--
- Geoffrey Keating <geoffk@geoffk.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Garbage Collector interface - GTY
2003-02-22 23:02 ` Geoff Keating
@ 2003-02-22 23:09 ` Josef Zlomek
2003-02-23 2:23 ` Geoff Keating
0 siblings, 1 reply; 6+ messages in thread
From: Josef Zlomek @ 2003-02-22 23:09 UTC (permalink / raw)
To: Geoff Keating; +Cc: gcc
> > Hi,
> >
> > Although I know how to tell garbage collector to mark simple
> > datastructures, I have a problem with the following one which is more
> > complicated. I have read the documentation but it is too brief for me.
> >
> > The data structure is a dynamic array, each element is a struct of
> > two members - the first and the last element of the chained list. The
> > nodes (and their internals) of the chained list should be garbage
> > collected I do not know how to tell GC not to mark the struct itself.
>
> This is not supported, by design. Anything that refers to a GCed
> object must be either a global variable or must be GCed itself; you
> can't have references to GCed objects in malloced memory.
So its better to split the array of structures to 2 arrays, right?
GTY machinery would be used for one of them (the main one),
the second (auxiliary) one will not be marked.
Josef
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Garbage Collector interface - GTY
2003-02-22 23:09 ` Josef Zlomek
@ 2003-02-23 2:23 ` Geoff Keating
2003-02-23 3:00 ` Daniel Berlin
0 siblings, 1 reply; 6+ messages in thread
From: Geoff Keating @ 2003-02-23 2:23 UTC (permalink / raw)
To: zlomj9am; +Cc: gcc
> Date: Sat, 22 Feb 2003 21:29:54 +0100
> From: Josef Zlomek <zlomj9am@artax.karlin.mff.cuni.cz>
> So its better to split the array of structures to 2 arrays, right?
> GTY machinery would be used for one of them (the main one),
> the second (auxiliary) one will not be marked.
I doubt it. Why can't the whole array be in GCed memory?
--
- Geoffrey Keating <geoffk@geoffk.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Garbage Collector interface - GTY
2003-02-23 2:23 ` Geoff Keating
@ 2003-02-23 3:00 ` Daniel Berlin
2003-02-23 12:02 ` Josef Zlomek
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Berlin @ 2003-02-23 3:00 UTC (permalink / raw)
To: Geoff Keating; +Cc: zlomj9am, gcc
On Saturday, February 22, 2003, at 08:33 PM, Geoff Keating wrote:
>> Date: Sat, 22 Feb 2003 21:29:54 +0100
>> From: Josef Zlomek <zlomj9am@artax.karlin.mff.cuni.cz>
>
>> So its better to split the array of structures to 2 arrays, right?
>> GTY machinery would be used for one of them (the main one),
>> the second (auxiliary) one will not be marked.
>
> I doubt it. Why can't the whole array be in GCed memory?
>
It is, actually, and i'm confused what Josef thinks is wrong.
Josef, it does generate *markers* for the struct definition, they just
are never *used* anywhere.
It uses the right markers for the table:
static void gt_ggc_ma_decl_loc_table PARAMS ((void *));
static void
gt_ggc_ma_decl_loc_table (x_p)
void *x_p ATTRIBUTE_UNUSED;
{
if (decl_loc_table != NULL) {
size_t i0;
ggc_mark (decl_loc_table);
for (i0 = 0; i0 < (size_t)(decl_loc_table_allocated); i0++) {
gt_ggc_m_12var_loc_node (decl_loc_table[i0].first);
gt_ggc_m_12var_loc_node (decl_loc_table[i0].last);
}
}
}
> --
> - Geoffrey Keating <geoffk@geoffk.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Garbage Collector interface - GTY
2003-02-23 3:00 ` Daniel Berlin
@ 2003-02-23 12:02 ` Josef Zlomek
0 siblings, 0 replies; 6+ messages in thread
From: Josef Zlomek @ 2003-02-23 12:02 UTC (permalink / raw)
To: Daniel Berlin; +Cc: Geoff Keating, gcc
> >>So its better to split the array of structures to 2 arrays, right?
> >>GTY machinery would be used for one of them (the main one),
> >>the second (auxiliary) one will not be marked.
> >
> >I doubt it. Why can't the whole array be in GCed memory?
> >
>
> It is, actually, and i'm confused what Josef thinks is wrong.
>
> Josef, it does generate *markers* for the struct definition, they just
> are never *used* anywhere.
>
> It uses the right markers for the table:
>
> static void gt_ggc_ma_decl_loc_table PARAMS ((void *));
> static void
> gt_ggc_ma_decl_loc_table (x_p)
> void *x_p ATTRIBUTE_UNUSED;
> {
> if (decl_loc_table != NULL) {
> size_t i0;
> ggc_mark (decl_loc_table);
> for (i0 = 0; i0 < (size_t)(decl_loc_table_allocated); i0++) {
> gt_ggc_m_12var_loc_node (decl_loc_table[i0].first);
> gt_ggc_m_12var_loc_node (decl_loc_table[i0].last);
> }
> }
> }
I see. Thanks for explaining :-) I apologize I took your time.
I was confused by the following, but now I have found out that it really is not
used anywhere.
void
gt_ggc_mx_var_loc_list_def (x_p)
void *x_p;
{
struct var_loc_list_def * const x = (struct var_loc_list_def *)x_p;
if (ggc_test_and_set_mark (x))
{
gt_ggc_m_12var_loc_node ((*x).first);
}
}
Josef
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-02-23 10:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-22 12:09 Garbage Collector interface - GTY Josef Zlomek
2003-02-22 23:02 ` Geoff Keating
2003-02-22 23:09 ` Josef Zlomek
2003-02-23 2:23 ` Geoff Keating
2003-02-23 3:00 ` Daniel Berlin
2003-02-23 12:02 ` Josef Zlomek
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).