[EH] Tidy up format_exception.cpp (NFC) - #16995
Merged
Merged
Conversation
This makes small cosmetic changes that do not affect the functionality. - Use `using namespace __cxxabiv1`. This namespace is used many times and I think it's OK to put this at the top. Other libc++abi cpp files also do this. - Use `static_cast` instead of the old cast. This is also in line with the rest of libc++abi. - Change some variable names. This tries to make variable names in line with libc++abi's other files; personally I don't particularly like their long names such as `exception_header`, but I think keeping them in line with the rest of the code is generally good and possibly be helpful when we upstream the changes. - Add `cxa_exception_from_thrown_object` and use it. The reason I copied this function from cxa_exception.cpp is I'm planning to use all these three when I add Wasm EH support for this function, and it will be easier to read if we use these than just doing the arthmetic ourselves. https://github.com/emscripten-core/emscripten/blob/d5ef6937fe395488e23a82c1e582a7ea5c2dab83/system/lib/libcxxabi/src/cxa_exception.cpp#L39-L67 The reason I copied them is they are static functions in cxa_exception.cpp. We possibly can move them to a header file and include it both places, but that means further changes to libc++abi codebase, which I think will make this harder to upstream. - Use `__shim_type_info::can_catch` directly instead of `__cxa_catch`, which is a wrapper created to be called from JS. This removes the need to include the declaration of `__cxa_catch` in this file.
Member
Author
|
cc @hoodmane |
sbc100
reviewed
May 20, 2022
| static inline __cxa_exception* | ||
| cxa_exception_from_thrown_object(void* thrown_object) { | ||
| return static_cast<__cxa_exception*>(thrown_object) - 1; | ||
| } |
Collaborator
There was a problem hiding this comment.
I have another change that also adds this function: #16627
But I don't mind merging them when I land that.
sbc100
approved these changes
May 20, 2022
kripken
approved these changes
May 20, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This makes small cosmetic changes that do not affect the functionality.
using namespace __cxxabiv1. This namespace is used many timesand I think it's OK to put this at the top. Other libc++abi cpp files
also do this.
static_castinstead of the old cast. This is also in line withthe rest of libc++abi.
with libc++abi's other files; personally I don't particularly like
their long names such as
exception_header, but I think keeping themin line with the rest of the code is generally good and possibly
helpful when we upstream the changes.
cxa_exception_from_thrown_objectand use it. The reason I copiedthis function from cxa_exception.cpp is I'm planning to use all these
three when I add Wasm EH support for this function, and it will be
easier to read if we use these than just doing the arthmetic
ourselves.
emscripten/system/lib/libcxxabi/src/cxa_exception.cpp
Lines 39 to 67 in d5ef693
The reason I copied them is they are static functions in
cxa_exception.cpp. We possibly can move them to a header file and
include it both places, but that means further changes to libc++abi
codebase, which I think will make this harder to upstream.
__shim_type_info::can_catchdirectly instead of__cxa_catch,which is a wrapper created to be called from JS. This removes the need
to include the declaration of
__cxa_catchin this file.