This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[BC] Patch: FYI: more verifier fixes


I'm checking this in on the BC branch.

This changes the type maps to hold pointers to Object, not just Object.
It removes the debugging prints, which were getting in my way (hope
nobody minds -- you can always compile with -DVERIFY_DEBUG).
It arranges to initialize the `this_type' field of a new state,
failure to do this was causing bogus verifier failures.
It also fixes another earlier goof of mine.

Andrew, Bryce -- I found a reason that the "everything is Object"
approach to type maps isn't that great, namely that it means we may
have to emit more array store type checks.

I haven't looked to see how many more we'll really have to emit.  With
BC we have to emit more anyway, as I think the "final class
optimization" in there right now is not valid for BC.  So, it might
not be too bad.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* verify-impl.c (verify_instructions): Call vfy_note_local_type.
	(init_state_with_stack): Initialize `this_type' in state.
	(verify_method): Use debug_print.
	* verify-glue.c (vfy_is_primitive): Removed debugging print.
	(vfy_note_stack_depth): Reverted last patch.
	(vfy_note_stack_type): Note pointer to Object, not Object.
	(vfy_note_local_type): Likewise.

Index: verify-glue.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-glue.c,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 verify-glue.c
--- verify-glue.c 19 Oct 2004 21:54:14 -0000 1.1.2.6
+++ verify-glue.c 19 Oct 2004 23:54:50 -0000
@@ -266,7 +266,6 @@
 bool
 vfy_is_primitive (vfy_jclass klass)
 {
-  printf ("debug: vfy_is_primitive()\n");
   return JPRIMITIVE_TYPE_P (klass);
 }
 
@@ -382,7 +381,7 @@
 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 + 1);
+  LABEL_TYPE_STATE (label) = make_tree_vec (method->max_locals + depth);
 }
 
 void
@@ -390,6 +389,9 @@
 {
   slot += method->max_locals;
 
+  if (type == object_type_node)
+    type = object_ptr_type_node;
+
   tree label = lookup_label (pc);
   tree vec = LABEL_TYPE_STATE (label);
   TREE_VEC_ELT (vec, slot) = type;
@@ -399,6 +401,9 @@
 vfy_note_local_type (vfy_method *method ATTRIBUTE_UNUSED, int pc, int slot,
 		     vfy_jclass type)
 {
+  if (type == object_type_node)
+    type = object_ptr_type_node;
+
   tree label = lookup_label (pc);
   tree vec = LABEL_TYPE_STATE (label);
   TREE_VEC_ELT (vec, slot) = type;
Index: verify-impl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-impl.c,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 verify-impl.c
--- verify-impl.c 19 Oct 2004 21:54:14 -0000 1.1.2.9
+++ verify-impl.c 19 Oct 2004 23:54:50 -0000
@@ -1057,6 +1057,7 @@
   s->locals = (type *) vfy_alloc (max_locals * sizeof (type));
   for (i = 0; i < max_locals; ++i)
     init_type_from_tag (&s->locals[i], unsuitable_type);
+  init_type_from_tag (&s->this_type, unsuitable_type);
   s->pc = NO_NEXT;
   s->next = INVALID_STATE;
 }
@@ -3342,7 +3343,7 @@
 
       /* Tell the compiler about each local variable.  */
       for (j = 0; j < vfr->current_method->max_locals; ++j)
-	vfy_note_stack_type (vfr->current_method, i, j,
+	vfy_note_local_type (vfr->current_method, i, j,
 			     collapse_type (&curr->locals[j]));
       /* Tell the compiler about each stack slot.  */
       for (j = 0; j < curr->stackdepth; ++j)
@@ -3426,8 +3427,8 @@
 int
 verify_method (vfy_method *meth)
 {
-  printf ("verify_method (%s) %i\n", vfy_string_bytes (meth->name),
-	  meth->code_length);
+  debug_print ("verify_method (%s) %i\n", vfy_string_bytes (meth->name),
+	       meth->code_length);
   
   if (vfr != NULL)
     verify_fail ("verifier re-entered");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]