Skip to content

add tests for proposed faster-promise-try change - #5072

Merged
bakkot merged 2 commits into
tc39:mainfrom
bakkot:promise-try-faster
Aug 10, 2026
Merged

bakkot merged 2 commits into
tc39:mainfrom
bakkot:promise-try-faster

Conversation

@bakkot

@bakkot bakkot commented Jun 19, 2026

Copy link
Copy Markdown
Member

Tests for tc39/ecma262#3883.

Also includes a test that Subclass.try uses the subclass to wrap the rejection. The linked PR doesn't change that but it's untested currently. I can split it into its own PR if you'd like.

None of the existing tests are affected by that PR.

Comment thread test/built-ins/Promise/try/avoids-wrap-for-subclass.js
Comment thread test/built-ins/Promise/try/avoids-wrap.js
Comment thread test/built-ins/Promise/try/ctx-ctor-for-error.js
@bakkot
bakkot marked this pull request as ready for review July 20, 2026 20:30
@bakkot
bakkot requested a review from a team as a code owner July 20, 2026 20:30
@bakkot
bakkot enabled auto-merge (squash) August 10, 2026 16:13
@bakkot
bakkot merged commit 440b64f into tc39:main Aug 10, 2026
14 checks passed
webkit-commit-queue pushed a commit to Constellation/WebKit that referenced this pull request Aug 17, 2026
https://bugs.webkit.org/show_bug.cgi?id=321890
rdar://185064567

Reviewed by Sosuke Suzuki.

Test262 is updated[1] to include the latest spec change proposal
for Promise.try[2], which uses PromiseResolve instead of a promise
created by NewPromiseCapability. This simplifies our Promise.try
implementation since we can just use @promiseResolve and @promisereject
helpers instead. Also this removes the reference to
@newPromiseCapability in JSC code. So we drop PromiseOperations.js and
its JS builtins, and replace @newPromiseCapability with C++ version for
remaining WebCore users.

WebCore users can be replaced by using normal Promise + first-resolving
handler. This is fixed in a subsequent change.

[1]: tc39/test262#5072
[2]: tc39/ecma262#3883

* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/DerivedSources-input.xcfilelist:
* Source/JavaScriptCore/DerivedSources.make:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/PromiseConstructor.js:
(try):
* Source/JavaScriptCore/builtins/PromiseOperations.js: Removed.
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSGlobalObject::init):

Canonical link: https://commits.webkit.org/319276@main
@bakkot
bakkot deleted the promise-try-faster branch August 24, 2026 22:18
ljharb added a commit to es-shims/Promise.try that referenced this pull request Sep 9, 2026
tc39/ecma262#3883 changed `Promise.try` to end with
`Return ? PromiseResolve(ctor, ! status)`,
instead of creating a capability up front and resolving through it.
A promise returned from the callback is now passed through rather than wrapped,
and the capability is only created on the abrupt-completion path.

test262 pins this in `built-ins/Promise/try/avoids-wrap.js` and `avoids-wrap-for-subclass.js` (tc39/test262#5072).

No engine has shipped the change yet,
so `getPolyfill` probes for the older wrapping behavior and falls back to the implementation.
ljharb added a commit to es-shims/Promise.try that referenced this pull request Sep 9, 2026
tc39/ecma262#3883 changed `Promise.try` to end with
`Return ? PromiseResolve(ctor, ! status)`,
instead of creating a capability up front and resolving through it.
A promise returned from the callback is now passed through rather than wrapped,
and the capability is only created on the abrupt-completion path.

test262 pins this in `built-ins/Promise/try/avoids-wrap.js` and `avoids-wrap-for-subclass.js` (tc39/test262#5072).

No engine has shipped the change yet,
so `getPolyfill` probes for the older wrapping behavior and falls back to the implementation.
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.

3 participants