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/common-operator-reducer.h" | 8 #include "src/compiler/common-operator-reducer.h" |
| 9 #include "src/compiler/dead-code-elimination.h" | 9 #include "src/compiler/dead-code-elimination.h" |
| 10 #include "src/compiler/frame.h" | 10 #include "src/compiler/frame.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 } | 242 } |
| 243 | 243 |
| 244 if (FLAG_trace_turbo_graph) { // Simple textual RPO. | 244 if (FLAG_trace_turbo_graph) { // Simple textual RPO. |
| 245 OFStream os(stdout); | 245 OFStream os(stdout); |
| 246 os << "-- Graph after OSR duplication -- " << std::endl; | 246 os << "-- Graph after OSR duplication -- " << std::endl; |
| 247 os << AsRPO(*graph); | 247 os << AsRPO(*graph); |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 static void TransferOsrValueTypesFromLoopPhis(Zone* zone, Node* osr_loop_entry, | |
| 253 Node* osr_loop) { | |
|
titzer
2015/07/06 09:12:34
I don't think it's necessary to delete this code.
Benedikt Meurer
2015/07/06 09:15:03
This is the main cause for the bug. So we could on
| |
| 254 // Find the index of the osr loop entry into the loop. | |
| 255 int index = 0; | |
| 256 for (index = 0; index < osr_loop->InputCount(); index++) { | |
| 257 if (osr_loop->InputAt(index) == osr_loop_entry) break; | |
| 258 } | |
| 259 if (index == osr_loop->InputCount()) return; | |
| 260 | |
| 261 for (Node* osr_value : osr_loop_entry->uses()) { | |
| 262 if (osr_value->opcode() != IrOpcode::kOsrValue) continue; | |
| 263 bool unknown = true; | |
| 264 for (Node* phi : osr_value->uses()) { | |
| 265 if (phi->opcode() != IrOpcode::kPhi) continue; | |
| 266 if (NodeProperties::GetControlInput(phi) != osr_loop) continue; | |
| 267 if (phi->InputAt(index) != osr_value) continue; | |
| 268 if (NodeProperties::IsTyped(phi)) { | |
| 269 // Transfer the type from the phi to the OSR value itself. | |
| 270 Bounds phi_bounds = NodeProperties::GetBounds(phi); | |
| 271 if (unknown) { | |
| 272 NodeProperties::SetBounds(osr_value, phi_bounds); | |
| 273 } else { | |
| 274 Bounds osr_bounds = NodeProperties::GetBounds(osr_value); | |
| 275 NodeProperties::SetBounds(osr_value, | |
| 276 Bounds::Both(phi_bounds, osr_bounds, zone)); | |
| 277 } | |
| 278 unknown = false; | |
| 279 } | |
| 280 } | |
| 281 if (unknown) NodeProperties::SetBounds(osr_value, Bounds::Unbounded(zone)); | |
| 282 } | |
| 283 } | |
| 284 | |
| 285 | |
| 286 void OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, | 252 void OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, |
| 287 Zone* tmp_zone) { | 253 Zone* tmp_zone) { |
| 288 Graph* graph = jsgraph->graph(); | 254 Graph* graph = jsgraph->graph(); |
| 289 Node* osr_normal_entry = nullptr; | 255 Node* osr_normal_entry = nullptr; |
| 290 Node* osr_loop_entry = nullptr; | 256 Node* osr_loop_entry = nullptr; |
| 291 Node* osr_loop = nullptr; | 257 Node* osr_loop = nullptr; |
| 292 | 258 |
| 293 for (Node* node : graph->start()->uses()) { | 259 for (Node* node : graph->start()->uses()) { |
| 294 if (node->opcode() == IrOpcode::kOsrLoopEntry) { | 260 if (node->opcode() == IrOpcode::kOsrLoopEntry) { |
| 295 osr_loop_entry = node; // found the OSR loop entry | 261 osr_loop_entry = node; // found the OSR loop entry |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 306 | 272 |
| 307 for (Node* use : osr_loop_entry->uses()) { | 273 for (Node* use : osr_loop_entry->uses()) { |
| 308 if (use->opcode() == IrOpcode::kLoop) { | 274 if (use->opcode() == IrOpcode::kLoop) { |
| 309 CHECK(!osr_loop); // should be only one OSR loop. | 275 CHECK(!osr_loop); // should be only one OSR loop. |
| 310 osr_loop = use; // found the OSR loop. | 276 osr_loop = use; // found the OSR loop. |
| 311 } | 277 } |
| 312 } | 278 } |
| 313 | 279 |
| 314 CHECK(osr_loop); // Should have found the OSR loop. | 280 CHECK(osr_loop); // Should have found the OSR loop. |
| 315 | 281 |
| 316 // Transfer the types from loop phis to the OSR values which flow into them. | |
| 317 TransferOsrValueTypesFromLoopPhis(graph->zone(), osr_loop_entry, osr_loop); | |
| 318 | |
| 319 // Analyze the graph to determine how deeply nested the OSR loop is. | 282 // Analyze the graph to determine how deeply nested the OSR loop is. |
| 320 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); | 283 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); |
| 321 | 284 |
| 322 Node* dead = jsgraph->Dead(); | 285 Node* dead = jsgraph->Dead(); |
| 323 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); | 286 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); |
| 324 if (loop->depth() > 0) { | 287 if (loop->depth() > 0) { |
| 325 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, | 288 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, |
| 326 osr_normal_entry, osr_loop_entry); | 289 osr_normal_entry, osr_loop_entry); |
| 327 } | 290 } |
| 328 | 291 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 // The optimized frame will subsume the unoptimized frame. Do so by reserving | 328 // The optimized frame will subsume the unoptimized frame. Do so by reserving |
| 366 // the first spill slots. | 329 // the first spill slots. |
| 367 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); | 330 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); |
| 368 // The frame needs to be adjusted by the number of unoptimized frame slots. | 331 // The frame needs to be adjusted by the number of unoptimized frame slots. |
| 369 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); | 332 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); |
| 370 } | 333 } |
| 371 | 334 |
| 372 } // namespace compiler | 335 } // namespace compiler |
| 373 } // namespace internal | 336 } // namespace internal |
| 374 } // namespace v8 | 337 } // namespace v8 |
| OLD | NEW |