[turbofan] Restrict redundancy elimination from widening types
This CL prevents redundancy elimination from widening types, which can cause problems if the input of a DeadValue (which has type None) is replaced by an equivalent node that does not have type None. This can happen because load elimination does not re-type nodes, for example. Bug: chromium:919340 Change-Id: I89e872412edbcdc610e70ae160cde56cd045006c Reviewed-on: https://chromium-review.googlesource.com/c/1397709 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Cr-Commit-Position: refs/heads/master@{#58617}
This commit is contained in:
parent
9525443498
commit
5a9fa8f304
@ -200,11 +200,22 @@ bool CheckSubsumes(Node const* a, Node const* b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeSubsumes(Node* node, Node* replacement) {
|
||||
if (!NodeProperties::IsTyped(node) || !NodeProperties::IsTyped(replacement)) {
|
||||
// If either node is untyped, we are running during an untyped optimization
|
||||
// phase, and replacement is OK.
|
||||
return true;
|
||||
}
|
||||
Type node_type = NodeProperties::GetType(node);
|
||||
Type replacement_type = NodeProperties::GetType(replacement);
|
||||
return replacement_type.Is(node_type);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Node* RedundancyElimination::EffectPathChecks::LookupCheck(Node* node) const {
|
||||
for (Check const* check = head_; check != nullptr; check = check->next) {
|
||||
if (CheckSubsumes(check->node, node)) {
|
||||
if (CheckSubsumes(check->node, node) && TypeSubsumes(node, check->node)) {
|
||||
DCHECK(!check->node->IsDead());
|
||||
return check->node;
|
||||
}
|
||||
|
17
test/mjsunit/regress/regress-919340.js
Normal file
17
test/mjsunit/regress/regress-919340.js
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --allow-natives-syntax --opt
|
||||
|
||||
var E = 'Σ';
|
||||
var PI = 123;
|
||||
function f() {
|
||||
print(E = 2, /b/.test(E) || /b/.test(E = 2));
|
||||
((E = 3) * PI);
|
||||
}
|
||||
|
||||
f();
|
||||
f();
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f();
|
Loading…
Reference in New Issue
Block a user