OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 HConstant* HGraph::GetConstantFalse() { | 627 HConstant* HGraph::GetConstantFalse() { |
628 return GetConstant(&constant_false_, isolate()->factory()->false_value()); | 628 return GetConstant(&constant_false_, isolate()->factory()->false_value()); |
629 } | 629 } |
630 | 630 |
631 | 631 |
632 HConstant* HGraph::GetConstantHole() { | 632 HConstant* HGraph::GetConstantHole() { |
633 return GetConstant(&constant_hole_, isolate()->factory()->the_hole_value()); | 633 return GetConstant(&constant_hole_, isolate()->factory()->the_hole_value()); |
634 } | 634 } |
635 | 635 |
636 | 636 |
637 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, BailoutId id) | 637 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, |
638 BailoutId id) | |
Michael Starzinger
2013/02/21 19:39:23
Still fits into one line.
danno
2013/02/25 11:11:23
Done.
| |
638 : builder_(builder), | 639 : builder_(builder), |
639 finished_(false), | 640 finished_(false), |
640 id_(id) { | 641 id_(id) { |
641 HEnvironment* env = builder->environment(); | 642 HEnvironment* env = builder->environment(); |
642 HEnvironment* true_env = env->Copy(); | 643 HEnvironment* true_env = env->Copy(); |
643 HEnvironment* false_env = env->Copy(); | 644 HEnvironment* false_env = env->Copy(); |
644 HEnvironment* merge_env = env->Copy(); | 645 first_true_block_ = builder->CreateBasicBlock(true_env); |
645 true_block_ = builder->CreateBasicBlock(true_env); | 646 last_true_block_ = NULL; |
646 false_block_ = builder->CreateBasicBlock(false_env); | 647 first_false_block_ = builder->CreateBasicBlock(false_env); |
647 merge_block_ = builder->CreateBasicBlock(merge_env); | |
648 } | 648 } |
649 | 649 |
650 | 650 |
651 void HGraphBuilder::IfBuilder::BeginTrue(HValue* left, | 651 HInstruction* HGraphBuilder::IfBuilder::BeginTrue( |
652 HValue* right, | 652 HValue* left, |
653 Token::Value token) { | 653 HValue* right, |
654 Token::Value token, | |
655 Representation input_representation) { | |
654 HCompareIDAndBranch* compare = | 656 HCompareIDAndBranch* compare = |
655 new(zone()) HCompareIDAndBranch(left, right, token); | 657 new(zone()) HCompareIDAndBranch(left, right, token); |
656 compare->ChangeRepresentation(Representation::Integer32()); | 658 compare->set_observed_input_representation(input_representation, |
657 compare->SetSuccessorAt(0, true_block_); | 659 input_representation); |
658 compare->SetSuccessorAt(1, false_block_); | 660 compare->ChangeRepresentation(input_representation); |
661 compare->SetSuccessorAt(0, first_true_block_); | |
662 compare->SetSuccessorAt(1, first_false_block_); | |
659 builder_->current_block()->Finish(compare); | 663 builder_->current_block()->Finish(compare); |
660 builder_->set_current_block(true_block_); | 664 builder_->set_current_block(first_true_block_); |
665 return compare; | |
661 } | 666 } |
662 | 667 |
663 | 668 |
664 void HGraphBuilder::IfBuilder::BeginFalse() { | 669 void HGraphBuilder::IfBuilder::BeginFalse() { |
665 builder_->current_block()->Goto(merge_block_); | 670 last_true_block_ = builder_->current_block(); |
666 builder_->set_current_block(false_block_); | 671 ASSERT(!last_true_block_->IsFinished()); |
672 builder_->set_current_block(first_false_block_); | |
667 } | 673 } |
668 | 674 |
669 | 675 |
670 void HGraphBuilder::IfBuilder::End() { | 676 void HGraphBuilder::IfBuilder::End() { |
671 ASSERT(!finished_); | 677 ASSERT(!finished_); |
672 builder_->current_block()->Goto(merge_block_); | 678 ASSERT(!last_true_block_->IsFinished()); |
679 HBasicBlock* last_false_block = builder_->current_block(); | |
680 ASSERT(!last_false_block->IsFinished()); | |
681 HEnvironment* merge_env = | |
682 last_true_block_->last_environment()->Copy(); | |
683 merge_block_ = builder_->CreateBasicBlock(merge_env); | |
684 last_true_block_->Goto(merge_block_); | |
685 last_false_block->Goto(merge_block_); | |
686 merge_block_->SetJoinId(id_); | |
673 builder_->set_current_block(merge_block_); | 687 builder_->set_current_block(merge_block_); |
674 merge_block_->SetJoinId(id_); | |
675 finished_ = true; | 688 finished_ = true; |
676 } | 689 } |
677 | 690 |
678 | 691 |
679 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, | 692 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, |
680 HValue* context, | 693 HValue* context, |
681 LoopBuilder::Direction direction, | 694 LoopBuilder::Direction direction, |
682 BailoutId id) | 695 BailoutId id) |
683 : builder_(builder), | 696 : builder_(builder), |
684 context_(context), | 697 context_(context), |
685 direction_(direction), | 698 direction_(direction), |
686 id_(id), | 699 id_(id), |
687 finished_(false) { | 700 finished_(false) { |
688 HEnvironment* env = builder_->environment(); | |
689 HEnvironment* body_env = env->Copy(); | |
690 HEnvironment* exit_env = env->Copy(); | |
691 header_block_ = builder->CreateLoopHeaderBlock(); | 701 header_block_ = builder->CreateLoopHeaderBlock(); |
692 body_block_ = builder->CreateBasicBlock(body_env); | 702 body_block_ = NULL; |
693 exit_block_ = builder->CreateBasicBlock(exit_env); | 703 exit_block_ = NULL; |
694 } | 704 } |
695 | 705 |
696 | 706 |
697 HValue* HGraphBuilder::LoopBuilder::BeginBody(HValue* initial, | 707 HValue* HGraphBuilder::LoopBuilder::BeginBody( |
698 HValue* terminating, | 708 HValue* initial, |
699 Token::Value token) { | 709 HValue* terminating, |
700 phi_ = new(zone()) HPhi(0, zone()); | 710 Token::Value token, |
711 Representation input_representation) { | |
712 HEnvironment* env = builder_->environment(); | |
713 phi_ = new(zone()) HPhi(env->values()->length(), zone()); | |
701 header_block_->AddPhi(phi_); | 714 header_block_->AddPhi(phi_); |
702 phi_->AddInput(initial); | 715 phi_->AddInput(initial); |
703 phi_->ChangeRepresentation(Representation::Integer32()); | 716 phi_->ChangeRepresentation(Representation::Integer32()); |
704 HEnvironment* env = builder_->environment(); | |
705 env->Push(initial); | 717 env->Push(initial); |
706 builder_->current_block()->Goto(header_block_); | 718 builder_->current_block()->Goto(header_block_); |
707 builder_->set_current_block(header_block_); | 719 |
720 HEnvironment* body_env = env->Copy(); | |
721 HEnvironment* exit_env = env->Copy(); | |
722 body_block_ = builder_->CreateBasicBlock(body_env); | |
723 exit_block_ = builder_->CreateBasicBlock(exit_env); | |
724 // Remove the phi from the expression stack | |
725 body_env->Pop(); | |
708 | 726 |
709 builder_->set_current_block(header_block_); | 727 builder_->set_current_block(header_block_); |
710 HCompareIDAndBranch* compare = | 728 HCompareIDAndBranch* compare = |
711 new(zone()) HCompareIDAndBranch(phi_, terminating, token); | 729 new(zone()) HCompareIDAndBranch(phi_, terminating, token); |
712 compare->ChangeRepresentation(Representation::Integer32()); | 730 compare->set_observed_input_representation(input_representation, |
731 input_representation); | |
732 compare->ChangeRepresentation(input_representation); | |
713 compare->SetSuccessorAt(0, body_block_); | 733 compare->SetSuccessorAt(0, body_block_); |
714 compare->SetSuccessorAt(1, exit_block_); | 734 compare->SetSuccessorAt(1, exit_block_); |
715 builder_->current_block()->Finish(compare); | 735 builder_->current_block()->Finish(compare); |
716 | 736 |
717 builder_->set_current_block(body_block_); | 737 builder_->set_current_block(body_block_); |
718 if (direction_ == kPreIncrement || direction_ == kPreDecrement) { | 738 if (direction_ == kPreIncrement || direction_ == kPreDecrement) { |
719 HValue* one = builder_->graph()->GetConstant1(); | 739 HValue* one = builder_->graph()->GetConstant1(); |
720 if (direction_ == kPreIncrement) { | 740 if (direction_ == kPreIncrement) { |
721 increment_ = HAdd::New(zone(), context_, phi_, one); | 741 increment_ = HAdd::New(zone(), context_, phi_, one); |
722 } else { | 742 } else { |
(...skipping 17 matching lines...) Expand all Loading... | |
740 if (direction_ == kPostIncrement) { | 760 if (direction_ == kPostIncrement) { |
741 increment_ = HAdd::New(zone(), context_, phi_, one); | 761 increment_ = HAdd::New(zone(), context_, phi_, one); |
742 } else { | 762 } else { |
743 increment_ = HSub::New(zone(), context_, phi_, one); | 763 increment_ = HSub::New(zone(), context_, phi_, one); |
744 } | 764 } |
745 increment_->ClearFlag(HValue::kCanOverflow); | 765 increment_->ClearFlag(HValue::kCanOverflow); |
746 increment_->ChangeRepresentation(Representation::Integer32()); | 766 increment_->ChangeRepresentation(Representation::Integer32()); |
747 builder_->AddInstruction(increment_); | 767 builder_->AddInstruction(increment_); |
748 } | 768 } |
749 | 769 |
770 // Push the new increment value on the expression stack to merge into the phi. | |
750 builder_->environment()->Push(increment_); | 771 builder_->environment()->Push(increment_); |
751 builder_->current_block()->Goto(header_block_); | 772 builder_->current_block()->Goto(header_block_); |
752 header_block_->loop_information()->RegisterBackEdge(body_block_); | 773 header_block_->loop_information()->RegisterBackEdge(body_block_); |
753 header_block_->SetJoinId(BailoutId::StubEntry()); | 774 header_block_->SetJoinId(id_); |
775 | |
754 builder_->set_current_block(exit_block_); | 776 builder_->set_current_block(exit_block_); |
777 // Pop the phi from the expression stack | |
778 builder_->environment()->Pop(); | |
755 finished_ = true; | 779 finished_ = true; |
756 } | 780 } |
757 | 781 |
758 | 782 |
759 HGraph* HGraphBuilder::CreateGraph() { | 783 HGraph* HGraphBuilder::CreateGraph() { |
760 graph_ = new(zone()) HGraph(info_); | 784 graph_ = new(zone()) HGraph(info_); |
761 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info_); | 785 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info_); |
762 HPhase phase("H_Block building"); | 786 HPhase phase("H_Block building"); |
763 set_current_block(graph()->entry_block()); | 787 set_current_block(graph()->entry_block()); |
764 if (!BuildGraph()) return NULL; | 788 if (!BuildGraph()) return NULL; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 values_(16, info->zone()), | 1167 values_(16, info->zone()), |
1144 phi_list_(NULL), | 1168 phi_list_(NULL), |
1145 uint32_instructions_(NULL), | 1169 uint32_instructions_(NULL), |
1146 info_(info), | 1170 info_(info), |
1147 zone_(info->zone()), | 1171 zone_(info->zone()), |
1148 is_recursive_(false), | 1172 is_recursive_(false), |
1149 use_optimistic_licm_(false), | 1173 use_optimistic_licm_(false), |
1150 has_soft_deoptimize_(false), | 1174 has_soft_deoptimize_(false), |
1151 type_change_checksum_(0) { | 1175 type_change_checksum_(0) { |
1152 if (info->IsStub()) { | 1176 if (info->IsStub()) { |
1177 HydrogenCodeStub* stub = info->code_stub(); | |
1178 int param_count = | |
1179 stub->GetInterfaceDescriptor(isolate_)->register_param_count_; | |
1153 start_environment_ = | 1180 start_environment_ = |
1154 new(zone_) HEnvironment(zone_); | 1181 new(zone_) HEnvironment(zone_, param_count); |
1155 } else { | 1182 } else { |
1156 start_environment_ = | 1183 start_environment_ = |
1157 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); | 1184 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); |
1158 } | 1185 } |
1159 start_environment_->set_ast_id(BailoutId::FunctionEntry()); | 1186 start_environment_->set_ast_id(BailoutId::FunctionEntry()); |
1160 entry_block_ = CreateBasicBlock(); | 1187 entry_block_ = CreateBasicBlock(); |
1161 entry_block_->SetInitialEnvironment(start_environment_); | 1188 entry_block_->SetInitialEnvironment(start_environment_); |
1162 } | 1189 } |
1163 | 1190 |
1164 | 1191 |
(...skipping 8926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10091 outer_(outer), | 10118 outer_(outer), |
10092 entry_(NULL), | 10119 entry_(NULL), |
10093 pop_count_(0), | 10120 pop_count_(0), |
10094 push_count_(0), | 10121 push_count_(0), |
10095 ast_id_(BailoutId::None()), | 10122 ast_id_(BailoutId::None()), |
10096 zone_(zone) { | 10123 zone_(zone) { |
10097 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); | 10124 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); |
10098 } | 10125 } |
10099 | 10126 |
10100 | 10127 |
10101 HEnvironment::HEnvironment(Zone* zone) | 10128 HEnvironment::HEnvironment(Zone* zone, int parameter_count) |
10102 : values_(0, zone), | 10129 : values_(0, zone), |
10103 frame_type_(STUB), | 10130 frame_type_(STUB), |
10104 parameter_count_(0), | 10131 parameter_count_(parameter_count), |
10105 specials_count_(0), | 10132 specials_count_(1), |
10106 local_count_(0), | 10133 local_count_(0), |
10107 outer_(NULL), | 10134 outer_(NULL), |
10108 entry_(NULL), | 10135 entry_(NULL), |
10109 pop_count_(0), | 10136 pop_count_(0), |
10110 push_count_(0), | 10137 push_count_(0), |
10111 ast_id_(BailoutId::None()), | 10138 ast_id_(BailoutId::None()), |
10112 zone_(zone) { | 10139 zone_(zone) { |
10113 Initialize(0, 0, 0); | 10140 Initialize(parameter_count, 0, 0); |
10114 } | 10141 } |
10115 | 10142 |
10116 | 10143 |
10117 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) | 10144 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) |
10118 : values_(0, zone), | 10145 : values_(0, zone), |
10119 frame_type_(JS_FUNCTION), | 10146 frame_type_(JS_FUNCTION), |
10120 parameter_count_(0), | 10147 parameter_count_(0), |
10121 specials_count_(0), | 10148 specials_count_(0), |
10122 local_count_(0), | 10149 local_count_(0), |
10123 outer_(NULL), | 10150 outer_(NULL), |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10712 } | 10739 } |
10713 } | 10740 } |
10714 | 10741 |
10715 #ifdef DEBUG | 10742 #ifdef DEBUG |
10716 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10743 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10717 if (allocator_ != NULL) allocator_->Verify(); | 10744 if (allocator_ != NULL) allocator_->Verify(); |
10718 #endif | 10745 #endif |
10719 } | 10746 } |
10720 | 10747 |
10721 } } // namespace v8::internal | 10748 } } // namespace v8::internal |
OLD | NEW |