From f3ca2142221a1f29be4c43b1fd44840df1318df2 Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Tue, 12 Jul 2016 02:30:50 -0700 Subject: [PATCH] [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} --- src/compiler/verifier.cc | 22 ---------------------- test/mjsunit/mjsunit.status | 3 --- test/unittests/compiler/node-unittest.cc | 6 ++++++ 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/compiler/verifier.cc b/src/compiler/verifier.cc index 040537d99d..90f45e1fc2 100644 --- a/src/compiler/verifier.cc +++ b/src/compiler/verifier.cc @@ -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)); } } diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index 3b3fe9c498..d9319718d1 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -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], diff --git a/test/unittests/compiler/node-unittest.cc b/test/unittests/compiler/node-unittest.cc index 5341f69716..8379e2668d 100644 --- a/test/unittests/compiler/node-unittest.cc +++ b/test/unittests/compiler/node-unittest.cc @@ -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)); } }