-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++] Inline fast path for exception_ptr copy constructor & destructor
#165909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vogelsgesang
wants to merge
18
commits into
llvm:main
Choose a base branch
from
vogelsgesang:avogelsgesang-exception-ptr-inline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b97ad48
[libc++] Inline copy constructor & destructor for `std::exception_ptr`
vogelsgesang 419f64d
Add release note
vogelsgesang b32d1be
Support new visibility attribute in clang-tidy check
vogelsgesang ddaf78e
Update ABI list
vogelsgesang a026801
Fix Windows build by positioning `_LIBCPP_DIAGNOSTIC_POP` correctly
vogelsgesang f787db6
Address review comments
vogelsgesang d731778
Remove unnecessary changes
vogelsgesang a7316f9
CI fixes
vogelsgesang 2ef680d
More CI fixes
vogelsgesang 455a2a6
Simplify `#ifdef` in header
vogelsgesang 68f72ea
Simlify `#warning` in exception_unimplemented
vogelsgesang 12373fa
Deduplicate ref-counted implementations
vogelsgesang 4c75c4e
Formatting
vogelsgesang 2e0cbd1
Early return
vogelsgesang 209c1e3
Remove `swap` specialization
vogelsgesang 96f1f68
Fix stupid mistake 🤦
vogelsgesang 9dbbc70
Add availability markup
vogelsgesang addd78f
Update ABI lists
vogelsgesang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
libcxx/src/support/runtime/exception_pointer_refcounted.ipp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // -*- C++ -*- | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // Provides the common functionality shared between cxxabi and glibcxx. | ||
|
|
||
| namespace std { | ||
|
|
||
| exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept { | ||
| exception_ptr ptr; | ||
| ptr.__ptr_ = __e; | ||
| __increment_refcount(ptr.__ptr_); | ||
|
|
||
| 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; | ||
| } | ||
|
|
||
| } // namespace std |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
We have 3 choices:
swapand the move operator, delegate move to swap (previous solution)swapand the move operator independently (currently in review)swapTo me, (3) actually feels most natural. My gut feeling tells me that "move" assignments are more frequently used/specialized than
swap, so it feels more natural to implement the more common function (move) and delegate the less frequently used (swap) to the other oneI updated the PR accordingly. Please let me know in case you prefer going into a different direction