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]

[gcjx] Patch: FYI: verifier notification (part 1)


I'm checking this in on the gcjx branch.

This changes the verifier so it can notify the bytecode-lowering code
about basic blocks and other things.  It also cleans up verify.h in
libjava a tiny bit.  As I recall notification gets changed again in a
later patch, so this is just a bridge.

Tom

Index: gcjx/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* bytecode/verify.cc (branch_prepass): Respect
	VFY_WANT_NOTIFICATION.
	(verify_instructions_0): Likewise.
	* model/bytecode.cc (verify): Call allocate_flags.
	* model/bytecode.hh (model_bytecode_block::flags): New field.
	(model_bytecode_block): Initialize it.
	(~model_bytecode_block): Delete 'flags'.
	(model_bytecode_block::allocate_flags): New method.
	(model_bytecode_block::get_flags): Likewise.
	* verify.h (VERIFY_SEEN): New define.
	(VERIFY_TARGET): Likewise.
	(VFY_WANT_NOTIFICATION): Likewise.
	(vfy_method::flags): New field.
	(vfy_notify_verified): Wrote.  Added 'method' argument.
	(vfy_notify_branch_target): New function.

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* lower.cc (VERIFY_SEEN, VERIFY_TARGET): Removed.
	(visit_bytecode_block): Get verifier flags from the block.

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

	* include/verify.h (vfy_notify_verified): Removed.

Index: gcjx/verify.h
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/verify.h,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 verify.h
--- gcjx/verify.h 27 Mar 2005 02:44:28 -0000 1.1.2.3
+++ gcjx/verify.h 3 Apr 2005 23:36:19 -0000
@@ -41,12 +41,23 @@
 
 typedef model_bytecode_block::exception vfy_exception;
 
+// These flags aren't used by the verifier itself, but are set on the
+// model_bytecode_block during verification.
+#define VERIFY_SEEN 1
+#define VERIFY_TARGET 2
+
+// This tells the verifier that we want notification of live bytecode
+// and branch targets.
+#define VFY_WANT_NOTIFICATION
+
+
 struct vfy_method
 {
   model_method *method;
   model_bytecode_block *block;
   resolution_scope *scope;
   model_unit_class *unit;
+  unsigned char *flags;
 
   // These fields are referred to directly by the verifier.
   vfy_jclass defining_class;
@@ -67,6 +78,7 @@
     max_locals = block->get_max_locals ();
     code_length = block->get_code_length ();
     exc_count = block->get_exception_length ();
+    flags = block->get_flags ();
   }
 };
 
@@ -315,9 +327,14 @@
     % pc % method->method % message;
 }
 
-inline void vfy_notify_verified (int pc)
+inline void vfy_notify_verified (vfy_method *method, int pc)
+{
+  method->flags[pc] |= VERIFY_SEEN;
+}
+
+inline void vfy_notify_branch_target (vfy_method *method, int pc)
 {
-  // FIXME: nothing for now, but should notify the compiler.
+  method->flags[pc] |= VERIFY_TARGET;
 }
 
 // Return the primitive type corresponding to the argument to
Index: gcjx/bytecode/verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/verify.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 verify.cc
--- gcjx/bytecode/verify.cc 27 Mar 2005 02:44:29 -0000 1.1.2.3
+++ gcjx/bytecode/verify.cc 3 Apr 2005 23:36:21 -0000
@@ -1930,6 +1930,9 @@
 		       end);
 
 	flags[handler] |= FLAG_BRANCH_TARGET;
+#ifdef VFY_WANT_NOTIFICATION
+	vfy_notify_branch_target (current_method, handler);
+#endif
       }
   }
 
@@ -2236,6 +2239,10 @@
 	// sane.
 	start_PC = PC;
 
+#ifdef VFY_WANT_NOTIFICATION
+	vfy_notify_verified (current_method, PC);
+#endif
+
 	// Update states for all active exception handlers.  Ordinarily
 	// there are not many exception handlers.  So we simply run
 	// through them all.
Index: gcjx/model/bytecode.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/bytecode.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 bytecode.cc
--- gcjx/model/bytecode.cc 13 Feb 2005 03:39:45 -0000 1.1.2.2
+++ gcjx/model/bytecode.cc 3 Apr 2005 23:36:21 -0000
@@ -49,6 +49,8 @@
 	    = assert_cast<model_unit_class *> (klass->get_compilation_unit ());
 	}
 
+      allocate_flags (length);
+
       if (global->get_compiler ()->verbose ())
 	std::cout << "[verifying method "
 		  << decl->get_fully_qualified_name ()
Index: gcjx/model/bytecode.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/bytecode.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 bytecode.hh
--- gcjx/model/bytecode.hh 13 Feb 2005 03:39:45 -0000 1.1.2.2
+++ gcjx/model/bytecode.hh 3 Apr 2005 23:36:21 -0000
@@ -68,6 +68,19 @@
 
   // fixme variable and debug info
 
+  // Flags set during the verification process.  This is allocated
+  // with new[] and owned by this object.
+  unsigned char *flags;
+
+
+  /// Allocate space for the flags.
+  void allocate_flags (int size)
+  {
+    assert (! flags);
+    flags = new unsigned char[size];
+    memset (flags, 0, size);
+  }
+
 public:
 
   model_bytecode_block (const location &w)
@@ -78,7 +91,8 @@
       bytes (NULL),
       exc_length (-1),
       excs (NULL),
-      verified (false)
+      verified (false),
+      flags (NULL)
   {
   }
 
@@ -86,6 +100,8 @@
   {
     if (excs)
       delete[] excs;
+    if (flags)
+      delete[] flags;
   }
 
   void resolve (resolution_scope *);
@@ -176,6 +192,13 @@
   /// come from a .class file, and that class' compilation unit is
   /// used.
   void verify (model_method *, model_unit_class * = NULL);
+
+  /// Get the flags for this block.
+  unsigned char *get_flags () const
+  {
+    assert (flags);
+    return flags;
+  }
 };
 
 /// This is a phony block which is used when reading a .class file
Index: gcc/java/lower.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/lower.cc,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 lower.cc
--- gcc/java/lower.cc 27 Mar 2005 03:01:24 -0000 1.1.2.8
+++ gcc/java/lower.cc 3 Apr 2005 23:36:28 -0000
@@ -26,10 +26,6 @@
 #include "bytecode/insns.hh"
 #include "verify.h"
 
-// FIXME: these must come from the verifier.
-#define VERIFY_SEEN 1
-#define VERIFY_TARGET 2
-
 // This is used to determine which particular variable is used for a
 // given stack or local variable slot.
 typedef enum
@@ -40,7 +36,7 @@
     TYPE_DOUBLE = 2,
     TYPE_OBJECT = 3		// Everything else.
   }
-  slot_type;
+slot_type;
 
 
 
@@ -127,7 +123,7 @@
   tree body = alloc_stmt_list ();
   tree_stmt_iterator statements = tsi_start (body);
 
-  int *flags;			// FIXME from the verifier
+  unsigned char *flags = block->get_flags ();
 
   int pc = 0;
   while (pc < length)
Index: libjava/include/verify.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/Attic/verify.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 verify.h
--- libjava/include/verify.h 27 Mar 2005 02:44:40 -0000 1.1.2.1
+++ libjava/include/verify.h 3 Apr 2005 23:36:33 -0000
@@ -312,11 +312,6 @@
   throw new java::lang::VerifyError (buf->toString ());
 }
 
-inline void vfy_notify_verified (int pc)
-{
-  // In libgcj, do nothing.
-}
-
 // Return the primitive type corresponding to the argument to
 // `newarray'.
 inline vfy_jclass vfy_get_primitive_type (int type)


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