Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -758,6 +758,46 @@ #endif #endif +// When CHROMIUM_CXX_TWEAK_INLINES is defined, certain STL types will be tweaked +// to ensure that their constructor, or certain methods, are never inlined. This can +// surprisingly reduce the size of the Chrome binary by more than 3%, with little +// impact on performance. +// +// This is controlled by modifying some libc++ headers using the following macros: +// +// CHROMIUM_LIBCPP_INLINE_VISIBILITY: +// Replaces an _existing_ _LIBCPP_INLINE_VISIBILITY use on a target method. +// I.e. this indicates libc++ methods that were already possibly inlined, +// but that will never be when the tweak is active. +// +// Equivalent to _LIBCPP_INLINE_VISIBILITY if the tweak is disabled. +// +// CHROMIUM_LIBCPP_NEVER_INLINE: +// This is added to ensure that a target method, which was _not_ already +// tagged with _LIBCPP_INLINE_VISIBILITY, will never be inlined. +// +// This is equivalent to adding CHROMIUM_LIBCPP_INLINE_VISIBILITY, except +// that it helps spot the places where _LIBCPP_INLINE_VISIBILITY was not +// used in the original libc++ header. +// +// Empty if the tweak is disabled. +// +// CHROMIUM_LIBCPP_ALWAYS_INLINE: +// This is added to ensure that a target method, which is _not_ already +// tagged with _LIBCPP_INLINE_VISIBILITY, will always be inlined. +// +// Empty if the tweak is disabled. +// +#ifdef CHROMIUM_CXX_TWEAK_INLINES +#define CHROMIUM_LIBCPP_INLINE_VISIBILITY __attribute__ ((noinline)) +#define CHROMIUM_LIBCPP_ALWAYS_INLINE _LIBCPP_ALWAYS_INLINE +#define CHROMIUM_LIBCPP_NEVER_INLINE __attribute__ ((noinline)) +#else +#define CHROMIUM_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY +#define CHROMIUM_LIBCPP_ALWAYS_INLINE +#define CHROMIUM_LIBCPP_NEVER_INLINE +#endif + #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__)) Index: include/string =================================================================== --- include/string +++ include/string @@ -543,23 +543,28 @@ // basic_string template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y); template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); @@ -754,21 +759,24 @@ public: static const size_type npos = -1; - _LIBCPP_INLINE_VISIBILITY basic_string() + // Adding CHROMIUM defines to constructors and operator+ saved 300kb (Sept 2017). + // Made __init __always_inline__, and functions that call it (constructors and operator+) noinline. + // For more context: https://crbug.com/738155 + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) + CHROMIUM_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value); #else _NOEXCEPT; #endif - basic_string(const basic_string& __str); - basic_string(const basic_string& __str, const allocator_type& __a); + CHROMIUM_LIBCPP_NEVER_INLINE basic_string(const basic_string& __str); + CHROMIUM_LIBCPP_NEVER_INLINE basic_string(const basic_string& __str, const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value); @@ -776,23 +784,24 @@ _NOEXCEPT; #endif - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str, const allocator_type& __a); #endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s); + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, const _Allocator& __a); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, size_type __n); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, _CharT __c); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, _CharT __c, const _Allocator& __a); + CHROMIUM_LIBCPP_NEVER_INLINE basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator()); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator()); template @@ -800,20 +809,20 @@ basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type(), typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0); - _LIBCPP_INLINE_VISIBILITY explicit + CHROMIUM_LIBCPP_INLINE_VISIBILITY explicit basic_string(__self_view __sv); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(__self_view __sv, const _Allocator& __a); template - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(_InputIterator __first, _InputIterator __last); template - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(initializer_list<_CharT> __il); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string(initializer_list<_CharT> __il, const _Allocator& __a); #endif // _LIBCPP_CXX03_LANG @@ -827,13 +836,13 @@ #ifndef _LIBCPP_CXX03_LANG template #endif - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string& operator=(__self_view __sv) {return assign(__sv);} #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string& operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());} #endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} @@ -1094,13 +1103,13 @@ basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, __self_view __sv) { return replace(__i1 - begin(), __i2 - __i1, __sv); } _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); @@ -1143,67 +1152,77 @@ _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return __alloc();} - _LIBCPP_INLINE_VISIBILITY + // Adding CHROMIUM defines to find methods saved 20kb (Sept 2017). + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - size_type rfind(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; + CHROMIUM_LIBCPP_INLINE_VISIBILITY + size_type rfind(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - size_type find_last_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; + CHROMIUM_LIBCPP_INLINE_VISIBILITY + size_type find_last_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - size_type find_last_not_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; + CHROMIUM_LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; + CHROMIUM_LIBCPP_NEVER_INLINE size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + // Adding CHROMIUM defines to compare and operator== saved 100kb (Sept 2017). + CHROMIUM_LIBCPP_INLINE_VISIBILITY int compare(const basic_string& __str) const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY int compare(__self_view __sv) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, __self_view __sv) const; @@ -1220,6 +1239,7 @@ compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; int compare(const value_type* __s) const _NOEXCEPT; int compare(size_type __pos1, size_type __n1, const value_type* __s) const; + CHROMIUM_LIBCPP_NEVER_INLINE int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; #if _LIBCPP_STD_VER > 17 @@ -1367,11 +1387,11 @@ __align_it (__s+1)) - 1;} - inline + inline CHROMIUM_LIBCPP_NEVER_INLINE void __init(const value_type* __s, size_type __sz, size_type __reserve); - inline + inline CHROMIUM_LIBCPP_NEVER_INLINE void __init(const value_type* __s, size_type __sz); - inline + inline CHROMIUM_LIBCPP_NEVER_INLINE void __init(size_type __n, value_type __c); template @@ -1381,7 +1401,7 @@ __is_exactly_input_iterator<_InputIterator>::value, void >::type - __init(_InputIterator __first, _InputIterator __last); + CHROMIUM_LIBCPP_ALWAYS_INLINE __init(_InputIterator __first, _InputIterator __last); template inline @@ -1390,7 +1410,7 @@ __is_forward_iterator<_ForwardIterator>::value, void >::type - __init(_ForwardIterator __first, _ForwardIterator __last); + CHROMIUM_LIBCPP_ALWAYS_INLINE __init(_ForwardIterator __first, _ForwardIterator __last); void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add = 0); @@ -1522,7 +1542,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value) { @@ -1533,7 +1553,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value) @@ -1549,6 +1569,7 @@ } template +CHROMIUM_LIBCPP_ALWAYS_INLINE void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) @@ -1574,6 +1595,7 @@ } template +CHROMIUM_LIBCPP_ALWAYS_INLINE void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { @@ -1598,7 +1620,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); @@ -1609,7 +1631,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) : __r_(__second_tag(), __a) { @@ -1621,7 +1643,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); @@ -1632,7 +1654,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) : __r_(__second_tag(), __a) { @@ -1644,6 +1666,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { @@ -1657,6 +1680,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator>::basic_string( const basic_string& __str, const allocator_type& __a) : __r_(__second_tag(), __a) @@ -1673,7 +1697,7 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value) @@ -1691,7 +1715,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__second_tag(), __a) { @@ -1712,6 +1736,7 @@ #endif // _LIBCPP_CXX03_LANG template +CHROMIUM_LIBCPP_ALWAYS_INLINE void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { @@ -1736,7 +1761,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) { __init(__n, __c); @@ -1746,7 +1771,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) : __r_(__second_tag(), __a) { @@ -1757,6 +1782,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a) @@ -1772,7 +1798,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a) : __r_(__second_tag(), __a) @@ -1788,6 +1814,7 @@ template template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator>::basic_string( const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a, typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *) @@ -1801,7 +1828,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv) { __init(__sv.data(), __sv.size()); @@ -1811,7 +1838,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv, const _Allocator& __a) : __r_(__second_tag(), __a) { @@ -1823,6 +1850,7 @@ template template +CHROMIUM_LIBCPP_ALWAYS_INLINE typename enable_if < __is_exactly_input_iterator<_InputIterator>::value, @@ -1850,6 +1878,7 @@ template template +CHROMIUM_LIBCPP_ALWAYS_INLINE typename enable_if < __is_forward_iterator<_ForwardIterator>::value, @@ -1881,7 +1910,7 @@ template template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) { __init(__first, __last); @@ -1892,7 +1921,7 @@ template template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __r_(__second_tag(), __a) @@ -1906,7 +1935,7 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il) { @@ -1917,8 +1946,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY - +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il, const _Allocator& __a) : __r_(__second_tag(), __a) @@ -2046,6 +2074,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { @@ -2067,6 +2096,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) { @@ -2110,7 +2140,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) @@ -3104,6 +3134,7 @@ }; template +CHROMIUM_LIBCPP_NEVER_INLINE typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, @@ -3115,7 +3146,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3135,7 +3166,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT @@ -3157,6 +3188,7 @@ // rfind template +CHROMIUM_LIBCPP_NEVER_INLINE typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, @@ -3168,7 +3200,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3178,7 +3210,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(__self_view __sv, size_type __pos) const _NOEXCEPT @@ -3188,7 +3220,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT @@ -3210,6 +3242,7 @@ // find_first_of template +CHROMIUM_LIBCPP_NEVER_INLINE typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, @@ -3221,7 +3254,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3231,7 +3264,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(__self_view __sv, size_type __pos) const _NOEXCEPT @@ -3241,7 +3274,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT @@ -3263,6 +3296,7 @@ // find_last_of template +CHROMIUM_LIBCPP_NEVER_INLINE typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, @@ -3274,7 +3308,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3294,7 +3328,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT @@ -3316,6 +3350,7 @@ // find_first_not_of template +CHROMIUM_LIBCPP_NEVER_INLINE typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos, @@ -3327,7 +3362,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3347,7 +3382,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT @@ -3370,6 +3405,7 @@ // find_last_not_of template +CHROMIUM_LIBCPP_NEVER_INLINE typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos, @@ -3381,7 +3417,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3401,7 +3437,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT @@ -3424,7 +3460,7 @@ // compare template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(__self_view __sv) const _NOEXCEPT { @@ -3442,7 +3478,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { @@ -3494,6 +3530,7 @@ template template +CHROMIUM_LIBCPP_NEVER_INLINE typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, @@ -3510,6 +3547,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, @@ -3521,6 +3559,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE int basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { @@ -3529,6 +3568,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, @@ -3559,7 +3599,7 @@ // operator== template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3571,7 +3611,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string, _Allocator>& __lhs, const basic_string, _Allocator>& __rhs) _NOEXCEPT @@ -3590,7 +3630,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3603,7 +3643,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3761,6 +3801,7 @@ // operator + template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) @@ -3774,6 +3815,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) { @@ -3786,6 +3828,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) { @@ -3797,6 +3840,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { @@ -3809,6 +3853,7 @@ } template +CHROMIUM_LIBCPP_NEVER_INLINE basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { @@ -3822,7 +3867,7 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { @@ -3830,7 +3875,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3838,7 +3883,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3846,7 +3891,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) { Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -358,7 +358,9 @@ size_type capacity() const _NOEXCEPT {return static_cast(__end_cap() - __begin_);} - _LIBCPP_INLINE_VISIBILITY + // Saved 33kb (Sept 2017). + // For more context: https://crbug.com/738155 + CHROMIUM_LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -404,7 +406,7 @@ }; template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY void __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -685,13 +687,15 @@ } #endif - _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); + // push_back and emplace_back saved 270kb (Sept 2017). + // For more context: https://crbug.com/738155 + CHROMIUM_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); + CHROMIUM_LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); template - _LIBCPP_INLINE_VISIBILITY + CHROMIUM_LIBCPP_INLINE_VISIBILITY #if _LIBCPP_STD_VER > 14 reference emplace_back(_Args&&... __args); #else @@ -1583,7 +1587,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) { @@ -1602,7 +1606,7 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_INLINE_VISIBILITY +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) { @@ -1634,7 +1638,7 @@ template template -inline +inline CHROMIUM_LIBCPP_INLINE_VISIBILITY #if _LIBCPP_STD_VER > 14 typename vector<_Tp, _Allocator>::reference #else