OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
6 #include "src/compiler/all-nodes.h" | 6 #include "src/compiler/all-nodes.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/control-reducer.h" | 8 #include "src/compiler/control-reducer.h" |
9 #include "src/compiler/frame.h" | 9 #include "src/compiler/frame.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); | 211 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); |
212 if (loop->depth() > 0) { | 212 if (loop->depth() > 0) { |
213 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, | 213 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, |
214 osr_normal_entry, osr_loop_entry); | 214 osr_normal_entry, osr_loop_entry); |
215 } | 215 } |
216 | 216 |
217 // Replace the normal entry with {Dead} and the loop entry with {Start} | 217 // Replace the normal entry with {Dead} and the loop entry with {Start} |
218 // and run the control reducer to clean up the graph. | 218 // and run the control reducer to clean up the graph. |
219 osr_normal_entry->ReplaceUses(dead); | 219 osr_normal_entry->ReplaceUses(dead); |
220 osr_loop_entry->ReplaceUses(graph->start()); | 220 osr_loop_entry->ReplaceUses(graph->start()); |
| 221 |
| 222 // Normally the control reducer removes loops whose first input is dead, |
| 223 // but we need to avoid that because the osr_loop is reachable through |
| 224 // the second input, so reduce it and its phis manually. |
| 225 osr_loop->ReplaceInput(0, dead); |
| 226 Node* node = ControlReducer::ReduceMerge(jsgraph, common, osr_loop); |
| 227 if (node != osr_loop) osr_loop->ReplaceUses(node); |
| 228 |
| 229 // Run the normal control reduction, which naturally trims away the dead |
| 230 // parts of the graph. |
221 ControlReducer::ReduceGraph(tmp_zone, jsgraph, common); | 231 ControlReducer::ReduceGraph(tmp_zone, jsgraph, common); |
222 | 232 |
223 return true; | 233 return true; |
224 } | 234 } |
225 | 235 |
226 | 236 |
227 void OsrHelper::SetupFrame(Frame* frame) { | 237 void OsrHelper::SetupFrame(Frame* frame) { |
228 // The optimized frame will subsume the unoptimized frame. Do so by reserving | 238 // The optimized frame will subsume the unoptimized frame. Do so by reserving |
229 // the first spill slots. | 239 // the first spill slots. |
230 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); | 240 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); |
231 // The frame needs to be adjusted by the number of unoptimized frame slots. | 241 // The frame needs to be adjusted by the number of unoptimized frame slots. |
232 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); | 242 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); |
233 } | 243 } |
234 | 244 |
235 | 245 |
236 } // namespace compiler | 246 } // namespace compiler |
237 } // namespace internal | 247 } // namespace internal |
238 } // namespace v8 | 248 } // namespace v8 |
OLD | NEW |