blob: 41770266c813ba83d0fa261d94e3e9186b21420a [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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 Murdoch4a90d5f2016-03-22 12:00:34 +00008#include "src/base/flags.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +00009#include "src/compiler/graph.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000010#include "src/types.h"
11
12namespace v8 {
13namespace internal {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000014
Emily Bernierd0a1eb72015-03-24 16:35:39 -040015// Forward declarations.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000016class CompilationDependencies;
17class TypeCache;
18
19namespace compiler {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040020
21
Ben Murdochb8a8cc12014-11-26 15:28:44 +000022class Typer {
23 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000024 // 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,
33 Type::FunctionType* function_type = nullptr);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040034 ~Typer();
Ben Murdochb8a8cc12014-11-26 15:28:44 +000035
Emily Bernierd0a1eb72015-03-24 16:35:39 -040036 void Run();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000037 // TODO(bmeurer,jarin): Remove this once we have a notion of "roots" on Graph.
38 void Run(const ZoneVector<Node*>& roots);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000039
40 private:
41 class Visitor;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040042 class Decorator;
43
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000044 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_; }
49 Type::FunctionType* function_type() const { return function_type_; }
50
51 Isolate* const isolate_;
52 Graph* const graph_;
53 Flags const flags_;
54 CompilationDependencies* const dependencies_;
55 Type::FunctionType* function_type_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040056 Decorator* decorator_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000057 TypeCache const& cache_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000058
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000059 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 Bernierd0a1eb72015-03-24 16:35:39 -040066
Emily Bernierd0a1eb72015-03-24 16:35:39 -040067 DISALLOW_COPY_AND_ASSIGN(Typer);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000068};
Emily Bernierd0a1eb72015-03-24 16:35:39 -040069
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000070DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags)
71
Emily Bernierd0a1eb72015-03-24 16:35:39 -040072} // namespace compiler
73} // namespace internal
74} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000075
76#endif // V8_COMPILER_TYPER_H_