1 // Copyright 2014 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_TYPER_H_ 6 #define V8_COMPILER_TYPER_H_ 7 8 #include "src/compiler/graph.h" 9 #include "src/compiler/operation-typer.h" 10 #include "src/globals.h" 11 12 namespace v8 { 13 namespace internal { 14 namespace compiler { 15 16 // Forward declarations. 17 class LoopVariableOptimizer; 18 19 class V8_EXPORT_PRIVATE Typer { 20 public: 21 enum Flag : uint8_t { 22 kNoFlags = 0, 23 kThisIsReceiver = 1u << 0, // Parameter this is an Object. 24 kNewTargetIsReceiver = 1u << 1, // Parameter new.target is an Object. 25 }; 26 typedef base::Flags<Flag> Flags; 27 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 void Run(const ZoneVector<Node*>& roots, 35 LoopVariableOptimizer* induction_vars); 36 37 private: 38 class Visitor; 39 class Decorator; 40 flags()41 Flags flags() const { return flags_; } graph()42 Graph* graph() const { return graph_; } zone()43 Zone* zone() const { return graph()->zone(); } operation_typer()44 OperationTyper* operation_typer() { return &operation_typer_; } js_heap_broker()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 Type singleton_false_; 55 Type singleton_true_; 56 57 DISALLOW_COPY_AND_ASSIGN(Typer); 58 }; 59 60 DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags); 61 62 } // namespace compiler 63 } // namespace internal 64 } // namespace v8 65 66 #endif // V8_COMPILER_TYPER_H_ 67