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 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 CheckInputsDominate(schedule, block, control, | 1147 CheckInputsDominate(schedule, block, control, |
1148 static_cast<int>(block->NodeCount()) - 1); | 1148 static_cast<int>(block->NodeCount()) - 1); |
1149 } | 1149 } |
1150 // Check inputs for all nodes in the block. | 1150 // Check inputs for all nodes in the block. |
1151 for (size_t i = 0; i < block->NodeCount(); i++) { | 1151 for (size_t i = 0; i < block->NodeCount(); i++) { |
1152 Node* node = block->NodeAt(i); | 1152 Node* node = block->NodeAt(i); |
1153 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); | 1153 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); |
1154 } | 1154 } |
1155 } | 1155 } |
1156 } | 1156 } |
| 1157 |
| 1158 |
| 1159 #ifdef DEBUG |
| 1160 |
| 1161 // static |
| 1162 void Verifier::VerifyNode(Node* node) { |
| 1163 CHECK_EQ(OperatorProperties::GetTotalInputCount(node->op()), |
| 1164 node->InputCount()); |
| 1165 // If this node has no effect or no control outputs, |
| 1166 // we check that no its uses are effect or control inputs. |
| 1167 bool check_no_control = node->op()->ControlOutputCount() == 0; |
| 1168 bool check_no_effect = node->op()->EffectOutputCount() == 0; |
| 1169 bool check_no_frame_state = node->opcode() != IrOpcode::kFrameState; |
| 1170 if (check_no_effect || check_no_control) { |
| 1171 for (Edge edge : node->use_edges()) { |
| 1172 Node* const user = edge.from(); |
| 1173 CHECK(!user->IsDead()); |
| 1174 if (NodeProperties::IsControlEdge(edge)) { |
| 1175 CHECK(!check_no_control); |
| 1176 } else if (NodeProperties::IsEffectEdge(edge)) { |
| 1177 CHECK(!check_no_effect); |
| 1178 } else if (NodeProperties::IsFrameStateEdge(edge)) { |
| 1179 CHECK(!check_no_frame_state); |
| 1180 } |
| 1181 } |
| 1182 } |
| 1183 // Frame state inputs should be frame states (or sentinels). |
| 1184 for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(node->op()); |
| 1185 i++) { |
| 1186 Node* input = NodeProperties::GetFrameStateInput(node, i); |
| 1187 CHECK(input->opcode() == IrOpcode::kFrameState || |
| 1188 input->opcode() == IrOpcode::kStart || |
| 1189 input->opcode() == IrOpcode::kDead); |
| 1190 } |
| 1191 // Effect inputs should be effect-producing nodes (or sentinels). |
| 1192 for (int i = 0; i < node->op()->EffectInputCount(); i++) { |
| 1193 Node* input = NodeProperties::GetEffectInput(node, i); |
| 1194 CHECK(input->op()->EffectOutputCount() > 0 || |
| 1195 input->opcode() == IrOpcode::kDead); |
| 1196 } |
| 1197 // Control inputs should be control-producing nodes (or sentinels). |
| 1198 for (int i = 0; i < node->op()->ControlInputCount(); i++) { |
| 1199 Node* input = NodeProperties::GetControlInput(node, i); |
| 1200 CHECK(input->op()->ControlOutputCount() > 0 || |
| 1201 input->opcode() == IrOpcode::kDead); |
| 1202 } |
| 1203 } |
| 1204 |
| 1205 |
| 1206 void Verifier::VerifyEdgeInputReplacement(const Edge& edge, |
| 1207 const Node* replacement) { |
| 1208 // Check that the user does not misuse the replacement. |
| 1209 DCHECK(!NodeProperties::IsControlEdge(edge) || |
| 1210 replacement->op()->ControlOutputCount() > 0); |
| 1211 DCHECK(!NodeProperties::IsEffectEdge(edge) || |
| 1212 replacement->op()->EffectOutputCount() > 0); |
| 1213 DCHECK(!NodeProperties::IsFrameStateEdge(edge) || |
| 1214 replacement->opcode() == IrOpcode::kFrameState); |
| 1215 } |
| 1216 |
| 1217 #endif // DEBUG |
| 1218 |
1157 } // namespace compiler | 1219 } // namespace compiler |
1158 } // namespace internal | 1220 } // namespace internal |
1159 } // namespace v8 | 1221 } // namespace v8 |
OLD | NEW |