verifier.h 2.13 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_VERIFIER_H_
#define V8_COMPILER_VERIFIER_H_

8
#include "src/base/macros.h"
9
#include "src/common/globals.h"
10 11 12 13 14

namespace v8 {
namespace internal {
namespace compiler {

15
class Graph;
16 17
class Edge;
class Node;
18 19 20 21
class Schedule;

// Verifies properties of a graph, such as the well-formedness of inputs to
// each node, etc.
22 23
class Verifier {
 public:
24
  enum Typing { TYPED, UNTYPED };
25
  enum CheckInputs { kValuesOnly, kAll };
26
  enum CodeType { kDefault, kWasm };
27

28 29 30
  Verifier(const Verifier&) = delete;
  Verifier& operator=(const Verifier&) = delete;

31
  static void Run(Graph* graph, Typing typing = TYPED,
32 33
                  CheckInputs check_inputs = kAll,
                  CodeType code_type = kDefault);
34

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#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

57 58 59
 private:
  class Visitor;
};
60 61

// Verifies properties of a schedule, such as dominance, phi placement, etc.
62
class V8_EXPORT_PRIVATE ScheduleVerifier {
63 64 65
 public:
  static void Run(Schedule* schedule);
};
66 67 68
}  // namespace compiler
}  // namespace internal
}  // namespace v8
69 70

#endif  // V8_COMPILER_VERIFIER_H_