public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5753] libstdc++: Restore unconditional atomic load in COW std::string
@ 2021-12-02 16:53 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-12-02 16:53 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:b5a568683f71b4a8b1e4e45a43484398e9a66ff2

commit r12-5753-gb5a568683f71b4a8b1e4e45a43484398e9a66ff2
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Dec 1 20:58:58 2021 +0000

    libstdc++: Restore unconditional atomic load in COW std::string
    
    The relaxed load is already optimal, checking the __single_threaded
    global before doing a non-atomic load isn't an optimization.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/cow_string.h (basic_string::_M_is_leaked()):
            Revert change to check __is_single_threaded() before using
            atomic load.

Diff:
---
 libstdc++-v3/include/bits/cow_string.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h
index d6ddf3489d1..389b39583e4 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -207,10 +207,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  // so we need to use an atomic load. However, _M_is_leaked
 	  // predicate does not change concurrently (i.e. the string is either
 	  // leaked or not), so a relaxed load is enough.
-	  if (!__gnu_cxx::__is_single_threaded())
-	    return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
-#endif
+	  return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
+#else
 	  return this->_M_refcount < 0;
+#endif
 	}
 
 	bool


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-02 16:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 16:53 [gcc r12-5753] libstdc++: Restore unconditional atomic load in COW std::string Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).