Skip to content

Remove dep between __cxa_rethrow_primary_exception and __cxa_rethrow (NFC)#26518

Merged
aheejin merged 10 commits intoemscripten-core:mainfrom
aheejin:rethrow_primary_refactor
Mar 24, 2026
Merged

Remove dep between __cxa_rethrow_primary_exception and __cxa_rethrow (NFC)#26518
aheejin merged 10 commits intoemscripten-core:mainfrom
aheejin:rethrow_primary_refactor

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented Mar 22, 2026

Currently __cxa_rethrow_primary_exception calls __cxa_rethrow, and __cxa_rethrow is unnecessarily complicated to split logic when it is called from __cxa_rethrow_primary_exception and when it is not.

This just decouples the two and duplicates the necessary logic in __cxa_rethrow_primary_exception. This makes __cxa_rethrow simple and easy to follow.

Currently `__cxa_rethrow_primary_exception` calls `__cxa_rethrow`, and
`__cxa_rethrow` is unnecessarily complicated to split logic when it is
called from `__cxa_rethrow_primary_exception` and when it is not.

This just decouples the two and duplicates the necessary logic in
`__cxa_rethrow_primary_exception`. This makes `__cxa_rethrow` simple and
easy to follow.
@aheejin aheejin requested a review from sbc100 March 22, 2026 03:35
aheejin added 2 commits March 22, 2026 05:32
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (8) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_cxx_except.json: 195391 => 195372 [-19 bytes / -0.01%]
codesize/test_codesize_cxx_mangle.json: 261882 => 261863 [-19 bytes / -0.01%]
codesize/test_codesize_hello_dylink_all.json: 821851 => 821662 [-189 bytes / -0.02%]
codesize/test_codesize_minimal_pthreads.json: 26629 => 26630 [+1 bytes / +0.00%]
codesize/test_codesize_minimal_pthreads_memgrowth.json: 27032 => 27033 [+1 bytes / +0.00%]
codesize/test_minimal_runtime_code_size_hello_embind.json: 14909 => 14908 [-1 bytes / -0.01%]
codesize/test_minimal_runtime_code_size_hello_embind_val.json: 11642 => 11641 [-1 bytes / -0.01%]
codesize/test_minimal_runtime_code_size_hello_wasm_worker.json: 4055 => 4060 [+5 bytes / +0.12%]

Average change: +0.01% (-0.02% - +0.12%)
```
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (6) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_hello_dylink_all.json: 821662 => 821851 [+189 bytes / +0.02%]
codesize/test_codesize_minimal_pthreads.json: 26630 => 26629 [-1 bytes / -0.00%]
codesize/test_codesize_minimal_pthreads_memgrowth.json: 27033 => 27032 [-1 bytes / -0.00%]
codesize/test_minimal_runtime_code_size_hello_embind.json: 14908 => 14909 [+1 bytes / +0.01%]
codesize/test_minimal_runtime_code_size_hello_embind_val.json: 11641 => 11642 [+1 bytes / +0.01%]
codesize/test_minimal_runtime_code_size_hello_wasm_worker.json: 4060 => 4055 [-5 bytes / -0.12%]

Average change: -0.02% (-0.12% - +0.02%)
```
#endif
#if EXCEPTION_DEBUG
dbg('__cxa_rethrow_primary_exception: ' + ptrToString(ptr));
#endif
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this debugging to the top of the function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: d8852eb

Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % comments

__cxa_rethrow: () => {
var info = exceptionCaught.pop();
if (!info) {
if (exceptionCaught.length == 0) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just do !exceptionCaught.length ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

aheejin added 5 commits March 24, 2026 00:02
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (2) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_cxx_except.json: 195711 => 195689 [-22 bytes / -0.01%]
codesize/test_codesize_cxx_mangle.json: 262202 => 262180 [-22 bytes / -0.01%]

Average change: -0.01% (-0.01% - -0.01%)
```
@aheejin aheejin merged commit ef01122 into emscripten-core:main Mar 24, 2026
38 checks passed
@aheejin aheejin deleted the rethrow_primary_refactor branch March 24, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants