Commit 4c521bad by Neil Booth Committed by Neil Booth

c-common.h (RID_FIRST_PQ): New.

	* c-common.h (RID_FIRST_PQ): New.
	* c-parse.in (objc_pq_context): New.
	(objc parser): Set objc_pq_context rather than calling
	remember_protocol_qualifiers and forget_protocol_qualifiers.
	Don't call save_and_forget_protocol_qualifiers.
	(yylexname): Handle objc protocol qualifiers here.
	* stringpool.c (struct str_header): Replace with sp_hashnode.
	(SP_EMPTY, SP_LEN, SP_TREE, SP_STR, SP_VALID): New.
	(alloc_string): Rename alloc_ident.  Use the SP_ accessors.
	Allocate an IDENTIFIER_NODE for each identifier.
	(FORALL_STRINGS, set_identifier): Delete.
	(FORALL_IDS, expand_string_table, stringpool_statistics): Update.
	(ggc_alloc_string): Use an obstack.
	(get_identifier, maybe_get_identifier, mark_string_hash): Update.
	* tree.h: Update comments.
	(set_identifier): Delete.
	* objc/objc-act.c (N_PQ, saved_pq, saved_not_pq,
	save_and_forget_protocol_qualifiers, forget_protocol_qualifiers,
	remember_protocol_qualifiers): Delete.

From-SVN: r42132
parent fca790eb
2001-05-16 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* c-common.h (RID_FIRST_PQ): New.
* c-parse.in (objc_pq_context): New.
(objc parser): Set objc_pq_context rather than calling
remember_protocol_qualifiers and forget_protocol_qualifiers.
Don't call save_and_forget_protocol_qualifiers.
(yylexname): Handle objc protocol qualifiers here.
* stringpool.c (struct str_header): Replace with sp_hashnode.
(SP_EMPTY, SP_LEN, SP_TREE, SP_STR, SP_VALID): New.
(alloc_string): Rename alloc_ident. Use the SP_ accessors.
Allocate an IDENTIFIER_NODE for each identifier.
(FORALL_STRINGS, set_identifier): Delete.
(FORALL_IDS, expand_string_table, stringpool_statistics): Update.
(ggc_alloc_string): Use an obstack.
(get_identifier, maybe_get_identifier, mark_string_hash): Update.
* tree.h: Update comments.
(set_identifier): Delete.
* objc/objc-act.c (N_PQ, saved_pq, saved_not_pq,
save_and_forget_protocol_qualifiers, forget_protocol_qualifiers,
remember_protocol_qualifiers): Delete.
Tue May 15 22:14:09 2001 Jeffrey A Law (law@cygnus.com) Tue May 15 22:14:09 2001 Jeffrey A Law (law@cygnus.com)
* flow.c (life_analysis): After life analysis is complete, do * flow.c (life_analysis): After life analysis is complete, do
......
...@@ -61,7 +61,7 @@ enum rid ...@@ -61,7 +61,7 @@ enum rid
RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE, RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE,
/* ObjC */ /* ObjC */
RID_IN, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF, RID_ONEWAY, RID_FIRST_PQ, RID_IN = RID_FIRST_PQ, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF, RID_ONEWAY,
/* C */ /* C */
RID_INT, RID_CHAR, RID_FLOAT, RID_DOUBLE, RID_VOID, RID_INT, RID_CHAR, RID_FLOAT, RID_DOUBLE, RID_VOID,
......
...@@ -271,6 +271,7 @@ tree objc_ivar_context; ...@@ -271,6 +271,7 @@ tree objc_ivar_context;
enum tree_code objc_inherit_code; enum tree_code objc_inherit_code;
int objc_receiver_context; int objc_receiver_context;
int objc_public_flag; int objc_public_flag;
int objc_pq_context;
end ifobjc end ifobjc
...@@ -2837,13 +2838,13 @@ classdef: ...@@ -2837,13 +2838,13 @@ classdef:
protocoldef: protocoldef:
PROTOCOL identifier protocolrefs PROTOCOL identifier protocolrefs
{ {
remember_protocol_qualifiers (); objc_pq_context = 1;
objc_interface_context objc_interface_context
= start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3); = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
} }
methodprotolist END methodprotolist END
{ {
forget_protocol_qualifiers(); objc_pq_context = 0;
finish_protocol(objc_interface_context); finish_protocol(objc_interface_context);
objc_interface_context = NULL_TREE; objc_interface_context = NULL_TREE;
} }
...@@ -2949,7 +2950,7 @@ ivar_declarator: ...@@ -2949,7 +2950,7 @@ ivar_declarator:
methoddef: methoddef:
'+' '+'
{ {
remember_protocol_qualifiers (); objc_pq_context = 1;
if (objc_implementation_context) if (objc_implementation_context)
objc_inherit_code = CLASS_METHOD_DECL; objc_inherit_code = CLASS_METHOD_DECL;
else else
...@@ -2957,7 +2958,7 @@ methoddef: ...@@ -2957,7 +2958,7 @@ methoddef:
} }
methoddecl methoddecl
{ {
forget_protocol_qualifiers (); objc_pq_context = 0;
add_class_method (objc_implementation_context, $3); add_class_method (objc_implementation_context, $3);
start_method_def ($3); start_method_def ($3);
objc_method_context = $3; objc_method_context = $3;
...@@ -2974,7 +2975,7 @@ methoddef: ...@@ -2974,7 +2975,7 @@ methoddef:
| '-' | '-'
{ {
remember_protocol_qualifiers (); objc_pq_context = 1;
if (objc_implementation_context) if (objc_implementation_context)
objc_inherit_code = INSTANCE_METHOD_DECL; objc_inherit_code = INSTANCE_METHOD_DECL;
else else
...@@ -2982,7 +2983,7 @@ methoddef: ...@@ -2982,7 +2983,7 @@ methoddef:
} }
methoddecl methoddecl
{ {
forget_protocol_qualifiers (); objc_pq_context = 0;
add_instance_method (objc_implementation_context, $3); add_instance_method (objc_implementation_context, $3);
start_method_def ($3); start_method_def ($3);
objc_method_context = $3; objc_method_context = $3;
...@@ -3023,13 +3024,13 @@ methodproto: ...@@ -3023,13 +3024,13 @@ methodproto:
'+' '+'
{ {
/* Remember protocol qualifiers in prototypes. */ /* Remember protocol qualifiers in prototypes. */
remember_protocol_qualifiers (); objc_pq_context = 1;
objc_inherit_code = CLASS_METHOD_DECL; objc_inherit_code = CLASS_METHOD_DECL;
} }
methoddecl methoddecl
{ {
/* Forget protocol qualifiers here. */ /* Forget protocol qualifiers here. */
forget_protocol_qualifiers (); objc_pq_context = 0;
add_class_method (objc_interface_context, $3); add_class_method (objc_interface_context, $3);
} }
semi_or_error semi_or_error
...@@ -3037,13 +3038,13 @@ methodproto: ...@@ -3037,13 +3038,13 @@ methodproto:
| '-' | '-'
{ {
/* Remember protocol qualifiers in prototypes. */ /* Remember protocol qualifiers in prototypes. */
remember_protocol_qualifiers (); objc_pq_context = 1;
objc_inherit_code = INSTANCE_METHOD_DECL; objc_inherit_code = INSTANCE_METHOD_DECL;
} }
methoddecl methoddecl
{ {
/* Forget protocol qualifiers here. */ /* Forget protocol qualifiers here. */
forget_protocol_qualifiers (); objc_pq_context = 0;
add_instance_method (objc_interface_context, $3); add_instance_method (objc_interface_context, $3);
} }
semi_or_error semi_or_error
...@@ -3615,9 +3616,6 @@ ifobjc ...@@ -3615,9 +3616,6 @@ ifobjc
= get_identifier (reswords[i].word + 1); = get_identifier (reswords[i].word + 1);
end ifobjc end ifobjc
} }
ifobjc
save_and_forget_protocol_qualifiers ();
end ifobjc
} }
const char * const char *
...@@ -3683,22 +3681,28 @@ yylexname () ...@@ -3683,22 +3681,28 @@ yylexname ()
if (C_IS_RESERVED_WORD (yylval.ttype)) if (C_IS_RESERVED_WORD (yylval.ttype))
{ {
enum rid rid_code = C_RID_CODE (yylval.ttype); enum rid rid_code = C_RID_CODE (yylval.ttype);
int yycode = rid_to_yy[(int) rid_code];
if (yycode == STRING_FUNC_NAME) ifobjc
{ if (!((unsigned int) rid_code - (unsigned int) RID_FIRST_PQ < 6)
/* __FUNCTION__ and __PRETTY_FUNCTION__ get converted || objc_pq_context)
to string constants. */ end ifobjc
const char *name = fname_string (rid_code); {
int yycode = rid_to_yy[(int) rid_code];
if (yycode == STRING_FUNC_NAME)
{
/* __FUNCTION__ and __PRETTY_FUNCTION__ get converted
to string constants. */
const char *name = fname_string (rid_code);
yylval.ttype = build_string (strlen (name) + 1, name); yylval.ttype = build_string (strlen (name) + 1, name);
last_token = CPP_STRING; /* so yyerror won't choke */ last_token = CPP_STRING; /* so yyerror won't choke */
return STRING; return STRING;
} }
/* Return the canonical spelling for this keyword. */ /* Return the canonical spelling for this keyword. */
yylval.ttype = ridpointers[(int) rid_code]; yylval.ttype = ridpointers[(int) rid_code];
return yycode; return yycode;
}
} }
decl = lookup_name (yylval.ttype); decl = lookup_name (yylval.ttype);
......
...@@ -8661,46 +8661,3 @@ lookup_objc_ivar (id) ...@@ -8661,46 +8661,3 @@ lookup_objc_ivar (id)
else else
return 0; return 0;
} }
/* Parser callbacks.
Some ObjC keywords are reserved only in a particular context:
in out inout bycopy byref oneway.
We have to save and restore the IDENTIFIER_NODEs that describe
them as keywords, when appropriate. */
#define N_PQ 6
static tree saved_pq[N_PQ];
static tree saved_not_pq[N_PQ];
static const char *const pq_strings[N_PQ] = {
"bycopy", "byref", "in", "inout", "oneway", "out"
};
void
save_and_forget_protocol_qualifiers ()
{
int i;
for (i = 0; i < N_PQ; i++)
saved_pq[i] = set_identifier (pq_strings[i], NULL_TREE);
ggc_add_tree_root (saved_pq, N_PQ);
ggc_add_tree_root (saved_not_pq, N_PQ);
}
void
forget_protocol_qualifiers ()
{
int i;
for (i = 0; i < N_PQ; i++)
{
set_identifier (pq_strings[i], saved_not_pq[i]);
saved_not_pq[i] = NULL_TREE;
}
}
void
remember_protocol_qualifiers ()
{
int i;
for (i = 0; i < N_PQ; i++)
saved_not_pq[i] = set_identifier (pq_strings[i], saved_pq[i]);
}
...@@ -49,21 +49,19 @@ const char digit_vector[] = { ...@@ -49,21 +49,19 @@ const char digit_vector[] = {
static struct obstack string_stack; static struct obstack string_stack;
/* This is the hash entry associated with each string. It lives in /* Each hashnode is just a pointer to a TREE_IDENTIFIER. */
the hash table; only the string lives in the obstack. Note that typedef struct tree_identifier *sp_hashnode;
the string is not necessarily NUL terminated. */
struct str_header #define SP_EMPTY(NODE) ((NODE) == NULL)
{ #define SP_LEN(NODE) ((NODE)->length)
const char *ptr; #define SP_TREE(NODE) ((tree) NODE)
tree data; /* for get_identifier */ #define SP_STR(NODE) ((NODE)->pointer)
unsigned int len; #define SP_VALID(NODE) (TREE_CODE (SP_TREE (NODE)) == IDENTIFIER_NODE)
};
/* This is the hash table structure. There's only one. */ /* This is the hash table structure. There's only one. */
struct str_hash struct str_hash
{ {
struct str_header *entries; sp_hashnode *entries;
size_t nslots; /* total slots in the entries array */ size_t nslots; /* total slots in the entries array */
size_t nelements; /* number of live elements */ size_t nelements; /* number of live elements */
...@@ -77,24 +75,17 @@ static struct str_hash string_hash = { 0, INITIAL_HASHSIZE, 0, 0, 0 }; ...@@ -77,24 +75,17 @@ static struct str_hash string_hash = { 0, INITIAL_HASHSIZE, 0, 0, 0 };
enum insert_option { INSERT, NO_INSERT }; enum insert_option { INSERT, NO_INSERT };
static struct str_header *alloc_string PARAMS ((const char *, size_t, static sp_hashnode alloc_ident PARAMS ((const char *, size_t,
enum insert_option)); enum insert_option));
static inline unsigned int calc_hash PARAMS ((const unsigned char *, size_t)); static inline unsigned int calc_hash PARAMS ((const unsigned char *, size_t));
static void mark_string_hash PARAMS ((void *)); static void mark_string_hash PARAMS ((void *));
static struct str_header *expand_string_table PARAMS ((struct str_header *)); static void expand_string_table PARAMS ((void));
/* Convenience macro for iterating over the hash table. E is set to /* Convenience macro for iterating over the hash table. E is set to
each live entry in turn. */ each live entry in turn. */
#define FORALL_STRINGS(E) \
for (E = string_hash.entries; E < string_hash.entries+string_hash.nslots; E++) \
if (E->ptr != NULL)
/* block here */
/* Likewise, but tests ->data instead of ->ptr (for cases where we only
care about entries with ->data set) */
#define FORALL_IDS(E) \ #define FORALL_IDS(E) \
for (E = string_hash.entries; E < string_hash.entries+string_hash.nslots; E++) \ for (E = string_hash.entries; E < string_hash.entries+string_hash.nslots; E++) \
if (E->data != NULL) if (!SP_EMPTY (*E) && SP_VALID (*E))
/* 0 while creating built-in identifiers. */ /* 0 while creating built-in identifiers. */
static int do_identifier_warnings; static int do_identifier_warnings;
...@@ -109,8 +100,8 @@ init_stringpool () ...@@ -109,8 +100,8 @@ init_stringpool ()
/* Strings need no alignment. */ /* Strings need no alignment. */
obstack_alignment_mask (&string_stack) = 0; obstack_alignment_mask (&string_stack) = 0;
string_hash.entries = (struct str_header *) string_hash.entries = (sp_hashnode *)
xcalloc (string_hash.nslots, sizeof (struct str_header)); xcalloc (string_hash.nslots, sizeof (sp_hashnode));
} }
/* Enable warnings on similar identifiers (if requested). /* Enable warnings on similar identifiers (if requested).
...@@ -150,13 +141,13 @@ calc_hash (str, len) ...@@ -150,13 +141,13 @@ calc_hash (str, len)
#undef HASHSTEP #undef HASHSTEP
} }
/* Internal primitive: returns the header structure for the string of /* Internal primitive: returns the header structure for the identifier
length LENGTH, containing CONTENTS. If that string already exists of length LENGTH, containing CONTENTS. If that identifier already
in the table, returns the existing entry. If the string hasn't exists in the table, returns the existing entry. If the identifier
been seen before and the last argument is INSERT, inserts and returns hasn't been seen before and the last argument is INSERT, inserts
a new entry. Otherwise returns NULL. */ and returns a new entry. Otherwise returns NULL. */
static struct str_header * static sp_hashnode
alloc_string (contents, length, insert) alloc_ident (contents, length, insert)
const char *contents; const char *contents;
size_t length; size_t length;
enum insert_option insert; enum insert_option insert;
...@@ -165,8 +156,7 @@ alloc_string (contents, length, insert) ...@@ -165,8 +156,7 @@ alloc_string (contents, length, insert)
unsigned int hash2; unsigned int hash2;
unsigned int index; unsigned int index;
size_t sizemask; size_t sizemask;
struct str_header *entry; sp_hashnode entry;
struct str_header *entries = string_hash.entries;
sizemask = string_hash.nslots - 1; sizemask = string_hash.nslots - 1;
index = hash & sizemask; index = hash & sizemask;
...@@ -178,13 +168,13 @@ alloc_string (contents, length, insert) ...@@ -178,13 +168,13 @@ alloc_string (contents, length, insert)
for (;;) for (;;)
{ {
entry = entries + index; entry = string_hash.entries[index];
if (entry->ptr == NULL) if (SP_EMPTY (entry))
break; break;
if (entry->len == length if ((size_t) SP_LEN (entry) == length
&& !memcmp (entry->ptr, contents, length)) && !memcmp (SP_STR (entry), contents, length))
return entry; return entry;
index = (index + hash2) & sizemask; index = (index + hash2) & sizemask;
...@@ -194,50 +184,47 @@ alloc_string (contents, length, insert) ...@@ -194,50 +184,47 @@ alloc_string (contents, length, insert)
if (insert == NO_INSERT) if (insert == NO_INSERT)
return NULL; return NULL;
obstack_grow0 (&string_stack, contents, length); entry = (sp_hashnode) make_node (IDENTIFIER_NODE);
entry->ptr = (const char *) obstack_finish (&string_stack); string_hash.entries[index] = entry;
entry->len = length; SP_STR (entry) = ggc_alloc_string (contents, length);
entry->data = NULL; SP_LEN (entry) = length;
/* This is not yet an identifier. */
TREE_SET_CODE (entry, ERROR_MARK);
if (++string_hash.nelements * 4 < string_hash.nslots * 3) if (++string_hash.nelements * 4 >= string_hash.nslots * 3)
return entry; /* Must expand the string table. */
expand_string_table ();
/* Must expand the string table. */ return entry;
return expand_string_table (entry);
} }
/* Subroutine of alloc_string which doubles the size of the hash table /* Subroutine of alloc_ident which doubles the size of the hash table
and rehashes all the strings into the new table. Returns the entry and rehashes all the strings into the new table. Returns the entry
in the new table corresponding to ENTRY. */ in the new table corresponding to ENTRY. */
static struct str_header * static void
expand_string_table (entry) expand_string_table ()
struct str_header *entry;
{ {
struct str_header *nentries; sp_hashnode *nentries;
struct str_header *e, *nentry = NULL; sp_hashnode *e;
size_t size, sizemask; size_t size, sizemask;
size = string_hash.nslots * 2; size = string_hash.nslots * 2;
nentries = (struct str_header *) xcalloc (size, sizeof (struct str_header)); nentries = (sp_hashnode *) xcalloc (size, sizeof (sp_hashnode));
sizemask = size - 1; sizemask = size - 1;
FORALL_STRINGS (e) FORALL_IDS (e)
{ {
unsigned int index, hash, hash2; unsigned int index, hash, hash2;
hash = calc_hash ((const unsigned char *) e->ptr, e->len); hash = calc_hash ((const unsigned char *) SP_STR (*e), SP_LEN (*e));
hash2 = ((hash * 17) & sizemask) | 1; hash2 = ((hash * 17) & sizemask) | 1;
index = hash & sizemask; index = hash & sizemask;
for (;;) for (;;)
{ {
if (nentries[index].ptr == NULL) if (SP_EMPTY (nentries[index]))
{ {
nentries[index].ptr = e->ptr; nentries[index] = *e;
nentries[index].len = e->len;
nentries[index].data = e->data;
if (e == entry)
nentry = nentries + index;
break; break;
} }
...@@ -248,7 +235,6 @@ expand_string_table (entry) ...@@ -248,7 +235,6 @@ expand_string_table (entry)
free (string_hash.entries); free (string_hash.entries);
string_hash.entries = nentries; string_hash.entries = nentries;
string_hash.nslots = size; string_hash.nslots = size;
return nentry;
} }
/* Allocate and return a string constant of length LENGTH, containing /* Allocate and return a string constant of length LENGTH, containing
...@@ -262,8 +248,6 @@ ggc_alloc_string (contents, length) ...@@ -262,8 +248,6 @@ ggc_alloc_string (contents, length)
const char *contents; const char *contents;
int length; int length;
{ {
struct str_header *str;
if (length == -1) if (length == -1)
length = strlen (contents); length = strlen (contents);
...@@ -272,8 +256,8 @@ ggc_alloc_string (contents, length) ...@@ -272,8 +256,8 @@ ggc_alloc_string (contents, length)
if (length == 1 && contents[0] >= '0' && contents[0] <= '9') if (length == 1 && contents[0] >= '0' && contents[0] <= '9')
return digit_string (contents[0] - '0'); return digit_string (contents[0] - '0');
str = alloc_string (contents, length, INSERT); obstack_grow0 (&string_stack, contents, length);
return str->ptr; return obstack_finish (&string_stack);
} }
/* Return an IDENTIFIER_NODE whose name is TEXT (a null-terminated string). /* Return an IDENTIFIER_NODE whose name is TEXT (a null-terminated string).
...@@ -283,43 +267,36 @@ tree ...@@ -283,43 +267,36 @@ tree
get_identifier (text) get_identifier (text)
const char *text; const char *text;
{ {
tree idp; sp_hashnode node;
struct str_header *str;
size_t length = strlen (text); size_t length = strlen (text);
str = alloc_string (text, length, INSERT); node = alloc_ident (text, length, INSERT);
idp = str->data; if (!SP_VALID (node))
if (idp == NULL)
{ {
if (TREE_CODE_LENGTH (IDENTIFIER_NODE) < 0)
abort (); /* set_identifier_size hasn't been called. */
/* If this identifier is longer than the clash-warning length, /* If this identifier is longer than the clash-warning length,
do a brute force search of the entire table for clashes. */ do a brute force search of the entire table for clashes. */
if (warn_id_clash && do_identifier_warnings && length >= (size_t) id_clash_len) if (warn_id_clash && do_identifier_warnings && length >= (size_t) id_clash_len)
{ {
struct str_header *e; sp_hashnode *e;
FORALL_IDS (e) FORALL_IDS (e)
{ {
if (e->len >= (size_t)id_clash_len if (SP_LEN (*e) >= id_clash_len
&& !strncmp (e->ptr, text, id_clash_len)) && !strncmp (SP_STR (*e), text, id_clash_len))
{ {
warning ("\"%s\" and \"%s\" identical in first %d characters", warning ("\"%s\" and \"%s\" identical in first %d characters",
text, e->ptr, id_clash_len); text, SP_STR (*e), id_clash_len);
break; break;
} }
} }
} }
idp = make_node (IDENTIFIER_NODE); TREE_SET_CODE (node, IDENTIFIER_NODE);
IDENTIFIER_LENGTH (idp) = length;
IDENTIFIER_POINTER (idp) = str->ptr;
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
id_string_size += length; id_string_size += length;
#endif #endif
str->data = idp;
} }
return idp;
return SP_TREE (node);
} }
/* If an identifier with the name TEXT (a null-terminated string) has /* If an identifier with the name TEXT (a null-terminated string) has
...@@ -330,33 +307,14 @@ tree ...@@ -330,33 +307,14 @@ tree
maybe_get_identifier (text) maybe_get_identifier (text)
const char *text; const char *text;
{ {
struct str_header *str; sp_hashnode node;
size_t length = strlen (text); size_t length = strlen (text);
str = alloc_string (text, length, NO_INSERT); node = alloc_ident (text, length, NO_INSERT);
if (str) if (!SP_EMPTY (node) && SP_VALID (node))
return str->data; /* N.B. str->data might be null here, if the return SP_TREE (node);
string has been used but not as an identifier. */
return NULL_TREE;
}
/* Look up an identifier with the name TEXT, replace its identifier return NULL_TREE;
node with NODE, and return the old identifier node. This is used
by languages which need to enable and disable keywords based on
context; e.g. see remember_protocol_qualifiers in objc/objc-act.c. */
tree
set_identifier (text, node)
const char *text;
tree node;
{
struct str_header *str;
tree old;
size_t length = strlen (text);
str = alloc_string (text, length, INSERT);
old = str->data; /* might be null */
str->data = node;
return old;
} }
/* Report some basic statistics about the string pool. */ /* Report some basic statistics about the string pool. */
...@@ -367,7 +325,7 @@ stringpool_statistics () ...@@ -367,7 +325,7 @@ stringpool_statistics ()
size_t nelts, nids, overhead, headers; size_t nelts, nids, overhead, headers;
size_t total_bytes, longest, sum_of_squares; size_t total_bytes, longest, sum_of_squares;
double exp_len, exp_len2, exp2_len; double exp_len, exp_len2, exp2_len;
struct str_header *e; sp_hashnode *e;
#define SCALE(x) ((unsigned long) ((x) < 1024*10 \ #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
? (x) \ ? (x) \
: ((x) < 1024*1024*10 \ : ((x) < 1024*1024*10 \
...@@ -376,21 +334,21 @@ stringpool_statistics () ...@@ -376,21 +334,21 @@ stringpool_statistics ()
#define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M')) #define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M'))
total_bytes = longest = sum_of_squares = nids = 0; total_bytes = longest = sum_of_squares = nids = 0;
FORALL_STRINGS (e) FORALL_IDS (e)
{ {
size_t n = e->len; size_t n = SP_LEN (*e);
total_bytes += n; total_bytes += n;
sum_of_squares += n*n; sum_of_squares += n*n;
if (n > longest) if (n > longest)
longest = n; longest = n;
if (e->data) if (SP_VALID (*e))
nids++; nids++;
} }
nelts = string_hash.nelements; nelts = string_hash.nelements;
overhead = obstack_memory_used (&string_stack) - total_bytes; overhead = obstack_memory_used (&string_stack) - total_bytes;
headers = string_hash.nslots * sizeof (struct str_header); headers = string_hash.nslots * sizeof (sp_hashnode);
fprintf (stderr, fprintf (stderr,
"\nString pool\n\ "\nString pool\n\
...@@ -429,10 +387,10 @@ static void ...@@ -429,10 +387,10 @@ static void
mark_string_hash (arg) mark_string_hash (arg)
void *arg ATTRIBUTE_UNUSED; void *arg ATTRIBUTE_UNUSED;
{ {
struct str_header *h; sp_hashnode *h;
FORALL_IDS (h) FORALL_IDS (h)
{ {
ggc_mark_tree (h->data); ggc_mark_tree (SP_TREE (*h));
} }
} }
...@@ -188,7 +188,7 @@ struct tree_common ...@@ -188,7 +188,7 @@ struct tree_common
TREE_OVERFLOW in TREE_OVERFLOW in
INTEGER_CST, REAL_CST, COMPLEX_CST INTEGER_CST, REAL_CST, COMPLEX_CST
TREE_PUBLIC in TREE_PUBLIC in
VAR_DECL or FUNCTION_DECL VAR_DECL or FUNCTION_DECL or IDENTIFIER_NODE
TREE_VIA_PUBLIC in TREE_VIA_PUBLIC in
TREE_LIST or TREE_VEC TREE_LIST or TREE_VEC
EXPR_WFL_EMIT_LINE_NOTE in EXPR_WFL_EMIT_LINE_NOTE in
...@@ -261,7 +261,8 @@ struct tree_common ...@@ -261,7 +261,8 @@ struct tree_common
bounded_flag: bounded_flag:
TREE_BOUNDED in TREE_BOUNDED in
expressions, VAR_DECL, PARM_DECL, FIELD_DECL, FUNCTION_DECL expressions, VAR_DECL, PARM_DECL, FIELD_DECL, FUNCTION_DECL,
IDENTIFIER_NODE
TYPE_BOUNDED in TYPE_BOUNDED in
..._TYPE ..._TYPE
*/ */
...@@ -517,7 +518,7 @@ extern void tree_class_check_failed PARAMS ((const tree, int, ...@@ -517,7 +518,7 @@ extern void tree_class_check_failed PARAMS ((const tree, int,
/* In a VAR_DECL or FUNCTION_DECL, /* In a VAR_DECL or FUNCTION_DECL,
nonzero means name is to be accessible from outside this module. nonzero means name is to be accessible from outside this module.
In an identifier node, nonzero means an external declaration In an IDENTIFIER_NODE, nonzero means an external declaration
accessible from outside this module was previously seen accessible from outside this module was previously seen
for this name in an inner scope. */ for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag) #define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
...@@ -1952,13 +1953,6 @@ extern tree get_identifier PARAMS ((const char *)); ...@@ -1952,13 +1953,6 @@ extern tree get_identifier PARAMS ((const char *));
extern tree maybe_get_identifier PARAMS ((const char *)); extern tree maybe_get_identifier PARAMS ((const char *));
/* Look up an identifier with the name TEXT, replace its identifier
node with NODE, and return the old identifier node. This is used
by languages which need to enable and disable keywords based on
context; e.g. see remember_protocol_qualifiers in objc/objc-act.c. */
extern tree set_identifier PARAMS ((const char *, tree));
/* Construct various types of nodes. */ /* Construct various types of nodes. */
#define build_int_2(LO,HI) \ #define build_int_2(LO,HI) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment