| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/codegen.h" | 5 #include "src/codegen.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/diamond.h" | 8 #include "src/compiler/diamond.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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 CHECK_EQ(loop->InputCount(), count); | 84 CHECK_EQ(loop->InputCount(), count); |
| 85 CHECK_EQ(osr_loop_entry, loop->InputAt(1)); | 85 CHECK_EQ(osr_loop_entry, loop->InputAt(1)); |
| 86 | 86 |
| 87 Node* inputs[6]; | 87 Node* inputs[6]; |
| 88 inputs[0] = incoming; | 88 inputs[0] = incoming; |
| 89 inputs[1] = osr_values[osr_value]; | 89 inputs[1] = osr_values[osr_value]; |
| 90 if (count > 2) inputs[2] = back1; | 90 if (count > 2) inputs[2] = back1; |
| 91 if (count > 3) inputs[3] = back2; | 91 if (count > 3) inputs[3] = back2; |
| 92 if (count > 4) inputs[4] = back3; | 92 if (count > 4) inputs[4] = back3; |
| 93 inputs[count] = loop; | 93 inputs[count] = loop; |
| 94 return graph.NewNode(common.Phi(kMachAnyTagged, count), count + 1, inputs); | 94 return graph.NewNode(common.Phi(MachineRepresentation::kTagged, count), |
| 95 count + 1, inputs); |
| 95 } | 96 } |
| 96 | 97 |
| 97 Node* NewLoop(bool is_osr, int num_backedges, Node* entry = nullptr) { | 98 Node* NewLoop(bool is_osr, int num_backedges, Node* entry = nullptr) { |
| 98 if (entry == nullptr) entry = osr_normal_entry; | 99 if (entry == nullptr) entry = osr_normal_entry; |
| 99 Node* loop = graph.NewNode(common.Loop(1), entry); | 100 Node* loop = graph.NewNode(common.Loop(1), entry); |
| 100 if (is_osr) { | 101 if (is_osr) { |
| 101 loop->AppendInput(graph.zone(), osr_loop_entry); | 102 loop->AppendInput(graph.zone(), osr_loop_entry); |
| 102 } | 103 } |
| 103 for (int i = 0; i < num_backedges; i++) { | 104 for (int i = 0; i < num_backedges; i++) { |
| 104 loop->AppendInput(graph.zone(), loop); | 105 loop->AppendInput(graph.zone(), loop); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 loop->ReplaceInput(loop->InputCount() - 1, if_true); | 308 loop->ReplaceInput(loop->InputCount() - 1, if_true); |
| 308 } | 309 } |
| 309 | 310 |
| 310 void Nest(While& that) { | 311 void Nest(While& that) { |
| 311 that.loop->ReplaceInput(that.loop->InputCount() - 1, exit); | 312 that.loop->ReplaceInput(that.loop->InputCount() - 1, exit); |
| 312 this->loop->ReplaceInput(0, that.if_true); | 313 this->loop->ReplaceInput(0, that.if_true); |
| 313 } | 314 } |
| 314 | 315 |
| 315 Node* Phi(Node* i1, Node* i2, Node* i3) { | 316 Node* Phi(Node* i1, Node* i2, Node* i3) { |
| 316 if (loop->InputCount() == 2) { | 317 if (loop->InputCount() == 2) { |
| 317 return t.graph.NewNode(t.common.Phi(kMachAnyTagged, 2), i1, i2, loop); | 318 return t.graph.NewNode(t.common.Phi(MachineRepresentation::kTagged, 2), |
| 319 i1, i2, loop); |
| 318 } else { | 320 } else { |
| 319 return t.graph.NewNode(t.common.Phi(kMachAnyTagged, 3), i1, i2, i3, loop); | 321 return t.graph.NewNode(t.common.Phi(MachineRepresentation::kTagged, 3), |
| 322 i1, i2, i3, loop); |
| 320 } | 323 } |
| 321 } | 324 } |
| 322 }; | 325 }; |
| 323 | 326 |
| 324 | 327 |
| 325 static Node* FindSuccessor(Node* node, IrOpcode::Value opcode) { | 328 static Node* FindSuccessor(Node* node, IrOpcode::Value opcode) { |
| 326 for (Node* use : node->uses()) { | 329 for (Node* use : node->uses()) { |
| 327 if (use->opcode() == opcode) return use; | 330 if (use->opcode() == opcode) return use; |
| 328 } | 331 } |
| 329 UNREACHABLE(); // should have been found. | 332 UNREACHABLE(); // should have been found. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 469 |
| 467 Node* MakeCounter(JSGraph* jsgraph, Node* start, Node* loop) { | 470 Node* MakeCounter(JSGraph* jsgraph, Node* start, Node* loop) { |
| 468 int count = loop->InputCount(); | 471 int count = loop->InputCount(); |
| 469 NodeVector tmp_inputs(jsgraph->graph()->zone()); | 472 NodeVector tmp_inputs(jsgraph->graph()->zone()); |
| 470 for (int i = 0; i < count; i++) { | 473 for (int i = 0; i < count; i++) { |
| 471 tmp_inputs.push_back(start); | 474 tmp_inputs.push_back(start); |
| 472 } | 475 } |
| 473 tmp_inputs.push_back(loop); | 476 tmp_inputs.push_back(loop); |
| 474 | 477 |
| 475 Node* phi = jsgraph->graph()->NewNode( | 478 Node* phi = jsgraph->graph()->NewNode( |
| 476 jsgraph->common()->Phi(kMachInt32, count), count + 1, &tmp_inputs[0]); | 479 jsgraph->common()->Phi(MachineRepresentation::kWord32, count), count + 1, |
| 480 &tmp_inputs[0]); |
| 477 Node* inc = jsgraph->graph()->NewNode(&kIntAdd, phi, jsgraph->OneConstant()); | 481 Node* inc = jsgraph->graph()->NewNode(&kIntAdd, phi, jsgraph->OneConstant()); |
| 478 | 482 |
| 479 for (int i = 1; i < count; i++) { | 483 for (int i = 1; i < count; i++) { |
| 480 phi->ReplaceInput(i, inc); | 484 phi->ReplaceInput(i, inc); |
| 481 } | 485 } |
| 482 return phi; | 486 return phi; |
| 483 } | 487 } |
| 484 | 488 |
| 485 | 489 |
| 486 TEST(Deconstruct_osr_nested3) { | 490 TEST(Deconstruct_osr_nested3) { |
| 487 OsrDeconstructorTester T(1); | 491 OsrDeconstructorTester T(1); |
| 488 | 492 |
| 489 // outermost loop. | 493 // outermost loop. |
| 490 While loop0(T, T.p0, false, 1); | 494 While loop0(T, T.p0, false, 1); |
| 491 Node* loop0_cntr = MakeCounter(&T.jsgraph, T.p0, loop0.loop); | 495 Node* loop0_cntr = MakeCounter(&T.jsgraph, T.p0, loop0.loop); |
| 492 loop0.branch->ReplaceInput(0, loop0_cntr); | 496 loop0.branch->ReplaceInput(0, loop0_cntr); |
| 493 | 497 |
| 494 // middle loop. | 498 // middle loop. |
| 495 Node* loop1 = T.graph.NewNode(T.common.Loop(1), loop0.if_true); | 499 Node* loop1 = T.graph.NewNode(T.common.Loop(1), loop0.if_true); |
| 496 Node* loop1_phi = T.graph.NewNode(T.common.Phi(kMachAnyTagged, 2), loop0_cntr, | 500 Node* loop1_phi = |
| 497 loop0_cntr, loop1); | 501 T.graph.NewNode(T.common.Phi(MachineRepresentation::kTagged, 2), |
| 502 loop0_cntr, loop0_cntr, loop1); |
| 498 | 503 |
| 499 // innermost (OSR) loop. | 504 // innermost (OSR) loop. |
| 500 While loop2(T, T.p0, true, 1); | 505 While loop2(T, T.p0, true, 1); |
| 501 loop2.loop->ReplaceInput(0, loop1); | 506 loop2.loop->ReplaceInput(0, loop1); |
| 502 | 507 |
| 503 Node* loop2_cntr = MakeCounter(&T.jsgraph, loop1_phi, loop2.loop); | 508 Node* loop2_cntr = MakeCounter(&T.jsgraph, loop1_phi, loop2.loop); |
| 504 loop2_cntr->ReplaceInput(1, T.osr_values[0]); | 509 loop2_cntr->ReplaceInput(1, T.osr_values[0]); |
| 505 Node* osr_phi = loop2_cntr; | 510 Node* osr_phi = loop2_cntr; |
| 506 Node* loop2_inc = loop2_cntr->InputAt(2); | 511 Node* loop2_inc = loop2_cntr->InputAt(2); |
| 507 loop2.branch->ReplaceInput(0, loop2_cntr); | 512 loop2.branch->ReplaceInput(0, loop2_cntr); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 CHECK_EQ(new_loop0_phi, FindSuccessor(new_loop0_loop, IrOpcode::kPhi)); | 566 CHECK_EQ(new_loop0_phi, FindSuccessor(new_loop0_loop, IrOpcode::kPhi)); |
| 562 | 567 |
| 563 // Check that the return returns the phi from the OSR loop and control | 568 // Check that the return returns the phi from the OSR loop and control |
| 564 // depends on the copy of the outer loop0. | 569 // depends on the copy of the outer loop0. |
| 565 CheckInputs(new_ret, new_loop0_phi, T.graph.start(), new_loop0_exit); | 570 CheckInputs(new_ret, new_loop0_phi, T.graph.start(), new_loop0_exit); |
| 566 } | 571 } |
| 567 | 572 |
| 568 } // namespace compiler | 573 } // namespace compiler |
| 569 } // namespace internal | 574 } // namespace internal |
| 570 } // namespace v8 | 575 } // namespace v8 |
| OLD | NEW |