Home | History | Annotate | Download | only in compiler
      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, 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   void Run(const ZoneVector<Node*>& roots,
     34            LoopVariableOptimizer* induction_vars);
     35 
     36  private:
     37   class Visitor;
     38   class Decorator;
     39 
     40   Flags flags() const { return flags_; }
     41   Graph* graph() const { return graph_; }
     42   Zone* zone() const { return graph()->zone(); }
     43   Isolate* isolate() const { return isolate_; }
     44   OperationTyper* operation_typer() { return &operation_typer_; }
     45 
     46   Isolate* const isolate_;
     47   Flags const flags_;
     48   Graph* const graph_;
     49   Decorator* decorator_;
     50   TypeCache const& cache_;
     51   OperationTyper operation_typer_;
     52 
     53   Type* singleton_empty_string_;
     54   Type* singleton_false_;
     55   Type* singleton_true_;
     56   Type* falsish_;
     57   Type* truish_;
     58 
     59   DISALLOW_COPY_AND_ASSIGN(Typer);
     60 };
     61 
     62 DEFINE_OPERATORS_FOR_FLAGS(Typer::Flags);
     63 
     64 }  // namespace compiler
     65 }  // namespace internal
     66 }  // namespace v8
     67 
     68 #endif  // V8_COMPILER_TYPER_H_
     69