• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_VERIFIER_H_
6 #define V8_COMPILER_VERIFIER_H_
7 
8 #include "src/base/macros.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13 
14 class Graph;
15 class Edge;
16 class Node;
17 class Schedule;
18 
19 // Verifies properties of a graph, such as the well-formedness of inputs to
20 // each node, etc.
21 class Verifier {
22  public:
23   enum Typing { TYPED, UNTYPED };
24   enum CheckInputs { kValuesOnly, kAll };
25 
26   static void Run(Graph* graph, Typing typing = TYPED,
27                   CheckInputs check_inputs = kAll);
28 
29 #ifdef DEBUG
30   // Verifies consistency of node inputs and uses:
31   // - node inputs should agree with the input count computed from
32   //   the node's operator.
33   // - effect inputs should have effect outputs.
34   // - control inputs should have control outputs.
35   // - frame state inputs should be frame states.
36   // - if the node has control uses, it should produce control.
37   // - if the node has effect uses, it should produce effect.
38   // - if the node has frame state uses, it must be a frame state.
39   static void VerifyNode(Node* node);
40 
41   // Verify that {replacement} has the required outputs
42   // (effect, control or frame state) to be used as an input for {edge}.
43   static void VerifyEdgeInputReplacement(const Edge& edge,
44                                          const Node* replacement);
45 #else
VerifyNode(Node * node)46   static void VerifyNode(Node* node) {}
VerifyEdgeInputReplacement(const Edge & edge,const Node * replacement)47   static void VerifyEdgeInputReplacement(const Edge& edge,
48                                          const Node* replacement) {}
49 #endif  // DEBUG
50 
51  private:
52   class Visitor;
53   DISALLOW_COPY_AND_ASSIGN(Verifier);
54 };
55 
56 // Verifies properties of a schedule, such as dominance, phi placement, etc.
57 class ScheduleVerifier {
58  public:
59   static void Run(Schedule* schedule);
60 };
61 }  // namespace compiler
62 }  // namespace internal
63 }  // namespace v8
64 
65 #endif  // V8_COMPILER_VERIFIER_H_
66