typer.h 1.71 KB
Newer Older
1 2 3 4 5 6 7
// 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_

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

namespace v8 {
namespace internal {
14 15 16

class TickCounter;

17
namespace compiler {
18

19
// Forward declarations.
20
class LoopVariableOptimizer;
21

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

31 32
  Typer(JSHeapBroker* broker, Flags flags, Graph* graph,
        TickCounter* tick_counter);
33
  ~Typer();
34

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

 private:
  class Visitor;
42 43
  class Decorator;

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

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

58 59
  Type singleton_false_;
  Type singleton_true_;
60

61
  DISALLOW_COPY_AND_ASSIGN(Typer);
62
};
63

64
DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags)
65

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

#endif  // V8_COMPILER_TYPER_H_