[maglev] Drop values flowing into resumable loops

All IFS values of resumable loops are loop phis, so values from before
the loop can safely be dropped. In fact, if we don't drop them we might
not be able to restore them and crash in a safety check. Eagerly
dropping the values allows us to keep the safety check.

Bug: v8:7700
Change-Id: I99ef80e35db5aba965dc1c5c9d78f1d085e589fb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4110940
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84943}
This commit is contained in:
Toon Verwaest 2022-12-19 19:11:58 +01:00 committed by V8 LUCI CQ
parent 0621c2d553
commit ea1bac5386
2 changed files with 21 additions and 0 deletions

View File

@ -141,6 +141,10 @@ bool IsLiveAtTarget(ValueNode* node, ControlNode* source, BasicBlock* target) {
// Gap moves may already be inserted in the target, so skip over those.
return node->id() < target->FirstNonGapMoveId();
}
// Drop all values on resumable loop headers.
if (target->has_state() && target->state()->is_resumable_loop()) return false;
// TODO(verwaest): This should be true but isn't because we don't yet
// eliminate dead code.
// DCHECK_GT(node->next_use, source->id());

View File

@ -0,0 +1,17 @@
// Copyright 2022 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.
//
// Flags: --allow-natives-syntax --maglev
(function () {
async function foo() {
for (let i = 0; i == 1; i++) {
780109, { get: function() { } }; await 7;
}
}
%PrepareFunctionForOptimization(foo);
foo();
%OptimizeMaglevOnNextCall(foo);
foo();
})();