#include "src/compiler/graph-reducer.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
+#include "src/compiler/verifier.h"
namespace v8 {
namespace internal {
}
-namespace {
-
-
-void VerifyUseReplacement(const Edge& edge, const Node* replacement) {
- // Check that the user does not misuse the replacement.
- DCHECK(!NodeProperties::IsControlEdge(edge) ||
- replacement->op()->ControlOutputCount() > 0);
- DCHECK(!NodeProperties::IsEffectEdge(edge) ||
- replacement->op()->EffectOutputCount() > 0);
- DCHECK(!NodeProperties::IsFrameStateEdge(edge) ||
- replacement->opcode() == IrOpcode::kFrameState);
-}
-
-} // namespace
-
-
void GraphReducer::Replace(Node* node, Node* replacement, NodeId max_id) {
if (node == graph()->start()) graph()->SetStart(replacement);
if (node == graph()->end()) graph()->SetEnd(replacement);
// {replacement} was already reduced and finish.
for (Edge edge : node->use_edges()) {
Node* const user = edge.from();
- VerifyUseReplacement(edge, replacement);
+ Verifier::VerifyEdgeInputReplacement(edge, replacement);
edge.UpdateTo(replacement);
// Don't revisit this node if it refers to itself.
if (user != node) Revisit(user);
#include "src/base/bits.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
+#include "src/compiler/verifier.h"
namespace v8 {
namespace internal {
Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs,
bool incomplete) {
Node* node = NewNodeUnchecked(op, input_count, inputs, incomplete);
-#ifdef DEBUG
- NodeProperties::Verify(node);
-#endif // DEBUG
+ Verifier::VerifyNode(node);
return node;
}
#include "src/compiler/graph.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h"
+#include "src/compiler/verifier.h"
namespace v8 {
namespace internal {
// static
void NodeProperties::ChangeOp(Node* node, const Operator* new_op) {
node->set_op(new_op);
-
-#ifdef DEBUG
- Verify(node);
-#endif // DEBUG
+ Verifier::VerifyNode(node);
}
}
-// static
-void NodeProperties::Verify(Node* node) {
- CHECK_EQ(OperatorProperties::GetTotalInputCount(node->op()),
- node->InputCount());
- // If this node has no effect or no control outputs,
- // we check that no its uses are effect or control inputs.
- bool check_no_control = node->op()->ControlOutputCount() == 0;
- bool check_no_effect = node->op()->EffectOutputCount() == 0;
- bool check_no_frame_state = node->opcode() != IrOpcode::kFrameState;
- if (check_no_effect || check_no_control) {
- for (Edge edge : node->use_edges()) {
- Node* const user = edge.from();
- CHECK(!user->IsDead());
- if (NodeProperties::IsControlEdge(edge)) {
- CHECK(!check_no_control);
- } else if (NodeProperties::IsEffectEdge(edge)) {
- CHECK(!check_no_effect);
- } else if (NodeProperties::IsFrameStateEdge(edge)) {
- CHECK(!check_no_frame_state);
- }
- }
- }
- // Frame state inputs should be frame states (or sentinels).
- for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(node->op());
- i++) {
- Node* input = NodeProperties::GetFrameStateInput(node, i);
- CHECK(input->opcode() == IrOpcode::kFrameState ||
- input->opcode() == IrOpcode::kStart ||
- input->opcode() == IrOpcode::kDead);
- }
- // Effect inputs should be effect-producing nodes (or sentinels).
- for (int i = 0; i < node->op()->EffectInputCount(); i++) {
- Node* input = NodeProperties::GetEffectInput(node, i);
- CHECK(input->op()->EffectOutputCount() > 0 ||
- input->opcode() == IrOpcode::kDead);
- }
- // Control inputs should be control-producing nodes (or sentinels).
- for (int i = 0; i < node->op()->ControlInputCount(); i++) {
- Node* input = NodeProperties::GetControlInput(node, i);
- CHECK(input->op()->ControlOutputCount() > 0 ||
- input->opcode() == IrOpcode::kDead);
- }
-}
-
-
// static
bool NodeProperties::AllValueInputsAreTyped(Node* node) {
int input_count = node->op()->ValueInputCount();
// - Switch: [ IfValue, ..., IfDefault ]
static void CollectControlProjections(Node* node, Node** proj, size_t count);
- // Verifies consistency of node inputs and uses:
- // - node inputs should agree with the input count computed from
- // the node's operator.
- // - effect inputs should have effect outputs.
- // - control inputs should have control outputs.
- // - frame state inputs should be frame states.
- // - if the node has control uses, it should produce control.
- // - if the node has effect uses, it should produce effect.
- // - if the node has frame state uses, it must be a frame state.
- static void Verify(Node* node);
-
// ---------------------------------------------------------------------------
// Type.
}
}
}
+
+
+#ifdef DEBUG
+
+// static
+void Verifier::VerifyNode(Node* node) {
+ CHECK_EQ(OperatorProperties::GetTotalInputCount(node->op()),
+ node->InputCount());
+ // If this node has no effect or no control outputs,
+ // we check that no its uses are effect or control inputs.
+ bool check_no_control = node->op()->ControlOutputCount() == 0;
+ bool check_no_effect = node->op()->EffectOutputCount() == 0;
+ bool check_no_frame_state = node->opcode() != IrOpcode::kFrameState;
+ if (check_no_effect || check_no_control) {
+ for (Edge edge : node->use_edges()) {
+ Node* const user = edge.from();
+ CHECK(!user->IsDead());
+ if (NodeProperties::IsControlEdge(edge)) {
+ CHECK(!check_no_control);
+ } else if (NodeProperties::IsEffectEdge(edge)) {
+ CHECK(!check_no_effect);
+ } else if (NodeProperties::IsFrameStateEdge(edge)) {
+ CHECK(!check_no_frame_state);
+ }
+ }
+ }
+ // Frame state inputs should be frame states (or sentinels).
+ for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(node->op());
+ i++) {
+ Node* input = NodeProperties::GetFrameStateInput(node, i);
+ CHECK(input->opcode() == IrOpcode::kFrameState ||
+ input->opcode() == IrOpcode::kStart ||
+ input->opcode() == IrOpcode::kDead);
+ }
+ // Effect inputs should be effect-producing nodes (or sentinels).
+ for (int i = 0; i < node->op()->EffectInputCount(); i++) {
+ Node* input = NodeProperties::GetEffectInput(node, i);
+ CHECK(input->op()->EffectOutputCount() > 0 ||
+ input->opcode() == IrOpcode::kDead);
+ }
+ // Control inputs should be control-producing nodes (or sentinels).
+ for (int i = 0; i < node->op()->ControlInputCount(); i++) {
+ Node* input = NodeProperties::GetControlInput(node, i);
+ CHECK(input->op()->ControlOutputCount() > 0 ||
+ input->opcode() == IrOpcode::kDead);
+ }
+}
+
+
+void Verifier::VerifyEdgeInputReplacement(const Edge& edge,
+ const Node* replacement) {
+ // Check that the user does not misuse the replacement.
+ DCHECK(!NodeProperties::IsControlEdge(edge) ||
+ replacement->op()->ControlOutputCount() > 0);
+ DCHECK(!NodeProperties::IsEffectEdge(edge) ||
+ replacement->op()->EffectOutputCount() > 0);
+ DCHECK(!NodeProperties::IsFrameStateEdge(edge) ||
+ replacement->opcode() == IrOpcode::kFrameState);
+}
+
+#endif // DEBUG
+
} // namespace compiler
} // namespace internal
} // namespace v8
namespace compiler {
class Graph;
+class Edge;
+class Node;
class Schedule;
// Verifies properties of a graph, such as the well-formedness of inputs to
static void Run(Graph* graph, Typing typing = TYPED);
+#ifdef DEBUG
+ // Verifies consistency of node inputs and uses:
+ // - node inputs should agree with the input count computed from
+ // the node's operator.
+ // - effect inputs should have effect outputs.
+ // - control inputs should have control outputs.
+ // - frame state inputs should be frame states.
+ // - if the node has control uses, it should produce control.
+ // - if the node has effect uses, it should produce effect.
+ // - if the node has frame state uses, it must be a frame state.
+ static void VerifyNode(Node* node);
+
+ // Verify that {replacement} has the required outputs
+ // (effect, control or frame state) to be used as an input for {edge}.
+ static void VerifyEdgeInputReplacement(const Edge& edge,
+ const Node* replacement);
+#else
+ static void VerifyNode(Node* node) {}
+ static void VerifyEdgeInputReplacement(const Edge& edge,
+ const Node* replacement) {}
+#endif // DEBUG
+
private:
class Visitor;
DISALLOW_COPY_AND_ASSIGN(Verifier);