Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 8 | #include "src/base/macros.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | namespace compiler { |
| 13 | |
| 14 | class Graph; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 15 | class Edge; |
| 16 | class Node; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 23 | enum Typing { TYPED, UNTYPED }; |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 24 | enum CheckInputs { kValuesOnly, kAll }; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 25 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 26 | static void Run(Graph* graph, Typing typing = TYPED, |
| 27 | CheckInputs check_inputs = kAll); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 28 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 |
| 46 | static void VerifyNode(Node* node) {} |
| 47 | static void VerifyEdgeInputReplacement(const Edge& edge, |
| 48 | const Node* replacement) {} |
| 49 | #endif // DEBUG |
| 50 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 61 | } // namespace compiler |
| 62 | } // namespace internal |
| 63 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 64 | |
| 65 | #endif // V8_COMPILER_VERIFIER_H_ |