Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: src/compiler/verifier.cc

Issue 2140973003: [turbofan] Speed up structural graph verification. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/verifier.h" 5 #include "src/compiler/verifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <queue> 9 #include <queue>
10 #include <sstream> 10 #include <sstream>
(...skipping 10 matching lines...) Expand all
21 #include "src/compiler/operator-properties.h" 21 #include "src/compiler/operator-properties.h"
22 #include "src/compiler/schedule.h" 22 #include "src/compiler/schedule.h"
23 #include "src/compiler/simplified-operator.h" 23 #include "src/compiler/simplified-operator.h"
24 #include "src/ostreams.h" 24 #include "src/ostreams.h"
25 25
26 namespace v8 { 26 namespace v8 {
27 namespace internal { 27 namespace internal {
28 namespace compiler { 28 namespace compiler {
29 29
30 30
31 static bool IsDefUseChainLinkPresent(Node* def, Node* use) {
32 const Node::Uses uses = def->uses();
33 return std::find(uses.begin(), uses.end(), use) != uses.end();
34 }
35
36
37 static bool IsUseDefChainLinkPresent(Node* def, Node* use) {
38 const Node::Inputs inputs = use->inputs();
39 return std::find(inputs.begin(), inputs.end(), def) != inputs.end();
40 }
41
42
43 class Verifier::Visitor { 31 class Verifier::Visitor {
44 public: 32 public:
45 Visitor(Zone* z, Typing typed, CheckInputs check_inputs) 33 Visitor(Zone* z, Typing typed, CheckInputs check_inputs)
46 : zone(z), typing(typed), check_inputs(check_inputs) {} 34 : zone(z), typing(typed), check_inputs(check_inputs) {}
47 35
48 void Check(Node* node); 36 void Check(Node* node);
49 37
50 Zone* zone; 38 Zone* zone;
51 Typing typing; 39 Typing typing;
52 CheckInputs check_inputs; 40 CheckInputs check_inputs;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 110 }
123 CHECK_EQ(input_count, node->InputCount()); 111 CHECK_EQ(input_count, node->InputCount());
124 112
125 // Verify that frame state has been inserted for the nodes that need it. 113 // Verify that frame state has been inserted for the nodes that need it.
126 for (int i = 0; i < frame_state_count; i++) { 114 for (int i = 0; i < frame_state_count; i++) {
127 Node* frame_state = NodeProperties::GetFrameStateInput(node, i); 115 Node* frame_state = NodeProperties::GetFrameStateInput(node, i);
128 CHECK(frame_state->opcode() == IrOpcode::kFrameState || 116 CHECK(frame_state->opcode() == IrOpcode::kFrameState ||
129 // kFrameState uses Start as a sentinel. 117 // kFrameState uses Start as a sentinel.
130 (node->opcode() == IrOpcode::kFrameState && 118 (node->opcode() == IrOpcode::kFrameState &&
131 frame_state->opcode() == IrOpcode::kStart)); 119 frame_state->opcode() == IrOpcode::kStart));
132 CHECK(IsDefUseChainLinkPresent(frame_state, node));
133 CHECK(IsUseDefChainLinkPresent(frame_state, node));
134 } 120 }
135 121
136 // Verify all value inputs actually produce a value. 122 // Verify all value inputs actually produce a value.
137 for (int i = 0; i < value_count; ++i) { 123 for (int i = 0; i < value_count; ++i) {
138 Node* value = NodeProperties::GetValueInput(node, i); 124 Node* value = NodeProperties::GetValueInput(node, i);
139 CheckOutput(value, node, value->op()->ValueOutputCount(), "value"); 125 CheckOutput(value, node, value->op()->ValueOutputCount(), "value");
140 CHECK(IsDefUseChainLinkPresent(value, node));
141 CHECK(IsUseDefChainLinkPresent(value, node));
142 // Verify that only parameters and projections can have input nodes with 126 // Verify that only parameters and projections can have input nodes with
143 // multiple outputs. 127 // multiple outputs.
144 CHECK(node->opcode() == IrOpcode::kParameter || 128 CHECK(node->opcode() == IrOpcode::kParameter ||
145 node->opcode() == IrOpcode::kProjection || 129 node->opcode() == IrOpcode::kProjection ||
146 value->op()->ValueOutputCount() <= 1); 130 value->op()->ValueOutputCount() <= 1);
147 } 131 }
148 132
149 // Verify all context inputs are value nodes. 133 // Verify all context inputs are value nodes.
150 for (int i = 0; i < context_count; ++i) { 134 for (int i = 0; i < context_count; ++i) {
151 Node* context = NodeProperties::GetContextInput(node); 135 Node* context = NodeProperties::GetContextInput(node);
152 CheckOutput(context, node, context->op()->ValueOutputCount(), "context"); 136 CheckOutput(context, node, context->op()->ValueOutputCount(), "context");
153 CHECK(IsDefUseChainLinkPresent(context, node));
154 CHECK(IsUseDefChainLinkPresent(context, node));
155 } 137 }
156 138
157 if (check_inputs == kAll) { 139 if (check_inputs == kAll) {
158 // Verify all effect inputs actually have an effect. 140 // Verify all effect inputs actually have an effect.
159 for (int i = 0; i < effect_count; ++i) { 141 for (int i = 0; i < effect_count; ++i) {
160 Node* effect = NodeProperties::GetEffectInput(node); 142 Node* effect = NodeProperties::GetEffectInput(node);
161 CheckOutput(effect, node, effect->op()->EffectOutputCount(), "effect"); 143 CheckOutput(effect, node, effect->op()->EffectOutputCount(), "effect");
162 CHECK(IsDefUseChainLinkPresent(effect, node));
163 CHECK(IsUseDefChainLinkPresent(effect, node));
164 } 144 }
165 145
166 // Verify all control inputs are control nodes. 146 // Verify all control inputs are control nodes.
167 for (int i = 0; i < control_count; ++i) { 147 for (int i = 0; i < control_count; ++i) {
168 Node* control = NodeProperties::GetControlInput(node, i); 148 Node* control = NodeProperties::GetControlInput(node, i);
169 CheckOutput(control, node, control->op()->ControlOutputCount(), 149 CheckOutput(control, node, control->op()->ControlOutputCount(),
170 "control"); 150 "control");
171 CHECK(IsDefUseChainLinkPresent(control, node));
172 CHECK(IsUseDefChainLinkPresent(control, node));
173 } 151 }
174 } 152 }
175 153
176 switch (node->opcode()) { 154 switch (node->opcode()) {
177 case IrOpcode::kStart: 155 case IrOpcode::kStart:
178 // Start has no inputs. 156 // Start has no inputs.
179 CHECK_EQ(0, input_count); 157 CHECK_EQ(0, input_count);
180 // Type is a tuple. 158 // Type is a tuple.
181 // TODO(rossberg): Multiple outputs are currently typed as Internal. 159 // TODO(rossberg): Multiple outputs are currently typed as Internal.
182 CheckUpperIs(node, Type::Internal()); 160 CheckUpperIs(node, Type::Internal());
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 replacement->op()->EffectOutputCount() > 0); 1489 replacement->op()->EffectOutputCount() > 0);
1512 DCHECK(!NodeProperties::IsFrameStateEdge(edge) || 1490 DCHECK(!NodeProperties::IsFrameStateEdge(edge) ||
1513 replacement->opcode() == IrOpcode::kFrameState); 1491 replacement->opcode() == IrOpcode::kFrameState);
1514 } 1492 }
1515 1493
1516 #endif // DEBUG 1494 #endif // DEBUG
1517 1495
1518 } // namespace compiler 1496 } // namespace compiler
1519 } // namespace internal 1497 } // namespace internal
1520 } // namespace v8 1498 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698