diff options
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 781518b..d17f31d 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; } |