Skip to content
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

[JSC] Implement Promise.try #24802

Merged

Conversation

rkirsling
Copy link
Member

@rkirsling rkirsling commented Feb 20, 2024

6d51d57

[JSC] Implement Promise.try
https://bugs.webkit.org/show_bug.cgi?id=269775

Reviewed by Justin Michaud.

This patch implements https://github.com/tc39/proposal-promise-try behind a runtime option;
the proposal is currently at Stage 2 but the spec is very simple and not expected to change.

Effectively, Promise.try(f) is a more convenient way to write `new Promise((resolve) => { resolve(f()); })` --
we don't care whether f is sync or async, but if is synchronous, we want it to be executed immediately.

This implementation includes tc39/proposal-promise-try#16, which the champion expects to merge;
it simply extends the API to Promise.try(f, ...args) such that arguments can be forwarded to the callback.

* JSTests/stress/promise-try.js: Added.
* Source/JavaScriptCore/builtins/PromiseConstructor.js:
(try): Added.
* Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp:
(JSC::JSPromiseConstructor::finishCreation):
* Source/JavaScriptCore/runtime/OptionsList.h:

Canonical link: https://commits.webkit.org/275081@main

adb9e75

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
βœ… πŸ›  πŸ§ͺ jsc βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  πŸ§ͺ jsc-arm64 βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim βœ… πŸ›  jsc-armv7
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  watch-sim

@rkirsling rkirsling requested a review from a team as a code owner February 20, 2024 07:49
@rkirsling rkirsling self-assigned this Feb 20, 2024
@rkirsling rkirsling added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Feb 20, 2024
Copy link
Contributor

@justinmichaud justinmichaud left a comment

Choose a reason for hiding this comment

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

Nice!

@rkirsling rkirsling added the merge-queue Applied to send a pull request to merge-queue label Feb 20, 2024
@webkit-commit-queue
Copy link
Collaborator

Commit message contains (OOPS!) and no reviewer found, blocking PR #24802

@webkit-commit-queue webkit-commit-queue added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels Feb 20, 2024
@rkirsling rkirsling removed the merging-blocked Applied to prevent a change from being merged label Feb 20, 2024
Copy link
Contributor

@justinmichaud justinmichaud left a comment

Choose a reason for hiding this comment

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

r=me

@rkirsling rkirsling added the merge-queue Applied to send a pull request to merge-queue label Feb 21, 2024
https://bugs.webkit.org/show_bug.cgi?id=269775

Reviewed by Justin Michaud.

This patch implements https://github.com/tc39/proposal-promise-try behind a runtime option;
the proposal is currently at Stage 2 but the spec is very simple and not expected to change.

Effectively, Promise.try(f) is a more convenient way to write `new Promise((resolve) => { resolve(f()); })` --
we don't care whether f is sync or async, but if is synchronous, we want it to be executed immediately.

This implementation includes tc39/proposal-promise-try#16, which the champion expects to merge;
it simply extends the API to Promise.try(f, ...args) such that arguments can be forwarded to the callback.

* JSTests/stress/promise-try.js: Added.
* Source/JavaScriptCore/builtins/PromiseConstructor.js:
(try): Added.
* Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp:
(JSC::JSPromiseConstructor::finishCreation):
* Source/JavaScriptCore/runtime/OptionsList.h:

Canonical link: https://commits.webkit.org/275081@main
@webkit-commit-queue webkit-commit-queue merged commit 6d51d57 into WebKit:main Feb 21, 2024
@webkit-commit-queue
Copy link
Collaborator

Committed 275081@main (6d51d57): https://commits.webkit.org/275081@main

Reviewed commits have been landed. Closing PR #24802 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 21, 2024
@rkirsling rkirsling deleted the eng/JSC-Implement-Promise-try branch February 21, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.
Projects
None yet
4 participants