Changeset 153279 in webkit for trunk/Source/JavaScriptCore/dfg/DFGNaturalLoops.h
- Timestamp:
- Jul 24, 2013, 9:04:55 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGNaturalLoops.h
r153277 r153279 59 59 BasicBlock* at(unsigned i) const { return m_body[i]; } 60 60 BasicBlock* operator[](unsigned i) const { return at(i); } 61 61 62 // This is the slower, but simpler, way of asking if a block belongs to 63 // a natural loop. It's faster to call NaturalLoops::belongsTo(), which 64 // tries to be O(loop depth) rather than O(loop size). Loop depth is 65 // almost always smaller than loop size. A *lot* smaller. 62 66 bool contains(BasicBlock* block) const 63 67 { … … 109 113 const NaturalLoop* headerOf(BasicBlock* block) const 110 114 { 115 ASSERT(isValid()); 111 116 const NaturalLoop* loop = innerMostLoopOf(block); 117 if (!loop) 118 return 0; 112 119 if (loop->header() == block) 113 120 return loop; … … 121 128 const NaturalLoop* innerMostLoopOf(BasicBlock* block) const 122 129 { 130 ASSERT(isValid()); 123 131 unsigned index = block->innerMostLoopIndices[0]; 124 132 if (index == UINT_MAX) … … 129 137 const NaturalLoop* innerMostOuterLoop(const NaturalLoop& loop) const 130 138 { 139 ASSERT(isValid()); 131 140 if (loop.m_outerLoopIndex == UINT_MAX) 132 141 return 0; 133 142 return &m_loops[loop.m_outerLoopIndex]; 143 } 144 145 bool belongsTo(BasicBlock* block, const NaturalLoop& candidateLoop) const 146 { 147 ASSERT(isValid()); 148 // It's faster to do this test using the loop itself, if it's small. 149 if (candidateLoop.size() < 4) 150 return candidateLoop.contains(block); 151 152 for (const NaturalLoop* loop = innerMostLoopOf(block); loop; loop = innerMostOuterLoop(*loop)) { 153 if (loop == &candidateLoop) 154 return true; 155 } 156 return false; 134 157 } 135 158
Note:
See TracChangeset
for help on using the changeset viewer.