diff options
author | Trevor Saunders <tsaunders@mozilla.com> | 2014-11-20 15:10:11 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2014-11-20 15:10:11 +0000 |
commit | aebf76a2d6de989fe3e8c88aa047e4cfbd1e340e (patch) | |
tree | fa770de679e7f22bf1d98fb9ad84e84a0d60cfa0 /gcc/hash-table.h | |
parent | 77486f4480db2a2365e08a08c223655c7335aab4 (diff) | |
download | gcc-aebf76a2d6de989fe3e8c88aa047e4cfbd1e340e.zip gcc-aebf76a2d6de989fe3e8c88aa047e4cfbd1e340e.tar.gz gcc-aebf76a2d6de989fe3e8c88aa047e4cfbd1e340e.tar.bz2 |
implement a replacement for if_marked
gcc/ChangeLog:
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* doc/gty.texi: Document the new cache gty attribute.
* gengtype.c (finish_cache_funcs): New function.
(write_roots): Call gt_clear_cache on global variables with the cache
gty attribute.
* ggc-common.c (ggc_mark_roots): Call gt_clear_caches.
* ggc.h (gt_clear_caches): New declaration.
* hash-table.h (struct ggc_cache_hasher): New hasher for caches in gc
memory.
(gt_cleare_cache): New function.
* emit-rtl.c, rtl.h, tree.c: Use hash_table instead of htab.
From-SVN: r217866
Diffstat (limited to 'gcc/hash-table.h')
-rw-r--r-- | gcc/hash-table.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/hash-table.h b/gcc/hash-table.h index 2493f2e..a6f66c0 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -334,6 +334,44 @@ struct ggc_hasher } }; +/* Hasher for cache entry in gc memory. */ + +template<typename T> +struct ggc_cache_hasher +{ + typedef T value_type; + typedef T compare_type; + typedef int store_values_directly; + + static void remove (T &) {} + + /* Entries are weakly held because this is for caches. */ + + static void ggc_mx (T &) {} + + static void + pch_nx (T &p) + { + extern void gt_pch_nx (T &); + gt_pch_nx (p); + } + + static void + pch_nx (T &p, gt_pointer_operator op, void *cookie) + { + op (&p, cookie); + } + + /* Clear out entries if they are about to be gc'd. */ + + static void + handle_cache_entry (T &e) + { + if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY && !ggc_marked_p (e)) + e = static_cast<T> (HTAB_DELETED_ENTRY); + } +}; + /* Table of primes and their inversion information. */ @@ -1667,4 +1705,16 @@ gt_pch_nx (hash_table<D> *h, gt_pointer_operator op, void *cookie) op (&h->m_entries, cookie); } +template<typename H> +inline void +gt_cleare_cache (hash_table<H> *h) +{ + if (!h) + return; + + for (typename hash_table<H>::iterator iter = h->begin (); iter != h->end (); + ++iter) + H::handle_cache_entry (*iter); +} + #endif /* TYPED_HASHTAB_H */ |