From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84872 invoked by alias); 4 Sep 2017 08:08:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 80436 invoked by uid 89); 4 Sep 2017 08:08:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=bonafide X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Sep 2017 08:08:26 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 15FF982338; Mon, 4 Sep 2017 10:08:23 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rdz69oekBY3u; Mon, 4 Sep 2017 10:08:23 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id D30A782310; Mon, 4 Sep 2017 10:08:22 +0200 (CEST) From: Eric Botcazou To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [C++] Fix PR bootstrap/81926 Date: Mon, 04 Sep 2017 08:08:00 -0000 Message-ID: <1514184.0xIGq3mKY2@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) In-Reply-To: <8F5955E0-4B06-4668-9BCC-233E90F6F7A0@gmail.com> References: <4078981.6jQ9KEkrUD@polaris> <8F5955E0-4B06-4668-9BCC-233E90F6F7A0@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2188903.fJXSx1FBAZ" Content-Transfer-Encoding: 7Bit X-SW-Source: 2017-09/txt/msg00146.txt.bz2 This is a multi-part message in MIME format. --nextPart2188903.fJXSx1FBAZ Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 406 > A solution would be to put them into a global GCed pointer-map or vector, > freeing that at free-lang-data time. Here's a version that implements a bona-fide type->offset_type map. PR bootstrap/81926 * cp-objcp-common.c (struct offset_type_hasher): New class. (offset_type_hash): New variable. (cp_get_debug_type): Associate the OFFSET_TYPEs with the types. -- Eric Botcazou --nextPart2188903.fJXSx1FBAZ Content-Disposition: attachment; filename="pr81926-2.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="pr81926-2.diff" Content-length: 2188 Index: cp/cp-objcp-common.c =================================================================== --- cp/cp-objcp-common.c (revision 251538) +++ cp/cp-objcp-common.c (working copy) @@ -131,6 +131,20 @@ cxx_types_compatible_p (tree x, tree y) return same_type_ignoring_top_level_qualifiers_p (x, y); } +struct offset_type_hasher : ggc_cache_ptr_hash +{ + static hashval_t hash (tree_map *m) { return tree_map_hash (m); } + static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); } + + static int + keep_cache_entry (tree_map *&e) + { + return ggc_marked_p (e->base.from); + } +}; + +static GTY((cache)) hash_table *offset_type_hash; + /* Return a type to use in the debug info instead of TYPE, or NULL_TREE to keep TYPE. */ @@ -138,8 +152,35 @@ tree cp_get_debug_type (const_tree type) { if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type)) - return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type), - TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))); + { + if (offset_type_hash == NULL) + offset_type_hash = hash_table::create_ggc (512); + + /* We cannot simply use build_offset_type here because the function uses + the type canonicalization hashtable, which is GC-ed, so its behavior + depends on the actual collection points. Since we are building these + types on the fly for the debug info only, they would not be attached + to any GC root and always be swept, so we would make the contents of + the debug info depend on the collection points. */ + struct tree_map in, *h; + + in.base.from = CONST_CAST_TREE (type); + in.hash = htab_hash_pointer (type); + h = offset_type_hash->find_with_hash (&in, in.hash); + if (h) + return h->to; + + tree t = build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type), + TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))); + + h = ggc_alloc (); + h->base.from = CONST_CAST_TREE (type); + h->hash = htab_hash_pointer (type); + h->to = t; + *offset_type_hash->find_slot_with_hash (h, h->hash, INSERT) = h; + + return t; + } return NULL_TREE; } --nextPart2188903.fJXSx1FBAZ--