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 new verifier to correctly handle wide types on the
stack when generating the type map.  It also fixes a few minor bugs in
the verifier glue code.

With this plus a not-yet-committed patch to the rest of the compiler,
I see pretty good results (== no crashes) compiling random jar files
from Eclipse 2.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* verify-impl.c (verify_instructions): Correctly handle wide
	types on the stack.
	* verify-glue.c (vfy_get_class_name): Use DECL_NAME.
	(vfy_get_component_type): Strip pointer types.
	(vfy_find_class): Use get_type_from_signature.  Strip pointer
	types.
	Include java-except.h.

Index: verify-glue.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-glue.c,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 verify-glue.c
--- verify-glue.c 20 Oct 2004 17:47:39 -0000 1.1.2.8
+++ verify-glue.c 20 Oct 2004 22:50:05 -0000
@@ -35,6 +35,7 @@
 
 #include "verify.h"
 #include "java-tree.h"
+#include "java-except.h"
 
 void *
 vfy_alloc (size_t bytes)
@@ -224,7 +225,7 @@
 vfy_string
 vfy_get_class_name (vfy_jclass klass)
 {
-  return TYPE_NAME (klass);
+  return DECL_NAME (TYPE_NAME (klass));
 }
 
 char
@@ -300,6 +301,8 @@
   if (! vfy_is_array (klass))
     abort ();
   k = TYPE_ARRAY_ELEMENT (klass);
+  if (TREE_CODE (k) == POINTER_TYPE)
+    k = TREE_TYPE (k);
   return k;
 }
 
@@ -313,7 +316,11 @@
 vfy_find_class (vfy_jclass ignore ATTRIBUTE_UNUSED, vfy_string name)
 {
   vfy_jclass k;
-  k = lookup_class (name);
+
+  k = get_type_from_signature (name);
+  if (TREE_CODE (k) == POINTER_TYPE)
+    k = TREE_TYPE (k);
+
   return k;
 }
 
Index: verify-impl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-impl.c,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 verify-impl.c
--- verify-impl.c 20 Oct 2004 18:46:31 -0000 1.1.2.12
+++ verify-impl.c 20 Oct 2004 22:50:06 -0000
@@ -3367,7 +3367,7 @@
   /* Now tell the rest of the compiler about the types we've found.  */
   for (i = 0; i < vfr->current_method->code_length; ++i)
     {
-      int j;
+      int j, slot;
       struct state *curr;
 
       if ((vfr->flags[i] & FLAG_INSN_SEEN) != 0)
@@ -3384,9 +3384,19 @@
 	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)
-	vfy_note_stack_type (vfr->current_method, i, j,
-			     collapse_type (&curr->stack[j]));
+      for (slot = j = 0; j < curr->stacktop; ++j, ++slot)
+	{
+	  vfy_note_stack_type (vfr->current_method, i, slot,
+			       collapse_type (&curr->stack[j]));
+	  if (type_iswide (&curr->stack[j]))
+	    {
+	      ++slot;
+	      vfy_note_stack_type (vfr->current_method, i, slot,
+				   vfy_unsuitable_type ());
+	    }
+	}
+      if (slot != curr->stackdepth)
+	abort ();
     }
 }
 


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