Commit b5c4fed9 by Per Bothner Committed by Per Bothner

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.

From-SVN: r39174
parent 3432b91b
2001-01-21 Per Bothner <per@bothner.com> 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. * jcf-parse.c (ggc_mark_jcf): New function.
(init_jcf_parse): Register current_jcf as ggc root. (init_jcf_parse): Register current_jcf as ggc root.
......
...@@ -83,6 +83,12 @@ static assume_compiled_node *find_assume_compiled_node ...@@ -83,6 +83,12 @@ static assume_compiled_node *find_assume_compiled_node
static assume_compiled_node *assume_compiled_tree; 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 /* Return the node that most closely represents the class whose name
is IDENT. Start the search from NODE. Return NULL if an is IDENT. Start the search from NODE. Return NULL if an
appropriate node does not exist. */ appropriate node does not exist. */
...@@ -978,22 +984,10 @@ build_static_field_ref (fdecl) ...@@ -978,22 +984,10 @@ build_static_field_ref (fdecl)
{ {
/* Compile as: /* Compile as:
* *(FTYPE*)build_class_ref(FCLASS)->fields[INDEX].info.addr */ * *(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 ref = build_class_ref (fclass);
tree fld; tree fld;
int field_index = 0; int field_index = 0;
ref = build1 (INDIRECT_REF, class_type_node, ref); 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, ref = build (COMPONENT_REF, field_ptr_type_node, ref,
lookup_field (&class_type_node, fields_ident)); lookup_field (&class_type_node, fields_ident));
...@@ -1508,7 +1502,7 @@ is_compiled_class (class) ...@@ -1508,7 +1502,7 @@ is_compiled_class (class)
if (class == current_class) if (class == current_class)
return 2; 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) if (CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (class) || seen_in_zip)
{ {
/* The class was seen in the current ZIP file and will be /* The class was seen in the current ZIP file and will be
...@@ -1628,19 +1622,10 @@ void ...@@ -1628,19 +1622,10 @@ void
layout_class (this_class) layout_class (this_class)
tree this_class; tree this_class;
{ {
static tree list = NULL_TREE;
static int initialized_p;
tree super_class = CLASSTYPE_SUPER (this_class); tree super_class = CLASSTYPE_SUPER (this_class);
tree field; tree field;
/* Register LIST with the garbage collector. */ class_list = tree_cons (this_class, NULL_TREE, class_list);
if (!initialized_p)
{
ggc_add_tree_root (&list, 1);
initialized_p = 1;
}
list = tree_cons (this_class, NULL_TREE, list);
if (CLASS_BEING_LAIDOUT (this_class)) if (CLASS_BEING_LAIDOUT (this_class))
{ {
char buffer [1024]; char buffer [1024];
...@@ -1651,7 +1636,7 @@ layout_class (this_class) ...@@ -1651,7 +1636,7 @@ layout_class (this_class)
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class)))); IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class))));
obstack_grow (&temporary_obstack, buffer, strlen (buffer)); obstack_grow (&temporary_obstack, buffer, strlen (buffer));
for (current = TREE_CHAIN (list); current; for (current = TREE_CHAIN (class_list); current;
current = TREE_CHAIN (current)) current = TREE_CHAIN (current))
{ {
tree decl = TYPE_NAME (TREE_PURPOSE (current)); tree decl = TYPE_NAME (TREE_PURPOSE (current));
...@@ -1679,7 +1664,7 @@ layout_class (this_class) ...@@ -1679,7 +1664,7 @@ layout_class (this_class)
{ {
TYPE_SIZE (this_class) = error_mark_node; TYPE_SIZE (this_class) = error_mark_node;
CLASS_BEING_LAIDOUT (this_class) = 0; CLASS_BEING_LAIDOUT (this_class) = 0;
list = TREE_CHAIN (list); class_list = TREE_CHAIN (class_list);
return; return;
} }
if (TYPE_SIZE (this_class) == NULL_TREE) if (TYPE_SIZE (this_class) == NULL_TREE)
...@@ -1721,7 +1706,7 @@ layout_class (this_class) ...@@ -1721,7 +1706,7 @@ layout_class (this_class)
{ {
TYPE_SIZE (this_class) = error_mark_node; TYPE_SIZE (this_class) = error_mark_node;
CLASS_BEING_LAIDOUT (this_class) = 0; CLASS_BEING_LAIDOUT (this_class) = 0;
list = TREE_CHAIN (list); class_list = TREE_CHAIN (class_list);
return; return;
} }
} }
...@@ -1733,7 +1718,7 @@ layout_class (this_class) ...@@ -1733,7 +1718,7 @@ layout_class (this_class)
fold (convert (int_type_node, TYPE_SIZE_UNIT (this_class))); fold (convert (int_type_node, TYPE_SIZE_UNIT (this_class)));
CLASS_BEING_LAIDOUT (this_class) = 0; CLASS_BEING_LAIDOUT (this_class) = 0;
list = TREE_CHAIN (list); class_list = TREE_CHAIN (class_list);
} }
void void
...@@ -1845,8 +1830,6 @@ layout_class_method (this_class, super_class, method_decl, dtable_count) ...@@ -1845,8 +1830,6 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
return dtable_count; return dtable_count;
} }
static tree registered_class = NULL_TREE;
void void
register_class () register_class ()
{ {
...@@ -1911,7 +1894,9 @@ void ...@@ -1911,7 +1894,9 @@ void
init_class_processing () init_class_processing ()
{ {
registerClass_libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterClass"); registerClass_libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterClass");
ggc_add_tree_root (&registered_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 (&registerClass_libfunc, 1); ggc_add_rtx_root (&registerClass_libfunc, 1);
gcc_obstack_init (&temporary_obstack); gcc_obstack_init (&temporary_obstack);
} }
...@@ -70,14 +70,16 @@ extern struct obstack permanent_obstack; ...@@ -70,14 +70,16 @@ extern struct obstack permanent_obstack;
before static field references. */ before static field references. */
extern int always_initialize_class_p; extern int always_initialize_class_p;
static tree parse_roots[3] = { NULL_TREE, NULL_TREE, NULL_TREE };
/* The FIELD_DECL for the current field. */ /* 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. */ /* The METHOD_DECL for the current method. */
static tree current_method = NULL_TREE; #define current_method parse_roots[1]
/* A list of file names. */ /* 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. */ /* The Java .class file that provides main_class; the main input file. */
static struct JCF main_jcf[1]; static struct JCF main_jcf[1];
...@@ -1119,9 +1121,7 @@ void ...@@ -1119,9 +1121,7 @@ void
init_jcf_parse () init_jcf_parse ()
{ {
/* Register roots with the garbage collector. */ /* Register roots with the garbage collector. */
ggc_add_tree_root (&current_field, 1); ggc_add_tree_root (parse_roots, sizeof (parse_roots) / sizeof(tree));
ggc_add_tree_root (&current_method, 1);
ggc_add_tree_root (&current_file_list, 1);
ggc_add_root (&current_jcf, 1, sizeof (JCF), ggc_mark_jcf); ggc_add_root (&current_jcf, 1, sizeof (JCF), ggc_mark_jcf);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment