Home | History | Annotate | Download | only in crankshaft
      1 // Copyright 2013 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_CRANKSHAFT_HYDROGEN_OSR_H_
      6 #define V8_CRANKSHAFT_HYDROGEN_OSR_H_
      7 
      8 #include "src/crankshaft/hydrogen.h"
      9 #include "src/zone/zone.h"
     10 
     11 namespace v8 {
     12 namespace internal {
     13 
     14 class IterationStatement;
     15 
     16 // Responsible for building graph parts related to OSR and otherwise
     17 // setting up the graph to do an OSR compile.
     18 class HOsrBuilder : public ZoneObject {
     19  public:
     20   explicit HOsrBuilder(HOptimizedGraphBuilder* builder)
     21     : unoptimized_frame_slots_(0),
     22       builder_(builder),
     23       osr_entry_(NULL),
     24       osr_loop_entry_(NULL),
     25       osr_values_(NULL) { }
     26 
     27   // Creates the loop entry block for the given statement, setting up OSR
     28   // entries as necessary, and sets the current block to the new block.
     29   HBasicBlock* BuildOsrLoopEntry(IterationStatement* statement);
     30 
     31   // Process the hydrogen graph after it has been completed, performing
     32   // any OSR-specific cleanups or changes.
     33   void FinishGraph();
     34 
     35   // Process the OSR values and phis after initial graph optimization.
     36   void FinishOsrValues();
     37 
     38   // Return the number of slots in the unoptimized frame at the entry to OSR.
     39   int UnoptimizedFrameSlots() const {
     40     return unoptimized_frame_slots_;
     41   }
     42 
     43   bool HasOsrEntryAt(IterationStatement* statement);
     44 
     45  private:
     46   int unoptimized_frame_slots_;
     47   HOptimizedGraphBuilder* builder_;
     48   HBasicBlock* osr_entry_;
     49   HBasicBlock* osr_loop_entry_;
     50   ZoneList<HUnknownOSRValue*>* osr_values_;
     51 };
     52 
     53 }  // namespace internal
     54 }  // namespace v8
     55 
     56 #endif  // V8_CRANKSHAFT_HYDROGEN_OSR_H_
     57