aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.stanford.edu>2000-11-17 06:05:31 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-11-17 06:05:31 +0000
commit520a57c81c83affcccb71eef52da0278991af777 (patch)
tree925528b7b20608d2eac0acf5e939480048b49271 /gcc/java
parent5af655cceef2b8b61a323734a6f9c250b4f420ca (diff)
downloadgcc-520a57c81c83affcccb71eef52da0278991af777.zip
gcc-520a57c81c83affcccb71eef52da0278991af777.tar.gz
gcc-520a57c81c83affcccb71eef52da0278991af777.tar.bz2
stringpool.c: New file.
* stringpool.c: New file. * ggc-common.c (ggc_mark_string_ptr, ggc_add_string_root): Delete. (ggc_alloc_string): Now in stringpool.o. * ggc-page.c, ggc-simple.c: Do not define or allocate empty_string. * ggc.h: Delete prototype of ggc_add_string_root. #define ggc_add_string_root and ggc_mark_string to nothing. Prototype init_stringpool and stringpool_statistics. (ggc_alloc_string): Returns a const char *. * tree.c (hash_table, do_identifier_warnings): Delete. (init_obstacks): Don't initialize the identifier hash table. (get_identifier, maybe_get_identifier, start_identifier_warnings, set_identifier_size): Now in stringpool.c. * tree.h (struct tree_string): Constify pointer field. (approx_sqrt): Prototype. * Makefile.in (stringpool.o): Add rule, mention in OBJS. * toplev.c (approx_sqrt): New function. (compile_file): Call stringpool_statistics if mem_report is on. (main): Call init_stringpool. * builtins.c (c_strlen), c-decl.c (finish_decl), c-lex.c (process_directive), c-typeck.c (constructor_asmspec, struct initializer_stack, start_init), except.c (create_rethrow_ref), stmt.c (digit_strings), toplev.c (decode_f_option), tree.c (built_in_filename), varasm,c (in_named_name, assemble_static_space, struct constant_descriptor, struct deferred_string, struct pool_constant, force_const_mem), i386.c (pic_label_name, global_offset_table_name), rs6000.c (rs6000_emit_prologue, rs6000_emit_epilogue) : Constify a char *. * c-common.c (combine_strings): Combine strings in scratch buffer, then pass to build_string. * optabs.c (init_libfuncs), profile.c (init_edge_profiler, output_func_start_profiler), stmt.c (init_stmt), alpha.c (alpha_need_linkage), arm.c (arm_encode_call_attribute), i386.c (load_pic_register), ia64.c (ia64_encode_section_info), rs6000.c (rs6000_encode_section_info): Create string in scratch buffer, then pass to ggc_alloc_string. * stmt.c (expand_asm_operands): If we must adjust the constraint strings, do so by creating a new one, not by modifying the old one in place. Constify some char *s. * config/pa/pa.c (hppa_encode_label): Drop unnecessary second argument. Create string in scratch buffer, then pass to ggc_alloc_string. * config/pa/pa-protos.h: Update prototype. * config/pa/elf.h, config/pa/pa.h, config/pa/som.h: hppa_encode_label takes only one argument. * c-parse.in (if_prefix): Find the filename and line number at $-2 and $-1 respectively. * diagnostic.c (error_recursion): Add missing newline, use fputs, translate string. cp: * lex.c (struct impl_files, internal_filename): Constify a char *. java: * jcf-parse.c (get_constant), parse.y (do_merge_string_cste): Create string in scratch buffer, then pass to build_string. From-SVN: r37514
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/jcf-parse.c52
-rw-r--r--gcc/java/parse.y8
3 files changed, 36 insertions, 29 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 156bcc1..5fb49c0 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,8 @@
+2000-11-16 Zack Weinberg <zack@wolery.stanford.edu>
+
+ * jcf-parse.c (get_constant), parse.y (do_merge_string_cste):
+ Create string in scratch buffer, then pass to build_string.
+
2000-11-13 Joseph S. Myers <jsm28@cam.ac.uk>
* parse.y (issue_warning_error_from_context): Add
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index 82c92ee..aa56811 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -328,29 +328,33 @@ get_constant (jcf, index)
{
tree name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index));
const char *utf8_ptr = IDENTIFIER_POINTER (name);
- unsigned char *str_ptr;
int utf8_len = IDENTIFIER_LENGTH (name);
- const unsigned char *str = (const unsigned char *)utf8_ptr;
- int i = utf8_len;
- int str_len;
+ unsigned char *str_ptr;
+ unsigned char *str;
+ const unsigned char *utf8;
+ int i, str_len;
/* Count the number of Unicode characters in the string,
while checking for a malformed Utf8 string. */
- for (str_len = 0; i > 0; str_len++)
+ utf8 = (const unsigned char *) utf8_ptr;
+ i = utf8_len;
+ str_len = 0;
+ while (i > 0)
{
- int char_len = UT8_CHAR_LENGTH (*str);
+ int char_len = UT8_CHAR_LENGTH (*utf8);
if (char_len < 0 || char_len > 3 || char_len > i)
fatal ("bad string constant");
- str += char_len;
+ utf8 += char_len;
i -= char_len;
+ str_len++;
}
- value = make_node (STRING_CST);
- TREE_TYPE (value) = build_pointer_type (string_type_node);
- TREE_STRING_LENGTH (value) = 2 * str_len;
- TREE_STRING_POINTER (value) = ggc_alloc (2 * str_len);
- str_ptr = (unsigned char *) TREE_STRING_POINTER (value);
- str = (const unsigned char *)utf8_ptr;
+ /* Allocate a scratch buffer, convert the string to UCS2, and copy it
+ into the new space. */
+ str_ptr = (unsigned char *) alloca (2 * str_len);
+ str = str_ptr;
+ utf8 = (const unsigned char *)utf8_ptr;
+
for (i = 0; i < str_len; i++)
{
int char_value;
@@ -358,31 +362,33 @@ get_constant (jcf, index)
switch (char_len)
{
case 1:
- char_value = *str++;
+ char_value = *utf8++;
break;
case 2:
- char_value = *str++ & 0x1F;
- char_value = (char_value << 6) | (*str++ & 0x3F);
+ char_value = *utf8++ & 0x1F;
+ char_value = (char_value << 6) | (*utf8++ & 0x3F);
break;
case 3:
- char_value = *str++ & 0x0F;
- char_value = (char_value << 6) | (*str++ & 0x3F);
- char_value = (char_value << 6) | (*str++ & 0x3F);
+ char_value = *utf8++ & 0x0F;
+ char_value = (char_value << 6) | (*utf8++ & 0x3F);
+ char_value = (char_value << 6) | (*utf8++ & 0x3F);
break;
default:
goto bad;
}
if (BYTES_BIG_ENDIAN)
{
- *str_ptr++ = char_value >> 8;
- *str_ptr++ = char_value & 0xFF;
+ *str++ = char_value >> 8;
+ *str++ = char_value & 0xFF;
}
else
{
- *str_ptr++ = char_value & 0xFF;
- *str_ptr++ = char_value >> 8;
+ *str++ = char_value & 0xFF;
+ *str++ = char_value >> 8;
}
}
+ value = build_string (str - str_ptr, str_ptr);
+ TREE_TYPE (value) = build_pointer_type (string_type_node);
}
break;
default:
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index e422c85..a35e6dc 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -13070,11 +13070,7 @@ do_merge_string_cste (cste, string, string_len, after)
const char *old = TREE_STRING_POINTER (cste);
int old_len = TREE_STRING_LENGTH (cste);
int len = old_len + string_len;
- char *new;
-
- cste = make_node (STRING_CST);
- TREE_STRING_LENGTH (cste) = len;
- new = TREE_STRING_POINTER (cste) = ggc_alloc (len+1);
+ char *new = alloca (len+1);
if (after)
{
@@ -13087,7 +13083,7 @@ do_merge_string_cste (cste, string, string_len, after)
memcpy (&new [old_len], string, string_len);
}
new [len] = '\0';
- return cste;
+ return build_string (len, new);
}
/* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a