typer.h 1.62 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
#include "src/globals.h"
11 12 13

namespace v8 {
namespace internal {
14
namespace compiler {
15

16
// Forward declarations.
17
class LoopVariableOptimizer;
18

19
class V8_EXPORT_PRIVATE Typer {
20
 public:
21 22 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.
  };
  typedef base::Flags<Flag> Flags;

28
  Typer(JSHeapBroker* broker, Flags flags, Graph* graph);
29
  ~Typer();
30

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

 private:
  class Visitor;
38 39
  class Decorator;

40
  Flags flags() const { return flags_; }
41 42
  Graph* graph() const { return graph_; }
  Zone* zone() const { return graph()->zone(); }
43
  OperationTyper* operation_typer() { return &operation_typer_; }
44
  JSHeapBroker* broker() const { return broker_; }
45

46
  Flags const flags_;
47
  Graph* const graph_;
48
  Decorator* decorator_;
49
  TypeCache const* cache_;
50
  JSHeapBroker* broker_;
51
  OperationTyper operation_typer_;
52

53 54
  Type singleton_false_;
  Type singleton_true_;
55

56
  DISALLOW_COPY_AND_ASSIGN(Typer);
57
};
58

59 60
DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags);

61 62 63
}  // namespace compiler
}  // namespace internal
}  // namespace v8
64 65

#endif  // V8_COMPILER_TYPER_H_