Commit 00150bf9 by Andrew Haley Committed by Andrew Haley

verify.c (verify_jvm_instructions): Comment change only.

2004-07-20  Andrew Haley  <aph@redhat.com>

	* verify.c (verify_jvm_instructions): Comment change only.

	* typeck.c (build_java_array_type): Add size field to array name.

	* java-tree.h (LOCAL_SLOT_P): New.
	(update_aliases): Add PC argument.
	(pushdecl_function_level): New function.

	* java-gimplify.c (java_gimplify_expr): Handle VAR_DECL,
	MODIFY_EXPR, and SAVE_EXPR.
	(java_gimplify_modify_expr): New function.

	* expr.c (push_type_0): Call find_stack_slot() to create temporary.
	(expand_iinc): Pass PC to update_aliases().
	(STORE_INTERNAL): Likewise.
	(process_jvm_instruction): Likewise.

	* decl.c (base_decl_map): New variable.
	(uniq): New variable.
	(update_aliases): Rewrite with more thorough checking.
	(debug_variable_p): New function.
	(push_jvm_slot): Don't initialize local variable.  Don't pushdecl.
	(check_local_named_variable): Delete whole function.
	(initialize_local_variable): New function.
	(check_local_unnamed_variable): Add checks and comments.
	(find_local_variable): Rewrite.
	(java_replace_reference): New function.
	(function_binding_level): New variable.
	(pushdecl_function_level): New function.
	(maybe_pushlevels): Set DECL_LOCAL_END_PC.
	(maybe_pushlevels): Call pushdecl() on each of the new decls.
	(start_java_method): Reset uniq.  Create base_decl_map.  Set
	function_binding_level.
	(end_java_method): Null unused fields to save memory.

From-SVN: r85009
parent 5d16533a
2004-07-20 Andrew Haley <aph@redhat.com>
* verify.c (verify_jvm_instructions): Comment change only.
* typeck.c (build_java_array_type): Add size field to array name.
* java-tree.h (LOCAL_SLOT_P): New.
(update_aliases): Add PC argument.
(pushdecl_function_level): New function.
* java-gimplify.c (java_gimplify_expr): Handle VAR_DECL,
MODIFY_EXPR, and SAVE_EXPR.
(java_gimplify_modify_expr): New function.
* expr.c (push_type_0): Call find_stack_slot() to create temporary.
(expand_iinc): Pass PC to update_aliases().
(STORE_INTERNAL): Likewise.
(process_jvm_instruction): Likewise.
* decl.c (base_decl_map): New variable.
(uniq): New variable.
(update_aliases): Rewrite with more thorough checking.
(debug_variable_p): New function.
(push_jvm_slot): Don't initialize local variable. Don't pushdecl.
(check_local_named_variable): Delete whole function.
(initialize_local_variable): New function.
(check_local_unnamed_variable): Add checks and comments.
(find_local_variable): Rewrite.
(java_replace_reference): New function.
(function_binding_level): New variable.
(pushdecl_function_level): New function.
(maybe_pushlevels): Set DECL_LOCAL_END_PC.
(maybe_pushlevels): Call pushdecl() on each of the new decls.
(start_java_method): Reset uniq. Create base_decl_map. Set
function_binding_level.
(end_java_method): Null unused fields to save memory.
2004-07-20 Nathan Sidwell <nathan@codesourcery.com> 2004-07-20 Nathan Sidwell <nathan@codesourcery.com>
* class.c (add_interface_do): Remove. * class.c (add_interface_do): Remove.
......
...@@ -255,6 +255,9 @@ push_type_0 (tree type) ...@@ -255,6 +255,9 @@ push_type_0 (tree type)
n_words = 1 + TYPE_IS_WIDE (type); n_words = 1 + TYPE_IS_WIDE (type);
if (stack_pointer + n_words > DECL_MAX_STACK (current_function_decl)) if (stack_pointer + n_words > DECL_MAX_STACK (current_function_decl))
return 0; return 0;
/* Allocate decl for this variable now, so we get a temporary that
survives the whole method. */
find_stack_slot (stack_pointer, type);
stack_type_map[stack_pointer++] = type; stack_type_map[stack_pointer++] = type;
n_words--; n_words--;
while (--n_words >= 0) while (--n_words >= 0)
...@@ -368,7 +371,7 @@ pop_type (tree type) ...@@ -368,7 +371,7 @@ pop_type (tree type)
return type; return type;
} }
/* Return 1f if SOURCE_TYPE can be safely widened to TARGET_TYPE. /* Return 1 if SOURCE_TYPE can be safely widened to TARGET_TYPE.
Handles array types and interfaces. */ Handles array types and interfaces. */
int int
...@@ -1289,7 +1292,7 @@ expand_iinc (unsigned int local_var_index, int ival, int pc) ...@@ -1289,7 +1292,7 @@ expand_iinc (unsigned int local_var_index, int ival, int pc)
constant_value = build_int_2 (ival, ival < 0 ? -1 : 0); constant_value = build_int_2 (ival, ival < 0 ? -1 : 0);
res = fold (build2 (PLUS_EXPR, int_type_node, local_var, constant_value)); res = fold (build2 (PLUS_EXPR, int_type_node, local_var, constant_value));
java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (local_var), local_var, res)); java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (local_var), local_var, res));
update_aliases (local_var, local_var_index); update_aliases (local_var, local_var_index, pc);
} }
...@@ -2758,7 +2761,8 @@ process_jvm_instruction (int PC, const unsigned char* byte_ops, ...@@ -2758,7 +2761,8 @@ process_jvm_instruction (int PC, const unsigned char* byte_ops,
{ \ { \
int saw_index = 0; \ int saw_index = 0; \
int index = OPERAND_VALUE; \ int index = OPERAND_VALUE; \
build_java_ret (find_local_variable (index, ptr_type_node, oldpc)); \ build_java_ret \
(find_local_variable (index, return_address_type_node, oldpc)); \
} }
#define JSR(OPERAND_TYPE, OPERAND_VALUE) \ #define JSR(OPERAND_TYPE, OPERAND_VALUE) \
...@@ -2937,7 +2941,7 @@ process_jvm_instruction (int PC, const unsigned char* byte_ops, ...@@ -2937,7 +2941,7 @@ process_jvm_instruction (int PC, const unsigned char* byte_ops,
decl = find_local_variable (index, type, oldpc); \ decl = find_local_variable (index, type, oldpc); \
set_local_type (index, type); \ set_local_type (index, type); \
java_add_stmt (build2 (MODIFY_EXPR, type, decl, value)); \ java_add_stmt (build2 (MODIFY_EXPR, type, decl, value)); \
update_aliases (decl, index); \ update_aliases (decl, index, PC); \
} }
#define STORE(OPERAND_TYPE, OPERAND_VALUE) \ #define STORE(OPERAND_TYPE, OPERAND_VALUE) \
......
...@@ -37,6 +37,7 @@ static tree java_gimplify_default_expr (tree); ...@@ -37,6 +37,7 @@ static tree java_gimplify_default_expr (tree);
static tree java_gimplify_block (tree); static tree java_gimplify_block (tree);
static tree java_gimplify_new_array_init (tree); static tree java_gimplify_new_array_init (tree);
static tree java_gimplify_try_expr (tree); static tree java_gimplify_try_expr (tree);
static tree java_gimplify_modify_expr (tree);
static void dump_java_tree (enum tree_dump_index, tree); static void dump_java_tree (enum tree_dump_index, tree);
...@@ -117,6 +118,21 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED, ...@@ -117,6 +118,21 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
*expr_p = build_exception_object_ref (TREE_TYPE (*expr_p)); *expr_p = build_exception_object_ref (TREE_TYPE (*expr_p));
break; break;
case VAR_DECL:
*expr_p = java_replace_reference (*expr_p, /* want_lvalue */ false);
return GS_UNHANDLED;
case MODIFY_EXPR:
*expr_p = java_gimplify_modify_expr (*expr_p);
return GS_UNHANDLED;
case SAVE_EXPR:
if (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == VAR_DECL)
TREE_OPERAND (*expr_p, 0)
= java_replace_reference (TREE_OPERAND (*expr_p, 0),
/* want_lvalue */ false);
return GS_UNHANDLED;
/* These should already be lowered before we get here. */ /* These should already be lowered before we get here. */
case URSHIFT_EXPR: case URSHIFT_EXPR:
case COMPARE_EXPR: case COMPARE_EXPR:
...@@ -140,6 +156,33 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED, ...@@ -140,6 +156,33 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
return GS_OK; return GS_OK;
} }
/* This is specific to the bytecode compiler. If a variable has
LOCAL_SLOT_P set, replace an assignment to it with an assignment to
the corresponding variable that holds all its aliases. */
static tree
java_gimplify_modify_expr (tree modify_expr)
{
tree lhs = TREE_OPERAND (modify_expr, 0);
tree rhs = TREE_OPERAND (modify_expr, 1);
tree lhs_type = TREE_TYPE (lhs);
if (TREE_CODE (lhs) == VAR_DECL
&& DECL_LANG_SPECIFIC (lhs)
&& LOCAL_SLOT_P (lhs)
&& TREE_CODE (lhs_type) == POINTER_TYPE)
{
tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), rhs);
modify_expr = build (MODIFY_EXPR, TREE_TYPE (new_lhs),
new_lhs, new_rhs);
modify_expr = build1 (NOP_EXPR, lhs_type, modify_expr);
}
return modify_expr;
}
static tree static tree
java_gimplify_case_expr (tree expr) java_gimplify_case_expr (tree expr)
{ {
......
...@@ -925,6 +925,8 @@ union lang_tree_node ...@@ -925,6 +925,8 @@ union lang_tree_node
/* True if NODE is a variable that is out of scope. */ /* True if NODE is a variable that is out of scope. */
#define LOCAL_VAR_OUT_OF_SCOPE_P(NODE) \ #define LOCAL_VAR_OUT_OF_SCOPE_P(NODE) \
(DECL_LANG_SPECIFIC (NODE)->u.v.freed) (DECL_LANG_SPECIFIC (NODE)->u.v.freed)
#define LOCAL_SLOT_P(NODE) \
(DECL_LANG_SPECIFIC (NODE)->u.v.local_slot)
/* Create a DECL_LANG_SPECIFIC if necessary. */ /* Create a DECL_LANG_SPECIFIC if necessary. */
#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T) \ #define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T) \
if (DECL_LANG_SPECIFIC (T) == NULL) \ if (DECL_LANG_SPECIFIC (T) == NULL) \
...@@ -1010,7 +1012,8 @@ struct lang_decl_var GTY(()) ...@@ -1010,7 +1012,8 @@ struct lang_decl_var GTY(())
tree owner; tree owner;
unsigned int final_iud : 1; /* Final initialized upon declaration */ unsigned int final_iud : 1; /* Final initialized upon declaration */
unsigned int cif : 1; /* True: decl is a class initialization flag */ unsigned int cif : 1; /* True: decl is a class initialization flag */
unsigned int freed; /* Decl is no longer in scope. */ unsigned int freed : 1; /* Decl is no longer in scope. */
unsigned int local_slot : 1; /* Decl is a temporary in the stack frame. */
}; };
/* This is what 'lang_decl' really points to. */ /* This is what 'lang_decl' really points to. */
...@@ -1176,7 +1179,7 @@ extern void set_java_signature (tree, tree); ...@@ -1176,7 +1179,7 @@ extern void set_java_signature (tree, tree);
extern tree build_static_field_ref (tree); extern tree build_static_field_ref (tree);
extern tree build_address_of (tree); extern tree build_address_of (tree);
extern tree find_local_variable (int index, tree type, int pc); extern tree find_local_variable (int index, tree type, int pc);
extern void update_aliases (tree decl, int index); extern void update_aliases (tree decl, int index, int pc);
extern tree find_stack_slot (int index, tree type); extern tree find_stack_slot (int index, tree type);
extern tree build_prim_array_type (tree, HOST_WIDE_INT); extern tree build_prim_array_type (tree, HOST_WIDE_INT);
extern tree build_java_array_type (tree, HOST_WIDE_INT); extern tree build_java_array_type (tree, HOST_WIDE_INT);
...@@ -1254,6 +1257,8 @@ extern void java_layout_seen_class_methods (void); ...@@ -1254,6 +1257,8 @@ extern void java_layout_seen_class_methods (void);
extern void check_for_initialization (tree, tree); extern void check_for_initialization (tree, tree);
extern tree pushdecl_top_level (tree); extern tree pushdecl_top_level (tree);
extern tree pushdecl_function_level (tree);
extern tree java_replace_reference (tree, bool);
extern int alloc_class_constant (tree); extern int alloc_class_constant (tree);
extern void init_expr_processing (void); extern void init_expr_processing (void);
extern void push_super_field (tree, tree); extern void push_super_field (tree, tree);
......
...@@ -391,9 +391,17 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length) ...@@ -391,9 +391,17 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length)
el_name = TYPE_NAME (el_name); el_name = TYPE_NAME (el_name);
if (TREE_CODE (el_name) == TYPE_DECL) if (TREE_CODE (el_name) == TYPE_DECL)
el_name = DECL_NAME (el_name); el_name = DECL_NAME (el_name);
TYPE_NAME (t) = build_decl (TYPE_DECL, {
identifier_subst (el_name, "", '.', '.', "[]"), char suffix[12];
if (length >= 0)
sprintf (suffix, "[%d]", (int)length);
else
strcpy (suffix, "[]");
TYPE_NAME (t)
= build_decl (TYPE_DECL,
identifier_subst (el_name, "", '.', '.', suffix),
t); t);
}
set_java_signature (t, sig); set_java_signature (t, sig);
set_super_info (0, t, object_type_node, 0); set_super_info (0, t, object_type_node, 0);
......
...@@ -734,8 +734,8 @@ verify_jvm_instructions (JCF* jcf, const unsigned char *byte_ops, long length) ...@@ -734,8 +734,8 @@ verify_jvm_instructions (JCF* jcf, const unsigned char *byte_ops, long length)
handlers. */ handlers. */
prev_eh_ranges = NULL_EH_RANGE; prev_eh_ranges = NULL_EH_RANGE;
/* Allocate decl and rtx for this variable now, so if we're not /* Allocate decl for this variable now, so we get a temporary
optimizing, we get a temporary that survives the whole method. */ ! that survives the whole method. */
find_local_variable (index, type, oldpc); find_local_variable (index, type, oldpc);
if (TYPE_IS_WIDE (type)) if (TYPE_IS_WIDE (type))
......
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