• 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/common/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   enum CodeType { kDefault, kWasm };
27 
28   Verifier(const Verifier&) = delete;
29   Verifier& operator=(const Verifier&) = delete;
30 
31   static void Run(Graph* graph, Typing typing = TYPED,
32                   CheckInputs check_inputs = kAll,
33                   CodeType code_type = kDefault);
34 
35 #ifdef DEBUG
36   // Verifies consistency of node inputs and uses:
37   // - node inputs should agree with the input count computed from
38   //   the node's operator.
39   // - effect inputs should have effect outputs.
40   // - control inputs should have control outputs.
41   // - frame state inputs should be frame states.
42   // - if the node has control uses, it should produce control.
43   // - if the node has effect uses, it should produce effect.
44   // - if the node has frame state uses, it must be a frame state.
45   static void VerifyNode(Node* node);
46 
47   // Verify that {replacement} has the required outputs
48   // (effect, control or frame state) to be used as an input for {edge}.
49   static void VerifyEdgeInputReplacement(const Edge& edge,
50                                          const Node* replacement);
51 #else
VerifyNode(Node * node)52   static void VerifyNode(Node* node) {}
VerifyEdgeInputReplacement(const Edge & edge,const Node * replacement)53   static void VerifyEdgeInputReplacement(const Edge& edge,
54                                          const Node* replacement) {}
55 #endif  // DEBUG
56 
57  private:
58   class Visitor;
59 };
60 
61 // Verifies properties of a schedule, such as dominance, phi placement, etc.
62 class V8_EXPORT_PRIVATE ScheduleVerifier {
63  public:
64   static void Run(Schedule* schedule);
65 };
66 }  // namespace compiler
67 }  // namespace internal
68 }  // namespace v8
69 
70 #endif  // V8_COMPILER_VERIFIER_H_
71