This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

merge java pc label patch into 4.0?


As people use gcj to turn .jar files into object files, this problem
will show up more and more often.  Any chance I could get approval to
check this into the 4.0 branch?  I'm bootstrapping it on
amd64-linux-gnu ATM.

Index: gcc/java/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	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.

Index: gcc/java/jcf-parse.c
===================================================================
--- gcc/java/jcf-parse.c	(revision 107670)
+++ gcc/java/jcf-parse.c	(working copy)
@@ -919,6 +919,21 @@
 
       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);
 
Index: gcc/java/expr.c
===================================================================
--- gcc/java/expr.c	(revision 107670)
+++ gcc/java/expr.c	(working copy)
@@ -138,6 +138,12 @@
 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)
 {
@@ -1771,7 +1777,9 @@
 {
   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: gcc/java/java-tree.h
===================================================================
--- gcc/java/java-tree.h	(revision 107670)
+++ gcc/java/java-tree.h	(working copy)
@@ -242,6 +242,12 @@
 
 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
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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