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/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 VisitStatements(clause->statements()); | 597 VisitStatements(clause->statements()); |
598 compare_switch.EndCase(); | 598 compare_switch.EndCase(); |
599 } | 599 } |
600 | 600 |
601 compare_switch.EndSwitch(); | 601 compare_switch.EndSwitch(); |
602 } | 602 } |
603 | 603 |
604 | 604 |
605 void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { | 605 void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
606 LoopBuilder while_loop(this); | 606 LoopBuilder while_loop(this); |
607 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); | 607 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
608 VisitIterationBody(stmt, &while_loop, 0); | 608 VisitIterationBody(stmt, &while_loop, 0); |
609 while_loop.EndBody(); | 609 while_loop.EndBody(); |
610 VisitForTest(stmt->cond()); | 610 VisitForTest(stmt->cond()); |
611 Node* condition = environment()->Pop(); | 611 Node* condition = environment()->Pop(); |
612 while_loop.BreakUnless(condition); | 612 while_loop.BreakUnless(condition); |
613 while_loop.EndLoop(); | 613 while_loop.EndLoop(); |
614 } | 614 } |
615 | 615 |
616 | 616 |
617 void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 617 void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
618 LoopBuilder while_loop(this); | 618 LoopBuilder while_loop(this); |
619 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); | 619 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
620 VisitForTest(stmt->cond()); | 620 VisitForTest(stmt->cond()); |
621 Node* condition = environment()->Pop(); | 621 Node* condition = environment()->Pop(); |
622 while_loop.BreakUnless(condition); | 622 while_loop.BreakUnless(condition); |
623 VisitIterationBody(stmt, &while_loop, 0); | 623 VisitIterationBody(stmt, &while_loop, 0); |
624 while_loop.EndBody(); | 624 while_loop.EndBody(); |
625 while_loop.EndLoop(); | 625 while_loop.EndLoop(); |
626 } | 626 } |
627 | 627 |
628 | 628 |
629 void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { | 629 void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { |
630 LoopBuilder for_loop(this); | 630 LoopBuilder for_loop(this); |
631 VisitIfNotNull(stmt->init()); | 631 VisitIfNotNull(stmt->init()); |
632 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); | 632 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
633 if (stmt->cond() != NULL) { | 633 if (stmt->cond() != NULL) { |
634 VisitForTest(stmt->cond()); | 634 VisitForTest(stmt->cond()); |
635 Node* condition = environment()->Pop(); | 635 Node* condition = environment()->Pop(); |
636 for_loop.BreakUnless(condition); | 636 for_loop.BreakUnless(condition); |
637 } else { | 637 } else { |
638 for_loop.BreakUnless(jsgraph()->TrueConstant()); | 638 for_loop.BreakUnless(jsgraph()->TrueConstant()); |
639 } | 639 } |
640 VisitIterationBody(stmt, &for_loop, 0); | 640 VisitIterationBody(stmt, &for_loop, 0); |
641 for_loop.EndBody(); | 641 for_loop.EndBody(); |
642 VisitIfNotNull(stmt->next()); | 642 VisitIfNotNull(stmt->next()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 } | 707 } |
708 is_null.End(); | 708 is_null.End(); |
709 } | 709 } |
710 is_undefined.End(); | 710 is_undefined.End(); |
711 } | 711 } |
712 | 712 |
713 | 713 |
714 // TODO(dcarney): this is a big function. Try to clean up some. | 714 // TODO(dcarney): this is a big function. Try to clean up some. |
715 void AstGraphBuilder::VisitForInBody(ForInStatement* stmt) { | 715 void AstGraphBuilder::VisitForInBody(ForInStatement* stmt) { |
716 LoopBuilder for_loop(this); | 716 LoopBuilder for_loop(this); |
717 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); | 717 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
718 | 718 |
719 // These stack values are renamed in the case of OSR, so reload them | 719 // These stack values are renamed in the case of OSR, so reload them |
720 // from the environment. | 720 // from the environment. |
721 Node* index = environment()->Peek(0); | 721 Node* index = environment()->Peek(0); |
722 Node* cache_length = environment()->Peek(1); | 722 Node* cache_length = environment()->Peek(1); |
723 Node* cache_array = environment()->Peek(2); | 723 Node* cache_array = environment()->Peek(2); |
724 Node* cache_type = environment()->Peek(3); | 724 Node* cache_type = environment()->Peek(3); |
725 Node* obj = environment()->Peek(4); | 725 Node* obj = environment()->Peek(4); |
726 | 726 |
727 // Check loop termination condition. | 727 // Check loop termination condition. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 environment()->Poke(0, index_inc); | 786 environment()->Poke(0, index_inc); |
787 for_loop.EndLoop(); | 787 for_loop.EndLoop(); |
788 environment()->Drop(5); | 788 environment()->Drop(5); |
789 // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 789 // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
790 } | 790 } |
791 | 791 |
792 | 792 |
793 void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { | 793 void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { |
794 LoopBuilder for_loop(this); | 794 LoopBuilder for_loop(this); |
795 VisitForEffect(stmt->assign_iterator()); | 795 VisitForEffect(stmt->assign_iterator()); |
796 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); | 796 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
797 VisitForEffect(stmt->next_result()); | 797 VisitForEffect(stmt->next_result()); |
798 VisitForTest(stmt->result_done()); | 798 VisitForTest(stmt->result_done()); |
799 Node* condition = environment()->Pop(); | 799 Node* condition = environment()->Pop(); |
800 for_loop.BreakWhen(condition); | 800 for_loop.BreakWhen(condition); |
801 VisitForEffect(stmt->assign_each()); | 801 VisitForEffect(stmt->assign_each()); |
802 VisitIterationBody(stmt, &for_loop, 0); | 802 VisitIterationBody(stmt, &for_loop, 0); |
803 for_loop.EndBody(); | 803 for_loop.EndBody(); |
804 for_loop.EndLoop(); | 804 for_loop.EndLoop(); |
805 } | 805 } |
806 | 806 |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 Node* tag = NewNode(jsgraph()->machine()->UintLessThan(), limit, stack); | 2405 Node* tag = NewNode(jsgraph()->machine()->UintLessThan(), limit, stack); |
2406 stack_check.If(tag, BranchHint::kTrue); | 2406 stack_check.If(tag, BranchHint::kTrue); |
2407 stack_check.Then(); | 2407 stack_check.Then(); |
2408 stack_check.Else(); | 2408 stack_check.Else(); |
2409 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0)); | 2409 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0)); |
2410 stack_check.End(); | 2410 stack_check.End(); |
2411 return guard; | 2411 return guard; |
2412 } | 2412 } |
2413 | 2413 |
2414 | 2414 |
2415 bool AstGraphBuilder::IsOsrLoopEntry(IterationStatement* stmt) { | 2415 bool AstGraphBuilder::CheckOsrEntry(IterationStatement* stmt) { |
2416 return info()->osr_ast_id() == stmt->OsrEntryId(); | 2416 if (info()->osr_ast_id() == stmt->OsrEntryId()) { |
| 2417 info()->set_osr_expr_stack_height(std::max( |
| 2418 environment()->stack_height(), info()->osr_expr_stack_height())); |
| 2419 return true; |
| 2420 } |
| 2421 return false; |
2417 } | 2422 } |
2418 | 2423 |
2419 | 2424 |
2420 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, | 2425 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, |
2421 OutputFrameStateCombine combine) { | 2426 OutputFrameStateCombine combine) { |
2422 if (OperatorProperties::HasFrameStateInput(node->op())) { | 2427 if (OperatorProperties::HasFrameStateInput(node->op())) { |
2423 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == | 2428 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == |
2424 IrOpcode::kDead); | 2429 IrOpcode::kDead); |
2425 NodeProperties::ReplaceFrameStateInput( | 2430 NodeProperties::ReplaceFrameStateInput( |
2426 node, environment()->Checkpoint(ast_id, combine)); | 2431 node, environment()->Checkpoint(ast_id, combine)); |
2427 } | 2432 } |
2428 } | 2433 } |
2429 | 2434 |
2430 | 2435 |
2431 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( | 2436 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( |
2432 IterationStatement* stmt) { | 2437 IterationStatement* stmt) { |
2433 if (loop_assignment_analysis_ == NULL) return NULL; | 2438 if (loop_assignment_analysis_ == NULL) return NULL; |
2434 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); | 2439 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); |
2435 } | 2440 } |
2436 | 2441 |
2437 } // namespace compiler | 2442 } // namespace compiler |
2438 } // namespace internal | 2443 } // namespace internal |
2439 } // namespace v8 | 2444 } // namespace v8 |
OLD | NEW |