typer.h 1.75 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
  Typer(const Typer&) = delete;
  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 40
  void Run(const ZoneVector<Node*>& roots,
           LoopVariableOptimizer* induction_vars);
41 42 43

 private:
  class Visitor;
44 45
  class Decorator;

46
  Flags flags() const { return flags_; }
47 48
  Graph* graph() const { return graph_; }
  Zone* zone() const { return graph()->zone(); }
49
  OperationTyper* operation_typer() { return &operation_typer_; }
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 61
  Type singleton_false_;
  Type singleton_true_;
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_