Patch: remove "java" fields from tree_label_decl

Tom Tromey tromey@redhat.com
Tue Aug 14 20:51:00 GMT 2007


This patch changed gcj so that it no longer needs the various "java"
fields in tree_label_decl.  It also removes these fields.

Tested by bootstrapping on x86 FC6, then running the gcj test suite.

Ok?  I only need approval for the tree.h part.

Tom

ChangeLog:
2007-08-13  Tom Tromey  <tromey@redhat.com>

	* tree.h (struct tree_label_decl): Removed old "java" fields.

java/ChangeLog:
2007-08-13  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.

Index: tree.h
===================================================================
--- tree.h	(revision 127484)
+++ tree.h	(working copy)
@@ -2914,14 +2914,6 @@
 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(())
Index: java/verify-glue.c
===================================================================
--- java/verify-glue.c	(revision 127484)
+++ java/verify-glue.c	(working copy)
@@ -393,37 +393,41 @@
 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
Index: java/expr.c
===================================================================
--- java/expr.c	(revision 127484)
+++ java/expr.c	(working copy)
@@ -1772,7 +1772,6 @@
     {
       /* 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);
     }
 }
@@ -1801,9 +1800,15 @@
   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)
 {
@@ -2953,11 +2958,11 @@
   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++)
@@ -3000,6 +3005,8 @@
   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;)
@@ -3158,8 +3165,8 @@
           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))
Index: java/java-tree.h
===================================================================
--- java/java-tree.h	(revision 127484)
+++ java/java-tree.h	(working copy)
@@ -771,16 +771,6 @@
    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)
@@ -1248,7 +1238,6 @@
 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);
@@ -1418,6 +1407,9 @@
 /* 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;



More information about the Java-patches mailing list