This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Java: Utf8 merging patch committed
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Mon, 04 Feb 2002 16:08:18 +1300
- Subject: Java: Utf8 merging patch committed
I confirmed that the latest version of Anthony & Jakub's patch to merge
Java Utf8Consts at link time seems to be working correctly. Since it was
already approved, I've checked it in as follows.
regards
Bryce
2001-02-04 Anthony Green <green@redhat.com>
* output.h (SECTION_OVERRIDE): Define.
* varasm.c (named_section): Obey SECTION_OVERRIDE.
2002-02-04 Anthony Green <green@redhat.com>
* class.c (build_utf8_ref): Put UTF-8 constants into merged
sections if available.
Index: output.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/output.h,v
retrieving revision 1.92
diff -u -r1.92 output.h
--- output.h 2001/12/17 15:05:22 1.92
+++ output.h 2002/02/04 02:55:03
@@ -512,7 +512,8 @@
#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 /* allow override of default 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));
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.244
diff -u -r1.244 varasm.c
--- varasm.c 2002/01/21 13:08:32 1.244
+++ varasm.c 2002/02/04 02:55:04
@@ -445,11 +445,15 @@
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);
Index: java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.125
diff -u -r1.125 class.c
--- class.c 2002/02/03 06:23:37 1.125
+++ class.c 2002/02/04 02:55:04
@@ -967,7 +967,7 @@
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)
@@ -1000,6 +1000,20 @@
TREE_READONLY (decl) = 1;
TREE_THIS_VOLATILE (decl) = 0;
DECL_INITIAL (decl) = cinit;
+#ifdef HAVE_GAS_SHF_MERGE
+ /* Ensure decl_size is a multiple of utf8const_type's alignment. */
+ 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);