Jonathan Wakely 2b83bc6097 libstdc++: Optimize ref-count updates in COW std::string
Most ref-count updates in the COW string are done via the functions in
<ext/atomicity.h>, which will use non-atomic ops when the program is
known to be single-threaded. The _M_is_leaked() and _M_is_shared()
functions use __atomic_load_n directly, because <ext/atomicity.h>
doesn't provide a load operation. Those functions can check the
__is_single_threaded() predicate to avoid using __atomic_load_n when not
needed.

The move constructor for the fully-dynamic-string increments the
ref-count by either 2 or 1, for leaked or non-leaked strings
respectively. That can be changed to use a non-atomic store of 1 for all
non-shared strings. It can be non-atomic because even if the program is
multi-threaded, conflicting access to the rvalue object while it's being
moved from would be data race anyway. It can store 1 directly for all
non-shared strings because it doesn't matter whether the initial
refcount was -1 or 0, it should be 1 after the move constructor creates
a second owner.

libstdc++-v3/ChangeLog:

	* include/bits/cow_string.h (basic_string::_M_is_leaked): Use
	non-atomic load when __is_single_threaded() is true.
	(basic_string::_M_is_shared): Likewise.
	(basic_string::(basic_string&&)) [_GLIBCXX_FULLY_DYNAMIC_STRING]:
	Use non-atomic store when rvalue is not shared.
2021-12-01 15:00:33 +00:00
2021-10-27 00:16:33 +00:00
2021-12-01 00:17:04 +00:00
2021-11-25 00:16:29 +00:00
2021-11-24 00:16:29 +00:00
2021-10-23 00:16:26 +00:00
2021-09-22 00:16:28 +00:00
2021-11-13 00:16:39 +00:00
2021-11-30 00:16:44 +00:00
2021-10-23 00:16:26 +00:00
2021-11-13 00:16:39 +00:00
2021-08-18 00:16:48 +00:00
2021-11-02 00:16:32 +00:00
2021-10-23 00:16:26 +00:00
2021-11-16 00:16:31 +00:00
2021-12-01 00:17:04 +00:00
2021-10-19 00:16:23 +00:00
2021-12-01 00:17:04 +00:00
2021-11-30 00:16:44 +00:00
2021-11-27 00:16:19 +00:00
2021-10-20 00:16:43 +00:00
2021-12-01 00:17:04 +00:00
2021-11-29 00:16:16 +00:00
2021-09-14 00:16:23 +00:00
2021-12-01 00:17:04 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 3.1 GiB
Languages
C 48%
Ada 18.3%
C++ 14.1%
Go 7%
GCC Machine Description 4.6%
Other 7.7%