This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: more verifier fixes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 18 Nov 2001 17:56:21 -0700
- Subject: Patch: FYI: more verifier fixes
- Reply-to: tromey at redhat dot com
I'm checking this in. It fixes more verifier bugs.
I added some better debug output to a few failure messages.
I made pop_type promote the match type. Without this something like
putfield could expect a `bool' but see an `int' on the stack and then
erroneously fail.
I changed set_initialized to do nothing if the type is not an
uninitialized reference or if the PC had the `UNINIT' value.
Finally, I cleaned up set_uninitialized and fixed a shadowing bug
there.
Today's fixes are all courtesy of running Mauve under gij.
The test harness still doesn't verify, so there's more to do.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* verify.cc (_Jv_BytecodeVerifier::pop_type): Put PC into error
message.
(_Jv_BytecodeVerifier::pop64): Likewise.
(_Jv_BytecodeVerifier::pop32): Likewise.
(_Jv_BytecodeVerifier::pop_raw): Likewise.
(_Jv_BytecodeVerifier::pop_type): Promote the match type.
(type::set_initialized): Only modify uninitialized types.
(type::set_uninitialized): Fix shadowing bug. Simplify code.
Index: verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.8
diff -u -r1.8 verify.cc
--- verify.cc 2001/11/18 23:04:28 1.8
+++ verify.cc 2001/11/19 00:28:14
@@ -353,20 +353,23 @@
}
// Mark this type as the uninitialized result of `new'.
- void set_uninitialized (int pc)
+ void set_uninitialized (int npc)
{
- if (key != reference_type && key != unresolved_reference_type)
+ if (key == reference_type)
+ key = uninitialized_reference_type;
+ else if (key == unresolved_reference_type)
+ key = uninitialized_unresolved_reference_type;
+ else
verify_fail ("internal error in type::uninitialized");
- key = (key == reference_type
- ? uninitialized_reference_type
- : uninitialized_unresolved_reference_type);
- pc = pc;
+ pc = npc;
}
// Mark this type as now initialized.
void set_initialized (int npc)
{
- if (pc == npc)
+ if (npc != UNINIT && pc == npc
+ && (key == uninitialized_reference_type
+ || key == uninitialized_unresolved_reference_type))
{
key = (key == uninitialized_reference_type
? reference_type
@@ -834,11 +837,11 @@
type pop_raw ()
{
if (current_state->stacktop <= 0)
- verify_fail ("stack empty");
+ verify_fail ("stack empty", start_PC);
type r = current_state->stack[--current_state->stacktop];
current_state->stackdepth -= r.depth ();
if (current_state->stackdepth < 0)
- verify_fail ("stack empty");
+ verify_fail ("stack empty", start_PC);
return r;
}
@@ -846,7 +849,7 @@
{
type r = pop_raw ();
if (r.iswide ())
- verify_fail ("narrow pop of wide type");
+ verify_fail ("narrow pop of wide type", start_PC);
return r;
}
@@ -854,15 +857,16 @@
{
type r = pop_raw ();
if (! r.iswide ())
- verify_fail ("wide pop of narrow type");
+ verify_fail ("wide pop of narrow type", start_PC);
return r;
}
type pop_type (type match)
{
+ match.promote ();
type t = pop_raw ();
if (! match.compatible (t))
- verify_fail ("incompatible type on stack");
+ verify_fail ("incompatible type on stack", start_PC);
return t;
}