Commit 30439676 authored by Caitlin Potter's avatar Caitlin Potter Committed by Commit Bot

[async-iteration] implement spec change to [Async-from-Sync Iterator]

A really slight change in behaviour introduced by
https://github.com/tc39/proposal-async-iteration/commit/395b2e3b2f5acb62f9fae11c5e189423d4af50e6

Just swaps the order that properties are loaded from an iterator result
object in the various Async-from-Sync Iterator methods.

Fixes for the test262 tests have been submitted already (https://github.com/tc39/test262/pull/961).

BUG=v8:5855, v8:6242
R=littledan@chromium.org, jwolfe@igalia.com,

Change-Id: I1ff0e1b7758c126d02aec27d67ceeb15b91c06cf
Reviewed-on: https://chromium-review.googlesource.com/474087Reviewed-by: 's avatarDaniel Ehrenberg <littledan@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#44572}
parent 38c5394c
......@@ -160,26 +160,26 @@ std::pair<Node*, Node*> AsyncFromSyncBuiltinsAssembler::LoadIteratorResult(
BIND(&if_fastpath);
{
var_done.Bind(LoadObjectField(iter_result, JSIteratorResult::kDoneOffset));
var_value.Bind(
LoadObjectField(iter_result, JSIteratorResult::kValueOffset));
var_done.Bind(LoadObjectField(iter_result, JSIteratorResult::kDoneOffset));
Goto(&merge);
}
BIND(&if_slowpath);
{
// Let nextValue be IteratorValue(nextResult).
// IfAbruptRejectPromise(nextValue, promiseCapability).
Node* const value =
GetProperty(context, iter_result, factory()->value_string());
GotoIfException(value, if_exception, var_exception);
// Let nextDone be IteratorComplete(nextResult).
// IfAbruptRejectPromise(nextDone, promiseCapability).
Node* const done =
GetProperty(context, iter_result, factory()->done_string());
GotoIfException(done, if_exception, var_exception);
// Let nextValue be IteratorValue(nextResult).
// IfAbruptRejectPromise(nextValue, promiseCapability).
Node* const value =
GetProperty(context, iter_result, factory()->value_string());
GotoIfException(value, if_exception, var_exception);
var_value.Bind(value);
var_done.Bind(done);
Goto(&merge);
......
......@@ -668,3 +668,95 @@ if (testFailed) {
assertThrowsAsync(() => extractedReturn.call(undefined), TypeError);
assertThrowsAsync(() => extractedReturn.call(1), TypeError);
})();
(function AsyncFromSyncIteratorOrdering() {
let i = 0;
let log = [];
function r(value, done) {
let number = (++i);
return {
get value() {
log.push("get iterResult #" + number + ".value");
return {
get then() {
log.push("get nextValue#" + number + ".then");
return (r) => {
log.push("call nextValue#" + number + ".then");
r(value);
}
}
};
},
get done() {
log.push("get iterResult #" + number + ".done");
return done;
}
};
}
var results = [r("value1", false), r("value2", false), r("value3", true),
r("value4", false)];
var iter = {
get [Symbol.asyncIterator]() {
log.push("get syncIterable[@@asyncIterator]");
return null;
},
get [Symbol.iterator]() {
log.push("get syncIterable[@@iterator]");
return (...args) => {
log.push("call syncIterable[@@iterator](" + args.join(", ") + ")");
return this;
}
},
next_: 0,
get next() {
log.push("get syncIterable.next");
let i = this.next_++;
return (...args) => {
log.push("call syncIterable.next(" + args.join(", ") + ")");
return results[i];
}
}
};
async function iterate(iterable) {
log.push("before");
for await (let x of iterable) {
log.push("got value " + x);
}
log.push("after");
return log;
}
iterate(iter).then(log => {
assertEquals([
"before",
"get syncIterable[@@asyncIterator]",
"get syncIterable[@@iterator]",
"call syncIterable[@@iterator]()",
"get syncIterable.next",
"call syncIterable.next()",
"get iterResult #1.done",
"get iterResult #1.value",
"get nextValue#1.then",
"call nextValue#1.then",
"got value value1",
"get syncIterable.next",
"call syncIterable.next()",
"get iterResult #2.done",
"get iterResult #2.value",
"get nextValue#2.then",
"call nextValue#2.then",
"got value value2",
"get syncIterable.next",
"call syncIterable.next()",
"get iterResult #3.done",
"get iterResult #3.value",
"get nextValue#3.then",
"call nextValue#3.then",
"after"
], log)
}).catch(x => %AbortJS(String(x)));
})();
......@@ -451,6 +451,32 @@
'language/statements/class/async-gen-method-yield-star-async-return': [FAIL],
'language/statements/class/async-gen-method-yield-star-async-throw': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=6242
'language/expressions/async-generator/named-yield-star-sync-next': [FAIL],
'language/expressions/async-generator/named-yield-star-sync-return': [FAIL],
'language/expressions/async-generator/named-yield-star-sync-throw': [FAIL],
'language/expressions/async-generator/yield-star-sync-next': [FAIL],
'language/expressions/async-generator/yield-star-sync-return': [FAIL],
'language/expressions/async-generator/yield-star-sync-throw': [FAIL],
'language/expressions/class/async-gen-method-static-yield-star-sync-next': [FAIL],
'language/expressions/class/async-gen-method-static-yield-star-sync-return': [FAIL],
'language/expressions/class/async-gen-method-static-yield-star-sync-throw': [FAIL],
'language/expressions/class/async-gen-method-yield-star-sync-next': [FAIL],
'language/expressions/class/async-gen-method-yield-star-sync-return': [FAIL],
'language/expressions/class/async-gen-method-yield-star-sync-throw': [FAIL],
'language/expressions/object/method-definition/async-gen-yield-star-sync-next': [FAIL],
'language/expressions/object/method-definition/async-gen-yield-star-sync-return': [FAIL],
'language/expressions/object/method-definition/async-gen-yield-star-sync-throw': [FAIL],
'language/statements/async-generator/yield-star-sync-next': [FAIL],
'language/statements/async-generator/yield-star-sync-return': [FAIL],
'language/statements/async-generator/yield-star-sync-throw': [FAIL],
'language/statements/class/async-gen-method-static-yield-star-sync-next': [FAIL],
'language/statements/class/async-gen-method-static-yield-star-sync-return': [FAIL],
'language/statements/class/async-gen-method-static-yield-star-sync-throw': [FAIL],
'language/statements/class/async-gen-method-yield-star-sync-next': [FAIL],
'language/statements/class/async-gen-method-yield-star-sync-return': [FAIL],
'language/statements/class/async-gen-method-yield-star-sync-throw': [FAIL],
# SharedArrayBuffer tests that require flags
'built-ins/SharedArrayBuffer/*': ['--harmony-sharedarraybuffer'],
'built-ins/Atomics/*': ['--harmony-sharedarraybuffer'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment