@@ -1,3 +1,15 @@
+2012-02-01 Diego Novillo <dnovillo@google.com>
+
+ * config-lang.in (gtfiles): Remove pph-out.c. Add pph-core.c.
+ * pph-core.c: Include gt-cp-pph-core.h.
+ (pph_cached_trees): Declare.
+ (pph_cache_insert_at): If adding a tree to the cache, also
+ add it to pph_cached_trees.
+ (pph_streamer_init): Set pph_cached_trees to NULL.
+ (pph_streamer_finish): Likewise.
+ Call ggc_collect.
+ * pph-out.c (pph_decls_in_symtab): Remove. Update all users.
+
2012-02-01 Lawrence Crowl <crowl@google.com>
* pph-streamer.h (pph_trace_tree): Add name parameter. Adjust callers
@@ -30,4 +30,4 @@ compilers="cc1plus\$(exeext)"
target_libs="target-libstdc++-v3"
-gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.h \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/cp-lang.c \$(srcdir)/cp/except.c \$(srcdir)/cp/pph-out.c"
+gtfiles="\$(srcdir)/cp/rtti.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.h \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/cp-lang.c \$(srcdir)/cp/except.c \$(srcdir)/cp/pph-core.c"
@@ -90,6 +90,19 @@ struct pph_stream_registry_d {
static struct pph_stream_registry_d pph_stream_registry;
+/* List of all the trees added to PPH pickle caches.
+
+ FIXME pph, the *only* purpose of this list is to act as a GC root
+ to avoid these trees from being garbage collected.
+
+ The parser will invoke garbage collection, which may clobber some
+ trees in the pickle caches (because the pickle caches are stored on
+ the heap). Ideally, we would put all these data structures on GC
+ memory. */
+static GTY(()) VEC(tree,gc) *pph_cached_trees;
+
+
+
/*************************************************************** pph logging */
@@ -540,6 +553,11 @@ pph_cache_insert_at (pph_cache *cache, void *data, unsigned ix,
VEC_safe_grow_cleared (pph_cache_entry, heap, cache->v, ix + 1);
VEC_replace (pph_cache_entry, cache->v, ix, &e);
+ /* FIXME pph. Hack to prevent cached trees from being garbage
+ collected. */
+ if ((unsigned) tag <= (unsigned) PPH_any_tree)
+ VEC_safe_push (tree, gc, pph_cached_trees, (tree) data);
+
return pph_cache_get_entry (cache, ix);
}
@@ -1337,6 +1355,7 @@ pph_streamer_init (void)
{
pph_hooks_init ();
pph_init_preloaded_cache ();
+ pph_cached_trees = NULL;
}
@@ -1433,6 +1452,10 @@ pph_streamer_finish (void)
VEC_free (pph_stream_ptr, heap, pph_stream_registry.v);
pointer_map_destroy (pph_stream_registry.image_ix);
htab_delete (pph_stream_registry.name_ix);
+
+ /* Get rid of all the dead trees we may have had in caches. */
+ pph_cached_trees = NULL;
+ ggc_collect ();
}
@@ -1455,3 +1478,5 @@ pph_finish (void)
if (flag_pph_logfile)
fclose (pph_logfile);
}
+
+#include "gt-cp-pph-core.h"
@@ -54,19 +54,6 @@ static void pph_out_merge_key_tree (pph_stream *, tree);
static pph_stream *pph_out_stream = NULL;
-/* List of all the symbols added to the PPH symbol table.
-
- FIXME pph, the *only* purpose of this list is to act as a GC root
- to avoid these DECLs from being garbage collected.
-
- The parser will invoke garbage collection, which may clobber some
- DECLs in the symbol table (because the symbol table is stored on
- the heap). Ideally, we would notice when DECLs go unused, but for
- now this will just keep these DECLs around until we finalize PPH
- processing. */
-static GTY(()) VEC(tree,gc) *pph_decls_in_symtab;
-
-
/* Return the stream we are currently generating. We declare this function
with external linkage so it can be accessed from pph_include_handler,
but this really should be private to this file. */
@@ -109,7 +96,6 @@ pph_writer_init (void)
pph_out_stream = pph_stream_open (pph_out_file, "wb");
if (pph_out_stream == NULL)
fatal_error ("Cannot open PPH file %s for writing: %m", pph_out_file);
- pph_decls_in_symtab = NULL;
}
@@ -2551,7 +2537,6 @@ pph_add_decl_to_symtab (tree decl, enum pph_symtab_action action,
entry.top_level = top_level;
entry.at_end = at_end;
VEC_safe_push (pph_symtab_entry, heap, pph_out_stream->symtab.v, &entry);
- VEC_safe_push (tree, gc, pph_decls_in_symtab, decl);
}
@@ -2838,11 +2823,6 @@ pph_writer_finish (void)
pph_stream_close (pph_out_stream);
pph_out_stream = NULL;
-
- /* Get rid of all the dead DECLs we may have had in the symbol
- table. */
- pph_decls_in_symtab = NULL;
- ggc_collect ();
}
@@ -2871,5 +2851,3 @@ pph_disable_output (void)
of disabling PPH generation we may want to simply abort compilation. */
pph_disable_reader ();
}
-
-#include "gt-cp-pph-out.h"