This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Java: byte compiler bug fixes
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 28 Aug 2002 16:47:05 +0100 (BST)
- Subject: Java: byte compiler bug fixes
Not all Java bytecode is produced by Java compilers, and some of it
can be downright weird. I've come across a case where a special
compiler for Java Server Pages generates very bogus-looking code,
where exception handlers recursively invoke themselves. This can't
work (can it?) but is perfectly legal Java bytecode according to the
spec. So, I'll allow it but I will generate a warning.
I also found an unrelated bug where one member of struct eh_range
ins't initialized.
Andrew.
2002-08-28 Andrew Haley <aph@cambridge.redhat.com>
* verify.c (verify_jvm_instructions): Allow exception handler
inside code that is being protected, but generate a warning.
* except.c (link_handler): Initialize `expanded' in new eh_range.
(binding_depth, is_class_level, current_pc): Declare extern.
Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/except.c,v
retrieving revision 1.28
diff -c -2 -p -r1.28 except.c
*** except.c 4 Aug 2002 22:45:30 -0000 1.28
--- except.c 28 Aug 2002 15:31:12 -0000
*************** struct eh_range whole_range;
*** 62,68 ****
#if defined(DEBUG_JAVA_BINDING_LEVELS)
! int binding_depth;
! int is_class_level;
! int current_pc;
extern void indent ();
--- 62,68 ----
#if defined(DEBUG_JAVA_BINDING_LEVELS)
! extern int binding_depth;
! extern int is_class_level;
! extern int current_pc;
extern void indent ();
*************** link_handler (range, outer)
*** 173,176 ****
--- 173,177 ----
TREE_VALUE (range->handlers));
h->next_sibling = NULL;
+ h->expanded = 0;
/* Restart both from the top to avoid having to make this
function smart about reentrancy. */
Index: verify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/verify.c,v
retrieving revision 1.48
diff -c -2 -p -r1.48 verify.c
*** verify.c 4 Jun 2002 20:32:08 -0000 1.48
--- verify.c 28 Aug 2002 15:31:13 -0000
*************** verify_jvm_instructions (jcf, byte_ops,
*** 472,476 ****
|| end_pc < 0 || end_pc > length || start_pc >= end_pc
|| handler_pc < 0 || handler_pc >= length
- || (handler_pc >= start_pc && handler_pc < end_pc)
|| ! (instruction_bits [start_pc] & BCODE_INSTRUCTION_START)
|| (end_pc < length &&
--- 472,475 ----
*************** verify_jvm_instructions (jcf, byte_ops,
*** 482,485 ****
--- 481,487 ----
return 0;
}
+
+ if (handler_pc >= start_pc && handler_pc < end_pc)
+ warning ("exception handler inside code that is being protected");
add_handler (start_pc, end_pc,