Commit f3ca2142 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Speed up structural graph verification.

This removes the checking for use-def and def-use chain links from the
graph verification. Presence of such links can only be violated by a bug
in the actual {Node} implementation itself. That container class is also
covered by unit tests.

The verification in question was useful in the early days when the graph
implementation itself was prone to bugs. By now it has stabilized and
spending O(n^2) time during graph verification is too wasteful to still
be considered a reasonable trade-off.

R=jarin@chromium.org
TEST=unittests/NodeTest.*

Review-Url: https://codereview.chromium.org/2140973003
Cr-Commit-Position: refs/heads/master@{#37670}
parent 85969ede
......@@ -28,18 +28,6 @@ namespace internal {
namespace compiler {
static bool IsDefUseChainLinkPresent(Node* def, Node* use) {
const Node::Uses uses = def->uses();
return std::find(uses.begin(), uses.end(), use) != uses.end();
}
static bool IsUseDefChainLinkPresent(Node* def, Node* use) {
const Node::Inputs inputs = use->inputs();
return std::find(inputs.begin(), inputs.end(), def) != inputs.end();
}
class Verifier::Visitor {
public:
Visitor(Zone* z, Typing typed, CheckInputs check_inputs)
......@@ -129,16 +117,12 @@ void Verifier::Visitor::Check(Node* node) {
// kFrameState uses Start as a sentinel.
(node->opcode() == IrOpcode::kFrameState &&
frame_state->opcode() == IrOpcode::kStart));
CHECK(IsDefUseChainLinkPresent(frame_state, node));
CHECK(IsUseDefChainLinkPresent(frame_state, node));
}
// Verify all value inputs actually produce a value.
for (int i = 0; i < value_count; ++i) {
Node* value = NodeProperties::GetValueInput(node, i);
CheckOutput(value, node, value->op()->ValueOutputCount(), "value");
CHECK(IsDefUseChainLinkPresent(value, node));
CHECK(IsUseDefChainLinkPresent(value, node));
// Verify that only parameters and projections can have input nodes with
// multiple outputs.
CHECK(node->opcode() == IrOpcode::kParameter ||
......@@ -150,8 +134,6 @@ void Verifier::Visitor::Check(Node* node) {
for (int i = 0; i < context_count; ++i) {
Node* context = NodeProperties::GetContextInput(node);
CheckOutput(context, node, context->op()->ValueOutputCount(), "context");
CHECK(IsDefUseChainLinkPresent(context, node));
CHECK(IsUseDefChainLinkPresent(context, node));
}
if (check_inputs == kAll) {
......@@ -159,8 +141,6 @@ void Verifier::Visitor::Check(Node* node) {
for (int i = 0; i < effect_count; ++i) {
Node* effect = NodeProperties::GetEffectInput(node);
CheckOutput(effect, node, effect->op()->EffectOutputCount(), "effect");
CHECK(IsDefUseChainLinkPresent(effect, node));
CHECK(IsUseDefChainLinkPresent(effect, node));
}
// Verify all control inputs are control nodes.
......@@ -168,8 +148,6 @@ void Verifier::Visitor::Check(Node* node) {
Node* control = NodeProperties::GetControlInput(node, i);
CheckOutput(control, node, control->op()->ControlOutputCount(),
"control");
CHECK(IsDefUseChainLinkPresent(control, node));
CHECK(IsUseDefChainLinkPresent(control, node));
}
}
......
......@@ -94,9 +94,6 @@
'debug-set-variable-value': [PASS, NO_VARIANTS],
'es6/debug-evaluate-blockscopes': [PASS, NO_VARIANTS],
# TODO(titzer): too slow in --turbo mode due to O(n^2) graph verification.
'regress/regress-1122': [PASS, NO_VARIANTS],
# Assumptions about optimization need investigation in TurboFan.
'regress-sync-optimized-lists': [PASS, NO_VARIANTS],
......
......@@ -7,7 +7,9 @@
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
using testing::Contains;
using testing::ElementsAre;
using testing::ElementsAreArray;
using testing::UnorderedElementsAre;
namespace v8 {
......@@ -252,6 +254,10 @@ TEST_F(NodeTest, BigNodes) {
for (int i = 0; i < size; i++) {
EXPECT_EQ(inputs[i], node->InputAt(i));
}
EXPECT_THAT(n0->uses(), Contains(node));
EXPECT_THAT(n1->uses(), Contains(node));
EXPECT_THAT(node->inputs(), ElementsAreArray(inputs, size));
}
}
......
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