expr.c (int highest_label_pc_this_method, [...]): New globals.
authorPer Bothner <per@bothner.com>
Mon, 13 Jun 2005 19:30:47 +0000 (12:30 -0700)
committerPer Bothner <bothner@gcc.gnu.org>
Mon, 13 Jun 2005 19:30:47 +0000 (12:30 -0700)
* expr.c (int highest_label_pc_this_method,
start_label_pc_this_method): New globals.
(lookup_label): Add start_label_pc_this_method to pc for label, and
update highest_label_pc_this_method.  This prevents conflicts between
labels from different methods.
* java-tree.h: Declare new globals.
* jcf-parse.c (parse_class_file): If needed bump
start_label_pc_this_method and reset highest_label_pc_this_method.

From-SVN: r100896

gcc/java/ChangeLog
gcc/java/expr.c
gcc/java/java-tree.h
gcc/java/jcf-parse.c

index 52196e49a36316de63eea1e24c179d182fab9e34..320be475713e06928a178d5c22b72306da0b6578 100644 (file)
@@ -1,3 +1,14 @@
+2005-06-13  Per Bothner  <per@bothner.com>
+
+       * expr.c (int highest_label_pc_this_method,
+       start_label_pc_this_method): New globals.
+       (lookup_label): Add start_label_pc_this_method to pc for label, and
+       update highest_label_pc_this_method.  This prevents conflicts between
+       labels from different methods.
+       * java-tree.h: Declare new globals.
+       * jcf-parse.c (parse_class_file): If needed bump
+       start_label_pc_this_method and reset highest_label_pc_this_method.
+
 2005-06-13  Tom Tromey  <tromey@redhat.com>
 
        PR java/21844:
index b48847126b850bd7001cccf139d2420225ba356c..90f8ff404602cd08f8b0c8631a0b80657d03580b 100644 (file)
@@ -138,6 +138,12 @@ int stack_pointer;
 const unsigned char *linenumber_table;
 int linenumber_count;
 
+/* Largest pc so far in this method that has been passed to lookup_label. */
+int highest_label_pc_this_method = -1;
+
+/* Base value for this method to add to pc to get generated label. */
+int start_label_pc_this_method = 0;
+
 void
 init_expr_processing (void)
 {
@@ -1766,7 +1772,9 @@ lookup_label (int pc)
 {
   tree name;
   char buf[32];
-  ASM_GENERATE_INTERNAL_LABEL(buf, "LJpc=", pc);
+  if (pc > highest_label_pc_this_method)
+    highest_label_pc_this_method = pc;
+  ASM_GENERATE_INTERNAL_LABEL(buf, "LJpc=", start_label_pc_this_method + pc);
   name = get_identifier (buf);
   if (IDENTIFIER_LOCAL_VALUE (name))
     return IDENTIFIER_LOCAL_VALUE (name);
index 826d4cba19e6bfb9986afba17b078ae85fbf8b11..5651dc3f64309b1604edaffc1588438b6bbc3eb6 100644 (file)
@@ -234,6 +234,12 @@ extern int always_initialize_class_p;
 
 extern int flag_verify_invocations;
 
+/* Largest pc so far in this method that has been passed to lookup_label. */
+extern int highest_label_pc_this_method;
+
+/* Base value for this method to add to pc to get generated label. */
+extern int start_label_pc_this_method;
+
 typedef struct CPool constant_pool;
 
 #define CONSTANT_ResolvedFlag 16
index ccf6d34d35792b542bea8c636e48f8aea943a1ec..29c257fe951a947588408f8f26288df7ec44c5f3 100644 (file)
@@ -929,6 +929,21 @@ parse_class_file (void)
 
       give_name_to_locals (jcf);
 
+      /* Bump up start_label_pc_this_method so we get a unique label number
+        and reset highest_label_pc_this_method. */
+      if (highest_label_pc_this_method >= 0)
+       {
+         /* We adjust to the next multiple of 1000.  This is just a frill
+            so the last 3 digits of the label number match the bytecode
+            offset, which might make debugging marginally more convenient. */
+         start_label_pc_this_method
+           = ((((start_label_pc_this_method + highest_label_pc_this_method)
+                / 1000)
+               + 1)
+              * 1000);
+         highest_label_pc_this_method = -1;
+       }
+
       /* Convert bytecode to trees.  */
       expand_byte_code (jcf, method);