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_TYPER_H_ |
| 6 | #define V8_COMPILER_TYPER_H_ |
| 7 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 8 | #include "src/base/flags.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | #include "src/compiler/graph.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 10 | #include "src/types.h" |
| 11 | |
| 12 | namespace v8 { |
| 13 | namespace internal { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 14 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 15 | // Forward declarations. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 16 | class CompilationDependencies; |
| 17 | class TypeCache; |
| 18 | |
| 19 | namespace compiler { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 20 | |
| 21 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 22 | class Typer { |
| 23 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 24 | // Flags that control the mode of operation. |
| 25 | enum Flag { |
| 26 | kNoFlags = 0u, |
| 27 | kDeoptimizationEnabled = 1u << 0, |
| 28 | }; |
| 29 | typedef base::Flags<Flag> Flags; |
| 30 | |
| 31 | Typer(Isolate* isolate, Graph* graph, Flags flags = kNoFlags, |
| 32 | CompilationDependencies* dependencies = nullptr, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 33 | FunctionType* function_type = nullptr); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 34 | ~Typer(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 35 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 36 | void Run(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 37 | // TODO(bmeurer,jarin): Remove this once we have a notion of "roots" on Graph. |
| 38 | void Run(const ZoneVector<Node*>& roots); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | class Visitor; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 42 | class Decorator; |
| 43 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 44 | Graph* graph() const { return graph_; } |
| 45 | Zone* zone() const { return graph()->zone(); } |
| 46 | Isolate* isolate() const { return isolate_; } |
| 47 | Flags flags() const { return flags_; } |
| 48 | CompilationDependencies* dependencies() const { return dependencies_; } |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 49 | FunctionType* function_type() const { return function_type_; } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 50 | |
| 51 | Isolate* const isolate_; |
| 52 | Graph* const graph_; |
| 53 | Flags const flags_; |
| 54 | CompilationDependencies* const dependencies_; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 55 | FunctionType* function_type_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 56 | Decorator* decorator_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 57 | TypeCache const& cache_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 58 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 59 | Type* singleton_false_; |
| 60 | Type* singleton_true_; |
| 61 | Type* singleton_the_hole_; |
| 62 | Type* signed32ish_; |
| 63 | Type* unsigned32ish_; |
| 64 | Type* falsish_; |
| 65 | Type* truish_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 66 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 67 | DISALLOW_COPY_AND_ASSIGN(Typer); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 68 | }; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 69 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 70 | DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags) |
| 71 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 72 | } // namespace compiler |
| 73 | } // namespace internal |
| 74 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 75 | |
| 76 | #endif // V8_COMPILER_TYPER_H_ |