This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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 fixes a few bugs in the new verifier:

* We weren't returning the correct value from verify_method
* We incorrectly computed the size of the type map
* We weren't telling the compiler about exceptions
* The compiler needs a type map at PC=0

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* verify-glue.c (vfy_note_stack_depth): Fix off-by-one error.
	(verify_jvm_instructions_new): Call method_init_exceptions,
	add_handler, and handle_nested_ranges.
	* verify-impl.c (verify_method): Return 1 on success.
	(verify_instructions_0): Save the state at PC=0.

Index: verify-glue.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-glue.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 verify-glue.c
--- verify-glue.c 15 Oct 2004 17:45:25 -0000 1.1.2.4
+++ verify-glue.c 19 Oct 2004 21:27:15 -0000
@@ -382,7 +382,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);
+  LABEL_TYPE_STATE (label) = make_tree_vec (method->max_locals + depth + 1);
 }
 
 void
@@ -415,7 +415,8 @@
   int i, result, eh_count;
   vfy_exception *exceptions;
 
-  /*method_init_exceptions ();*/
+  method_init_exceptions ();
+
   JCF_SEEK (jcf, DECL_CODE_OFFSET (current_function_decl) + length);
   eh_count = JCF_readu2 (jcf);
 
@@ -442,8 +443,15 @@
       exceptions[i].start = start_pc;
       exceptions[i].end = end_pc;
       exceptions[i].type = catch_type;
+
+      add_handler (start_pc, end_pc,
+		   lookup_label (handler_pc),
+		   catch_type == 0 ? NULL_TREE
+		   : get_class_constant (jcf, catch_type));
     }
 
+  handle_nested_ranges ();
+
   method.method = current_function_decl;
   method.signature = build_java_signature (TREE_TYPE (current_function_decl));
   method.name = DECL_NAME (current_function_decl);
Index: verify-impl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-impl.c,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 verify-impl.c
--- verify-impl.c 19 Oct 2004 20:27:57 -0000 1.1.2.7
+++ verify-impl.c 19 Oct 2004 21:27:15 -0000
@@ -2346,6 +2346,10 @@
 
   vfr->next_verify_state = NULL;
 
+  /* Other parts of the compiler assume that there is a label with a
+     type map at PC=0.  */
+  add_new_state (0, vfr->current_state);
+
   while (true)
     {
       /* If the PC was invalidated, get a new one from the work list.  */
@@ -3419,7 +3423,7 @@
 verify_method (vfy_method *meth)
 {
   printf ("verify_method (%s) %i\n", vfy_string_bytes (meth->name),
-    meth->code_length);
+	  meth->code_length);
   
   if (vfr != NULL)
     verify_fail ("verifier re-entered");
@@ -3429,5 +3433,5 @@
   free_verifier_context ();
   vfr = NULL;
 
-  return 0;
+  return 1;
 }


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