Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: src/compiler/osr.cc

Issue 920573004: [turbofan] Fix control reducer for dead loops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | test/cctest/compiler/test-control-reducer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | test/cctest/compiler/test-control-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698