[prev in list] [next in list] [prev in thread] [next in thread] 

List:       webkit-changes
Subject:    [webkit-changes] [WebKit/WebKit] 464a30: [JSC] Implement array-from-async
From:       Yusuke Suzuki <noreply () github ! com>
Date:       2022-11-30 14:54:38
Message-ID: WebKit/WebKit/push/refs/heads/main/4467fe-464a30 () github ! com
[Download RAW message or body]

  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 464a308595c09e6151402adbb8e4e94018a115bd
      https://github.com/WebKit/WebKit/commit/464a308595c09e6151402adbb8e4e94018a115bd
  Author: Yusuke Suzuki <ysuzuki@apple.com>
  Date:   2022-11-30 (Wed, 30 Nov 2022)

  Changed paths:
    A JSTests/stress/array-from-async-basic.js
    A JSTests/stress/array-from-async-map-promise.js
    A JSTests/stress/array-from-async-map-this.js
    A JSTests/stress/array-from-async-map.js
    M LayoutTests/js/Object-getOwnPropertyNames-expected.txt
    M LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
    M Source/JavaScriptCore/builtins/ArrayConstructor.js
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
    M Source/JavaScriptCore/runtime/ArrayConstructor.cpp
    M Source/JavaScriptCore/runtime/OptionsList.h

  Log Message:
  -----------
  [JSC] Implement array-from-async
https://bugs.webkit.org/show_bug.cgi?id=245260
rdar://problem/100303653

Reviewed by Alexey Shvayka.

This patch implements stage-3 Array.fromAsync[1] feature.
The goal of this feature is providing async iteration version of Array.from.

Array.from's concept.

    const arr = [];
    for (const v of iterable) {
        arr.push(v);
    }

Array.fromAsync's concept.

    const arr = [];
    for await (const v of asyncIterable) {
        arr.push(v);
    }

The complicated part of this change is that, when using `async function` in builtin JS,
it automatically generates internal promise, which we would like to avoid here.
In the future, we would like to remove internal promise completely, but for now, we
workaround this restriction by the convention that, when the builtin JS function's name
starts with `defaultAsync`, then we use normal promise instead of internal promise.

[1]: https://github.com/tc39/proposal-array-from-async

* JSTests/stress/array-from-async-basic.js: Added.
(shouldBe):
(shouldBeArray):
(async test.async shouldBeArray):
(async test):
(test.catch):
* JSTests/stress/array-from-async-map-promise.js: Added.
(shouldBe):
(shouldBeArray):
(async test.):
(async test.async shouldBeArray):
(async test):
(test.catch):
* JSTests/stress/array-from-async-map-this.js: Added.
(shouldBe):
(shouldBeArray):
(async test.):
(async test.async shouldBeArray):
(async test):
(test.catch):
* JSTests/stress/array-from-async-map.js: Added.
(shouldBe):
(shouldBeArray):
(async test.):
(async test.async shouldBeArray):
(async test):
(test.catch):
* Source/JavaScriptCore/builtins/ArrayConstructor.js:
(from.wrapper.iterator):
(from):
(wrapper.asyncIterator):
(linkTimeConstant.async defaultAsyncFromAsyncIterator):
(linkTimeConstant.async defaultAsyncFromAsyncArrayLike):
(fromAsync):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* Source/JavaScriptCore/runtime/ArrayConstructor.cpp:
(JSC::ArrayConstructor::finishCreation):
* Source/JavaScriptCore/runtime/OptionsList.h:

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic