From patchwork Thu Feb 2 02:56:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 139063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 44EE5104785 for ; Thu, 2 Feb 2012 13:56:55 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328756215; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=squ+eRw pFHKM1HiLOmQUl6C2ItA=; b=ZhhGlo6E24ggSu2AYh1sIjQ28wVXrP7sxa90pQS T4OWODqzd13t5ftB9pB0qb9azi0mN3k0G5MhXQXvz4AqxspOVGGPzyf0TX1KkFLD q/qpNBRghPvQ7IPi7f1ELERGXBok8/ZS7CfhLLVN07W8kuBvCzFYEMBYjnW/+9SJ WXgo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=omt4AegwXbNMRNYi1H2SXdea/0KSkCRMYij0N8/I1He/eQwzwAOZvEoePCVyqi /OP0axT4VNWzLuL+UZo24LEXjbmTlpw5gRpugLDD4CeDJRici7wXA7Zz2O1+j+bp MiS6Q08MP1Mn5VgJrW+fuE2IxzYwspgg0lgZneX6kjnZE=; Received: (qmail 16056 invoked by alias); 2 Feb 2012 02:56:51 -0000 Received: (qmail 16043 invoked by uid 22791); 2 Feb 2012 02:56:50 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, TW_BJ, TW_JC, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ww0-f73.google.com (HELO mail-ww0-f73.google.com) (74.125.82.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Feb 2012 02:56:36 +0000 Received: by wgbdr11 with SMTP id dr11so64325wgb.2 for ; Wed, 01 Feb 2012 18:56:35 -0800 (PST) Received: by 10.213.3.136 with SMTP id 8mr122275ebn.11.1328151394935; Wed, 01 Feb 2012 18:56:34 -0800 (PST) Received: by 10.213.3.136 with SMTP id 8mr122262ebn.11.1328151394646; Wed, 01 Feb 2012 18:56:34 -0800 (PST) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id x18si702378eex.1.2012.02.01.18.56.34 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 01 Feb 2012 18:56:34 -0800 (PST) Received: from tobiano.tor.corp.google.com (tobiano.tor.corp.google.com [172.29.41.6]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 4F8905C0050; Wed, 1 Feb 2012 18:56:34 -0800 (PST) Received: by tobiano.tor.corp.google.com (Postfix, from userid 54752) id 258E2AE1D7; Wed, 1 Feb 2012 21:56:33 -0500 (EST) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] More GC fixes (issue5606049) Message-Id: <20120202025633.258E2AE1D7@tobiano.tor.corp.google.com> Date: Wed, 1 Feb 2012 21:56:32 -0500 (EST) From: dnovillo@google.com (Diego Novillo) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch extends the hack I added in http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01031.html to pacify the garbage collector. I have to keep using the same fake GC root because these trees are added to structures that I can't seem to get properly annotated for GC. In particular, I'm having trouble with 'FILE' pointers. I will try to figure this out at some point, but we've got bigger issues to address at the moment. The specific problem this time was that bitsizetype was being GC'd out while we were reading a PPH image. This was causing ICEs when we were trying to read many PPH images. 2012-02-01 Diego Novillo * 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. --- gcc/cp/ChangeLog.pph | 12 ++++++++++++ gcc/cp/config-lang.in | 2 +- gcc/cp/pph-core.c | 25 +++++++++++++++++++++++++ gcc/cp/pph-out.c | 22 ---------------------- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index 8e8080d..ec80b56 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,3 +1,15 @@ +2012-02-01 Diego Novillo + + * 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 * pph-streamer.h (pph_trace_tree): Add name parameter. Adjust callers diff --git a/gcc/cp/config-lang.in b/gcc/cp/config-lang.in index ab8e686..7dbfe95 100644 --- a/gcc/cp/config-lang.in +++ b/gcc/cp/config-lang.in @@ -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" diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index d20d45b..814060f 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/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" diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index 4fb1f7c..203b111 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -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"