blob: b6c5cb333cae56d50776baeadc6e8c1368e574c2 [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 Murdoch61f157c2016-09-16 13:49:30 +010010#include "src/compiler/operation-typer.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000011#include "src/types.h"
12
13namespace v8 {
14namespace internal {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000015
Emily Bernierd0a1eb72015-03-24 16:35:39 -040016// Forward declarations.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000017class CompilationDependencies;
18class TypeCache;
19
20namespace compiler {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040021
Ben Murdoch61f157c2016-09-16 13:49:30 +010022class OperationTyper;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040023
Ben Murdochb8a8cc12014-11-26 15:28:44 +000024class Typer {
25 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000026 // Flags that control the mode of operation.
27 enum Flag {
28 kNoFlags = 0u,
29 kDeoptimizationEnabled = 1u << 0,
30 };
31 typedef base::Flags<Flag> Flags;
32
33 Typer(Isolate* isolate, Graph* graph, Flags flags = kNoFlags,
34 CompilationDependencies* dependencies = nullptr,
Ben Murdoch097c5b22016-05-18 11:27:45 +010035 FunctionType* function_type = nullptr);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040036 ~Typer();
Ben Murdochb8a8cc12014-11-26 15:28:44 +000037
Emily Bernierd0a1eb72015-03-24 16:35:39 -040038 void Run();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000039 // TODO(bmeurer,jarin): Remove this once we have a notion of "roots" on Graph.
40 void Run(const ZoneVector<Node*>& roots);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000041
42 private:
43 class Visitor;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040044 class Decorator;
45
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000046 Graph* graph() const { return graph_; }
47 Zone* zone() const { return graph()->zone(); }
48 Isolate* isolate() const { return isolate_; }
49 Flags flags() const { return flags_; }
50 CompilationDependencies* dependencies() const { return dependencies_; }
Ben Murdoch097c5b22016-05-18 11:27:45 +010051 FunctionType* function_type() const { return function_type_; }
Ben Murdoch61f157c2016-09-16 13:49:30 +010052 OperationTyper* operation_typer() { return &operation_typer_; }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000053
54 Isolate* const isolate_;
55 Graph* const graph_;
56 Flags const flags_;
57 CompilationDependencies* const dependencies_;
Ben Murdoch097c5b22016-05-18 11:27:45 +010058 FunctionType* function_type_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040059 Decorator* decorator_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000060 TypeCache const& cache_;
Ben Murdoch61f157c2016-09-16 13:49:30 +010061 OperationTyper operation_typer_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000062
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000063 Type* singleton_false_;
64 Type* singleton_true_;
65 Type* singleton_the_hole_;
66 Type* signed32ish_;
67 Type* unsigned32ish_;
68 Type* falsish_;
69 Type* truish_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040070
Emily Bernierd0a1eb72015-03-24 16:35:39 -040071 DISALLOW_COPY_AND_ASSIGN(Typer);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000072};
Emily Bernierd0a1eb72015-03-24 16:35:39 -040073
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000074DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags)
75
Emily Bernierd0a1eb72015-03-24 16:35:39 -040076} // namespace compiler
77} // namespace internal
78} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000079
80#endif // V8_COMPILER_TYPER_H_