This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: avoid crash with variable ranges
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 17 Apr 2005 12:34:12 -0600
- Subject: [gcjx] Patch: FYI: avoid crash with variable ranges
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This changes the bytecode back end to handle the case where a variable
is live through the end of the method. This is kind of a hack, as
there is no way to represent the block just after the end of the
method, so instead we see NULL.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* bytecode/generate.hh (bytecode_generator::get_byte_count): New
method.
* bytecode/locals.cc (update): Changed assertion.
(emit): Handle case where 'end' is NULL.
Index: bytecode/generate.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/generate.hh,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 generate.hh
--- bytecode/generate.hh 20 Jan 2005 18:02:38 -0000 1.1.2.5
+++ bytecode/generate.hh 17 Apr 2005 18:34:39 -0000
@@ -386,6 +386,12 @@
return current_block;
}
+ /// Return the number of bytes in the bytecode.
+ int get_byte_count () const
+ {
+ return bytecode_length;
+ }
+
void visit_method (model_method *,
const std::list<ref_variable_decl> &,
Index: bytecode/locals.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/locals.cc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 locals.cc
--- bytecode/locals.cc 13 Feb 2005 03:22:42 -0000 1.1.2.5
+++ bytecode/locals.cc 17 Apr 2005 18:34:39 -0000
@@ -155,7 +155,9 @@
if (info.start->live_p ())
{
info.end = info.end->update ();
- assert (info.end->live_p ());
+ // NULL is ok here since that just means it is live through
+ // the end of the bytecode.
+ assert (info.end == NULL || info.end->live_p ());
// Don't emit debug info for a zero-length range.
if (info.start != info.end)
++valid;
@@ -185,8 +187,7 @@
}
int
-locals::emit (output_constant_pool *pool, bytecode_stream *out,
- bool types)
+locals::emit (output_constant_pool *pool, bytecode_stream *out, bool types)
{
int count = 0;
for (std::list<debug_info>::iterator i = var_descriptions.begin ();
@@ -230,7 +231,8 @@
continue;
out->put2 (info.start->get_pc ());
- out->put2 (info.end->get_pc () - info.start->get_pc ());
+ int last = info.end ? info.end->get_pc () : gen->get_byte_count ();
+ out->put2 (last - info.start->get_pc ());
out->put2 (pool->add_utf (info.variable->get_name ()));
out->put2 (pool->add_utf (types ? t->get_signature ()
: t->get_descriptor ()));