[libcxx-commits] [libcxx] [libc++] Inline fast path for`exception_ptr` copy constructor & destructor (PR #165909)

Adrian Vogelsgesang via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 10 08:01:17 PST 2025


================
@@ -36,6 +29,21 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
   return ptr;
 }
 
+exception_ptr::~exception_ptr() noexcept { __decrement_refcount(__ptr_); }
+
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
+  __increment_refcount(__ptr_);
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
+  if (__ptr_ != other.__ptr_) {
+    __increment_refcount(other.__ptr_);
+    __decrement_refcount(__ptr_);
+    __ptr_ = other.__ptr_;
+  }
+  return *this;
----------------
vogelsgesang wrote:

merged into `exception_pointer_refcounted.ipp`. Not 100% happy with the name, would be open to a more speaking name

I realized that `__from_native_exception_pointer` is also identical between all 3 ABIs and could also inlined into the header. I think this would only give us marginal performance savings, though. Should we still do it for other reasons, e.g. consistency?

https://github.com/llvm/llvm-project/pull/165909


More information about the libcxx-commits mailing list