| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 Bounds::Both(phi_bounds, osr_bounds, zone)); | 278 Bounds::Both(phi_bounds, osr_bounds, zone)); |
| 279 } | 279 } |
| 280 unknown = false; | 280 unknown = false; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 if (unknown) NodeProperties::SetBounds(osr_value, Bounds::Unbounded(zone)); | 283 if (unknown) NodeProperties::SetBounds(osr_value, Bounds::Unbounded(zone)); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, | 288 void OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, |
| 289 Zone* tmp_zone) { | 289 Zone* tmp_zone) { |
| 290 Graph* graph = jsgraph->graph(); | 290 Graph* graph = jsgraph->graph(); |
| 291 Node* osr_normal_entry = nullptr; | 291 Node* osr_normal_entry = nullptr; |
| 292 Node* osr_loop_entry = nullptr; | 292 Node* osr_loop_entry = nullptr; |
| 293 Node* osr_loop = nullptr; | 293 Node* osr_loop = nullptr; |
| 294 | 294 |
| 295 for (Node* node : graph->start()->uses()) { | 295 for (Node* node : graph->start()->uses()) { |
| 296 if (node->opcode() == IrOpcode::kOsrLoopEntry) { | 296 if (node->opcode() == IrOpcode::kOsrLoopEntry) { |
| 297 osr_loop_entry = node; // found the OSR loop entry | 297 osr_loop_entry = node; // found the OSR loop entry |
| 298 } else if (node->opcode() == IrOpcode::kOsrNormalEntry) { | 298 } else if (node->opcode() == IrOpcode::kOsrNormalEntry) { |
| 299 osr_normal_entry = node; | 299 osr_normal_entry = node; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 if (osr_loop_entry == nullptr) { | 303 if (osr_loop_entry == nullptr) { |
| 304 // No OSR entry found, do nothing. | 304 // No OSR entry found, do nothing. |
| 305 CHECK(osr_normal_entry); | 305 CHECK(osr_normal_entry); |
| 306 return true; | 306 return; |
| 307 } | 307 } |
| 308 | 308 |
| 309 for (Node* use : osr_loop_entry->uses()) { | 309 for (Node* use : osr_loop_entry->uses()) { |
| 310 if (use->opcode() == IrOpcode::kLoop) { | 310 if (use->opcode() == IrOpcode::kLoop) { |
| 311 CHECK(!osr_loop); // should be only one OSR loop. | 311 CHECK(!osr_loop); // should be only one OSR loop. |
| 312 osr_loop = use; // found the OSR loop. | 312 osr_loop = use; // found the OSR loop. |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 CHECK(osr_loop); // Should have found the OSR loop. | 316 CHECK(osr_loop); // Should have found the OSR loop. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 338 // Normally the control reducer removes loops whose first input is dead, | 338 // Normally the control reducer removes loops whose first input is dead, |
| 339 // but we need to avoid that because the osr_loop is reachable through | 339 // but we need to avoid that because the osr_loop is reachable through |
| 340 // the second input, so reduce it and its phis manually. | 340 // the second input, so reduce it and its phis manually. |
| 341 osr_loop->ReplaceInput(0, dead); | 341 osr_loop->ReplaceInput(0, dead); |
| 342 Node* node = ControlReducer::ReduceMerge(jsgraph, common, osr_loop); | 342 Node* node = ControlReducer::ReduceMerge(jsgraph, common, osr_loop); |
| 343 if (node != osr_loop) osr_loop->ReplaceUses(node); | 343 if (node != osr_loop) osr_loop->ReplaceUses(node); |
| 344 | 344 |
| 345 // Run the normal control reduction, which naturally trims away the dead | 345 // Run the normal control reduction, which naturally trims away the dead |
| 346 // parts of the graph. | 346 // parts of the graph. |
| 347 ControlReducer::ReduceGraph(tmp_zone, jsgraph, common); | 347 ControlReducer::ReduceGraph(tmp_zone, jsgraph, common); |
| 348 | |
| 349 return true; | |
| 350 } | 348 } |
| 351 | 349 |
| 352 | 350 |
| 353 void OsrHelper::SetupFrame(Frame* frame) { | 351 void OsrHelper::SetupFrame(Frame* frame) { |
| 354 // The optimized frame will subsume the unoptimized frame. Do so by reserving | 352 // The optimized frame will subsume the unoptimized frame. Do so by reserving |
| 355 // the first spill slots. | 353 // the first spill slots. |
| 356 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); | 354 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); |
| 357 // The frame needs to be adjusted by the number of unoptimized frame slots. | 355 // The frame needs to be adjusted by the number of unoptimized frame slots. |
| 358 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); | 356 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); |
| 359 } | 357 } |
| 360 | 358 |
| 361 | 359 |
| 362 } // namespace compiler | 360 } // namespace compiler |
| 363 } // namespace internal | 361 } // namespace internal |
| 364 } // namespace v8 | 362 } // namespace v8 |
| OLD | NEW |