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