typer.h 1.68 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(Isolate* isolate, JSHeapBroker* js_heap_broker, Flags flags,
29
        Graph* graph);
30
  ~Typer();
31

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

 private:
  class Visitor;
39 40
  class Decorator;

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

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

54 55
  Type singleton_false_;
  Type singleton_true_;
56

57
  DISALLOW_COPY_AND_ASSIGN(Typer);
58
};
59

60 61
DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags);

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

#endif  // V8_COMPILER_TYPER_H_