[PATCH] Java: patch for an old EH problem + question.

Alexandre Petit-Bianco apbianco@cygnus.com
Fri Jan 7 17:59:00 GMT 2000


I'm checking in this old patch to fix an exception handling problem
first reported and analyzed by Godmar Back:

  http://egcs.cygnus.com/ml/gcc-bugs/1999-12/msg00120.html

I know Godmar issued a recommendation on fixing gen_exception_label
with an assert, since a preceding comment states that exception labels
should be generated on a permanent obstack. I tried something like:

Fri Jan  7 17:44:25 2000  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* except.c (gen_exception_label): Complain if the current obstack
 	isn't the permanent obstack.

Index: except.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/except.c,v
retrieving revision 1.110
diff -u -p -r1.110 except.c
--- except.c    1999/12/20 13:18:15     1.110
+++ except.c    2000/01/08 01:44:04
@@ -570,7 +570,12 @@ top_label_entry (stack)
 rtx
 gen_exception_label ()
 {
+  extern struct obstack *current_obstack;
   rtx lab;
+
+  if (current_obstack != &permanent_obstack)
+    fatal ("non permanent current obstack - gen_exception_label");
+
   lab = gen_label_rtx ();
   return lab;
 }

and I started to hit `fatal' pretty often, notably coming from
expand_expr at `WITH_CLEANUP_EXPR:'.

My question is: should the condition be enforced all the time (in
which case the reported error points out at something wrong somewhere
else that I still have to investigate) or are they exceptions?

./A

Wed Dec  8 15:33:26 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * expr.c (java_lang_expand_expr): Switch to permanent obstack
        before calling expand_eh_region_start and expand_start_all_catch.
        * except.c (expand_start_java_handler): Switch to permanent
        obstack before calling expand_eh_region_start.
        (expand_end_java_handler): Switch to permanent obstack before
        calling expand_start_all_catch.

Index: except.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/except.c,v
retrieving revision 1.15
diff -u -p -r1.15 except.c
--- except.c	1999/12/06 19:37:30	1.15
+++ except.c	2000/01/08 01:17:05
@@ -291,7 +291,9 @@ static void
 expand_start_java_handler (range)
   struct eh_range *range ATTRIBUTE_UNUSED;
 {
+  push_obstacks (&permanent_obstack, &permanent_obstack);
   expand_eh_region_start ();
+  pop_obstacks ();
 }
 
 tree
@@ -327,7 +329,9 @@ expand_end_java_handler (range)
      struct eh_range *range;
 {
   tree handler = range->handlers;
+  push_obstacks (&permanent_obstack, &permanent_obstack);
   expand_start_all_catch ();
+  pop_obstacks ();
   for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler))
     {
       start_catch_handler (prepare_eh_table_type (TREE_PURPOSE (handler)));
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/expr.c,v
retrieving revision 1.55
diff -u -p -r1.55 expr.c
--- expr.c	2000/01/07 23:07:52	1.55
+++ expr.c	2000/01/08 01:17:05
@@ -2024,9 +2024,13 @@ java_lang_expand_expr (exp, target, tmod
       /* We expand a try[-catch] block */
 
       /* Expand the try block */
+      push_obstacks (&permanent_obstack, &permanent_obstack);
       expand_eh_region_start ();
+      pop_obstacks ();
       expand_expr_stmt (TREE_OPERAND (exp, 0));
+      push_obstacks (&permanent_obstack, &permanent_obstack);
       expand_start_all_catch ();
+      pop_obstacks ();
 
       /* Expand all catch clauses (EH handlers) */
       for (current = TREE_OPERAND (exp, 1); current; 


More information about the Gcc-patches mailing list