typer.h 1.72 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_TYPER_H_
#define V8_COMPILER_TYPER_H_

#include "src/compiler/graph.h"
9
#include "src/compiler/operation-typer.h"
10 11 12

namespace v8 {
namespace internal {
13 14 15

class TickCounter;

16
namespace compiler {
17

18
// Forward declarations.
19
class LoopVariableOptimizer;
20

21
class V8_EXPORT_PRIVATE Typer {
22
 public:
23 24 25 26 27
  enum Flag : uint8_t {
    kNoFlags = 0,
    kThisIsReceiver = 1u << 0,       // Parameter this is an Object.
    kNewTargetIsReceiver = 1u << 1,  // Parameter new.target is an Object.
  };
28
  using Flags = base::Flags<Flag>;
29

30 31
  Typer(JSHeapBroker* broker, Flags flags, Graph* graph,
        TickCounter* tick_counter);
32
  ~Typer();
33 34
  Typer(const Typer&) = delete;
  Typer& operator=(const Typer&) = delete;
35

36
  void Run();
37
  // TODO(bmeurer,jarin): Remove this once we have a notion of "roots" on Graph.
38 39
  void Run(const ZoneVector<Node*>& roots,
           LoopVariableOptimizer* induction_vars);
40 41 42

 private:
  class Visitor;
43 44
  class Decorator;

45
  Flags flags() const { return flags_; }
46 47
  Graph* graph() const { return graph_; }
  Zone* zone() const { return graph()->zone(); }
48
  OperationTyper* operation_typer() { return &operation_typer_; }
49
  JSHeapBroker* broker() const { return broker_; }
50

51
  Flags const flags_;
52
  Graph* const graph_;
53
  Decorator* decorator_;
54
  TypeCache const* cache_;
55
  JSHeapBroker* broker_;
56
  OperationTyper operation_typer_;
57
  TickCounter* const tick_counter_;
58

59 60
  Type singleton_false_;
  Type singleton_true_;
61
};
62

63
DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags)
64

65 66 67
}  // namespace compiler
}  // namespace internal
}  // namespace v8
68 69

#endif  // V8_COMPILER_TYPER_H_