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/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/control-reducer.h" | 7 #include "src/compiler/control-reducer.h" |
8 #include "src/compiler/frame.h" | 8 #include "src/compiler/frame.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 for (Node* node : graph->start()->uses()) { | 33 for (Node* node : graph->start()->uses()) { |
34 if (node->opcode() == IrOpcode::kOsrLoopEntry) { | 34 if (node->opcode() == IrOpcode::kOsrLoopEntry) { |
35 osr_loop_entry = node; // found the OSR loop entry | 35 osr_loop_entry = node; // found the OSR loop entry |
36 } else if (node->opcode() == IrOpcode::kOsrNormalEntry) { | 36 } else if (node->opcode() == IrOpcode::kOsrNormalEntry) { |
37 osr_normal_entry = node; | 37 osr_normal_entry = node; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 if (osr_loop_entry == nullptr) { | 41 if (osr_loop_entry == nullptr) { |
42 // No OSR entry found, do nothing. | 42 // No OSR entry found, do nothing. |
43 CHECK_NE(nullptr, osr_normal_entry); | 43 CHECK(osr_normal_entry); |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 for (Node* use : osr_loop_entry->uses()) { | 47 for (Node* use : osr_loop_entry->uses()) { |
48 if (use->opcode() == IrOpcode::kLoop) { | 48 if (use->opcode() == IrOpcode::kLoop) { |
49 CHECK_EQ(nullptr, osr_loop); // should be only one OSR loop. | 49 CHECK(!osr_loop); // should be only one OSR loop. |
50 osr_loop = use; // found the OSR loop. | 50 osr_loop = use; // found the OSR loop. |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 CHECK_NE(nullptr, osr_loop); // Should have found the OSR loop. | 54 CHECK(osr_loop); // Should have found the OSR loop. |
55 | 55 |
56 // Analyze the graph to determine how deeply nested the OSR loop is. | 56 // Analyze the graph to determine how deeply nested the OSR loop is. |
57 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); | 57 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); |
58 | 58 |
59 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); | 59 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); |
60 if (loop->depth() > 0) return false; // cannot OSR inner loops yet. | 60 if (loop->depth() > 0) return false; // cannot OSR inner loops yet. |
61 | 61 |
62 // TODO(titzer): perform loop peeling or graph duplication. | 62 // TODO(titzer): perform loop peeling or graph duplication. |
63 | 63 |
64 // Replace the normal entry with {Dead} and the loop entry with {Start} | 64 // Replace the normal entry with {Dead} and the loop entry with {Start} |
65 // and run the control reducer to clean up the graph. | 65 // and run the control reducer to clean up the graph. |
66 osr_normal_entry->ReplaceUses(graph->NewNode(common->Dead())); | 66 osr_normal_entry->ReplaceUses(graph->NewNode(common->Dead())); |
67 osr_loop_entry->ReplaceUses(graph->start()); | 67 osr_loop_entry->ReplaceUses(graph->start()); |
68 ControlReducer::ReduceGraph(tmp_zone, jsgraph, common); | 68 ControlReducer::ReduceGraph(tmp_zone, jsgraph, common); |
69 | 69 |
70 return true; | 70 return true; |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 void OsrHelper::SetupFrame(Frame* frame) { | 74 void OsrHelper::SetupFrame(Frame* frame) { |
75 // The optimized frame will subsume the unoptimized frame. Do so by reserving | 75 // The optimized frame will subsume the unoptimized frame. Do so by reserving |
76 // the first spill slots. | 76 // the first spill slots. |
77 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); | 77 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 } // namespace compiler | 81 } // namespace compiler |
82 } // namespace internal | 82 } // namespace internal |
83 } // namespace v8 | 83 } // namespace v8 |
OLD | NEW |