Java Patch: Merge UTF-8 contants at link time

Anthony Green green@redhat.com
Thu Sep 13 12:16:00 GMT 2001


This patch enables the merging of gcj's UTF-8 constants at link time
when combined with a recent gas/ld and this patch:
  http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00500.html

libgcj.so is almost 300k smaller on IA-32 Linux with this patch.

Tested on i686-pc-linux-gnu.  Ok to commit? (assuming the
SECTION_OVERRIDE patch is accepted)


2001-09-13  Anthony Green  <green@redhat.com>

	* class.c (build_utf8_ref): Put UTF-8 constants into merged
	sections if possible.

Index: gcc/java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.114
diff -u -p -r1.114 class.c
--- class.c	2001/09/10 08:52:54	1.114
+++ class.c	2001/09/13 19:09:58
@@ -986,6 +986,17 @@ build_utf8_ref (name)
   TREE_READONLY (decl) = 1;
   TREE_THIS_VOLATILE (decl) = 0;
   DECL_INITIAL (decl) = cinit;
+#ifdef HAVE_GAS_SHF_MERGE
+  if (flag_merge_constants && (name_len + 5) < 256)
+  {
+    char buf[32];
+    int flags = SECTION_OVERRIDE 
+      | SECTION_MERGE | (SECTION_ENTSIZE & (name_len + 5));
+    sprintf (buf, ".rodata.jutf8.%d", name_len + 5);
+    named_section_flags (buf, flags);
+    DECL_SECTION_NAME (decl) = build_string (strlen (buf), buf);
+  }
+#endif  
   TREE_CHAIN (decl) = utf8_decl_list;
   layout_decl (decl, 0);
   pushdecl (decl);



More information about the Java-patches mailing list