-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[EH] Use _UA_SEARCH_PHASE in personality function (NFC) #17991
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -798,6 +798,8 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, | |||
{ | ||||
// Native exception caught by exception | ||||
// specification. | ||||
assert(actions & _UA_SEARCH_PHASE); | ||||
results.ttypeIndex = ttypeIndex; | ||||
results.actionRecord = actionRecord; | ||||
results.adjustedPtr = adjustedPtr; | ||||
results.reason = _URC_HANDLER_FOUND; | ||||
|
@@ -964,6 +966,11 @@ __gxx_personality_v0 | |||
exc->languageSpecificData = results.languageSpecificData; | ||||
exc->catchTemp = reinterpret_cast<void*>(results.landingPad); | ||||
exc->adjustedPtr = results.adjustedPtr; | ||||
#ifdef __USING_WASM_EXCEPTIONS__ | ||||
// Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the | ||||
// results here. | ||||
set_registers(unwind_exception, context, results); | ||||
#endif | ||||
Comment on lines
+969
to
+973
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to save our selector computation result. In the upstream version, the search phase searches for a matching catch handler and caches the result, and the second cleanup phase retrieves the result and sets registers with the final selector value. (In Wasm's libunwind, they are not registers but just a field in a struct.). They do it in the second cleanup phase:
But now we only use the search phase, we do it here. Instead, we are able to remove our duplicated caching code in line 984-993 below. |
||||
} | ||||
return _URC_HANDLER_FOUND; | ||||
} | ||||
|
@@ -981,16 +988,6 @@ __gxx_personality_v0 | |||
exception_header->catchTemp = 0; | ||||
#endif | ||||
} | ||||
#ifdef __USING_WASM_EXCEPTIONS__ | ||||
// Wasm uses only one phase in _UA_CLEANUP_PHASE, so we should set | ||||
// these here. | ||||
__cxa_exception* exception_header = (__cxa_exception*)(unwind_exception+1) - 1; | ||||
exception_header->handlerSwitchValue = static_cast<int>(results.ttypeIndex); | ||||
exception_header->actionRecord = results.actionRecord; | ||||
exception_header->languageSpecificData = results.languageSpecificData; | ||||
exception_header->catchTemp = reinterpret_cast<void*>(results.landingPad); | ||||
exception_header->adjustedPtr = results.adjustedPtr; | ||||
#endif | ||||
Comment on lines
-984
to
-993
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what the upstream code does in the first search phase, but we used only the cleanup phase, we duplicated the code here. Now we can remove it. |
||||
return _URC_INSTALL_CONTEXT; | ||||
} | ||||
|
||||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
This is not related to this PR, but I compared our
cxa_personality.cpp
with llvm 14.0.0 version (on which our current libc++abi is based on), this part is missing. I guess it was dropped when we upgraded the library. I don't think Wasm is using this part of the code though, reducing difference from the upstream code seems better.