1 // Copyright 2015 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_LOOP_PEELING_H_ 6 #define V8_COMPILER_LOOP_PEELING_H_ 7 8 #include "src/base/compiler-specific.h" 9 #include "src/compiler/loop-analysis.h" 10 #include "src/globals.h" 11 12 namespace v8 { 13 namespace internal { 14 namespace compiler { 15 16 // Represents the output of peeling a loop, which is basically the mapping 17 // from the body of the loop to the corresponding nodes in the peeled 18 // iteration. 19 class V8_EXPORT_PRIVATE PeeledIteration : public NON_EXPORTED_BASE(ZoneObject) { 20 public: 21 // Maps {node} to its corresponding copy in the peeled iteration, if 22 // the node was part of the body of the loop. Returns {node} otherwise. 23 Node* map(Node* node); 24 25 protected: 26 PeeledIteration() {} 27 }; 28 29 class CommonOperatorBuilder; 30 31 // Implements loop peeling. 32 class V8_EXPORT_PRIVATE LoopPeeler { 33 public: 34 static bool CanPeel(LoopTree* loop_tree, LoopTree::Loop* loop); 35 static PeeledIteration* Peel(Graph* graph, CommonOperatorBuilder* common, 36 LoopTree* loop_tree, LoopTree::Loop* loop, 37 Zone* tmp_zone); 38 static void PeelInnerLoopsOfTree(Graph* graph, CommonOperatorBuilder* common, 39 LoopTree* loop_tree, Zone* tmp_zone); 40 41 static void EliminateLoopExits(Graph* graph, Zone* temp_zone); 42 static const size_t kMaxPeeledNodes = 1000; 43 }; 44 45 46 } // namespace compiler 47 } // namespace internal 48 } // namespace v8 49 50 #endif // V8_COMPILER_LOOP_PEELING_H_ 51