@@ -1,3 +1,14 @@
+2012-01-20 Diego Novillo <dnovillo@google.com>
+
+ * config-lang.in (gtfiles): Remove pph.h and pph-core.c.
+ Add pph-out.c
+ * pph-out.c: Include gt-cp-pph-out.h.
+ (pph_decls_in_symtab): Declare.
+ (pph_writer_init): Initialize.
+ (pph_add_decl_to_symtab): Add DECL to pph_decls_in_symtab.
+ (pph_writer_finish): Set pph_decls_in_symtab and call
+ ggc_collect.
+
2012-01-20 Lawrence Crowl <crowl@google.com>
* parser.c (cp_debug_parser_where): Protect against null pointers.
@@ -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/pph.h \$(srcdir)/cp/pph-core.c \$(srcdir)/cp/except.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-out.c"
@@ -52,6 +52,19 @@ 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;
+
+
/* Initialize buffers and tables in STREAM for writing. */
void
@@ -81,6 +94,7 @@ 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;
}
@@ -2503,6 +2517,7 @@ 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);
}
@@ -2787,6 +2802,11 @@ 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 ();
}
@@ -2814,3 +2834,5 @@ pph_disable_output (void)
pph_stream_close_no_flush (pph_out_stream);
pph_out_file = NULL;
}
+
+#include "gt-cp-pph-out.h"