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