Skip to content

Commit 349e4ee

Browse files
GeorgNeisCommit Bot
authored andcommitted
[turbofan] Make GraphAssembler branching respect typing
GraphAssembler creates Phi nodes and creates additional inputs to them depending on how many jumps go there. If the typer decorator is active, it will type the Phi node at creation time. GraphAssembler was not aware of types (until recently it was not used while the graph is typed) and did not update the Phi type with each new input. This CL fixes that. Bug: chromium:1082704 Change-Id: Id94bcda752c7b3dc836eb2b6c6b55b1690185a09 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2202978 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#67823}
1 parent 6771d3e commit 349e4ee

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/compiler/graph-assembler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ void GraphAssembler::MergeState(GraphAssemblerLabel<sizeof...(Vars)>* label,
582582
label->effect_->ReplaceInput(1, effect());
583583
for (size_t i = 0; i < kVarCount; i++) {
584584
label->bindings_[i]->ReplaceInput(1, var_array[i]);
585+
CHECK(!NodeProperties::IsTyped(var_array[i])); // Unsupported.
585586
}
586587
}
587588
} else {
@@ -625,6 +626,13 @@ void GraphAssembler::MergeState(GraphAssemblerLabel<sizeof...(Vars)>* label,
625626
NodeProperties::ChangeOp(
626627
label->bindings_[i],
627628
common()->Phi(label->representations_[i], merged_count + 1));
629+
if (NodeProperties::IsTyped(label->bindings_[i])) {
630+
CHECK(NodeProperties::IsTyped(var_array[i]));
631+
Type old_type = NodeProperties::GetType(label->bindings_[i]);
632+
Type new_type = Type::Union(
633+
old_type, NodeProperties::GetType(var_array[i]), graph()->zone());
634+
NodeProperties::SetType(label->bindings_[i], new_type);
635+
}
628636
}
629637
}
630638
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2020 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
var array = [[]];
8+
function foo() {
9+
const x = array[0];
10+
const y = [][0];
11+
return x == y;
12+
}
13+
%PrepareFunctionForOptimization(foo);
14+
assertFalse(foo());
15+
%OptimizeFunctionOnNextCall(foo);
16+
assertFalse(foo());

0 commit comments

Comments
 (0)