Chromium Code Reviews| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 end->ReplaceInput(0, merge); | 167 end->ReplaceInput(0, merge); |
| 168 | 168 |
| 169 if (FLAG_trace_turbo_graph) { // Simple textual RPO. | 169 if (FLAG_trace_turbo_graph) { // Simple textual RPO. |
| 170 OFStream os(stdout); | 170 OFStream os(stdout); |
| 171 os << "-- Graph after OSR duplication -- " << std::endl; | 171 os << "-- Graph after OSR duplication -- " << std::endl; |
| 172 os << AsRPO(*graph); | 172 os << AsRPO(*graph); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 static void TransferOsrValueTypesFromLoopPhis(Zone* zone, Node* osr_loop_entry, | |
| 178 Node* osr_loop) { | |
| 179 // Find the index of the osr loop entry into the loop. | |
| 180 int index = 0; | |
| 181 for (index = 0; index < osr_loop->InputCount(); index++) { | |
| 182 if (osr_loop->InputAt(index) == osr_loop_entry) break; | |
| 183 } | |
| 184 if (index == osr_loop->InputCount()) return; | |
| 185 | |
| 186 for (Node* osr_value : osr_loop_entry->uses()) { | |
| 187 if (osr_value->opcode() != IrOpcode::kOsrValue) continue; | |
| 188 bool unknown = true; | |
| 189 for (Node* phi : osr_value->uses()) { | |
| 190 if (phi->opcode() != IrOpcode::kPhi) continue; | |
| 191 if (NodeProperties::GetControlInput(phi) != osr_loop) continue; | |
| 192 if (phi->InputAt(index) != osr_value) continue; | |
| 193 if (NodeProperties::IsTyped(phi)) { | |
| 194 // Transfer the type from the phi to the OSR value itself. | |
| 195 NodeProperties::SetBounds(osr_value, NodeProperties::GetBounds(phi)); | |
|
Jarin
2015/02/16 14:33:03
As discussed offline, we should combine the types
| |
| 196 unknown = false; | |
| 197 } | |
| 198 } | |
| 199 if (unknown) NodeProperties::SetBounds(osr_value, Bounds::Unbounded(zone)); | |
| 200 } | |
| 201 } | |
| 202 | |
| 203 | |
| 177 bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, | 204 bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, |
| 178 Zone* tmp_zone) { | 205 Zone* tmp_zone) { |
| 179 Graph* graph = jsgraph->graph(); | 206 Graph* graph = jsgraph->graph(); |
| 180 Node* osr_normal_entry = nullptr; | 207 Node* osr_normal_entry = nullptr; |
| 181 Node* osr_loop_entry = nullptr; | 208 Node* osr_loop_entry = nullptr; |
| 182 Node* osr_loop = nullptr; | 209 Node* osr_loop = nullptr; |
| 183 | 210 |
| 184 for (Node* node : graph->start()->uses()) { | 211 for (Node* node : graph->start()->uses()) { |
| 185 if (node->opcode() == IrOpcode::kOsrLoopEntry) { | 212 if (node->opcode() == IrOpcode::kOsrLoopEntry) { |
| 186 osr_loop_entry = node; // found the OSR loop entry | 213 osr_loop_entry = node; // found the OSR loop entry |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 197 | 224 |
| 198 for (Node* use : osr_loop_entry->uses()) { | 225 for (Node* use : osr_loop_entry->uses()) { |
| 199 if (use->opcode() == IrOpcode::kLoop) { | 226 if (use->opcode() == IrOpcode::kLoop) { |
| 200 CHECK(!osr_loop); // should be only one OSR loop. | 227 CHECK(!osr_loop); // should be only one OSR loop. |
| 201 osr_loop = use; // found the OSR loop. | 228 osr_loop = use; // found the OSR loop. |
| 202 } | 229 } |
| 203 } | 230 } |
| 204 | 231 |
| 205 CHECK(osr_loop); // Should have found the OSR loop. | 232 CHECK(osr_loop); // Should have found the OSR loop. |
| 206 | 233 |
| 234 // Transfer the types from loop phis to the OSR values which flow into them. | |
| 235 TransferOsrValueTypesFromLoopPhis(graph->zone(), osr_loop_entry, osr_loop); | |
| 236 | |
| 207 // Analyze the graph to determine how deeply nested the OSR loop is. | 237 // Analyze the graph to determine how deeply nested the OSR loop is. |
| 208 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); | 238 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); |
| 209 | 239 |
| 210 Node* dead = graph->NewNode(common->Dead()); | 240 Node* dead = graph->NewNode(common->Dead()); |
| 211 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); | 241 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); |
| 212 if (loop->depth() > 0) { | 242 if (loop->depth() > 0) { |
| 213 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, | 243 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, |
| 214 osr_normal_entry, osr_loop_entry); | 244 osr_normal_entry, osr_loop_entry); |
| 215 } | 245 } |
| 216 | 246 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 229 // the first spill slots. | 259 // the first spill slots. |
| 230 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); | 260 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); |
| 231 // The frame needs to be adjusted by the number of unoptimized frame slots. | 261 // The frame needs to be adjusted by the number of unoptimized frame slots. |
| 232 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); | 262 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); |
| 233 } | 263 } |
| 234 | 264 |
| 235 | 265 |
| 236 } // namespace compiler | 266 } // namespace compiler |
| 237 } // namespace internal | 267 } // namespace internal |
| 238 } // namespace v8 | 268 } // namespace v8 |
| OLD | NEW |