Changeset 209113 in webkit


Ignore:
Timestamp:
Nov 29, 2016, 7:42:55 PM (9 years ago)
Author:
caitp@igalia.com
Message:

[JSC] always wrap AwaitExpression operand in a new Promise
https://bugs.webkit.org/show_bug.cgi?id=165181

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/async-await-basic.js:

(async.awaitedPromisesAreWrapped):

Source/JavaScriptCore:

Ensure operand of AwaitExpression is wrapped in a new Promise by
explicitly creating a new Promise Capability and invoking its
resolve callback. This avoids the specified short-circuit for
Promise.resolve().

  • builtins/AsyncFunctionPrototype.js:

(globalPrivate.asyncFunctionResume):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r209083 r209113  
     12016-11-29  Caitlin Potter  <caitp@igalia.com>
     2
     3        [JSC] always wrap AwaitExpression operand in a new Promise
     4        https://bugs.webkit.org/show_bug.cgi?id=165181
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * stress/async-await-basic.js:
     9        (async.awaitedPromisesAreWrapped):
     10
    1112016-11-29  Keith Miller  <keith_miller@apple.com>
    212
  • trunk/JSTests/stress/async-await-basic.js

    r208843 r209113  
    295295shouldThrowSyntaxError("class C { async ['foo'] , bar };", "Unexpected token ','. Expected an opening '(' before a async method's parameter list.");
    296296shouldThrowSyntaxError("class C { async ['foo'] }", "Unexpected token '}'. Expected an opening '(' before a async method's parameter list.");
     297
     298// Ensure awaited builtin Promise objects are themselves wrapped in a new Promise,
     299// per https://tc39.github.io/ecma262/#sec-async-functions-abstract-operations-async-function-await
     300log = [];
     301async function awaitedPromisesAreWrapped() {
     302    log.push("before");
     303    await Promise.resolve();
     304    log.push("after");
     305}
     306awaitedPromisesAreWrapped();
     307Promise.resolve().then(() => log.push("Promise.resolve()"));
     308drainMicrotasks();
     309shouldBe("before|Promise.resolve()|after", log.join("|"));
  • trunk/Source/JavaScriptCore/ChangeLog

    r209112 r209113  
     12016-11-29  Caitlin Potter  <caitp@igalia.com>
     2
     3        [JSC] always wrap AwaitExpression operand in a new Promise
     4        https://bugs.webkit.org/show_bug.cgi?id=165181
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Ensure operand of AwaitExpression is wrapped in a new Promise by
     9        explicitly creating a new Promise Capability and invoking its
     10        resolve callback. This avoids the specified short-circuit for
     11        Promise.resolve().
     12
     13        * builtins/AsyncFunctionPrototype.js:
     14        (globalPrivate.asyncFunctionResume):
     15
    1162016-11-29  Saam Barati  <sbarati@apple.com>
    217
  • trunk/Source/JavaScriptCore/builtins/AsyncFunctionPrototype.js

    r208726 r209113  
    4848    }
    4949
    50     @Promise.@resolve(value).@then(
     50    let wrappedValue = @newPromiseCapability(@Promise);
     51    wrappedValue.@resolve.@call(@undefined, value);
     52
     53    wrappedValue.@promise.@then(
    5154        function(value) { @asyncFunctionResume(generator, promiseCapability, value, @GeneratorResumeModeNormal); },
    5255        function(error) { @asyncFunctionResume(generator, promiseCapability, error, @GeneratorResumeModeThrow); });
Note: See TracChangeset for help on using the changeset viewer.