* tree.h (struct tree_label_decl): Removed old "java" fields.
gcc/java:
* java-tree.h (LABEL_TYPE_STATE): Removed.
(load_type_state): Removed.
(LABEL_PC): Removed.
(LABEL_VERIFIED): Removed.
(type_states): Declare.
* expr.c (type_states): New global.
(load_type_state): Now static. Use type_states. Changed
argument.
(lookup_label): Don't set LABEL_PC.
(expand_byte_code): Don't use LABEL_VERIFIED.
(note_instructions): Initialize type_states.
* verify-glue.c (vfy_note_stack_depth): Rewrote.
(vfy_note_stack_type): Use type_states.
(vfy_note_local_type): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127587
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-08-17 Tom Tromey <tromey@redhat.com>
+
+ * tree.h (struct tree_label_decl): Removed old "java" fields.
+
2007-08-17 Richard Sandiford <richard@codesourcery.com>
Nigel Stephens <nigel@mips.com>
+2007-08-17 Tom Tromey <tromey@redhat.com>
+
+ * java-tree.h (LABEL_TYPE_STATE): Removed.
+ (load_type_state): Removed.
+ (LABEL_PC): Removed.
+ (LABEL_VERIFIED): Removed.
+ (type_states): Declare.
+ * expr.c (type_states): New global.
+ (load_type_state): Now static. Use type_states. Changed
+ argument.
+ (lookup_label): Don't set LABEL_PC.
+ (expand_byte_code): Don't use LABEL_VERIFIED.
+ (note_instructions): Initialize type_states.
+ * verify-glue.c (vfy_note_stack_depth): Rewrote.
+ (vfy_note_stack_type): Use type_states.
+ (vfy_note_local_type): Likewise.
+
2007-08-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* jcf-parse.c (read_class, java_parse_file): Use CONST_CAST.
{
/* The type of the address of a label is return_address_type_node. */
tree decl = create_label_decl (name);
- LABEL_PC (decl) = pc;
return pushdecl (decl);
}
}
return decl;
}
-/* This maps a bytecode offset (PC) to various flags. */
+/* This maps a bytecode offset (PC) to various flags. */
char *instruction_bits;
+/* This is a vector of type states for the current method. It is
+ indexed by PC. Each element is a tree vector holding the type
+ state at that PC. We only note type states at basic block
+ boundaries. */
+VEC(tree, gc) *type_states;
+
static void
note_label (int current_pc ATTRIBUTE_UNUSED, int target_pc)
{
TREE_THIS_VOLATILE (field_ref) = TREE_THIS_VOLATILE (field_decl);
}
-void
-load_type_state (tree label)
+static void
+load_type_state (int pc)
{
int i;
- tree vec = LABEL_TYPE_STATE (label);
+ tree vec = VEC_index (tree, type_states, pc);
int cur_length = TREE_VEC_LENGTH (vec);
stack_pointer = cur_length - DECL_MAX_LOCALS(current_function_decl);
for (i = 0; i < cur_length; i++)
byte_ops = jcf->read_ptr;
instruction_bits = xrealloc (instruction_bits, length + 1);
memset (instruction_bits, 0, length + 1);
+ type_states = VEC_alloc (tree, gc, length + 1);
+ VEC_safe_grow_cleared (tree, gc, type_states, length + 1);
/* This pass figures out which PC can be the targets of jumps. */
for (PC = 0; PC < length;)
flush_quick_stack ();
if ((instruction_bits [PC] & BCODE_TARGET) != 0)
java_add_stmt (build1 (LABEL_EXPR, void_type_node, label));
- if (LABEL_VERIFIED (label) || PC == 0)
- load_type_state (label);
+ if ((instruction_bits[PC] & BCODE_VERIFIED) != 0)
+ load_type_state (PC);
}
if (! (instruction_bits [PC] & BCODE_VERIFIED))
FIELD_LOCAL_ALIAS. */
#define FIELD_THISN(DECL) DECL_LANG_FLAG_7 (VAR_OR_FIELD_CHECK (DECL))
-/* In a LABEL_DECL, a TREE_VEC that saves the type_map at that point. */
-#define LABEL_TYPE_STATE(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_1)
-
-/* In a LABEL_DECL, the corresponding bytecode program counter. */
-#define LABEL_PC(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_4)
-
-/* In a LABEL_DECL, true if we have verified instructions starting here. */
-#define LABEL_VERIFIED(NODE) \
- (instruction_bits[LABEL_PC (NODE)] & BCODE_VERIFIED)
-
/* The slot number for this local variable. */
#define DECL_LOCAL_SLOT_NUMBER(NODE) \
(DECL_LANG_SPECIFIC (NODE)->u.v.slot_number)
extern int merge_type_state (tree);
extern int push_type_0 (tree);
extern void push_type (tree);
-extern void load_type_state (tree);
extern void add_interface (tree, tree);
extern tree force_evaluation_order (tree);
extern tree java_create_object (tree);
/* Use CLASS_LOADED_P? FIXME */
#define CLASS_COMPLETE_P(DECL) DECL_LANG_FLAG_2 (DECL)
+/* A vector used to track type states for the current method. */
+extern VEC(tree, gc) *type_states;
+
/* This maps a bytecode offset (PC) to various flags,
listed below (starting with BCODE_). */
extern char *instruction_bits;
void
vfy_note_stack_depth (vfy_method *method, int pc, int depth)
{
- tree label = lookup_label (pc);
- LABEL_TYPE_STATE (label) = make_tree_vec (method->max_locals + depth);
+ tree val = make_tree_vec (method->max_locals + depth);
+ VEC_replace (tree, type_states, pc, val);
+ /* Called for side effects. */
+ lookup_label (pc);
}
void
vfy_note_stack_type (vfy_method *method, int pc, int slot, vfy_jclass type)
{
- tree label, vec;
+ tree vec;
slot += method->max_locals;
if (type == object_type_node)
type = object_ptr_type_node;
- label = lookup_label (pc);
- vec = LABEL_TYPE_STATE (label);
+ vec = VEC_index (tree, type_states, pc);
TREE_VEC_ELT (vec, slot) = type;
+ /* Called for side effects. */
+ lookup_label (pc);
}
void
vfy_note_local_type (vfy_method *method ATTRIBUTE_UNUSED, int pc, int slot,
vfy_jclass type)
{
- tree label, vec;
+ tree vec;
if (type == object_type_node)
type = object_ptr_type_node;
- label = lookup_label (pc);
- vec = LABEL_TYPE_STATE (label);
+ vec = VEC_index (tree, type_states, pc);
TREE_VEC_ELT (vec, slot) = type;
+ /* Called for side effects. */
+ lookup_label (pc);
}
void
struct tree_label_decl GTY(())
{
struct tree_decl_with_rtl common;
- /* Java's verifier has some need to store information about labels,
- and was using fields that no longer exist on labels.
- Once the verifier doesn't need these anymore, they should be removed. */
- tree java_field_1;
- tree java_field_2;
- tree java_field_3;
- unsigned int java_field_4;
-
};
struct tree_result_decl GTY(())