Fix PR java/13183.
* constants.c (cpool_for_class): New function.
(outgoing_cpool): Remove global variable.
(alloc_name_constant): Use cpool_for_class.
(build_constants_constructor): Likewise.
* decl.c (java_expand_body): Set current_class.
* java-tree.h (outgoing_cpool) Remove declaration.
(init_outgoing_cpool): Likewise.
* jcf-parse.c (init_outgoing_cpool): Remove function.
(parse_class_file): Don't call init_outgoing_cpool.
* parse.y (java_complete_expand_methods): Don't call
init_outgoing_cpool. Don't save outgoing_cpool.
(java_expand_classes): Don't restore outgoing_cpool.
(java_finish_classes): Likewise.
From-SVN: r73926
+2003-11-25 Jeff Sturm <jsturm@one-point.com>
+
+ Fix PR java/13183.
+ * constants.c (cpool_for_class): New function.
+ (outgoing_cpool): Remove global variable.
+ (alloc_name_constant): Use cpool_for_class.
+ (build_constants_constructor): Likewise.
+ * decl.c (java_expand_body): Set current_class.
+ * java-tree.h (outgoing_cpool) Remove declaration.
+ (init_outgoing_cpool): Likewise.
+ * jcf-parse.c (init_outgoing_cpool): Remove function.
+ (parse_class_file): Don't call init_outgoing_cpool.
+ * parse.y (java_complete_expand_methods): Don't call
+ init_outgoing_cpool. Don't save outgoing_cpool.
+ (java_expand_classes): Don't restore outgoing_cpool.
+ (java_finish_classes): Likewise.
+
2003-11-24 Mohan Embar <gnustuff@thisiscool.com>
* Make-lang.in: (java.install-common) Add
static int find_name_and_type_constant (CPool *, tree, tree);
static tree get_tag_node (int);
static tree build_constant_data_ref (void);
+static CPool *cpool_for_class (tree);
/* Set the INDEX'th constant in CPOOL to have the given TAG and VALUE. */
abort ();
}
-CPool *outgoing_cpool;
-
static GTY(()) tree tag_nodes[13];
static tree
get_tag_node (int tag)
return tag_nodes[tag];
}
+/* Given a class, return its constant pool, creating one if necessary. */
+
+static CPool *
+cpool_for_class (tree class)
+{
+ CPool *cpool = TYPE_CPOOL (class);
+
+ if (cpool == NULL)
+ {
+ cpool = ggc_alloc_cleared (sizeof (struct CPool));
+ TYPE_CPOOL (class) = cpool;
+ }
+ return cpool;
+}
+
/* Look for a constant pool entry that matches TAG and NAME.
Creates a new entry if not found.
TAG is one of CONSTANT_Utf8, CONSTANT_String or CONSTANT_Class.
int
alloc_name_constant (int tag, tree name)
{
+ CPool *outgoing_cpool = cpool_for_class (current_class);
return find_tree_constant (outgoing_cpool, tag, name);
}
tree
build_constants_constructor (void)
{
+ CPool *outgoing_cpool = cpool_for_class (current_class);
tree tags_value, data_value;
tree cons;
tree tags_list = NULL_TREE;
current_function_decl = fndecl;
input_location = DECL_SOURCE_LOCATION (fndecl);
+ current_class = DECL_CONTEXT (fndecl);
timevar_push (TV_EXPAND);
#define nativecode_ptr_type_node ptr_type_node
-/* They need to be reset before processing each class */
-extern GTY(()) struct CPool *outgoing_cpool;
-
#define wfl_operator \
java_global_trees[JTI_WFL_OPERATOR]
extern void complete_start_java_method (tree);
extern tree build_result_decl (tree);
extern void emit_handlers (void);
-extern void init_outgoing_cpool (void);
extern void make_class_data (tree);
extern void register_class (void);
extern int alloc_name_constant (int, tree);
}
}
-void
-init_outgoing_cpool (void)
-{
- outgoing_cpool = ggc_alloc_cleared (sizeof (struct CPool));
-}
-
static void
parse_class_file (void)
{
input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
input_line = 0;
(*debug_hooks->start_source_file) (input_line, input_filename);
- init_outgoing_cpool ();
/* Currently we always have to emit calls to _Jv_InitClass when
compiling from class files. */
current_class = TREE_TYPE (class_decl);
- /* Initialize a new constant pool */
- init_outgoing_cpool ();
-
/* Pre-expand <clinit> to figure whether we really need it or
not. If we do need it, we pre-expand the static fields so they're
ready to be used somewhere else. <clinit> will be fully expanded
if (DECL_CONSTRUCTOR_P (decl)
&& verify_constructor_circularity (decl, decl))
break;
-
- /* Save the constant pool. We'll need to restore it later. */
- TYPE_CPOOL (current_class) = outgoing_cpool;
}
/* Attempt to create <clinit>. Pre-expand static fields so they can be
current = TREE_CHAIN (current))
{
current_class = TREE_TYPE (TREE_VALUE (current));
- outgoing_cpool = TYPE_CPOOL (current_class);
if (flag_emit_class_files)
write_classfile (current_class);
if (flag_emit_xref)
for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
{
current_class = TREE_TYPE (current);
- outgoing_cpool = TYPE_CPOOL (current_class);
finish_class ();
}
}