This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Garbage Collector interface - GTY
- From: Josef Zlomek <zlomj9am at artax dot karlin dot mff dot cuni dot cz>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 22 Feb 2003 11:45:43 +0100
- Subject: Garbage Collector interface - GTY
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