Changeset 189126 in webkit for trunk/Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
- Timestamp:
- Aug 28, 2015, 3:38:41 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
r189070 r189126 47 47 struct LoopData { 48 48 LoopData() 49 : preHeader( 0)49 : preHeader(nullptr) 50 50 { 51 51 } … … 113 113 const NaturalLoop& loop = m_graph.m_naturalLoops.loop(loopIndex); 114 114 LoopData& data = m_data[loop.index()]; 115 115 116 for ( 116 117 const NaturalLoop* outerLoop = m_graph.m_naturalLoops.innerMostOuterLoop(loop); … … 120 121 121 122 BasicBlock* header = loop.header(); 122 BasicBlock* preHeader = 0; 123 BasicBlock* preHeader = nullptr; 124 unsigned numberOfPreHeaders = 0; // We're cool if this is 1. 125 126 // This is guaranteed because we expect the CFG not to have unreachable code. Therefore, a 127 // loop header must have a predecessor. (Also, we don't allow the root block to be a loop, 128 // which cuts out the one other way of having a loop header with only one predecessor.) 129 DFG_ASSERT(m_graph, header->at(0), header->predecessors.size() > 1); 130 123 131 for (unsigned i = header->predecessors.size(); i--;) { 124 132 BasicBlock* predecessor = header->predecessors[i]; 125 133 if (m_graph.m_dominators.dominates(header, predecessor)) 126 134 continue; 127 DFG_ASSERT(m_graph, nullptr, !preHeader || preHeader == predecessor); 135 128 136 preHeader = predecessor; 129 } 130 137 ++numberOfPreHeaders; 138 } 139 140 // We need to validate the pre-header. There are a bunch of things that could be wrong 141 // about it: 142 // 143 // - There might be more than one. This means that pre-header creation either did not run, 144 // or some CFG transformation destroyed the pre-headers. 145 // 146 // - It may not be legal to exit at the pre-header. That would be a real bummer. Currently, 147 // LICM assumes that it can always hoist checks. See 148 // https://bugs.webkit.org/show_bug.cgi?id=148545. Though even with that fixed, we anyway 149 // would need to check if it's OK to exit at the pre-header since if we can't then we 150 // would have to restrict hoisting to non-exiting nodes. 151 152 if (numberOfPreHeaders != 1) 153 continue; 154 155 // This is guaranteed because the header has multiple predecessors and critical edges are 156 // broken. Therefore the predecessors must all have one successor, which implies that they 157 // must end in a Jump. 131 158 DFG_ASSERT(m_graph, preHeader->terminal(), preHeader->terminal()->op() == Jump); 132 133 // We should validate the pre-header. This currently assumes that it's valid to OSR exit at 134 // the Jump of the pre-header. That may not always be the case, like if we lowered a Node 135 // that was ExitInvalid to a loop. This phase should somehow defend against this - at the 136 // very least with assertions, if not with something better (like only hoisting things that 137 // cannot exit). 138 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=148259 159 160 if (!preHeader->terminal()->origin.exitOK) 161 continue; 139 162 140 163 data.preHeader = preHeader; … … 147 170 // - The node doesn't write anything. 148 171 // - The node doesn't read anything that the loop writes. 172 // - The preHeader is valid (i.e. it passed the validation above). 149 173 // - The preHeader's state at tail makes the node safe to execute. 150 174 // - The loop's children all belong to nodes that strictly dominate the loop header. … … 206 230 Node* node = nodeRef; 207 231 LoopData& data = m_data[loop->index()]; 232 233 if (!data.preHeader) { 234 if (verbose) 235 dataLog(" Not hoisting ", node, " because the pre-header is invalid.\n"); 236 return false; 237 } 208 238 209 239 if (!data.preHeader->cfaDidFinish) {
Note:
See TracChangeset
for help on using the changeset viewer.