Commit 75182467 by Jeff Sturm Committed by Jeff Sturm

re PR java/13183 ([unit-at-a-time] incorrect multidimensional array initializer with -O2)

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
parent fbe3f997
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> 2003-11-24 Mohan Embar <gnustuff@thisiscool.com>
* Make-lang.in: (java.install-common) Add * Make-lang.in: (java.install-common) Add
......
...@@ -37,6 +37,7 @@ static int find_class_or_string_constant (CPool *, int, tree); ...@@ -37,6 +37,7 @@ static int find_class_or_string_constant (CPool *, int, tree);
static int find_name_and_type_constant (CPool *, tree, tree); static int find_name_and_type_constant (CPool *, tree, tree);
static tree get_tag_node (int); static tree get_tag_node (int);
static tree build_constant_data_ref (void); 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. */ /* Set the INDEX'th constant in CPOOL to have the given TAG and VALUE. */
...@@ -315,8 +316,6 @@ write_constant_pool (CPool *cpool, unsigned char *buffer, int length) ...@@ -315,8 +316,6 @@ write_constant_pool (CPool *cpool, unsigned char *buffer, int length)
abort (); abort ();
} }
CPool *outgoing_cpool;
static GTY(()) tree tag_nodes[13]; static GTY(()) tree tag_nodes[13];
static tree static tree
get_tag_node (int tag) get_tag_node (int tag)
...@@ -328,6 +327,21 @@ get_tag_node (int tag) ...@@ -328,6 +327,21 @@ get_tag_node (int tag)
return tag_nodes[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. /* Look for a constant pool entry that matches TAG and NAME.
Creates a new entry if not found. Creates a new entry if not found.
TAG is one of CONSTANT_Utf8, CONSTANT_String or CONSTANT_Class. TAG is one of CONSTANT_Utf8, CONSTANT_String or CONSTANT_Class.
...@@ -337,6 +351,7 @@ get_tag_node (int tag) ...@@ -337,6 +351,7 @@ get_tag_node (int tag)
int int
alloc_name_constant (int tag, tree name) alloc_name_constant (int tag, tree name)
{ {
CPool *outgoing_cpool = cpool_for_class (current_class);
return find_tree_constant (outgoing_cpool, tag, name); return find_tree_constant (outgoing_cpool, tag, name);
} }
...@@ -414,6 +429,7 @@ build_ref_from_constant_pool (int index) ...@@ -414,6 +429,7 @@ build_ref_from_constant_pool (int index)
tree tree
build_constants_constructor (void) build_constants_constructor (void)
{ {
CPool *outgoing_cpool = cpool_for_class (current_class);
tree tags_value, data_value; tree tags_value, data_value;
tree cons; tree cons;
tree tags_list = NULL_TREE; tree tags_list = NULL_TREE;
......
...@@ -1860,6 +1860,7 @@ java_expand_body (tree fndecl) ...@@ -1860,6 +1860,7 @@ java_expand_body (tree fndecl)
current_function_decl = fndecl; current_function_decl = fndecl;
input_location = DECL_SOURCE_LOCATION (fndecl); input_location = DECL_SOURCE_LOCATION (fndecl);
current_class = DECL_CONTEXT (fndecl);
timevar_push (TV_EXPAND); timevar_push (TV_EXPAND);
......
...@@ -694,9 +694,6 @@ extern GTY(()) tree java_global_trees[JTI_MAX]; ...@@ -694,9 +694,6 @@ extern GTY(()) tree java_global_trees[JTI_MAX];
#define nativecode_ptr_type_node ptr_type_node #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 \ #define wfl_operator \
java_global_trees[JTI_WFL_OPERATOR] java_global_trees[JTI_WFL_OPERATOR]
...@@ -1219,7 +1216,6 @@ extern int enclosing_context_p (tree, tree); ...@@ -1219,7 +1216,6 @@ extern int enclosing_context_p (tree, tree);
extern void complete_start_java_method (tree); extern void complete_start_java_method (tree);
extern tree build_result_decl (tree); extern tree build_result_decl (tree);
extern void emit_handlers (void); extern void emit_handlers (void);
extern void init_outgoing_cpool (void);
extern void make_class_data (tree); extern void make_class_data (tree);
extern void register_class (void); extern void register_class (void);
extern int alloc_name_constant (int, tree); extern int alloc_name_constant (int, tree);
......
...@@ -693,12 +693,6 @@ load_inner_classes (tree cur_class) ...@@ -693,12 +693,6 @@ load_inner_classes (tree cur_class)
} }
} }
void
init_outgoing_cpool (void)
{
outgoing_cpool = ggc_alloc_cleared (sizeof (struct CPool));
}
static void static void
parse_class_file (void) parse_class_file (void)
{ {
...@@ -710,7 +704,6 @@ parse_class_file (void) ...@@ -710,7 +704,6 @@ parse_class_file (void)
input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class)); input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
input_line = 0; input_line = 0;
(*debug_hooks->start_source_file) (input_line, input_filename); (*debug_hooks->start_source_file) (input_line, input_filename);
init_outgoing_cpool ();
/* Currently we always have to emit calls to _Jv_InitClass when /* Currently we always have to emit calls to _Jv_InitClass when
compiling from class files. */ compiling from class files. */
......
...@@ -7689,9 +7689,6 @@ java_complete_expand_methods (tree class_decl) ...@@ -7689,9 +7689,6 @@ java_complete_expand_methods (tree class_decl)
current_class = TREE_TYPE (class_decl); 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 /* 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 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 ready to be used somewhere else. <clinit> will be fully expanded
...@@ -7775,9 +7772,6 @@ java_complete_expand_methods (tree class_decl) ...@@ -7775,9 +7772,6 @@ java_complete_expand_methods (tree class_decl)
if (DECL_CONSTRUCTOR_P (decl) if (DECL_CONSTRUCTOR_P (decl)
&& verify_constructor_circularity (decl, decl)) && verify_constructor_circularity (decl, decl))
break; 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 /* Attempt to create <clinit>. Pre-expand static fields so they can be
...@@ -9157,7 +9151,6 @@ java_expand_classes (void) ...@@ -9157,7 +9151,6 @@ java_expand_classes (void)
current = TREE_CHAIN (current)) current = TREE_CHAIN (current))
{ {
current_class = TREE_TYPE (TREE_VALUE (current)); current_class = TREE_TYPE (TREE_VALUE (current));
outgoing_cpool = TYPE_CPOOL (current_class);
if (flag_emit_class_files) if (flag_emit_class_files)
write_classfile (current_class); write_classfile (current_class);
if (flag_emit_xref) if (flag_emit_xref)
...@@ -9179,7 +9172,6 @@ java_finish_classes (void) ...@@ -9179,7 +9172,6 @@ java_finish_classes (void)
for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
{ {
current_class = TREE_TYPE (current); current_class = TREE_TYPE (current);
outgoing_cpool = TYPE_CPOOL (current_class);
finish_class (); finish_class ();
} }
} }
......
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