This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[BC] Patch: FYI: more verifier updates
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 19 Oct 2004 15:53:25 -0600
- Subject: [BC] Patch: FYI: more verifier updates
- Reply-to: tromey at redhat dot com
I'm checking this in on the BC branch.
This changes the verifier to notify the rest of the compiler about
dead code and about exception handlers. It also moves the
state-saving for PC=0 later on in the verification function; at the
old location it caused verification to exit early -- my oops for not
noticing this.
With this patch in place the new verifier crashes in the type map code
(which is good since it is what I planned to work on today :-)
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* verify.h (vfy_note_instruction_seen): Declare.
* verify-glue.c (verify_jvm_instructions_new): Set
BCODE_EXCEPTION_TARGET on target instruction.
(vfy_note_instruction_seen): New function.
* verify-impl.c (FLAG_INSN_SEEN): New define.
(verify_instructions_0): Set flag on instruction. Save state for
PC=0 later.
(verify_instructions): Call vfy_note_instruction_seen.
Index: verify-glue.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-glue.c,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 verify-glue.c
--- verify-glue.c 19 Oct 2004 21:29:48 -0000 1.1.2.5
+++ verify-glue.c 19 Oct 2004 21:50:16 -0000
@@ -404,6 +404,11 @@
TREE_VEC_ELT (vec, slot) = type;
}
+void
+vfy_note_instruction_seen (int pc)
+{
+ instruction_bits[pc] |= BCODE_VERIFIED;
+}
/* Verify the bytecodes of the current method.
Return 1 on success, 0 on failure. */
@@ -448,6 +453,7 @@
lookup_label (handler_pc),
catch_type == 0 ? NULL_TREE
: get_class_constant (jcf, catch_type));
+ instruction_bits[handler_pc] |= BCODE_EXCEPTION_TARGET;
}
handle_nested_ranges ();
Index: verify-impl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify-impl.c,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 verify-impl.c
--- verify-impl.c 19 Oct 2004 21:29:48 -0000 1.1.2.8
+++ verify-impl.c 19 Oct 2004 21:50:16 -0000
@@ -147,6 +147,7 @@
#define FLAG_INSN_START 1
#define FLAG_BRANCH_TARGET 2
+#define FLAG_INSN_SEEN 4
struct state;
struct type;
@@ -2346,10 +2347,6 @@
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. */
@@ -2389,6 +2386,7 @@
the end of the bytecode until we process a `ret'. */
if (vfr->PC >= vfr->current_method->code_length)
verify_fail ("fell off end");
+ vfr->flags[vfr->PC] |= FLAG_INSN_SEEN;
/* We only have to keep saved state at branch targets. If
we're at a branch target and the state here hasn't been set
@@ -2396,7 +2394,10 @@
won't necessarily have FLAG_BRANCH_TARGET set. This
doesn't matter, since those states will be filled in by
merge_into. */
- if (vfr->states[vfr->PC] == NULL && (vfr->flags[vfr->PC] & FLAG_BRANCH_TARGET))
+ /* Note that other parts of the compiler assume that there is a
+ label with a type map at PC=0. */
+ if (vfr->states[vfr->PC] == NULL
+ && (vfr->PC == 0 || (vfr->flags[vfr->PC] & FLAG_BRANCH_TARGET) != 0))
add_new_state (vfr->PC, vfr->current_state);
/* Set this before handling exceptions so that debug output is
@@ -3330,6 +3331,9 @@
int j;
struct state *curr;
+ if ((vfr->flags[i] & FLAG_INSN_SEEN) != 0)
+ vfy_note_instruction_seen (i);
+
if (! vfr->states[i])
continue;
Index: verify.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/verify.h,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 verify.h
--- verify.h 15 Oct 2004 17:45:25 -0000 1.1.2.5
+++ verify.h 19 Oct 2004 21:50:16 -0000
@@ -125,6 +125,7 @@
vfy_jclass type);
void vfy_note_local_type (vfy_method *method, int pc, int slot,
vfy_jclass type);
+void vfy_note_instruction_seen (int pc);
#define GLOM(name, stuff) name ## stuff
#define VFY_PRIMITIVE_CLASS(name) \