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