This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PR 1208


>> Is this patch ok for the trunk or just the branch?

Alex> Well: it fixes a bug and at the time didn't introduce any
Alex> regressions, so I guess it's good to go in the branch and the
Alex> trunk. I remember that I worked a bit on this patch. Here's what
Alex> I found. I don't think my contribution deserves an entry, it's
Alex> just part of your patch.

The "check for duplicates" hunk is from a different patch, the one for
PR 383 (old numbering -- I don't know the new number).

I believe you approved that patch, too, but I wasn't going to put it
into 3.0.

I really should go through and commit all my pending patches.  I will
soon.

Meanwhile I'll await Per's review of the 1208 patch, which I've
appended.  I don't seem to have a ChangeLog entry for it handy.

Basically the patch works by not freeing certain local variables.  If
we do free them then they get reused inappropriately.

Tom

Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-write.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- jcf-write.c	2000/07/11 04:00:14	1.63
+++ jcf-write.c	2000/07/13 18:25:37	1.64
@@ -290,6 +290,7 @@
 static void put_linenumber PARAMS ((int, struct jcf_partial *));
 static void localvar_alloc PARAMS ((tree, struct jcf_partial *));
 static void localvar_free PARAMS ((tree, struct jcf_partial *));
+static void localvar_finish PARAMS ((tree, struct jcf_partial *));
 static int get_access_flags PARAMS ((tree));
 static void write_chunks PARAMS ((FILE *, struct chunk *));
 static int adjust_typed_op PARAMS ((tree, int));
@@ -644,6 +645,25 @@
     }
 }
 
+/* Like localvar_free, but leaves the variable allocated.  This lets
+   us avoid problems with inappropriate variable reuse in some
+   situations.  */
+static void
+localvar_finish (decl, state)
+     tree decl;     
+     struct jcf_partial *state;
+{
+  struct jcf_block *end_label = get_jcf_label_here (state);
+  int index = DECL_LOCAL_INDEX (decl);
+  register struct localvar_info **ptr = &localvar_buffer [index];
+  register struct localvar_info *info = *ptr;
+
+  info->end_label = end_label;
+
+  if (info->decl != decl)
+    abort ();
+}
+
 
 #define STACK_TARGET 1
 #define IGNORE_TARGET 2
@@ -2379,7 +2399,7 @@
 	RESERVE (1);
 	OP1 (OPCODE_athrow);
 	NOTE_POP (1);
-	localvar_free (exception_decl, state);
+	localvar_finish (exception_decl, state);
 
 	/* The finally block.  First save return PC into return_link. */
 	define_jcf_label (finally_label, state);
@@ -2388,7 +2408,7 @@
 
 	generate_bytecode_insns (finally, IGNORE_TARGET, state);
 	maybe_wide (OPCODE_ret, DECL_LOCAL_INDEX (return_link), state);
-	localvar_free (return_link, state);
+	localvar_finish (return_link, state);
 	define_jcf_label (finished_label, state);
       }
       break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]