Modified: trunk/JSTests/test262/expectations.yaml (262978 => 262979)
--- trunk/JSTests/test262/expectations.yaml 2020-06-12 22:05:26 UTC (rev 262978)
+++ trunk/JSTests/test262/expectations.yaml 2020-06-12 22:13:19 UTC (rev 262979)
@@ -651,9 +651,6 @@
test/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js:
default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
-test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js:
- default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: AsyncGeneratorResolve(generator, resultValue, true) Expected SameValue(«[object Promise]», «unwrapped-value») to be true'
- strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: AsyncGeneratorResolve(generator, resultValue, true) Expected SameValue(«[object Promise]», «unwrapped-value») to be true'
test/built-ins/DataView/custom-proto-access-detaches-buffer.js:
default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
@@ -3025,15 +3022,6 @@
test/language/statements/async-generator/return-undefined-implicit-and-explicit.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected [tick 1, g1 ret, tick 2, g2 ret, g3 ret, g4 ret] and [tick 1, g1 ret, g2 ret, tick 2, g3 ret, g4 ret] to have the same contents. Ticks for implicit and explicit return undefined'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected [tick 1, g1 ret, tick 2, g2 ret, g3 ret, g4 ret] and [tick 1, g1 ret, g2 ret, tick 2, g3 ret, g4 ret] to have the same contents. Ticks for implicit and explicit return undefined'
-test/language/statements/async-generator/yield-return-then-getter-ticks.js:
- default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected [start, tick 1, tick 2] and [start, tick 1, get then, tick 2] to have the same contents. Ticks for return with thenable getter'
- strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected [start, tick 1, tick 2] and [start, tick 1, get then, tick 2] to have the same contents. Ticks for return with thenable getter'
-test/language/statements/async-generator/yield-star-return-missing-value-is-awaited.js:
- default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«[object Promise]», «3») to be true'
- strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«[object Promise]», «3») to be true'
-test/language/statements/async-generator/yield-star-return-then-getter-ticks.js:
- default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected [start, tick 1, tick 2, get return, tick 3, tick 4] and [start, tick 1, tick 2, get then, tick 3, get return, get then, tick 4] to have the same contents. Ticks for return with thenable getter'
- strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected [start, tick 1, tick 2, get return, tick 3, tick 4] and [start, tick 1, tick 2, get then, tick 3, get return, get then, tick 4] to have the same contents. Ticks for return with thenable getter'
test/language/statements/class/class-name-ident-await-escaped.js:
default: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
strict mode: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
Modified: trunk/Source/_javascript_Core/ChangeLog (262978 => 262979)
--- trunk/Source/_javascript_Core/ChangeLog 2020-06-12 22:05:26 UTC (rev 262978)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-06-12 22:13:19 UTC (rev 262979)
@@ -1,3 +1,33 @@
+2020-06-12 Alexey Shvayka <[email protected]>
+
+ AsyncGenerator should await "return" completions
+ https://bugs.webkit.org/show_bug.cgi?id=212774
+
+ Reviewed by Ross Kirsling.
+
+ This patch fixes 2 spec discrepancies, observable with async generators if the
+ value of "return" completion is a Promise, aligning JSC with V8 and SpiderMonkey.
+
+ * builtins/AsyncGeneratorPrototype.js:
+ (onFulfilled):
+ This change implements step 8 of AsyncGeneratorYield [1], that is executed after
+ step 15 of AsyncGeneratorResumeNext [2] (implemented as @doAsyncGeneratorBodyCall).
+ We are safe to rely on [[AsyncGeneratorState]] being "suspendedYield" (set in
+ step 6 of AsyncGeneratorYield [1]) instead of adding extra field to AsyncGenerator:
+ AsyncGeneratorResumeNext [2] does not overwrite "suspendedYield" state.
+ This change fixes most of test262 cases.
+
+ [1]: https://tc39.es/ecma262/#sec-asyncgeneratoryield
+ [2]: https://tc39.es/ecma262/#sec-asyncgeneratorresumenext
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitDelegateYield):
+ This change implements step 7.c.iii.1 of yield* runtime semantics [3], that is
+ observable only if [[Value]] has userland "then" getter. Awaited result is discarded.
+ This change fixes async-generator/yield-star-return-then-getter-ticks.js test262 case.
+
+ [3]: https://tc39.es/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluation
+
2020-06-12 Ross Kirsling <[email protected]>
Unreviewed, address Darin's feedback on r262890.
Modified: trunk/Source/_javascript_Core/builtins/AsyncGeneratorPrototype.js (262978 => 262979)
--- trunk/Source/_javascript_Core/builtins/AsyncGeneratorPrototype.js 2020-06-12 22:05:26 UTC (rev 262978)
+++ trunk/Source/_javascript_Core/builtins/AsyncGeneratorPrototype.js 2020-06-12 22:13:19 UTC (rev 262979)
@@ -149,6 +149,14 @@
{
"use strict";
+ if (resumeMode === @GeneratorResumeModeReturn && @isSuspendYieldState(generator)) {
+ var _onFulfilled_ = function(result) { @doAsyncGeneratorBodyCall(generator, result, @GeneratorResumeModeReturn); };
+
+ @putAsyncGeneratorInternalField(generator, @asyncGeneratorFieldSuspendReason, @AsyncGeneratorSuspendReasonAwait);
+ @awaitValue(generator, resumeValue, onFulfilled);
+ return;
+ }
+
var value = @undefined;
var state = @getAsyncGeneratorInternalField(generator, @generatorFieldState);