What happened to java Utf-8 merging patches (was Re: Constant merging buggy? [Re: Java: enable constant merging])

Jakub Jelinek jakub@redhat.com
Sun Feb 3 12:12:00 GMT 2002


On Sat, Feb 02, 2002 at 10:59:27PM -0800, Anthony Green wrote:
> On Sat, 2002-02-02 at 14:23, Jakub Jelinek wrote:
> > First before I start looking into this, I'd like to know what happened to
> 
> Hmmmm... the way I remember it there was some kind of problem that you
> were going to look into. I should have a record of this exchange in an
> old mail folder.  I'll check next time I boot into that old OS I was
> using before (tomorrow?).

Well, I see no problem with the original varasm.c patch (below) - the only
thing it does is if you call named_section_flags (, SECTION_OVERRIDE | fl),
then all named_section () calls on the same section will use the flags
you've given.
Though I found a problem with class.c hunk.
Your patch would create something like:
        .section        .rodata.jutf8.21,"aM",@progbits,21
        .align 2
        .type   _Utf1,@object
        .size   _Utf1,4
_Utf1:
        .value  38141
        .value  16
        .ascii  "protectionDomain"
        .zero   1

which means
  [11] .rodata.jutf8.21  PROGBITS        00000000 001ff2 000016 15  AM  0  0  2
in the .o file.
This is wrong, for AM section st_size must be multiple st_entsize, otherwise
the output might be very interesting.
The problem is .align 2, basically if you add another 16 byte string after
this, it will not be placed at _Utf1 + 21, but _Utf1 + 22.
Solved in the patch below (though I found this after bootstrapping, so only
checked a couple of jc1 compilations, not done full bootstrap again).

--- gcc/java/class.c.jj	Thu Jan  3 12:04:49 2002
+++ gcc/java/class.c	Sun Feb  3 16:18:41 2002
@@ -963,7 +963,7 @@ build_utf8_ref (name)
   char buf[60];
   tree ctype, field = NULL_TREE, str_type, cinit, string;
   static int utf8_count = 0;
-  int name_hash;
+  int name_hash, decl_size;
   tree ref = IDENTIFIER_UTF8_REF (name);
   tree decl;
   if (ref != NULL_TREE)
@@ -996,6 +996,19 @@ build_utf8_ref (name)
   TREE_READONLY (decl) = 1;
   TREE_THIS_VOLATILE (decl) = 0;
   DECL_INITIAL (decl) = cinit;
+#ifdef HAVE_GAS_SHF_MERGE
+  decl_size = (name_len + 5 + TYPE_ALIGN_UNIT (utf8const_type) - 1)
+	      & ~(TYPE_ALIGN_UNIT (utf8const_type) - 1);
+  if (flag_merge_constants && decl_size < 256)
+    {
+      char buf[32];
+      int flags = (SECTION_OVERRIDE
+		   | SECTION_MERGE | (SECTION_ENTSIZE & decl_size));
+      sprintf (buf, ".rodata.jutf8.%d", decl_size);
+      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);
--- gcc/output.h.jj	Tue Dec 18 01:28:10 2001
+++ gcc/output.h	Sun Feb  3 11:24:31 2002
@@ -512,7 +512,8 @@ extern void no_asm_to_stream PARAMS ((FI
 #define SECTION_MERGE	 0x08000	/* contains mergeable data */
 #define SECTION_STRINGS  0x10000	/* contains zero terminated strings without
 					   embedded zeros */
-#define SECTION_MACH_DEP 0x20000	/* subsequent bits reserved for target */
+#define SECTION_OVERRIDE 0x20000	/* override default property flags */
+#define SECTION_MACH_DEP 0x40000	/* subsequent bits reserved for target */
 
 extern unsigned int get_named_section_flags PARAMS ((const char *));
 extern bool set_named_section_flags	PARAMS ((const char *, unsigned int));
--- gcc/varasm.c.jj	Sun Feb  3 11:25:00 2002
+++ gcc/varasm.c	Sun Feb  3 11:28:12 2002
@@ -445,11 +445,15 @@ named_section (decl, name, reloc)
   flags = (* targetm.section_type_flags) (decl, name, reloc);
 
   /* Sanity check user variables for flag changes.  Non-user
-     section flag changes will abort in named_section_flags.  */
+     section flag changes will abort in named_section_flags.
+     However, don't complain if SECTION_OVERRIDE is set.
+     We trust that the setter knows that it is safe to ignore
+     the default flags for this decl.  */
   if (decl && ! set_named_section_flags (name, flags))
     {
-      error_with_decl (decl, "%s causes a section type conflict");
       flags = get_named_section_flags (name);
+      if ((flags & SECTION_OVERRIDE) == 0)
+	error_with_decl (decl, "%s causes a section type conflict");
     }
 
   named_section_flags (name, flags);

	Jakub



More information about the Gcc-patches mailing list