diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-30 00:49:06 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-30 00:49:06 +0000 |
commit | 8ed01400ddf7575d1965862fd356aa32b8efae47 (patch) | |
tree | 53fb5889181940508762ddb472618440e4b6aca6 /gcc/stringpool.c | |
parent | 58ca5c8a1611ba8db9c317bc7b2239aa22d5c79d (diff) | |
download | gcc-8ed01400ddf7575d1965862fd356aa32b8efae47.tar.gz |
Index: libcpp/ChangeLog
2004-05-29 Geoffrey Keating <geoffk@apple.com>
* symtab.c (ht_create): Set entries_owned.
(ht_destroy): Honour entries_owned.
(ht_expand): Likewise.
(ht_load): New.
Index: libcpp/include/ChangeLog
2004-05-29 Geoffrey Keating <geoffk@apple.com>
* symtab.h (struct ht): New field 'entries_owned'
(ht_load): New prototype.
Index: gcc/ChangeLog
2004-05-29 Geoffrey Keating <geoffk@apple.com>
* gengtype-yacc.y: Add NESTED_PTR token.
(option): Record `nested_ptr' option.
* gengtype-lex.l: Handle `nested_ptr' keyword.
* gengtype.c (walk_type): Process `nested_ptr' option.
* gengtype.h (struct nested_ptr_data): New.
* doc/gty.texi (GTY Options): Document `nested_ptr' option.
* stringpool.c (struct string_pool_data): Make 'entries' point to
ht_identifier instead of tree.
(gt_pch_save_stringpool): Don't adjust pointers.
(gt_pch_restore_stringpool): Call ht_load.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82438 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stringpool.c')
-rw-r--r-- | gcc/stringpool.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/gcc/stringpool.c b/gcc/stringpool.c index 781518b9f7d..d17f31decdd 100644 --- a/gcc/stringpool.c +++ b/gcc/stringpool.c @@ -1,5 +1,5 @@ /* String pool for GCC. - Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GCC. @@ -201,7 +201,11 @@ gt_pch_n_S (const void *x) struct string_pool_data GTY(()) { - tree * GTY((length ("%h.nslots"))) entries; + struct ht_identifier * * + GTY((length ("%h.nslots"), + nested_ptr (union tree_node, "%h ? GCC_IDENT_TO_HT_IDENT (%h) : NULL", + "%h ? HT_IDENT_TO_GCC_IDENT (%h) : NULL"))) + entries; unsigned int nslots; unsigned int nelements; }; @@ -237,25 +241,20 @@ ht_copy_and_clear (cpp_reader *r ATTRIBUTE_UNUSED, hashnode hp, const void *ht2_ static struct ht *saved_ident_hash; -/* The hash table contains pointers to the cpp_hashnode inside the - lang_identifier. The PCH machinery can't handle pointers that refer - to the inside of an object, so to save the hash table for PCH the - pointers are adjusted and stored in the variable SPD. */ +/* Prepare the stringpool to be written (by clearing all the cpp parts + of each entry) and place the data to be saved in SPD. Save the + current state in SAVED_IDENT_HASH so that gt_pch_fixup_stringpool + can restore it. */ void gt_pch_save_stringpool (void) { - unsigned int i; - spd = ggc_alloc (sizeof (*spd)); spd->nslots = ident_hash->nslots; spd->nelements = ident_hash->nelements; - spd->entries = ggc_alloc (sizeof (tree *) * spd->nslots); - for (i = 0; i < spd->nslots; i++) - if (ident_hash->entries[i] != NULL) - spd->entries[i] = HT_IDENT_TO_GCC_IDENT (ident_hash->entries[i]); - else - spd->entries[i] = NULL; + spd->entries = ggc_alloc (sizeof (spd->entries[0]) * spd->nslots); + memcpy (spd->entries, ident_hash->entries, + spd->nslots * sizeof (spd->entries[0])); saved_ident_hash = ht_create (14); saved_ident_hash->alloc_node = alloc_node; @@ -274,23 +273,12 @@ gt_pch_fixup_stringpool (void) } /* A PCH file has been restored, which loaded SPD; fill the real hash table - with adjusted pointers from SPD. */ + from SPD. */ void gt_pch_restore_stringpool (void) { - unsigned int i; - - ident_hash->nslots = spd->nslots; - ident_hash->nelements = spd->nelements; - ident_hash->entries = xrealloc (ident_hash->entries, - sizeof (hashnode) * spd->nslots); - for (i = 0; i < spd->nslots; i++) - if (spd->entries[i] != NULL) - ident_hash->entries[i] = GCC_IDENT_TO_HT_IDENT (spd->entries[i]); - else - ident_hash->entries[i] = NULL; - + ht_load (ident_hash, spd->entries, spd->nslots, spd->nelements, false); spd = NULL; } |