[async] Fix bug with await in for 'next' position.

While removing dead code, v8 currently removes jump targets, but leaves
suspend points, resulting in bytecode analysis issues. This cl simply
removes the suspend point if the remainder of the block is dead.

Bug: v8:9825
Change-Id: Ib147ca01cf64c695c0316017852d61f52fd10cf4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1849197
Commit-Queue: Joshua Litt <joshualitt@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64223}
This commit is contained in:
Joshua Litt 2019-10-10 10:22:06 -07:00 committed by Commit Bot
parent c30740de7c
commit f796f861e6
3 changed files with 17 additions and 29 deletions

View File

@ -4010,6 +4010,12 @@ void BytecodeGenerator::VisitCompoundAssignment(CompoundAssignment* expr) {
// in the accumulator. When the generator is resumed, the sent value is loaded
// in the accumulator.
void BytecodeGenerator::BuildSuspendPoint(int position) {
// Because we eliminate jump targets in dead code, we also eliminate resumes
// when the suspend is not emitted because otherwise the below call to Bind
// would start a new basic block and the code would be considered alive.
if (builder()->RemainderOfBlockIsDead()) {
return;
}
const int suspend_id = suspend_count_++;
RegisterList registers = register_allocator()->AllLiveRegisters();

View File

@ -0,0 +1,11 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
async function foo() {
for (;;await[]) {
break;
}
}
foo();

View File

@ -722,33 +722,4 @@
'*': [SKIP],
}], # variant == jitless and not embedded_builtins
##############################################################################
['variant == stress', {
# https://bugs.chromium.org/p/v8/issues/detail?id=9817
'language/module-code/top-level-await/syntax/for-await-await-expr-array-literal': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-func-expression': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-literal-string': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-identifier': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-literal-number': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-null': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-nested': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-obj-literal': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-regexp': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-new-expr': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-this': [SKIP],
'language/module-code/top-level-await/syntax/for-await-await-expr-template-literal': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-array-literal': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-func-expression': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-literal-string': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-identifier': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-literal-number': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-null': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-nested': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-obj-literal': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-regexp': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-new-expr': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-this': [SKIP],
'language/module-code/top-level-await/syntax/for-await-expr-template-literal': [SKIP],
}], # variant == stress
]