Skip to content

Commit 51e91b6

Browse files
authored
[libc++abi] Implement __cxa_init_primary_exception and use it to optimize std::make_exception_ptr (#65534)
This patch implements __cxa_init_primary_exception, an extension to the Itanium C++ ABI. This extension is already present in both libsupc++ and libcxxrt. This patch also starts making use of this function in std::make_exception_ptr: instead of going through a full throw/catch cycle, we are now able to initialize an exception directly, thus making std::make_exception_ptr around 30x faster.
1 parent 6ba62f4 commit 51e91b6

28 files changed

+171
-34
lines changed

libcxx/benchmarks/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ set(BENCHMARK_TESTS
202202
allocation.bench.cpp
203203
deque.bench.cpp
204204
deque_iterator.bench.cpp
205+
exception_ptr.bench.cpp
205206
filesystem.bench.cpp
206207
format_to_n.bench.cpp
207208
format_to.bench.cpp
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include <benchmark/benchmark.h>
10+
#include <exception>
11+
12+
void bm_make_exception_ptr(benchmark::State& state) {
13+
for (auto _ : state) {
14+
benchmark::DoNotOptimize(std::make_exception_ptr(42));
15+
}
16+
}
17+
BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8);
18+
19+
BENCHMARK_MAIN();

libcxx/docs/BuildingLibcxx.rst

+3
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ We can now run CMake:
563563
$ cmake -G Ninja -S runtimes -B build \
564564
-DLLVM_ENABLE_RUNTIMES="libcxx" \
565565
-DLIBCXX_CXX_ABI=libstdc++ \
566+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
566567
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/"
567568
$ ninja -C build install-cxx
568569
@@ -589,6 +590,8 @@ We can now run CMake like:
589590
$ cmake -G Ninja -S runtimes -B build \
590591
-DLLVM_ENABLE_RUNTIMES="libcxx" \
591592
-DLIBCXX_CXX_ABI=libcxxrt \
593+
-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON \
594+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
592595
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src
593596
$ ninja -C build install-cxx
594597

libcxx/include/__availability

+22-3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
# define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST 1
102102
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
103103

104+
// These macros controls the availability of __cxa_init_primary_exception
105+
// in the built library, which std::make_exception_ptr might use
106+
// (see libcxx/include/__exception/exception_ptr.h).
107+
# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1
108+
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
109+
104110
// These macros control the availability of all parts of <filesystem> that
105111
// depend on something in the dylib.
106112
# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1
@@ -136,9 +142,9 @@
136142
# define _LIBCPP_AVAILABILITY_HAS_TZDB 1
137143
# define _LIBCPP_AVAILABILITY_TZDB
138144

139-
// This controls the availability of C++23 <print>, which
140-
// has a dependency on the built library (it needs access to
141-
// the underlying buffer types of std::cout, std::cerr, and std::clog.
145+
// This controls the availability of C++23 <print>, which
146+
// has a dependency on the built library (it needs access to
147+
// the underlying buffer types of std::cout, std::cerr, and std::clog.
142148
# define _LIBCPP_AVAILABILITY_HAS_PRINT 1
143149
# define _LIBCPP_AVAILABILITY_PRINT
144150

@@ -167,6 +173,10 @@
167173
# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
168174
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
169175

176+
// TODO: Update once this is released
177+
# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
178+
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION __attribute__((unavailable))
179+
170180
// <filesystem>
171181
// clang-format off
172182
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
@@ -303,4 +313,13 @@
303313
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
304314
#endif
305315

316+
// Define availability attributes that depend on both
317+
// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI.
318+
#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI)
319+
# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
320+
# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
321+
# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
322+
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
323+
#endif
324+
306325
#endif // _LIBCPP___AVAILABILITY

libcxx/include/__exception/exception_ptr.h

+50
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,56 @@
99
#ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1010
#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1111

12+
#include <__availability>
1213
#include <__config>
1314
#include <__exception/operations.h>
1415
#include <__memory/addressof.h>
16+
#include <__memory/construct_at.h>
17+
#include <__type_traits/decay.h>
1518
#include <cstddef>
1619
#include <cstdlib>
20+
#include <new>
21+
#include <typeinfo>
1722

1823
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1924
# pragma GCC system_header
2025
#endif
2126

27+
#ifndef _LIBCPP_ABI_MICROSOFT
28+
29+
namespace __cxxabiv1 {
30+
31+
extern "C" {
32+
_LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(size_t) throw();
33+
_LIBCPP_OVERRIDABLE_FUNC_VIS void __cxa_free_exception(void*) throw();
34+
35+
struct __cxa_exception;
36+
_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
37+
void*,
38+
std::type_info*,
39+
void(
40+
# if defined(_WIN32)
41+
__thiscall
42+
# endif
43+
*)(void*)) throw();
44+
}
45+
46+
} // namespace __cxxabiv1
47+
48+
#endif
49+
2250
namespace std { // purposefully not using versioning namespace
2351

2452
#ifndef _LIBCPP_ABI_MICROSOFT
2553

2654
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
2755
void* __ptr_;
2856

57+
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
58+
59+
template <class _Ep>
60+
friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
61+
2962
public:
3063
_LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
3164
_LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
@@ -51,11 +84,28 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
5184
template <class _Ep>
5285
_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
5386
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
87+
# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L
88+
using _Ep2 = __decay_t<_Ep>;
89+
90+
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
91+
(void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {
92+
std::__destroy_at(static_cast<_Ep2*>(__p));
93+
});
94+
95+
try {
96+
::new (__ex) _Ep2(__e);
97+
return exception_ptr::__from_native_exception_pointer(__ex);
98+
} catch (...) {
99+
__cxxabiv1::__cxa_free_exception(__ex);
100+
return current_exception();
101+
}
102+
# else
54103
try {
55104
throw __e;
56105
} catch (...) {
57106
return current_exception();
58107
}
108+
# endif
59109
# else
60110
((void)__e);
61111
std::abort();

libcxx/include/new

-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ _LIBCPP_END_NAMESPACE_STD
362362

363363
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
364364
# include <cstdlib>
365-
# include <exception>
366365
# include <type_traits>
367366
#endif
368367

libcxx/include/typeinfo

-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ _LIBCPP_END_NAMESPACE_STD
372372

373373
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
374374
# include <cstdlib>
375-
# include <exception>
376375
# include <type_traits>
377376
#endif
378377

libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist

+3
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
{'is_defined': False, 'name': '___cxa_guard_acquire', 'type': 'U'}
301301
{'is_defined': False, 'name': '___cxa_guard_release', 'type': 'U'}
302302
{'is_defined': False, 'name': '___cxa_increment_exception_refcount', 'type': 'U'}
303+
{'is_defined': False, 'name': '___cxa_init_primary_exception', 'type': 'U'}
303304
{'is_defined': False, 'name': '___cxa_pure_virtual', 'type': 'U'}
304305
{'is_defined': False, 'name': '___cxa_rethrow', 'type': 'U'}
305306
{'is_defined': False, 'name': '___cxa_rethrow_primary_exception', 'type': 'U'}
@@ -811,6 +812,7 @@
811812
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
812813
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
813814
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
815+
{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
814816
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
815817
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
816818
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -2509,6 +2511,7 @@
25092511
{'is_defined': True, 'name': '___cxa_guard_abort', 'type': 'I'}
25102512
{'is_defined': True, 'name': '___cxa_guard_acquire', 'type': 'I'}
25112513
{'is_defined': True, 'name': '___cxa_guard_release', 'type': 'I'}
2514+
{'is_defined': True, 'name': '___cxa_init_primary_exception', 'type': 'I'}
25122515
{'is_defined': True, 'name': '___cxa_pure_virtual', 'type': 'I'}
25132516
{'is_defined': True, 'name': '___cxa_rethrow', 'type': 'I'}
25142517
{'is_defined': True, 'name': '___cxa_throw', 'type': 'I'}

libcxx/lib/abi/i686-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist

+2
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD0Ev', 'type': 'FUNC'}
494494
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD1Ev', 'type': 'FUNC'}
495495
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD2Ev', 'type': 'FUNC'}
496+
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
496497
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
497498
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
498499
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -2311,6 +2312,7 @@
23112312
{'is_defined': True, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
23122313
{'is_defined': True, 'name': '__cxa_guard_release', 'type': 'FUNC'}
23132314
{'is_defined': True, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
2315+
{'is_defined': True, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
23142316
{'is_defined': True, 'name': '__cxa_new_handler', 'size': 4, 'type': 'OBJECT'}
23152317
{'is_defined': True, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
23162318
{'is_defined': True, 'name': '__cxa_rethrow', 'type': 'FUNC'}

libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist

+2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
250250
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
251251
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
252+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
252253
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
253254
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
254255
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
@@ -1111,6 +1112,7 @@
11111112
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_acquire', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11121113
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_release', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11131114
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
1115+
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_init_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11141116
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_pure_virtual', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11151117
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11161118
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist

+2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
250250
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
251251
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
252+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
252253
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
253254
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
254255
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
@@ -1111,6 +1112,7 @@
11111112
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_acquire', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11121113
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_guard_release', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11131114
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
1115+
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_init_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11141116
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_pure_virtual', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11151117
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
11161118
{'import_export': 'IMP', 'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist

+3
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
{'is_defined': False, 'name': '___cxa_guard_acquire', 'type': 'U'}
301301
{'is_defined': False, 'name': '___cxa_guard_release', 'type': 'U'}
302302
{'is_defined': False, 'name': '___cxa_increment_exception_refcount', 'type': 'U'}
303+
{'is_defined': False, 'name': '___cxa_init_primary_exception', 'type': 'U'}
303304
{'is_defined': False, 'name': '___cxa_pure_virtual', 'type': 'U'}
304305
{'is_defined': False, 'name': '___cxa_rethrow', 'type': 'U'}
305306
{'is_defined': False, 'name': '___cxa_rethrow_primary_exception', 'type': 'U'}
@@ -811,6 +812,7 @@
811812
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
812813
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
813814
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
815+
{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
814816
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
815817
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
816818
{'is_defined': True, 'name': '__ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -2543,6 +2545,7 @@
25432545
{'is_defined': True, 'name': '___cxa_guard_abort', 'type': 'I'}
25442546
{'is_defined': True, 'name': '___cxa_guard_acquire', 'type': 'I'}
25452547
{'is_defined': True, 'name': '___cxa_guard_release', 'type': 'I'}
2548+
{'is_defined': True, 'name': '___cxa_init_primary_exception', 'type': 'I'}
25462549
{'is_defined': True, 'name': '___cxa_pure_virtual', 'type': 'I'}
25472550
{'is_defined': True, 'name': '___cxa_rethrow', 'type': 'I'}
25482551
{'is_defined': True, 'name': '___cxa_throw', 'type': 'I'}

libcxx/lib/abi/x86_64-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist

+2
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD0Ev', 'type': 'FUNC'}
494494
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD1Ev', 'type': 'FUNC'}
495495
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD2Ev', 'type': 'FUNC'}
496+
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
496497
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
497498
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
498499
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -2305,6 +2306,7 @@
23052306
{'is_defined': True, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
23062307
{'is_defined': True, 'name': '__cxa_guard_release', 'type': 'FUNC'}
23072308
{'is_defined': True, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
2309+
{'is_defined': True, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
23082310
{'is_defined': True, 'name': '__cxa_new_handler', 'size': 8, 'type': 'OBJECT'}
23092311
{'is_defined': True, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
23102312
{'is_defined': True, 'name': '__cxa_rethrow', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
{'is_defined': False, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
5757
{'is_defined': False, 'name': '__cxa_guard_release', 'type': 'FUNC'}
5858
{'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
59+
{'is_defined': False, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
5960
{'is_defined': False, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
6061
{'is_defined': False, 'name': '__cxa_rethrow', 'type': 'FUNC'}
6162
{'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
@@ -523,6 +524,7 @@
523524
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
524525
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
525526
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
527+
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
526528
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
527529
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
528530
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
{'is_defined': False, 'name': '__cxa_guard_acquire', 'type': 'FUNC'}
5555
{'is_defined': False, 'name': '__cxa_guard_release', 'type': 'FUNC'}
5656
{'is_defined': False, 'name': '__cxa_increment_exception_refcount', 'type': 'FUNC'}
57+
{'is_defined': False, 'name': '__cxa_init_primary_exception', 'type': 'FUNC'}
5758
{'is_defined': False, 'name': '__cxa_pure_virtual', 'type': 'FUNC'}
5859
{'is_defined': False, 'name': '__cxa_rethrow', 'type': 'FUNC'}
5960
{'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
@@ -521,6 +522,7 @@
521522
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
522523
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
523524
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
525+
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
524526
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
525527
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
526528
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
494494
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
495495
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
496+
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
496497
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
497498
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}
498499
{'is_defined': True, 'name': '_ZNSt13exception_ptrD1Ev', 'type': 'FUNC'}
@@ -1999,4 +2000,4 @@
19992000
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev', 'type': 'FUNC'}
20002001
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev', 'type': 'FUNC'}
20012002
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD0Ev', 'type': 'FUNC'}
2002-
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD1Ev', 'type': 'FUNC'}
2003+
{'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD1Ev', 'type': 'FUNC'}

libcxx/src/support/runtime/exception_pointer_cxxabi.ipp

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
2828
return *this;
2929
}
3030

31+
exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept {
32+
exception_ptr ptr;
33+
ptr.__ptr_ = __e;
34+
__cxa_increment_exception_refcount(ptr.__ptr_);
35+
36+
return ptr;
37+
}
38+
3139
nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
3240

3341
nested_exception::~nested_exception() noexcept {}

0 commit comments

Comments
 (0)