Skip to content

Commit 4748b49

Browse files
authored
[libc++] Mark a few functions in the dylib as noexcept (#94098)
This avoids generating landing pads in some of the `atomic` functions that will never be used, since these functions never throw exceptions.
1 parent 7e5bc71 commit 4748b49

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

libcxx/include/__atomic/atomic_sync.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,21 @@ struct __atomic_wait_poll_impl {
7171

7272
#ifndef _LIBCPP_HAS_NO_THREADS
7373

74-
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
75-
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*);
76-
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile*);
77-
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile*, __cxx_contention_t);
74+
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT;
75+
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
76+
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
77+
__libcpp_atomic_monitor(void const volatile*) _NOEXCEPT;
78+
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
79+
__libcpp_atomic_wait(void const volatile*, __cxx_contention_t) _NOEXCEPT;
7880

7981
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
80-
__cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*);
82+
__cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
8183
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
82-
__cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*);
84+
__cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
8385
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
84-
__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*);
86+
__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
8587
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
86-
__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t);
88+
__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t) _NOEXCEPT;
8789

8890
template <class _AtomicWaitable, class _Poll>
8991
struct __atomic_wait_backoff_impl {

libcxx/include/barrier

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base*
102102
__construct_barrier_algorithm_base(ptrdiff_t& __expected);
103103

104104
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI bool
105-
__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase);
105+
__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept;
106106

107107
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
108-
__destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
108+
__destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept;
109109

110110
template <class _CompletionF>
111111
class __barrier_base {

libcxx/src/atomic.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,37 +169,38 @@ static void __libcpp_atomic_notify(void const volatile* __location) {
169169
&__entry->__platform_state,
170170
false /* when laundering, we can't handle notify_one */);
171171
}
172-
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) {
172+
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) noexcept {
173173
__libcpp_atomic_notify(__location);
174174
}
175-
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) {
175+
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) noexcept {
176176
__libcpp_atomic_notify(__location);
177177
}
178-
_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) {
178+
_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) noexcept {
179179
auto const __entry = __libcpp_contention_state(__location);
180180
return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state);
181181
}
182-
_LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) {
182+
_LIBCPP_EXPORTED_FROM_ABI void
183+
__libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) noexcept {
183184
auto const __entry = __libcpp_contention_state(__location);
184185
__libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value);
185186
}
186187

187188
/* When the incoming atomic happens to be the platform wait size, we still need to use the
188189
table for the contention detection, but we can use the atomic directly for the wait. */
189190

190-
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) {
191+
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) noexcept {
191192
__libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true);
192193
}
193-
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) {
194+
_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) noexcept {
194195
__libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false);
195196
}
196197
// This function is never used, but still exported for ABI compatibility.
197198
_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
198-
__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) {
199+
__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) noexcept {
199200
return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location);
200201
}
201202
_LIBCPP_EXPORTED_FROM_ABI void
202-
__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) {
203+
__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) noexcept {
203204
__libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value);
204205
}
205206

libcxx/src/barrier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorith
6363
return new __barrier_algorithm_base(__expected);
6464
}
6565
_LIBCPP_EXPORTED_FROM_ABI bool
66-
__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) {
66+
__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept {
6767
return __barrier->__arrive(__old_phase);
6868
}
69-
_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) {
69+
_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept {
7070
delete __barrier;
7171
}
7272

0 commit comments

Comments
 (0)