From patchwork Fri Oct 3 15:24:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 396273 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 750E614016A for ; Sat, 4 Oct 2014 01:24:40 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=gjlAb9HJ4y81zOUDI IwAc57FZM+0GR/90i2K2pei2nbQzKV07Kioq0d4oQKOQhZu2WUT8Lj0ZKm5bJ2Sp bDIOaQvmVpRGlSFw9XZBPQigCeFbbeOY73oKKfZptPhzVnIc5KNAnwUO1LXiQuIo zu0A3WCXXv7Uv0+0Lq0/gGoTJk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=nTzJof6jQWX0VyKji9eOV9H gYsE=; b=ImDTW7kqitn9e1wQSO9u/nUZLjlrO25AEAQasi8XUwXUWWuJnrBIwsD xqRghHSRTGifQZarUnwZJXzSrhklcM/xA44rH7QKfgVRCgFZ3QJJwdEL+DmeADU4 cZuUIBBXVaUHQMKSk4XwTr7gkkGPKf5DxYsqqg1WTGcwvNYQxflM= Received: (qmail 14651 invoked by alias); 3 Oct 2014 15:24:33 -0000 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 Received: (qmail 14626 invoked by uid 89); 3 Oct 2014 15:24:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 03 Oct 2014 15:24:30 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s93FOSpO011837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Oct 2014 11:24:28 -0400 Received: from localhost (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s93FOR6Y020929; Fri, 3 Oct 2014 11:24:27 -0400 Date: Fri, 3 Oct 2014 16:24:26 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Subject: Re: [patch] Use abi_tag attribute on std::list Message-ID: <20141003152426.GI4197@redhat.com> References: <20141003130447.GD4197@redhat.com> <20141003144955.GH4197@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141003144955.GH4197@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) On 03/10/14 15:49 +0100, Jonathan Wakely wrote: >On 03/10/14 16:25 +0200, Marc Glisse wrote: >>Do you mind if I move (in a future patch once yours is committed) >>_M_size into _M_impl::_M_node as suggested in PR 61347? > >Gah, that's where I had it until earlier this week, and I looked at it >and wondered why it was in the _List_impl class (because you only need >one member in there to benefit from the empty base-class >optimisation). > >I will move it back there, since I already have that code on another >branch, so there's no point making you change the code to match >something I've already got! Marc, this is the relative diff to go back to what I had earlier, with the size in the _List_impl in case you want to aply it locally (the dg-error tests are off-by-one with this patch) diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 3a56daf..4dbdaf0 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -333,6 +333,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER : public _Node_alloc_type { __detail::_List_node_base _M_node; +#if _GLIBCXX_USE_CXX11_ABI + size_t _M_size; + + // return the stored size + size_t _M_node_count() const { return _M_size; } +#else + // count the number of nodes + size_t _M_node_count() const + { return _S_distance(_M_node._M_next, std::__addressof(_M_node)); } +#endif + _List_impl() : _Node_alloc_type(), _M_node() { } @@ -350,24 +361,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _List_impl _M_impl; -#if _GLIBCXX_USE_CXX11_ABI - size_t _M_size; + _List_node<_Tp>* + _M_get_node() + { return _M_impl._Node_alloc_type::allocate(1); } + + void + _M_put_node(_List_node<_Tp>* __p) _GLIBCXX_NOEXCEPT + { _M_impl._Node_alloc_type::deallocate(__p, 1); } - size_t _M_get_size() const { return _M_size; } +#if _GLIBCXX_USE_CXX11_ABI + size_t _M_get_size() const { return _M_impl._M_size; } - void _M_set_size(size_t __n) { _M_size = __n; } + void _M_set_size(size_t __n) { _M_impl._M_size = __n; } - void _M_inc_size(size_t __n) { _M_size += __n; } + void _M_inc_size(size_t __n) { _M_impl._M_size += __n; } - void _M_dec_size(size_t __n) { _M_size -= __n; } + void _M_dec_size(size_t __n) { _M_impl._M_size -= __n; } size_t _M_distance(const __detail::_List_node_base* __first, const __detail::_List_node_base* __last) const { return _S_distance(__first, __last); } - - // return the stored size - size_t _M_node_count() const { return _M_size; } #else // dummy implementations used when the size is not stored size_t _M_get_size() const { return 0; } @@ -375,23 +389,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void _M_inc_size(size_t) { } void _M_dec_size(size_t) { } size_t _M_distance(const void*, const void*) const { return 0; } - - // count the number of nodes - size_t _M_node_count() const - { - return _S_distance(_M_impl._M_node._M_next, - std::__addressof(_M_impl._M_node)); - } #endif - _List_node<_Tp>* - _M_get_node() - { return _M_impl._Node_alloc_type::allocate(1); } - - void - _M_put_node(_List_node<_Tp>* __p) _GLIBCXX_NOEXCEPT - { _M_impl._Node_alloc_type::deallocate(__p, 1); } - public: typedef _Alloc allocator_type; @@ -941,7 +940,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** Returns the number of elements in the %list. */ size_type size() const _GLIBCXX_NOEXCEPT - { return this->_M_node_count(); } + { return this->_M_impl._M_node_count(); } /** Returns the size() of the largest possible %list. */ size_type