[webkit-changes] [WebKit/WebKit] 766a34: [JSC] Async functions and generators should proper...

Commit Queue noreply at github.com
Tue Dec 19 13:14:22 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 766a344cdf5c50e18624ceda6f98f2d9d3f5eac1
      https://github.com/WebKit/WebKit/commit/766a344cdf5c50e18624ceda6f98f2d9d3f5eac1
  Author: Alexey Shvayka <ashvayka at apple.com>
  Date:   2023-12-19 (Tue, 19 Dec 2023)

  Changed paths:
    A JSTests/stress/async-function-broken-promise.js
    M JSTests/test262/expectations.yaml
    M Source/JavaScriptCore/builtins/PromiseOperations.js

  Log Message:
  -----------
  [JSC] Async functions and generators should properly handle broken promises
https://bugs.webkit.org/show_bug.cgi?id=266502
<rdar://problem/119734587>

Reviewed by Justin Michaud.

Before this change, abrupt completions of PromiseResolve [1] that arised during "constructor" lookup
were not handled properly in async functions and generators, resulting in exception propagation up
the call stack rather than rejecting a promise. That affected `await`, `yield`, and `return` called
with a broken promise (i.e. with throwing "constructor" getter).

Most likely, this is a regression from implementing async / await tick reduction proposal [2].

This patch guards "constructor" lookup with exception handling, ensuring that all call sites supply
onRejected() callback that is semantically equivalent to throwing an exception at that point, as per
spec. Invoking onRejected() synchronously, without extra microtask, is also required to match the
standard, V8, and SpiderMonkey.

Also, this change implements a proposal [3] to fix AsyncGenerator.prototype.return() called on a
broken promise, aligning JSC with V8.

[1]: https://tc39.es/ecma262/#sec-promise-resolve (step 1.a)
[2]: https://github.com/tc39/ecma262/pull/1250
[3]: https://github.com/tc39/ecma262/pull/2683

* JSTests/stress/async-function-broken-promise.js: Added.
* JSTests/test262/expectations.yaml: Mark 4 tests as passing.
* Source/JavaScriptCore/builtins/PromiseOperations.js:
(linkTimeConstant.resolveWithoutPromiseForAsyncAwait):

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




More information about the webkit-changes mailing list