+2001-01-21 Per Bothner <per@bothner.com>
+
+ Minor optimization of static ggc roots.
+ * jcf-parse.c (parse_roots): New static field.
+ (current_field, current_method, current_file_list): Replace by macros
+ naming fields of parse_roots.
+ (init_jcf_parse): Combine 3 ggc_add_tree_root calls to 1.
+ * class.c (class_roots): New static field.
+ (registered_class, fields_ident, info_ident, class_list):
+ New macros naming fields of parse_roots.
+ (build_static_field_ref): Don't register roots here.
+ (layout_class): Static field list replaced by macro class_list.
+ (init_class_processing): Call ggc_add_tree_root for 4 roots.
+ Initialize fields_ident and info_ident here.
+
2001-01-21 Per Bothner <per@bothner.com>
* jcf-parse.c (ggc_mark_jcf): New function.
static assume_compiled_node *assume_compiled_tree;
+static tree class_roots[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
+#define registered_class class_roots[0]
+#define fields_ident class_roots[1] /* get_identifier ("fields") */
+#define info_ident class_roots[2] /* get_identifier ("info") */
+#define class_list class_roots[3]
+
/* Return the node that most closely represents the class whose name
is IDENT. Start the search from NODE. Return NULL if an
appropriate node does not exist. */
{
/* Compile as:
* *(FTYPE*)build_class_ref(FCLASS)->fields[INDEX].info.addr */
- static tree fields_ident = NULL_TREE;
- static tree info_ident = NULL_TREE;
tree ref = build_class_ref (fclass);
tree fld;
int field_index = 0;
ref = build1 (INDIRECT_REF, class_type_node, ref);
- if (fields_ident == NULL_TREE)
- {
- fields_ident = get_identifier ("fields");
- ggc_add_tree_root (&fields_ident, 1);
- }
- if (info_ident == NULL_TREE)
- {
- info_ident = get_identifier ("info");
- ggc_add_tree_root (&info_ident, 1);
- }
ref = build (COMPONENT_REF, field_ptr_type_node, ref,
lookup_field (&class_type_node, fields_ident));
if (class == current_class)
return 2;
- seen_in_zip = (TYPE_JCF (class) && TYPE_JCF (class)->seen_in_zip);
+ seen_in_zip = (TYPE_JCF (class) && JCF_SEEN_IN_ZIP (TYPE_JCF (class)));
if (CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (class) || seen_in_zip)
{
/* The class was seen in the current ZIP file and will be
layout_class (this_class)
tree this_class;
{
- static tree list = NULL_TREE;
- static int initialized_p;
tree super_class = CLASSTYPE_SUPER (this_class);
tree field;
- /* Register LIST with the garbage collector. */
- if (!initialized_p)
- {
- ggc_add_tree_root (&list, 1);
- initialized_p = 1;
- }
-
- list = tree_cons (this_class, NULL_TREE, list);
+ class_list = tree_cons (this_class, NULL_TREE, class_list);
if (CLASS_BEING_LAIDOUT (this_class))
{
char buffer [1024];
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class))));
obstack_grow (&temporary_obstack, buffer, strlen (buffer));
- for (current = TREE_CHAIN (list); current;
+ for (current = TREE_CHAIN (class_list); current;
current = TREE_CHAIN (current))
{
tree decl = TYPE_NAME (TREE_PURPOSE (current));
{
TYPE_SIZE (this_class) = error_mark_node;
CLASS_BEING_LAIDOUT (this_class) = 0;
- list = TREE_CHAIN (list);
+ class_list = TREE_CHAIN (class_list);
return;
}
if (TYPE_SIZE (this_class) == NULL_TREE)
{
TYPE_SIZE (this_class) = error_mark_node;
CLASS_BEING_LAIDOUT (this_class) = 0;
- list = TREE_CHAIN (list);
+ class_list = TREE_CHAIN (class_list);
return;
}
}
fold (convert (int_type_node, TYPE_SIZE_UNIT (this_class)));
CLASS_BEING_LAIDOUT (this_class) = 0;
- list = TREE_CHAIN (list);
+ class_list = TREE_CHAIN (class_list);
}
void
return dtable_count;
}
-static tree registered_class = NULL_TREE;
-
void
register_class ()
{
init_class_processing ()
{
registerClass_libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterClass");
- ggc_add_tree_root (®istered_class, 1);
+ ggc_add_tree_root (class_roots, sizeof (class_roots) / sizeof (tree));
+ fields_ident = get_identifier ("fields");
+ info_ident = get_identifier ("info");
ggc_add_rtx_root (®isterClass_libfunc, 1);
gcc_obstack_init (&temporary_obstack);
}
before static field references. */
extern int always_initialize_class_p;
+static tree parse_roots[3] = { NULL_TREE, NULL_TREE, NULL_TREE };
+
/* The FIELD_DECL for the current field. */
-static tree current_field = NULL_TREE;
+#define current_field parse_roots[0]
/* The METHOD_DECL for the current method. */
-static tree current_method = NULL_TREE;
+#define current_method parse_roots[1]
/* A list of file names. */
-static tree current_file_list = NULL_TREE;
+#define current_file_list parse_roots[2]
/* The Java .class file that provides main_class; the main input file. */
static struct JCF main_jcf[1];
init_jcf_parse ()
{
/* Register roots with the garbage collector. */
- ggc_add_tree_root (¤t_field, 1);
- ggc_add_tree_root (¤t_method, 1);
- ggc_add_tree_root (¤t_file_list, 1);
+ ggc_add_tree_root (parse_roots, sizeof (parse_roots) / sizeof(tree));
ggc_add_root (¤t_jcf, 1, sizeof (JCF), ggc_mark_jcf);
}