OLD | NEW |
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 std::ostringstream str; | 91 std::ostringstream str; |
92 str << "TypeError: node #" << node->id() << ":" << *node->op() | 92 str << "TypeError: node #" << node->id() << ":" << *node->op() |
93 << "(input @" << i << " = " << input->opcode() << ":" | 93 << "(input @" << i << " = " << input->opcode() << ":" |
94 << input->op()->mnemonic() << ") upper bound "; | 94 << input->op()->mnemonic() << ") upper bound "; |
95 bounds(input).upper->PrintTo(str); | 95 bounds(input).upper->PrintTo(str); |
96 str << " is not "; | 96 str << " is not "; |
97 type->PrintTo(str); | 97 type->PrintTo(str); |
98 FATAL(str.str().c_str()); | 98 FATAL(str.str().c_str()); |
99 } | 99 } |
100 } | 100 } |
| 101 void CheckOutput(Node* node, Node* use, int count, const char* kind) { |
| 102 if (count <= 0) { |
| 103 std::ostringstream str; |
| 104 str << "GraphError: node #" << node->id() << ":" << *node->op() |
| 105 << " does not produce " << kind << " output used by node #" |
| 106 << use->id() << ":" << *use->op(); |
| 107 FATAL(str.str().c_str()); |
| 108 } |
| 109 } |
101 }; | 110 }; |
102 | 111 |
103 | 112 |
104 void Verifier::Visitor::Check(Node* node) { | 113 void Verifier::Visitor::Check(Node* node) { |
105 int value_count = node->op()->ValueInputCount(); | 114 int value_count = node->op()->ValueInputCount(); |
106 int context_count = OperatorProperties::GetContextInputCount(node->op()); | 115 int context_count = OperatorProperties::GetContextInputCount(node->op()); |
107 int frame_state_count = | 116 int frame_state_count = |
108 OperatorProperties::GetFrameStateInputCount(node->op()); | 117 OperatorProperties::GetFrameStateInputCount(node->op()); |
109 int effect_count = node->op()->EffectInputCount(); | 118 int effect_count = node->op()->EffectInputCount(); |
110 int control_count = node->op()->ControlInputCount(); | 119 int control_count = node->op()->ControlInputCount(); |
(...skipping 10 matching lines...) Expand all Loading... |
121 // kFrameState uses Start as a sentinel. | 130 // kFrameState uses Start as a sentinel. |
122 (node->opcode() == IrOpcode::kFrameState && | 131 (node->opcode() == IrOpcode::kFrameState && |
123 frame_state->opcode() == IrOpcode::kStart)); | 132 frame_state->opcode() == IrOpcode::kStart)); |
124 CHECK(IsDefUseChainLinkPresent(frame_state, node)); | 133 CHECK(IsDefUseChainLinkPresent(frame_state, node)); |
125 CHECK(IsUseDefChainLinkPresent(frame_state, node)); | 134 CHECK(IsUseDefChainLinkPresent(frame_state, node)); |
126 } | 135 } |
127 | 136 |
128 // Verify all value inputs actually produce a value. | 137 // Verify all value inputs actually produce a value. |
129 for (int i = 0; i < value_count; ++i) { | 138 for (int i = 0; i < value_count; ++i) { |
130 Node* value = NodeProperties::GetValueInput(node, i); | 139 Node* value = NodeProperties::GetValueInput(node, i); |
131 CHECK(value->op()->ValueOutputCount() > 0); | 140 CheckOutput(value, node, value->op()->ValueOutputCount(), "value"); |
132 CHECK(IsDefUseChainLinkPresent(value, node)); | 141 CHECK(IsDefUseChainLinkPresent(value, node)); |
133 CHECK(IsUseDefChainLinkPresent(value, node)); | 142 CHECK(IsUseDefChainLinkPresent(value, node)); |
134 } | 143 } |
135 | 144 |
136 // Verify all context inputs are value nodes. | 145 // Verify all context inputs are value nodes. |
137 for (int i = 0; i < context_count; ++i) { | 146 for (int i = 0; i < context_count; ++i) { |
138 Node* context = NodeProperties::GetContextInput(node); | 147 Node* context = NodeProperties::GetContextInput(node); |
139 CHECK(context->op()->ValueOutputCount() > 0); | 148 CheckOutput(context, node, context->op()->ValueOutputCount(), "context"); |
140 CHECK(IsDefUseChainLinkPresent(context, node)); | 149 CHECK(IsDefUseChainLinkPresent(context, node)); |
141 CHECK(IsUseDefChainLinkPresent(context, node)); | 150 CHECK(IsUseDefChainLinkPresent(context, node)); |
142 } | 151 } |
143 | 152 |
144 // Verify all effect inputs actually have an effect. | 153 // Verify all effect inputs actually have an effect. |
145 for (int i = 0; i < effect_count; ++i) { | 154 for (int i = 0; i < effect_count; ++i) { |
146 Node* effect = NodeProperties::GetEffectInput(node); | 155 Node* effect = NodeProperties::GetEffectInput(node); |
147 CHECK(effect->op()->EffectOutputCount() > 0); | 156 CheckOutput(effect, node, effect->op()->EffectOutputCount(), "effect"); |
148 CHECK(IsDefUseChainLinkPresent(effect, node)); | 157 CHECK(IsDefUseChainLinkPresent(effect, node)); |
149 CHECK(IsUseDefChainLinkPresent(effect, node)); | 158 CHECK(IsUseDefChainLinkPresent(effect, node)); |
150 } | 159 } |
151 | 160 |
152 // Verify all control inputs are control nodes. | 161 // Verify all control inputs are control nodes. |
153 for (int i = 0; i < control_count; ++i) { | 162 for (int i = 0; i < control_count; ++i) { |
154 Node* control = NodeProperties::GetControlInput(node, i); | 163 Node* control = NodeProperties::GetControlInput(node, i); |
155 CHECK(control->op()->ControlOutputCount() > 0); | 164 CheckOutput(control, node, control->op()->ControlOutputCount(), "control"); |
156 CHECK(IsDefUseChainLinkPresent(control, node)); | 165 CHECK(IsDefUseChainLinkPresent(control, node)); |
157 CHECK(IsUseDefChainLinkPresent(control, node)); | 166 CHECK(IsUseDefChainLinkPresent(control, node)); |
158 } | 167 } |
159 | 168 |
160 // Verify all successors are projections if multiple value outputs exist. | 169 // Verify all successors are projections if multiple value outputs exist. |
161 if (node->op()->ValueOutputCount() > 1) { | 170 if (node->op()->ValueOutputCount() > 1) { |
162 for (Edge edge : node->use_edges()) { | 171 for (Edge edge : node->use_edges()) { |
163 Node* use = edge.from(); | 172 Node* use = edge.from(); |
164 CHECK(!NodeProperties::IsValueEdge(edge) || | 173 CHECK(!NodeProperties::IsValueEdge(edge) || |
165 use->opcode() == IrOpcode::kProjection || | 174 use->opcode() == IrOpcode::kProjection || |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 // Check inputs for all nodes in the block. | 1126 // Check inputs for all nodes in the block. |
1118 for (size_t i = 0; i < block->NodeCount(); i++) { | 1127 for (size_t i = 0; i < block->NodeCount(); i++) { |
1119 Node* node = block->NodeAt(i); | 1128 Node* node = block->NodeAt(i); |
1120 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); | 1129 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); |
1121 } | 1130 } |
1122 } | 1131 } |
1123 } | 1132 } |
1124 } // namespace compiler | 1133 } // namespace compiler |
1125 } // namespace internal | 1134 } // namespace internal |
1126 } // namespace v8 | 1135 } // namespace v8 |
OLD | NEW |