-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[embind] Allow awaiting Promises in non-Promise coroutines & catching Promise C++ exceptions #26195
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
stevenwdv
wants to merge
26
commits into
emscripten-core:main
Choose a base branch
from
stevenwdv:val-coro-fixes
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
26 commits
Select commit
Hold shift + click to select a range
4a9611a
WIP: Enable awaiting Promises in non-Promise coroutines (closes #2606…
stevenwdv c6c44e2
Enable EXCEPTION_STACK_TRACES in test_embind_val_coro_catch_cpp_excep…
stevenwdv 80b42d6
Remove TODO from `val::awaiter::reject_with`.
stevenwdv e8a0724
Merge remote-tracking branch 'origin/main' into val-coro-fixes
stevenwdv 051c8ce
Progress on awaiting val in non-val coroutine
stevenwdv 6fcdf4b
val::awaiter: detect JS errors and immediately reject
stevenwdv 478cffe
Merge branch main into val-coro-fixes
stevenwdv 9aaaef6
Fix val coroutine exceptions
stevenwdv 0b94d69
Fix val::awaiter naming
stevenwdv 912fc74
Fix libsigs.js
stevenwdv a1291fe
Remove TODO
stevenwdv e5461cd
Formatting
stevenwdv 66177af
Disable `-fwasm-exceptions` test for wasm2js
stevenwdv 8e14595
Fix no_wasm2js decorator for test_embind_val_coro_catch_cpp_exception…
stevenwdv ea8f476
Automatic rebaseline of codesize expectations. NFC
stevenwdv 8268283
Merge remote-tracking branch 'origin/main' into val-coro-fixes
stevenwdv 98f041d
Automatic rebaseline of codesize expectations. NFC
stevenwdv 7451552
Simplify is_catchable_cpp_exception check
stevenwdv 1c7998f
Comment formatting
stevenwdv 4f8251b
Merge branch 'main' into val-coro-fixes
stevenwdv 06acc36
Automatic rebaseline of codesize expectations. NFC
stevenwdv 072afe6
Merge branch 'main' into val-coro-fixes
stevenwdv 28ff776
Automatic rebaseline of codesize expectations. NFC
stevenwdv dcb575d
Clean up coroutine tests
stevenwdv 09b278f
Remove default list argument
stevenwdv b9dab68
Automatic rebaseline of codesize expectations. NFC
stevenwdv 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include <emscripten.h> | ||
| #include <emscripten/bind.h> | ||
| #include <emscripten/val.h> | ||
|
|
||
| using namespace emscripten; | ||
|
|
||
| EM_JS(EM_VAL, promise_fail_impl, (), { | ||
| let promise = new Promise((_, reject) => setTimeout(reject, 1, new Error("bang from JS promise!"))); | ||
| let handle = Emval.toHandle(promise); | ||
| // FIXME. See https://github.com/emscripten-core/emscripten/issues/16975. | ||
| #if __wasm64__ | ||
| handle = BigInt(handle); | ||
| #endif | ||
| return handle; | ||
| }); | ||
|
|
||
| val promise_fail() { | ||
| return val::take_ownership(promise_fail_impl()); | ||
| } | ||
|
|
||
| template <size_t N> | ||
| val failingPromise() { | ||
| co_await failingPromise<N - 1>(); | ||
| co_return 65; | ||
| } | ||
|
|
||
| template <> | ||
| val failingPromise<0>() { | ||
| co_await promise_fail(); | ||
| co_return 65; | ||
| } | ||
|
|
||
| EMSCRIPTEN_BINDINGS(test_val_coro) { | ||
| function("failingPromise", failingPromise<3>); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.