• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #include "src/common/globals.h"
9 #include "src/compiler/graph.h"
10 #include "src/compiler/operation-typer.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 class TickCounter;
16 
17 namespace compiler {
18 
19 // Forward declarations.
20 class LoopVariableOptimizer;
21 
22 class V8_EXPORT_PRIVATE Typer {
23  public:
24   enum Flag : uint8_t {
25     kNoFlags = 0,
26     kThisIsReceiver = 1u << 0,       // Parameter this is an Object.
27     kNewTargetIsReceiver = 1u << 1,  // Parameter new.target is an Object.
28   };
29   using Flags = base::Flags<Flag>;
30 
31   Typer(JSHeapBroker* broker, Flags flags, Graph* graph,
32         TickCounter* tick_counter);
33   ~Typer();
34   Typer(const Typer&) = delete;
35   Typer& operator=(const Typer&) = delete;
36 
37   void Run();
38   // TODO(bmeurer,jarin): Remove this once we have a notion of "roots" on Graph.
39   void Run(const ZoneVector<Node*>& roots,
40            LoopVariableOptimizer* induction_vars);
41 
42  private:
43   class Visitor;
44   class Decorator;
45 
flags()46   Flags flags() const { return flags_; }
graph()47   Graph* graph() const { return graph_; }
zone()48   Zone* zone() const { return graph()->zone(); }
operation_typer()49   OperationTyper* operation_typer() { return &operation_typer_; }
broker()50   JSHeapBroker* broker() const { return broker_; }
51 
52   Flags const flags_;
53   Graph* const graph_;
54   Decorator* decorator_;
55   TypeCache const* cache_;
56   JSHeapBroker* broker_;
57   OperationTyper operation_typer_;
58   TickCounter* const tick_counter_;
59 
60   Type singleton_false_;
61   Type singleton_true_;
62 };
63 
64 DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags)
65 
66 }  // namespace compiler
67 }  // namespace internal
68 }  // namespace v8
69 
70 #endif  // V8_COMPILER_TYPER_H_
71