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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 phi->Kill(); | 106 phi->Kill(); |
107 phis_.RemoveElement(phi); | 107 phis_.RemoveElement(phi); |
108 phi->SetBlock(NULL); | 108 phi->SetBlock(NULL); |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 void HBasicBlock::AddInstruction(HInstruction* instr) { | 112 void HBasicBlock::AddInstruction(HInstruction* instr) { |
113 ASSERT(!IsStartBlock() || !IsFinished()); | 113 ASSERT(!IsStartBlock() || !IsFinished()); |
114 ASSERT(!instr->IsLinked()); | 114 ASSERT(!instr->IsLinked()); |
115 ASSERT(!IsFinished()); | 115 ASSERT(!IsFinished()); |
116 // Make sure that we never add instructions without knowing | 116 |
117 // what the previous ast id is. | |
118 ASSERT(instr->IsSimulate() || instr->IsGoto() || | |
119 !last_environment()->previous_ast_id().IsNone()); | |
120 if (first_ == NULL) { | 117 if (first_ == NULL) { |
118 ASSERT(last_environment() != NULL); | |
119 ASSERT(!last_environment()->ast_id().IsNone()); | |
121 HBlockEntry* entry = new(zone()) HBlockEntry(); | 120 HBlockEntry* entry = new(zone()) HBlockEntry(); |
122 entry->InitializeAsFirst(this); | 121 entry->InitializeAsFirst(this); |
123 first_ = last_ = entry; | 122 first_ = last_ = entry; |
124 } | 123 } |
125 instr->InsertAfter(last_); | 124 instr->InsertAfter(last_); |
126 } | 125 } |
127 | 126 |
128 | 127 |
129 HDeoptimize* HBasicBlock::CreateDeoptimize( | 128 HDeoptimize* HBasicBlock::CreateDeoptimize( |
130 HDeoptimize::UseEnvironment has_uses) { | 129 HDeoptimize::UseEnvironment has_uses) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 ASSERT(return_value != NULL); | 207 ASSERT(return_value != NULL); |
209 AddInstruction(new(zone()) HLeaveInlined()); | 208 AddInstruction(new(zone()) HLeaveInlined()); |
210 last_environment_ = last_environment()->DiscardInlined(drop_extra); | 209 last_environment_ = last_environment()->DiscardInlined(drop_extra); |
211 last_environment()->Push(return_value); | 210 last_environment()->Push(return_value); |
212 AddSimulate(BailoutId::None()); | 211 AddSimulate(BailoutId::None()); |
213 HGoto* instr = new(zone()) HGoto(target); | 212 HGoto* instr = new(zone()) HGoto(target); |
214 Finish(instr); | 213 Finish(instr); |
215 } | 214 } |
216 | 215 |
217 | 216 |
218 void HBasicBlock::SetInitialEnvironment(HEnvironment* env, | 217 void HBasicBlock::SetInitialEnvironment(HEnvironment* env) { |
219 BailoutId previous_ast_id) { | |
220 ASSERT(!HasEnvironment()); | 218 ASSERT(!HasEnvironment()); |
221 ASSERT(first() == NULL); | 219 ASSERT(first() == NULL); |
222 UpdateEnvironment(env); | 220 UpdateEnvironment(env); |
223 env->set_previous_ast_id(previous_ast_id); | |
224 } | 221 } |
225 | 222 |
226 | 223 |
227 void HBasicBlock::SetJoinId(BailoutId ast_id) { | 224 void HBasicBlock::SetJoinId(BailoutId ast_id) { |
228 int length = predecessors_.length(); | 225 int length = predecessors_.length(); |
229 ASSERT(length > 0); | 226 ASSERT(length > 0); |
230 for (int i = 0; i < length; i++) { | 227 for (int i = 0; i < length; i++) { |
231 HBasicBlock* predecessor = predecessors_[i]; | 228 HBasicBlock* predecessor = predecessors_[i]; |
232 ASSERT(predecessor->end()->IsGoto()); | 229 ASSERT(predecessor->end()->IsGoto()); |
233 HSimulate* simulate = HSimulate::cast(predecessor->end()->previous()); | 230 HSimulate* simulate = HSimulate::cast(predecessor->end()->previous()); |
234 ASSERT(i != 0 || | 231 ASSERT(i != 0 || |
235 (predecessor->last_environment()->closure().is_null() || | 232 (predecessor->last_environment()->closure().is_null() || |
236 predecessor->last_environment()->closure()->shared() | 233 predecessor->last_environment()->closure()->shared() |
237 ->VerifyBailoutId(ast_id))); | 234 ->VerifyBailoutId(ast_id))); |
238 simulate->set_ast_id(ast_id); | 235 simulate->set_ast_id(ast_id); |
239 } | 236 predecessor->last_environment()->set_ast_id(ast_id); |
danno
2013/04/17 12:04:06
This turns out to be wrong. Please remove this las
titzer
2013/04/17 13:19:16
Tried this, and many tests are now failing with
#
danno
2013/04/17 13:22:51
I must have been confused. I think it is only inco
| |
240 HEnvironment* last_environment = this->last_environment(); | |
241 ASSERT(last_environment || IsFinished()); | |
242 if (last_environment != NULL) { | |
243 last_environment->set_previous_ast_id(ast_id); | |
244 } | 237 } |
245 } | 238 } |
246 | 239 |
247 | 240 |
248 bool HBasicBlock::Dominates(HBasicBlock* other) const { | 241 bool HBasicBlock::Dominates(HBasicBlock* other) const { |
249 HBasicBlock* current = other->dominator(); | 242 HBasicBlock* current = other->dominator(); |
250 while (current != NULL) { | 243 while (current != NULL) { |
251 if (current == this) return true; | 244 if (current == this) return true; |
252 current = current->dominator(); | 245 current = current->dominator(); |
253 } | 246 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 if (IsLoopHeader()) { | 287 if (IsLoopHeader()) { |
295 ASSERT(phis()->length() == incoming_env->length()); | 288 ASSERT(phis()->length() == incoming_env->length()); |
296 for (int i = 0; i < phis_.length(); ++i) { | 289 for (int i = 0; i < phis_.length(); ++i) { |
297 phis_[i]->AddInput(incoming_env->values()->at(i)); | 290 phis_[i]->AddInput(incoming_env->values()->at(i)); |
298 } | 291 } |
299 } else { | 292 } else { |
300 last_environment()->AddIncomingEdge(this, pred->last_environment()); | 293 last_environment()->AddIncomingEdge(this, pred->last_environment()); |
301 } | 294 } |
302 } else if (!HasEnvironment() && !IsFinished()) { | 295 } else if (!HasEnvironment() && !IsFinished()) { |
303 ASSERT(!IsLoopHeader()); | 296 ASSERT(!IsLoopHeader()); |
304 HEnvironment* new_env = pred->last_environment()->Copy(); | 297 SetInitialEnvironment(pred->last_environment()->Copy()); |
305 SetInitialEnvironment(new_env, | |
306 pred->last_environment()->previous_ast_id()); | |
307 } | 298 } |
308 | 299 |
309 predecessors_.Add(pred, zone()); | 300 predecessors_.Add(pred, zone()); |
310 } | 301 } |
311 | 302 |
312 | 303 |
313 void HBasicBlock::AddDominatedBlock(HBasicBlock* block) { | 304 void HBasicBlock::AddDominatedBlock(HBasicBlock* block) { |
314 ASSERT(!dominated_blocks_.Contains(block)); | 305 ASSERT(!dominated_blocks_.Contains(block)); |
315 // Keep the list of dominated blocks sorted such that if there is two | 306 // Keep the list of dominated blocks sorted such that if there is two |
316 // succeeding block in this list, the predecessor is before the successor. | 307 // succeeding block in this list, the predecessor is before the successor. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 if (second != NULL) { | 537 if (second != NULL) { |
547 ASSERT(second->predecessors()->Contains(block)); | 538 ASSERT(second->predecessors()->Contains(block)); |
548 } | 539 } |
549 } | 540 } |
550 | 541 |
551 // Check that phis have correct arguments. | 542 // Check that phis have correct arguments. |
552 for (int j = 0; j < block->phis()->length(); j++) { | 543 for (int j = 0; j < block->phis()->length(); j++) { |
553 HPhi* phi = block->phis()->at(j); | 544 HPhi* phi = block->phis()->at(j); |
554 phi->Verify(); | 545 phi->Verify(); |
555 } | 546 } |
547 | |
548 // Check that all join blocks have predecessors that end with an | |
549 // unconditional goto and agree on their environment node id. | |
550 if (block->predecessors()->length() >= 2) { | |
551 BailoutId id = | |
552 block->predecessors()->first()->last_environment()->ast_id(); | |
553 for (int k = 0; k < block->predecessors()->length(); k++) { | |
554 HBasicBlock* predecessor = block->predecessors()->at(k); | |
555 ASSERT(predecessor->end()->IsGoto()); | |
556 ASSERT(predecessor->last_environment()->ast_id() == id); | |
557 } | |
558 } | |
556 } | 559 } |
557 | 560 |
558 // Check special property of first block to have no predecessors. | 561 // Check special property of first block to have no predecessors. |
559 ASSERT(blocks_.at(0)->predecessors()->is_empty()); | 562 ASSERT(blocks_.at(0)->predecessors()->is_empty()); |
560 | 563 |
561 if (do_full_verify) { | 564 if (do_full_verify) { |
562 // Check that the graph is fully connected. | 565 // Check that the graph is fully connected. |
563 ReachabilityAnalyzer analyzer(entry_block_, blocks_.length(), NULL); | 566 ReachabilityAnalyzer analyzer(entry_block_, blocks_.length(), NULL); |
564 ASSERT(analyzer.visited_count() == blocks_.length()); | 567 ASSERT(analyzer.visited_count() == blocks_.length()); |
565 | 568 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 } | 633 } |
631 | 634 |
632 | 635 |
633 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true) | 636 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true) |
634 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false) | 637 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false) |
635 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false) | 638 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false) |
636 | 639 |
637 #undef DEFINE_GET_CONSTANT | 640 #undef DEFINE_GET_CONSTANT |
638 | 641 |
639 | 642 |
640 HGraphBuilder::CheckBuilder::CheckBuilder(HGraphBuilder* builder) | 643 HGraphBuilder::CheckBuilder::CheckBuilder(HGraphBuilder* builder, BailoutId id) |
641 : builder_(builder), | 644 : builder_(builder), |
642 finished_(false), | 645 finished_(false), |
643 id_(builder->current_block()->last_environment()->previous_ast_id()) { | 646 id_(id) { |
644 HEnvironment* env = builder->environment(); | 647 HEnvironment* env = builder->environment(); |
645 failure_block_ = builder->CreateBasicBlock(env->CopyWithoutHistory(), id_); | 648 failure_block_ = builder->CreateBasicBlock(env->CopyWithoutHistory()); |
646 merge_block_ = builder->CreateBasicBlock(env->CopyWithoutHistory(), id_); | 649 merge_block_ = builder->CreateBasicBlock(env->CopyWithoutHistory()); |
647 } | 650 } |
648 | 651 |
649 | 652 |
650 HValue* HGraphBuilder::CheckBuilder::CheckNotUndefined(HValue* value) { | 653 HValue* HGraphBuilder::CheckBuilder::CheckNotUndefined(HValue* value) { |
651 HEnvironment* env = builder_->environment(); | 654 HEnvironment* env = builder_->environment(); |
652 HIsNilAndBranch* compare = | 655 HIsNilAndBranch* compare = |
653 new(zone()) HIsNilAndBranch(value, kStrictEquality, kUndefinedValue); | 656 new(zone()) HIsNilAndBranch(value, kStrictEquality, kUndefinedValue); |
654 HBasicBlock* success_block = | 657 HBasicBlock* success_block = |
655 builder_->CreateBasicBlock(env->CopyWithoutHistory(), id_); | 658 builder_->CreateBasicBlock(env->CopyWithoutHistory()); |
656 HBasicBlock* failure_block = | 659 HBasicBlock* failure_block = |
657 builder_->CreateBasicBlock(env->CopyWithoutHistory(), id_); | 660 builder_->CreateBasicBlock(env->CopyWithoutHistory()); |
658 compare->SetSuccessorAt(0, failure_block); | 661 compare->SetSuccessorAt(0, failure_block); |
659 compare->SetSuccessorAt(1, success_block); | 662 compare->SetSuccessorAt(1, success_block); |
660 failure_block->Goto(failure_block_); | 663 failure_block->Goto(failure_block_); |
661 builder_->current_block()->Finish(compare); | 664 builder_->current_block()->Finish(compare); |
662 builder_->set_current_block(success_block); | 665 builder_->set_current_block(success_block); |
663 return compare; | 666 return compare; |
664 } | 667 } |
665 | 668 |
666 | 669 |
667 HValue* HGraphBuilder::CheckBuilder::CheckIntegerCompare(HValue* left, | 670 HValue* HGraphBuilder::CheckBuilder::CheckIntegerCompare(HValue* left, |
668 HValue* right, | 671 HValue* right, |
669 Token::Value op) { | 672 Token::Value op) { |
670 HEnvironment* env = builder_->environment(); | 673 HEnvironment* env = builder_->environment(); |
671 HCompareIDAndBranch* compare = | 674 HCompareIDAndBranch* compare = |
672 new(zone()) HCompareIDAndBranch(left, right, op); | 675 new(zone()) HCompareIDAndBranch(left, right, op); |
673 compare->AssumeRepresentation(Representation::Integer32()); | 676 compare->AssumeRepresentation(Representation::Integer32()); |
674 HBasicBlock* success_block = | 677 HBasicBlock* success_block = |
675 builder_->CreateBasicBlock(env->CopyWithoutHistory(), id_); | 678 builder_->CreateBasicBlock(env->CopyWithoutHistory()); |
676 HBasicBlock* failure_block = | 679 HBasicBlock* failure_block = |
677 builder_->CreateBasicBlock(env->CopyWithoutHistory(), id_); | 680 builder_->CreateBasicBlock(env->CopyWithoutHistory()); |
678 compare->SetSuccessorAt(0, success_block); | 681 compare->SetSuccessorAt(0, success_block); |
679 compare->SetSuccessorAt(1, failure_block); | 682 compare->SetSuccessorAt(1, failure_block); |
680 failure_block->Goto(failure_block_); | 683 failure_block->Goto(failure_block_); |
681 builder_->current_block()->Finish(compare); | 684 builder_->current_block()->Finish(compare); |
682 builder_->set_current_block(success_block); | 685 builder_->set_current_block(success_block); |
683 return compare; | 686 return compare; |
684 } | 687 } |
685 | 688 |
686 | 689 |
687 HValue* HGraphBuilder::CheckBuilder::CheckIntegerEq(HValue* left, | 690 HValue* HGraphBuilder::CheckBuilder::CheckIntegerEq(HValue* left, |
688 HValue* right) { | 691 HValue* right) { |
689 return CheckIntegerCompare(left, right, Token::EQ); | 692 return CheckIntegerCompare(left, right, Token::EQ); |
690 } | 693 } |
691 | 694 |
692 | 695 |
693 void HGraphBuilder::CheckBuilder::End() { | 696 void HGraphBuilder::CheckBuilder::End() { |
694 ASSERT(!finished_); | 697 ASSERT(!finished_); |
695 builder_->current_block()->Goto(merge_block_); | 698 builder_->current_block()->Goto(merge_block_); |
699 failure_block_->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | |
696 failure_block_->SetJoinId(id_); | 700 failure_block_->SetJoinId(id_); |
697 failure_block_->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | |
698 builder_->set_current_block(merge_block_); | 701 builder_->set_current_block(merge_block_); |
699 merge_block_->SetJoinId(id_); | 702 merge_block_->SetJoinId(id_); |
700 finished_ = true; | 703 finished_ = true; |
701 } | 704 } |
702 | 705 |
703 | 706 |
704 HConstant* HGraph::GetInvalidContext() { | 707 HConstant* HGraph::GetInvalidContext() { |
705 return GetConstantInt32(&constant_invalid_context_, 0xFFFFC0C7); | 708 return GetConstantInt32(&constant_invalid_context_, 0xFFFFC0C7); |
706 } | 709 } |
707 | 710 |
708 | 711 |
709 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder) | 712 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, BailoutId id) |
710 : builder_(builder), | 713 : builder_(builder), |
711 finished_(false), | 714 finished_(false), |
712 did_else_(false), | 715 did_else_(false), |
713 id_(builder->current_block()->last_environment()->previous_ast_id()) { | 716 id_(id) { |
714 HEnvironment* env = builder->environment(); | 717 HEnvironment* env = builder->environment(); |
715 first_true_block_ = builder->CreateBasicBlock(env->Copy(), id_); | 718 first_true_block_ = builder->CreateBasicBlock(env->Copy()); |
716 last_true_block_ = NULL; | 719 last_true_block_ = NULL; |
717 first_false_block_ = builder->CreateBasicBlock(env->Copy(), id_); | 720 first_false_block_ = builder->CreateBasicBlock(env->Copy()); |
718 } | 721 } |
719 | 722 |
720 | 723 |
721 HInstruction* HGraphBuilder::IfBuilder::BeginIf( | 724 HInstruction* HGraphBuilder::IfBuilder::BeginIf( |
722 HValue* left, | 725 HValue* left, |
723 HValue* right, | 726 HValue* right, |
724 Token::Value token, | 727 Token::Value token, |
725 Representation input_representation) { | 728 Representation input_representation) { |
726 HCompareIDAndBranch* compare = | 729 HCompareIDAndBranch* compare = |
727 new(zone()) HCompareIDAndBranch(left, right, token); | 730 new(zone()) HCompareIDAndBranch(left, right, token); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 | 771 |
769 | 772 |
770 void HGraphBuilder::IfBuilder::End() { | 773 void HGraphBuilder::IfBuilder::End() { |
771 ASSERT(!finished_); | 774 ASSERT(!finished_); |
772 if (!did_else_) BeginElse(); | 775 if (!did_else_) BeginElse(); |
773 ASSERT(!last_true_block_->IsFinished()); | 776 ASSERT(!last_true_block_->IsFinished()); |
774 HBasicBlock* last_false_block = builder_->current_block(); | 777 HBasicBlock* last_false_block = builder_->current_block(); |
775 ASSERT(!last_false_block->IsFinished()); | 778 ASSERT(!last_false_block->IsFinished()); |
776 HEnvironment* merge_env = | 779 HEnvironment* merge_env = |
777 last_true_block_->last_environment()->CopyWithoutHistory(); | 780 last_true_block_->last_environment()->CopyWithoutHistory(); |
778 merge_block_ = builder_->CreateBasicBlock(merge_env, id_); | 781 merge_block_ = builder_->CreateBasicBlock(merge_env); |
779 last_true_block_->Goto(merge_block_); | 782 last_true_block_->Goto(merge_block_); |
780 last_false_block->Goto(merge_block_); | 783 last_false_block->Goto(merge_block_); |
781 merge_block_->SetJoinId(id_); | 784 merge_block_->SetJoinId(id_); |
782 builder_->set_current_block(merge_block_); | 785 builder_->set_current_block(merge_block_); |
783 finished_ = true; | 786 finished_ = true; |
784 } | 787 } |
785 | 788 |
786 | 789 |
787 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, | 790 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, |
788 HValue* context, | 791 HValue* context, |
789 LoopBuilder::Direction direction) | 792 LoopBuilder::Direction direction, |
793 BailoutId id) | |
790 : builder_(builder), | 794 : builder_(builder), |
791 context_(context), | 795 context_(context), |
792 direction_(direction), | 796 direction_(direction), |
793 id_(builder->current_block()->last_environment()->previous_ast_id()), | 797 id_(id), |
794 finished_(false) { | 798 finished_(false) { |
795 header_block_ = builder->CreateLoopHeaderBlock(id_); | 799 header_block_ = builder->CreateLoopHeaderBlock(); |
796 body_block_ = NULL; | 800 body_block_ = NULL; |
797 exit_block_ = NULL; | 801 exit_block_ = NULL; |
798 } | 802 } |
799 | 803 |
800 | 804 |
801 HValue* HGraphBuilder::LoopBuilder::BeginBody( | 805 HValue* HGraphBuilder::LoopBuilder::BeginBody( |
802 HValue* initial, | 806 HValue* initial, |
803 HValue* terminating, | 807 HValue* terminating, |
804 Token::Value token, | 808 Token::Value token, |
805 Representation input_representation) { | 809 Representation input_representation) { |
806 HEnvironment* env = builder_->environment(); | 810 HEnvironment* env = builder_->environment(); |
807 phi_ = new(zone()) HPhi(env->values()->length(), zone()); | 811 phi_ = new(zone()) HPhi(env->values()->length(), zone()); |
808 header_block_->AddPhi(phi_); | 812 header_block_->AddPhi(phi_); |
809 phi_->AddInput(initial); | 813 phi_->AddInput(initial); |
810 phi_->ChangeRepresentation(Representation::Integer32()); | 814 phi_->ChangeRepresentation(Representation::Integer32()); |
811 env->Push(initial); | 815 env->Push(initial); |
812 builder_->current_block()->Goto(header_block_); | 816 builder_->current_block()->Goto(header_block_); |
813 | 817 |
814 HEnvironment* body_env = env->Copy(); | 818 HEnvironment* body_env = env->Copy(); |
815 HEnvironment* exit_env = env->Copy(); | 819 HEnvironment* exit_env = env->Copy(); |
816 body_block_ = builder_->CreateBasicBlock(body_env, id_); | 820 body_block_ = builder_->CreateBasicBlock(body_env); |
817 exit_block_ = builder_->CreateBasicBlock(exit_env, id_); | 821 exit_block_ = builder_->CreateBasicBlock(exit_env); |
818 // Remove the phi from the expression stack | 822 // Remove the phi from the expression stack |
819 body_env->Pop(); | 823 body_env->Pop(); |
820 | 824 |
821 builder_->set_current_block(header_block_); | 825 builder_->set_current_block(header_block_); |
822 HCompareIDAndBranch* compare = | 826 HCompareIDAndBranch* compare = |
823 new(zone()) HCompareIDAndBranch(phi_, terminating, token); | 827 new(zone()) HCompareIDAndBranch(phi_, terminating, token); |
824 compare->set_observed_input_representation(input_representation, | 828 compare->set_observed_input_representation(input_representation, |
825 input_representation); | 829 input_representation); |
826 compare->ChangeRepresentation(input_representation); | 830 compare->ChangeRepresentation(input_representation); |
827 compare->SetSuccessorAt(0, body_block_); | 831 compare->SetSuccessorAt(0, body_block_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 } | 897 } |
894 return instr; | 898 return instr; |
895 } | 899 } |
896 | 900 |
897 | 901 |
898 void HGraphBuilder::AddSimulate(BailoutId id, | 902 void HGraphBuilder::AddSimulate(BailoutId id, |
899 RemovableSimulate removable) { | 903 RemovableSimulate removable) { |
900 ASSERT(current_block() != NULL); | 904 ASSERT(current_block() != NULL); |
901 ASSERT(no_side_effects_scope_count_ == 0); | 905 ASSERT(no_side_effects_scope_count_ == 0); |
902 current_block()->AddSimulate(id, removable); | 906 current_block()->AddSimulate(id, removable); |
903 environment()->set_previous_ast_id(id); | 907 environment()->set_ast_id(id); |
904 } | 908 } |
905 | 909 |
906 | 910 |
907 HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, | 911 HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, |
908 HValue* length, | 912 HValue* length, |
909 BoundsCheckKeyMode key_mode, | 913 BoundsCheckKeyMode key_mode, |
910 Representation r) { | 914 Representation r) { |
911 if (!index->type().IsSmi()) { | 915 if (!index->type().IsSmi()) { |
912 index = new(graph()->zone()) HCheckSmiOrInt32(index); | 916 index = new(graph()->zone()) HCheckSmiOrInt32(index); |
913 AddInstruction(HCheckSmiOrInt32::cast(index)); | 917 AddInstruction(HCheckSmiOrInt32::cast(index)); |
(...skipping 14 matching lines...) Expand all Loading... | |
928 int num_parameters = graph()->info()->num_parameters(); | 932 int num_parameters = graph()->info()->num_parameters(); |
929 HValue* params = AddInstruction(new(graph()->zone()) | 933 HValue* params = AddInstruction(new(graph()->zone()) |
930 HConstant(num_parameters, Representation::Integer32())); | 934 HConstant(num_parameters, Representation::Integer32())); |
931 HReturn* return_instruction = new(graph()->zone()) | 935 HReturn* return_instruction = new(graph()->zone()) |
932 HReturn(value, context, params); | 936 HReturn(value, context, params); |
933 current_block()->FinishExit(return_instruction); | 937 current_block()->FinishExit(return_instruction); |
934 return return_instruction; | 938 return return_instruction; |
935 } | 939 } |
936 | 940 |
937 | 941 |
938 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env, | 942 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) { |
939 BailoutId previous_ast_id) { | |
940 HBasicBlock* b = graph()->CreateBasicBlock(); | 943 HBasicBlock* b = graph()->CreateBasicBlock(); |
941 b->SetInitialEnvironment(env, previous_ast_id); | 944 b->SetInitialEnvironment(env); |
942 return b; | 945 return b; |
943 } | 946 } |
944 | 947 |
945 | 948 |
946 HBasicBlock* HGraphBuilder::CreateLoopHeaderBlock(BailoutId previous_ast_id) { | 949 HBasicBlock* HGraphBuilder::CreateLoopHeaderBlock() { |
947 HBasicBlock* header = graph()->CreateBasicBlock(); | 950 HBasicBlock* header = graph()->CreateBasicBlock(); |
948 HEnvironment* entry_env = environment()->CopyAsLoopHeader(header); | 951 HEnvironment* entry_env = environment()->CopyAsLoopHeader(header); |
949 header->SetInitialEnvironment(entry_env, previous_ast_id); | 952 header->SetInitialEnvironment(entry_env); |
950 header->AttachLoopInformation(); | 953 header->AttachLoopInformation(); |
951 return header; | 954 return header; |
952 } | 955 } |
953 | 956 |
954 | 957 |
955 HInstruction* HGraphBuilder::BuildExternalArrayElementAccess( | 958 HInstruction* HGraphBuilder::BuildExternalArrayElementAccess( |
956 HValue* external_elements, | 959 HValue* external_elements, |
957 HValue* checked_key, | 960 HValue* checked_key, |
958 HValue* val, | 961 HValue* val, |
959 HValue* dependency, | 962 HValue* dependency, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1039 elements_kind); | 1042 elements_kind); |
1040 } | 1043 } |
1041 | 1044 |
1042 | 1045 |
1043 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, | 1046 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
1044 HValue* elements, | 1047 HValue* elements, |
1045 ElementsKind kind, | 1048 ElementsKind kind, |
1046 HValue* length, | 1049 HValue* length, |
1047 HValue* key, | 1050 HValue* key, |
1048 bool is_js_array) { | 1051 bool is_js_array) { |
1052 BailoutId ast_id = environment()->ast_id(); | |
1049 Zone* zone = this->zone(); | 1053 Zone* zone = this->zone(); |
1050 IfBuilder length_checker(this); | 1054 IfBuilder length_checker(this, ast_id); |
1051 | 1055 |
1052 length_checker.BeginIf(length, key, Token::EQ); | 1056 length_checker.BeginIf(length, key, Token::EQ); |
1053 | 1057 |
1054 HValue* current_capacity = | 1058 HValue* current_capacity = |
1055 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 1059 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
1056 | 1060 |
1057 IfBuilder capacity_checker(this); | 1061 IfBuilder capacity_checker(this, ast_id); |
1058 | 1062 |
1059 capacity_checker.BeginIf(length, current_capacity, Token::EQ); | 1063 capacity_checker.BeginIf(length, current_capacity, Token::EQ); |
1060 | 1064 |
1061 HValue* context = environment()->LookupContext(); | 1065 HValue* context = environment()->LookupContext(); |
1062 | 1066 |
1063 HValue* new_capacity = | 1067 HValue* new_capacity = |
1064 BuildNewElementsCapacity(context, current_capacity); | 1068 BuildNewElementsCapacity(context, current_capacity); |
1065 | 1069 |
1066 HValue* new_elements = BuildGrowElementsCapacity(object, elements, | 1070 HValue* new_elements = BuildGrowElementsCapacity(object, elements, |
1067 kind, length, | 1071 kind, length, |
1068 new_capacity); | 1072 new_capacity, ast_id); |
1069 | 1073 |
1070 environment()->Push(new_elements); | 1074 environment()->Push(new_elements); |
1071 capacity_checker.BeginElse(); | 1075 capacity_checker.BeginElse(); |
1072 | 1076 |
1073 environment()->Push(elements); | 1077 environment()->Push(elements); |
1074 capacity_checker.End(); | 1078 capacity_checker.End(); |
1075 | 1079 |
1076 if (is_js_array) { | 1080 if (is_js_array) { |
1077 HValue* new_length = AddInstruction( | 1081 HValue* new_length = AddInstruction( |
1078 HAdd::New(zone, context, length, graph_->GetConstant1())); | 1082 HAdd::New(zone, context, length, graph_->GetConstant1())); |
(...skipping 17 matching lines...) Expand all Loading... | |
1096 length_checker.End(); | 1100 length_checker.End(); |
1097 | 1101 |
1098 return environment()->Pop(); | 1102 return environment()->Pop(); |
1099 } | 1103 } |
1100 | 1104 |
1101 | 1105 |
1102 HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, | 1106 HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, |
1103 HValue* elements, | 1107 HValue* elements, |
1104 ElementsKind kind, | 1108 ElementsKind kind, |
1105 HValue* length) { | 1109 HValue* length) { |
1110 BailoutId ast_id = environment()->ast_id(); | |
1106 Zone* zone = this->zone(); | 1111 Zone* zone = this->zone(); |
1107 Heap* heap = isolate()->heap(); | 1112 Heap* heap = isolate()->heap(); |
1108 | 1113 |
1109 IfBuilder cow_checker(this); | 1114 IfBuilder cow_checker(this, ast_id); |
1110 | 1115 |
1111 cow_checker.BeginIfMapEquals(elements, | 1116 cow_checker.BeginIfMapEquals(elements, |
1112 Handle<Map>(heap->fixed_cow_array_map())); | 1117 Handle<Map>(heap->fixed_cow_array_map())); |
1113 | 1118 |
1114 HValue* capacity = | 1119 HValue* capacity = |
1115 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 1120 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
1116 | 1121 |
1117 HValue* new_elements = BuildGrowElementsCapacity(object, elements, | 1122 HValue* new_elements = BuildGrowElementsCapacity(object, elements, |
1118 kind, length, | 1123 kind, length, |
1119 capacity); | 1124 capacity, ast_id); |
1120 | 1125 |
1121 environment()->Push(new_elements); | 1126 environment()->Push(new_elements); |
1122 | 1127 |
1123 cow_checker.BeginElse(); | 1128 cow_checker.BeginElse(); |
1124 | 1129 |
1125 environment()->Push(elements); | 1130 environment()->Push(elements); |
1126 | 1131 |
1127 cow_checker.End(); | 1132 cow_checker.End(); |
1128 | 1133 |
1129 return environment()->Pop(); | 1134 return environment()->Pop(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 HLoadNamedField::NewArrayLength(zone, object, mapcheck, HType::Smi())); | 1176 HLoadNamedField::NewArrayLength(zone, object, mapcheck, HType::Smi())); |
1172 } else { | 1177 } else { |
1173 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 1178 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
1174 } | 1179 } |
1175 HValue* checked_key = NULL; | 1180 HValue* checked_key = NULL; |
1176 if (IsExternalArrayElementsKind(elements_kind)) { | 1181 if (IsExternalArrayElementsKind(elements_kind)) { |
1177 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { | 1182 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { |
1178 HLoadExternalArrayPointer* external_elements = | 1183 HLoadExternalArrayPointer* external_elements = |
1179 new(zone) HLoadExternalArrayPointer(elements); | 1184 new(zone) HLoadExternalArrayPointer(elements); |
1180 AddInstruction(external_elements); | 1185 AddInstruction(external_elements); |
1181 IfBuilder length_checker(this); | 1186 BailoutId previous_id = environment()->ast_id(); |
1187 ASSERT(!previous_id.IsNone()); | |
1188 IfBuilder length_checker(this, previous_id); | |
1182 length_checker.BeginIf(key, length, Token::LT); | 1189 length_checker.BeginIf(key, length, Token::LT); |
1183 CheckBuilder negative_checker(this); | 1190 CheckBuilder negative_checker(this, previous_id); |
1184 HValue* bounds_check = negative_checker.CheckIntegerCompare( | 1191 HValue* bounds_check = negative_checker.CheckIntegerCompare( |
1185 key, graph()->GetConstant0(), Token::GTE); | 1192 key, graph()->GetConstant0(), Token::GTE); |
1186 negative_checker.End(); | 1193 negative_checker.End(); |
1187 HInstruction* result = BuildExternalArrayElementAccess( | 1194 HInstruction* result = BuildExternalArrayElementAccess( |
1188 external_elements, key, val, bounds_check, | 1195 external_elements, key, val, bounds_check, |
1189 elements_kind, is_store); | 1196 elements_kind, is_store); |
1190 AddInstruction(result); | 1197 AddInstruction(result); |
1191 length_checker.End(); | 1198 length_checker.End(); |
1192 return result; | 1199 return result; |
1193 } else { | 1200 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 } | 1243 } |
1237 } | 1244 } |
1238 return AddInstruction( | 1245 return AddInstruction( |
1239 BuildFastElementAccess(elements, checked_key, val, mapcheck, | 1246 BuildFastElementAccess(elements, checked_key, val, mapcheck, |
1240 elements_kind, is_store, store_mode)); | 1247 elements_kind, is_store, store_mode)); |
1241 } | 1248 } |
1242 | 1249 |
1243 | 1250 |
1244 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, | 1251 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, |
1245 ElementsKind kind, | 1252 ElementsKind kind, |
1246 HValue* capacity) { | 1253 HValue* capacity, |
1254 BailoutId ast_id) { | |
1247 Zone* zone = this->zone(); | 1255 Zone* zone = this->zone(); |
1248 | 1256 |
1249 int elements_size = IsFastDoubleElementsKind(kind) | 1257 int elements_size = IsFastDoubleElementsKind(kind) |
1250 ? kDoubleSize : kPointerSize; | 1258 ? kDoubleSize : kPointerSize; |
1251 HConstant* elements_size_value = | 1259 HConstant* elements_size_value = |
1252 new(zone) HConstant(elements_size, Representation::Integer32()); | 1260 new(zone) HConstant(elements_size, Representation::Integer32()); |
1253 AddInstruction(elements_size_value); | 1261 AddInstruction(elements_size_value); |
1254 HValue* mul = AddInstruction( | 1262 HValue* mul = AddInstruction( |
1255 HMul::New(zone, context, capacity, elements_size_value)); | 1263 HMul::New(zone, context, capacity, elements_size_value)); |
1256 mul->ChangeRepresentation(Representation::Integer32()); | 1264 mul->ChangeRepresentation(Representation::Integer32()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1300 HInstruction* store_length = | 1308 HInstruction* store_length = |
1301 new(zone) HStoreNamedField(elements, fixed_array_length_field_name, | 1309 new(zone) HStoreNamedField(elements, fixed_array_length_field_name, |
1302 capacity, true, FixedArray::kLengthOffset); | 1310 capacity, true, FixedArray::kLengthOffset); |
1303 AddInstruction(store_length); | 1311 AddInstruction(store_length); |
1304 } | 1312 } |
1305 | 1313 |
1306 | 1314 |
1307 HValue* HGraphBuilder::BuildAllocateAndInitializeElements(HValue* context, | 1315 HValue* HGraphBuilder::BuildAllocateAndInitializeElements(HValue* context, |
1308 ElementsKind kind, | 1316 ElementsKind kind, |
1309 HValue* capacity) { | 1317 HValue* capacity) { |
1318 BailoutId ast_id = environment()->ast_id(); | |
1310 HValue* new_elements = | 1319 HValue* new_elements = |
1311 BuildAllocateElements(context, kind, capacity); | 1320 BuildAllocateElements(context, kind, capacity, ast_id); |
1312 BuildInitializeElements(new_elements, kind, capacity); | 1321 BuildInitializeElements(new_elements, kind, capacity); |
1313 return new_elements; | 1322 return new_elements; |
1314 } | 1323 } |
1315 | 1324 |
1316 | 1325 |
1317 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, | 1326 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, |
1318 HValue* map) { | 1327 HValue* map) { |
1319 Zone* zone = this->zone(); | 1328 Zone* zone = this->zone(); |
1320 Factory* factory = isolate()->factory(); | 1329 Factory* factory = isolate()->factory(); |
1321 Handle<String> map_field_name = factory->map_field_string(); | 1330 Handle<String> map_field_name = factory->map_field_string(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1378 AddInstruction(new(zone) | 1387 AddInstruction(new(zone) |
1379 HBoundsCheck(length, max_size_constant, | 1388 HBoundsCheck(length, max_size_constant, |
1380 DONT_ALLOW_SMI_KEY, Representation::Integer32())); | 1389 DONT_ALLOW_SMI_KEY, Representation::Integer32())); |
1381 } | 1390 } |
1382 | 1391 |
1383 | 1392 |
1384 HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, | 1393 HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, |
1385 HValue* elements, | 1394 HValue* elements, |
1386 ElementsKind kind, | 1395 ElementsKind kind, |
1387 HValue* length, | 1396 HValue* length, |
1388 HValue* new_capacity) { | 1397 HValue* new_capacity, |
1398 BailoutId ast_id) { | |
1389 Zone* zone = this->zone(); | 1399 Zone* zone = this->zone(); |
1390 HValue* context = environment()->LookupContext(); | 1400 HValue* context = environment()->LookupContext(); |
1391 | 1401 |
1392 BuildNewSpaceArrayCheck(new_capacity, kind); | 1402 BuildNewSpaceArrayCheck(new_capacity, kind); |
1393 | 1403 |
1394 HValue* new_elements = | 1404 HValue* new_elements = |
1395 BuildAllocateAndInitializeElements(context, kind, new_capacity); | 1405 BuildAllocateAndInitializeElements(context, kind, new_capacity); |
1396 | 1406 |
1397 BuildCopyElements(context, elements, kind, | 1407 BuildCopyElements(context, elements, kind, |
1398 new_elements, kind, | 1408 new_elements, kind, |
1399 length, new_capacity); | 1409 length, new_capacity, ast_id); |
1400 | 1410 |
1401 Factory* factory = isolate()->factory(); | 1411 Factory* factory = isolate()->factory(); |
1402 HInstruction* elements_store = AddInstruction(new(zone) HStoreNamedField( | 1412 HInstruction* elements_store = AddInstruction(new(zone) HStoreNamedField( |
1403 object, | 1413 object, |
1404 factory->elements_field_string(), | 1414 factory->elements_field_string(), |
1405 new_elements, true, | 1415 new_elements, true, |
1406 JSArray::kElementsOffset)); | 1416 JSArray::kElementsOffset)); |
1407 elements_store->SetGVNFlag(kChangesElementsPointer); | 1417 elements_store->SetGVNFlag(kChangesElementsPointer); |
1408 | 1418 |
1409 return new_elements; | 1419 return new_elements; |
1410 } | 1420 } |
1411 | 1421 |
1412 | 1422 |
1413 void HGraphBuilder::BuildFillElementsWithHole(HValue* context, | 1423 void HGraphBuilder::BuildFillElementsWithHole(HValue* context, |
1414 HValue* elements, | 1424 HValue* elements, |
1415 ElementsKind elements_kind, | 1425 ElementsKind elements_kind, |
1416 HValue* from, | 1426 HValue* from, |
1417 HValue* to) { | 1427 HValue* to, |
1428 BailoutId ast_id) { | |
1418 // Fast elements kinds need to be initialized in case statements below cause | 1429 // Fast elements kinds need to be initialized in case statements below cause |
1419 // a garbage collection. | 1430 // a garbage collection. |
1420 Factory* factory = isolate()->factory(); | 1431 Factory* factory = isolate()->factory(); |
1421 | 1432 |
1422 double nan_double = FixedDoubleArray::hole_nan_as_double(); | 1433 double nan_double = FixedDoubleArray::hole_nan_as_double(); |
1423 Zone* zone = this->zone(); | 1434 Zone* zone = this->zone(); |
1424 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) | 1435 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) |
1425 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(), | 1436 ? AddInstruction(new(zone) HConstant(factory->the_hole_value(), |
1426 Representation::Tagged())) | 1437 Representation::Tagged())) |
1427 : AddInstruction(new(zone) HConstant(nan_double, | 1438 : AddInstruction(new(zone) HConstant(nan_double, |
1428 Representation::Double())); | 1439 Representation::Double())); |
1429 | 1440 |
1430 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); | 1441 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement, ast_id); |
1431 | 1442 |
1432 HValue* key = builder.BeginBody(from, to, Token::LT); | 1443 HValue* key = builder.BeginBody(from, to, Token::LT); |
1433 | 1444 |
1434 AddInstruction(new(zone) HStoreKeyed(elements, key, hole, elements_kind)); | 1445 AddInstruction(new(zone) HStoreKeyed(elements, key, hole, elements_kind)); |
1435 | 1446 |
1436 builder.EndBody(); | 1447 builder.EndBody(); |
1437 } | 1448 } |
1438 | 1449 |
1439 | 1450 |
1440 void HGraphBuilder::BuildCopyElements(HValue* context, | 1451 void HGraphBuilder::BuildCopyElements(HValue* context, |
1441 HValue* from_elements, | 1452 HValue* from_elements, |
1442 ElementsKind from_elements_kind, | 1453 ElementsKind from_elements_kind, |
1443 HValue* to_elements, | 1454 HValue* to_elements, |
1444 ElementsKind to_elements_kind, | 1455 ElementsKind to_elements_kind, |
1445 HValue* length, | 1456 HValue* length, |
1446 HValue* capacity) { | 1457 HValue* capacity, |
1458 BailoutId ast_id) { | |
1447 bool pre_fill_with_holes = | 1459 bool pre_fill_with_holes = |
1448 IsFastDoubleElementsKind(from_elements_kind) && | 1460 IsFastDoubleElementsKind(from_elements_kind) && |
1449 IsFastObjectElementsKind(to_elements_kind); | 1461 IsFastObjectElementsKind(to_elements_kind); |
1450 | 1462 |
1451 if (pre_fill_with_holes) { | 1463 if (pre_fill_with_holes) { |
1452 // If the copy might trigger a GC, make sure that the FixedArray is | 1464 // If the copy might trigger a GC, make sure that the FixedArray is |
1453 // pre-initialized with holes to make sure that it's always in a consistent | 1465 // pre-initialized with holes to make sure that it's always in a consistent |
1454 // state. | 1466 // state. |
1455 BuildFillElementsWithHole(context, to_elements, to_elements_kind, | 1467 BuildFillElementsWithHole(context, to_elements, to_elements_kind, |
1456 graph()->GetConstant0(), capacity); | 1468 graph()->GetConstant0(), capacity, ast_id); |
1457 } | 1469 } |
1458 | 1470 |
1459 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); | 1471 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement, ast_id); |
1460 | 1472 |
1461 HValue* key = builder.BeginBody(graph()->GetConstant0(), length, Token::LT); | 1473 HValue* key = builder.BeginBody(graph()->GetConstant0(), length, Token::LT); |
1462 | 1474 |
1463 HValue* element = | 1475 HValue* element = |
1464 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, | 1476 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, |
1465 from_elements_kind, | 1477 from_elements_kind, |
1466 ALLOW_RETURN_HOLE)); | 1478 ALLOW_RETURN_HOLE)); |
1467 | 1479 |
1468 AddInstruction(new(zone()) HStoreKeyed(to_elements, key, element, | 1480 AddInstruction(new(zone()) HStoreKeyed(to_elements, key, element, |
1469 to_elements_kind)); | 1481 to_elements_kind)); |
1470 | 1482 |
1471 builder.EndBody(); | 1483 builder.EndBody(); |
1472 | 1484 |
1473 if (!pre_fill_with_holes && length != capacity) { | 1485 if (!pre_fill_with_holes && length != capacity) { |
1474 // Fill unused capacity with the hole. | 1486 // Fill unused capacity with the hole. |
1475 BuildFillElementsWithHole(context, to_elements, to_elements_kind, | 1487 BuildFillElementsWithHole(context, to_elements, to_elements_kind, |
1476 key, capacity); | 1488 key, capacity, ast_id); |
1477 } | 1489 } |
1478 } | 1490 } |
1479 | 1491 |
1480 | 1492 |
1481 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, | 1493 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
1482 HValue* boilerplate, | 1494 HValue* boilerplate, |
1483 AllocationSiteMode mode, | 1495 AllocationSiteMode mode, |
1484 ElementsKind kind, | 1496 ElementsKind kind, |
1485 int length) { | 1497 int length) { |
1486 Zone* zone = this->zone(); | 1498 Zone* zone = this->zone(); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1677 if (info->IsStub()) { | 1689 if (info->IsStub()) { |
1678 HydrogenCodeStub* stub = info->code_stub(); | 1690 HydrogenCodeStub* stub = info->code_stub(); |
1679 CodeStubInterfaceDescriptor* descriptor = | 1691 CodeStubInterfaceDescriptor* descriptor = |
1680 stub->GetInterfaceDescriptor(isolate_); | 1692 stub->GetInterfaceDescriptor(isolate_); |
1681 start_environment_ = | 1693 start_environment_ = |
1682 new(zone_) HEnvironment(zone_, descriptor->environment_length()); | 1694 new(zone_) HEnvironment(zone_, descriptor->environment_length()); |
1683 } else { | 1695 } else { |
1684 start_environment_ = | 1696 start_environment_ = |
1685 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); | 1697 new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); |
1686 } | 1698 } |
1699 start_environment_->set_ast_id(BailoutId::FunctionEntry()); | |
1687 entry_block_ = CreateBasicBlock(); | 1700 entry_block_ = CreateBasicBlock(); |
1688 entry_block_->SetInitialEnvironment(start_environment_, | 1701 entry_block_->SetInitialEnvironment(start_environment_); |
1689 BailoutId::FunctionEntry()); | |
1690 } | 1702 } |
1691 | 1703 |
1692 | 1704 |
1693 HBasicBlock* HGraph::CreateBasicBlock() { | 1705 HBasicBlock* HGraph::CreateBasicBlock() { |
1694 HBasicBlock* result = new(zone()) HBasicBlock(this); | 1706 HBasicBlock* result = new(zone()) HBasicBlock(this); |
1695 blocks_.Add(result, zone()); | 1707 blocks_.Add(result, zone()); |
1696 return result; | 1708 return result; |
1697 } | 1709 } |
1698 | 1710 |
1699 | 1711 |
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4289 // translation, so they cannot have an environment effect. The edge to | 4301 // translation, so they cannot have an environment effect. The edge to |
4290 // the body's entry block (along with some special logic for the start | 4302 // the body's entry block (along with some special logic for the start |
4291 // block in HInstruction::InsertAfter) seals the start block from | 4303 // block in HInstruction::InsertAfter) seals the start block from |
4292 // getting unwanted instructions inserted. | 4304 // getting unwanted instructions inserted. |
4293 // | 4305 // |
4294 // TODO(kmillikin): Fix this. Stop mutating the initial environment. | 4306 // TODO(kmillikin): Fix this. Stop mutating the initial environment. |
4295 // Make the Hydrogen instructions in the initial block into Hydrogen | 4307 // Make the Hydrogen instructions in the initial block into Hydrogen |
4296 // values (but not instructions), present in the initial environment and | 4308 // values (but not instructions), present in the initial environment and |
4297 // not replayed by the Lithium translation. | 4309 // not replayed by the Lithium translation. |
4298 HEnvironment* initial_env = environment()->CopyWithoutHistory(); | 4310 HEnvironment* initial_env = environment()->CopyWithoutHistory(); |
4299 HBasicBlock* body_entry = CreateBasicBlock(initial_env, | 4311 HBasicBlock* body_entry = CreateBasicBlock(initial_env); |
4300 BailoutId::FunctionEntry()); | |
4301 current_block()->Goto(body_entry); | 4312 current_block()->Goto(body_entry); |
4302 body_entry->SetJoinId(BailoutId::FunctionEntry()); | 4313 body_entry->SetJoinId(BailoutId::FunctionEntry()); |
4303 set_current_block(body_entry); | 4314 set_current_block(body_entry); |
4304 | 4315 |
4305 // Handle implicit declaration of the function name in named function | 4316 // Handle implicit declaration of the function name in named function |
4306 // expressions before other declarations. | 4317 // expressions before other declarations. |
4307 if (scope->is_function_scope() && scope->function() != NULL) { | 4318 if (scope->is_function_scope() && scope->function() != NULL) { |
4308 VisitVariableDeclaration(scope->function()); | 4319 VisitVariableDeclaration(scope->function()); |
4309 } | 4320 } |
4310 VisitDeclarations(scope->declarations()); | 4321 VisitDeclarations(scope->declarations()); |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5534 CHECK_BAILOUT(Visit(stmt->body())); | 5545 CHECK_BAILOUT(Visit(stmt->body())); |
5535 } | 5546 } |
5536 | 5547 |
5537 | 5548 |
5538 void HOptimizedGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { | 5549 void HOptimizedGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
5539 ASSERT(!HasStackOverflow()); | 5550 ASSERT(!HasStackOverflow()); |
5540 ASSERT(current_block() != NULL); | 5551 ASSERT(current_block() != NULL); |
5541 ASSERT(current_block()->HasPredecessor()); | 5552 ASSERT(current_block()->HasPredecessor()); |
5542 ASSERT(current_block() != NULL); | 5553 ASSERT(current_block() != NULL); |
5543 bool osr_entry = PreProcessOsrEntry(stmt); | 5554 bool osr_entry = PreProcessOsrEntry(stmt); |
5544 HBasicBlock* loop_entry = CreateLoopHeaderBlock(stmt->EntryId()); | 5555 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); |
5545 current_block()->Goto(loop_entry); | 5556 current_block()->Goto(loop_entry); |
5546 set_current_block(loop_entry); | 5557 set_current_block(loop_entry); |
5547 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); | 5558 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); |
5548 | 5559 |
5549 BreakAndContinueInfo break_info(stmt); | 5560 BreakAndContinueInfo break_info(stmt); |
5550 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); | 5561 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); |
5551 HBasicBlock* body_exit = | 5562 HBasicBlock* body_exit = |
5552 JoinContinue(stmt, current_block(), break_info.continue_block()); | 5563 JoinContinue(stmt, current_block(), break_info.continue_block()); |
5553 HBasicBlock* loop_successor = NULL; | 5564 HBasicBlock* loop_successor = NULL; |
5554 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { | 5565 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { |
(...skipping 22 matching lines...) Expand all Loading... | |
5577 set_current_block(loop_exit); | 5588 set_current_block(loop_exit); |
5578 } | 5589 } |
5579 | 5590 |
5580 | 5591 |
5581 void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 5592 void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
5582 ASSERT(!HasStackOverflow()); | 5593 ASSERT(!HasStackOverflow()); |
5583 ASSERT(current_block() != NULL); | 5594 ASSERT(current_block() != NULL); |
5584 ASSERT(current_block()->HasPredecessor()); | 5595 ASSERT(current_block()->HasPredecessor()); |
5585 ASSERT(current_block() != NULL); | 5596 ASSERT(current_block() != NULL); |
5586 bool osr_entry = PreProcessOsrEntry(stmt); | 5597 bool osr_entry = PreProcessOsrEntry(stmt); |
5587 HBasicBlock* loop_entry = CreateLoopHeaderBlock(stmt->EntryId()); | 5598 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); |
5588 current_block()->Goto(loop_entry); | 5599 current_block()->Goto(loop_entry); |
5589 set_current_block(loop_entry); | 5600 set_current_block(loop_entry); |
5590 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); | 5601 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); |
5591 | 5602 |
5592 | 5603 |
5593 // If the condition is constant true, do not generate a branch. | 5604 // If the condition is constant true, do not generate a branch. |
5594 HBasicBlock* loop_successor = NULL; | 5605 HBasicBlock* loop_successor = NULL; |
5595 if (!stmt->cond()->ToBooleanIsTrue()) { | 5606 if (!stmt->cond()->ToBooleanIsTrue()) { |
5596 HBasicBlock* body_entry = graph()->CreateBasicBlock(); | 5607 HBasicBlock* body_entry = graph()->CreateBasicBlock(); |
5597 loop_successor = graph()->CreateBasicBlock(); | 5608 loop_successor = graph()->CreateBasicBlock(); |
(...skipping 26 matching lines...) Expand all Loading... | |
5624 | 5635 |
5625 void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) { | 5636 void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) { |
5626 ASSERT(!HasStackOverflow()); | 5637 ASSERT(!HasStackOverflow()); |
5627 ASSERT(current_block() != NULL); | 5638 ASSERT(current_block() != NULL); |
5628 ASSERT(current_block()->HasPredecessor()); | 5639 ASSERT(current_block()->HasPredecessor()); |
5629 if (stmt->init() != NULL) { | 5640 if (stmt->init() != NULL) { |
5630 CHECK_ALIVE(Visit(stmt->init())); | 5641 CHECK_ALIVE(Visit(stmt->init())); |
5631 } | 5642 } |
5632 ASSERT(current_block() != NULL); | 5643 ASSERT(current_block() != NULL); |
5633 bool osr_entry = PreProcessOsrEntry(stmt); | 5644 bool osr_entry = PreProcessOsrEntry(stmt); |
5634 HBasicBlock* loop_entry = CreateLoopHeaderBlock(stmt->EntryId()); | 5645 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); |
5635 current_block()->Goto(loop_entry); | 5646 current_block()->Goto(loop_entry); |
5636 set_current_block(loop_entry); | 5647 set_current_block(loop_entry); |
5637 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); | 5648 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); |
5638 | 5649 |
5639 HBasicBlock* loop_successor = NULL; | 5650 HBasicBlock* loop_successor = NULL; |
5640 if (stmt->cond() != NULL) { | 5651 if (stmt->cond() != NULL) { |
5641 HBasicBlock* body_entry = graph()->CreateBasicBlock(); | 5652 HBasicBlock* body_entry = graph()->CreateBasicBlock(); |
5642 loop_successor = graph()->CreateBasicBlock(); | 5653 loop_successor = graph()->CreateBasicBlock(); |
5643 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); | 5654 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); |
5644 if (body_entry->HasPredecessor()) { | 5655 if (body_entry->HasPredecessor()) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5719 | 5730 |
5720 HInstruction* index_cache = AddInstruction( | 5731 HInstruction* index_cache = AddInstruction( |
5721 new(zone()) HForInCacheArray( | 5732 new(zone()) HForInCacheArray( |
5722 enumerable, | 5733 enumerable, |
5723 map, | 5734 map, |
5724 DescriptorArray::kEnumCacheBridgeIndicesCacheIndex)); | 5735 DescriptorArray::kEnumCacheBridgeIndicesCacheIndex)); |
5725 HForInCacheArray::cast(array)->set_index_cache( | 5736 HForInCacheArray::cast(array)->set_index_cache( |
5726 HForInCacheArray::cast(index_cache)); | 5737 HForInCacheArray::cast(index_cache)); |
5727 | 5738 |
5728 bool osr_entry = PreProcessOsrEntry(stmt); | 5739 bool osr_entry = PreProcessOsrEntry(stmt); |
5729 HBasicBlock* loop_entry = CreateLoopHeaderBlock(stmt->EntryId()); | 5740 HBasicBlock* loop_entry = CreateLoopHeaderBlock(); |
5730 current_block()->Goto(loop_entry); | 5741 current_block()->Goto(loop_entry); |
5731 set_current_block(loop_entry); | 5742 set_current_block(loop_entry); |
5732 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); | 5743 if (osr_entry) graph()->set_osr_loop_entry(loop_entry); |
5733 | 5744 |
5734 HValue* index = environment()->ExpressionStackAt(0); | 5745 HValue* index = environment()->ExpressionStackAt(0); |
5735 HValue* limit = environment()->ExpressionStackAt(1); | 5746 HValue* limit = environment()->ExpressionStackAt(1); |
5736 | 5747 |
5737 // Check that we still have more keys. | 5748 // Check that we still have more keys. |
5738 HCompareIDAndBranch* compare_index = | 5749 HCompareIDAndBranch* compare_index = |
5739 new(zone()) HCompareIDAndBranch(index, limit, Token::LT); | 5750 new(zone()) HCompareIDAndBranch(index, limit, Token::LT); |
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8272 // can remove the unsightly ifdefs in this function. | 8283 // can remove the unsightly ifdefs in this function. |
8273 HConstant* context = | 8284 HConstant* context = |
8274 new(zone()) HConstant(Handle<Context>(target->context()), | 8285 new(zone()) HConstant(Handle<Context>(target->context()), |
8275 Representation::Tagged()); | 8286 Representation::Tagged()); |
8276 AddInstruction(context); | 8287 AddInstruction(context); |
8277 inner_env->BindContext(context); | 8288 inner_env->BindContext(context); |
8278 #endif | 8289 #endif |
8279 | 8290 |
8280 AddSimulate(return_id); | 8291 AddSimulate(return_id); |
8281 current_block()->UpdateEnvironment(inner_env); | 8292 current_block()->UpdateEnvironment(inner_env); |
8282 inner_env->set_previous_ast_id(BailoutId::FunctionEntry()); | |
8283 ZoneList<HValue*>* arguments_values = NULL; | 8293 ZoneList<HValue*>* arguments_values = NULL; |
8284 | 8294 |
8285 // If the function uses arguments copy current arguments values | 8295 // If the function uses arguments copy current arguments values |
8286 // to use them for materialization. | 8296 // to use them for materialization. |
8287 if (function->scope()->arguments() != NULL) { | 8297 if (function->scope()->arguments() != NULL) { |
8288 HEnvironment* arguments_env = inner_env->arguments_environment(); | 8298 HEnvironment* arguments_env = inner_env->arguments_environment(); |
8289 int arguments_count = arguments_env->parameter_count(); | 8299 int arguments_count = arguments_env->parameter_count(); |
8290 arguments_values = new(zone()) ZoneList<HValue*>(arguments_count, zone()); | 8300 arguments_values = new(zone()) ZoneList<HValue*>(arguments_count, zone()); |
8291 for (int i = 0; i < arguments_count; i++) { | 8301 for (int i = 0; i < arguments_count; i++) { |
8292 arguments_values->Add(arguments_env->Lookup(i), zone()); | 8302 arguments_values->Add(arguments_env->Lookup(i), zone()); |
(...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11026 values_(0, zone), | 11036 values_(0, zone), |
11027 frame_type_(JS_FUNCTION), | 11037 frame_type_(JS_FUNCTION), |
11028 parameter_count_(0), | 11038 parameter_count_(0), |
11029 specials_count_(1), | 11039 specials_count_(1), |
11030 local_count_(0), | 11040 local_count_(0), |
11031 outer_(outer), | 11041 outer_(outer), |
11032 entry_(NULL), | 11042 entry_(NULL), |
11033 pop_count_(0), | 11043 pop_count_(0), |
11034 push_count_(0), | 11044 push_count_(0), |
11035 ast_id_(BailoutId::None()), | 11045 ast_id_(BailoutId::None()), |
11036 previous_ast_id_(BailoutId::None()), | |
11037 zone_(zone) { | 11046 zone_(zone) { |
11038 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); | 11047 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); |
11039 } | 11048 } |
11040 | 11049 |
11041 | 11050 |
11042 HEnvironment::HEnvironment(Zone* zone, int parameter_count) | 11051 HEnvironment::HEnvironment(Zone* zone, int parameter_count) |
11043 : values_(0, zone), | 11052 : values_(0, zone), |
11044 frame_type_(STUB), | 11053 frame_type_(STUB), |
11045 parameter_count_(parameter_count), | 11054 parameter_count_(parameter_count), |
11046 specials_count_(1), | 11055 specials_count_(1), |
11047 local_count_(0), | 11056 local_count_(0), |
11048 outer_(NULL), | 11057 outer_(NULL), |
11049 entry_(NULL), | 11058 entry_(NULL), |
11050 pop_count_(0), | 11059 pop_count_(0), |
11051 push_count_(0), | 11060 push_count_(0), |
11052 ast_id_(BailoutId::None()), | 11061 ast_id_(BailoutId::None()), |
11053 previous_ast_id_(BailoutId::None()), | |
11054 zone_(zone) { | 11062 zone_(zone) { |
11055 Initialize(parameter_count, 0, 0); | 11063 Initialize(parameter_count, 0, 0); |
11056 } | 11064 } |
11057 | 11065 |
11058 | 11066 |
11059 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) | 11067 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) |
11060 : values_(0, zone), | 11068 : values_(0, zone), |
11061 frame_type_(JS_FUNCTION), | 11069 frame_type_(JS_FUNCTION), |
11062 parameter_count_(0), | 11070 parameter_count_(0), |
11063 specials_count_(0), | 11071 specials_count_(0), |
11064 local_count_(0), | 11072 local_count_(0), |
11065 outer_(NULL), | 11073 outer_(NULL), |
11066 entry_(NULL), | 11074 entry_(NULL), |
11067 pop_count_(0), | 11075 pop_count_(0), |
11068 push_count_(0), | 11076 push_count_(0), |
11069 ast_id_(other->ast_id()), | 11077 ast_id_(other->ast_id()), |
11070 previous_ast_id_(BailoutId::None()), | |
11071 zone_(zone) { | 11078 zone_(zone) { |
11072 Initialize(other); | 11079 Initialize(other); |
11073 } | 11080 } |
11074 | 11081 |
11075 | 11082 |
11076 HEnvironment::HEnvironment(HEnvironment* outer, | 11083 HEnvironment::HEnvironment(HEnvironment* outer, |
11077 Handle<JSFunction> closure, | 11084 Handle<JSFunction> closure, |
11078 FrameType frame_type, | 11085 FrameType frame_type, |
11079 int arguments, | 11086 int arguments, |
11080 Zone* zone) | 11087 Zone* zone) |
11081 : closure_(closure), | 11088 : closure_(closure), |
11082 values_(arguments, zone), | 11089 values_(arguments, zone), |
11083 frame_type_(frame_type), | 11090 frame_type_(frame_type), |
11084 parameter_count_(arguments), | 11091 parameter_count_(arguments), |
11085 local_count_(0), | 11092 local_count_(0), |
11086 outer_(outer), | 11093 outer_(outer), |
11087 entry_(NULL), | 11094 entry_(NULL), |
11088 pop_count_(0), | 11095 pop_count_(0), |
11089 push_count_(0), | 11096 push_count_(0), |
11090 ast_id_(BailoutId::None()), | 11097 ast_id_(BailoutId::None()), |
11091 previous_ast_id_(BailoutId::None()), | |
11092 zone_(zone) { | 11098 zone_(zone) { |
11093 } | 11099 } |
11094 | 11100 |
11095 | 11101 |
11096 void HEnvironment::Initialize(int parameter_count, | 11102 void HEnvironment::Initialize(int parameter_count, |
11097 int local_count, | 11103 int local_count, |
11098 int stack_height) { | 11104 int stack_height) { |
11099 parameter_count_ = parameter_count; | 11105 parameter_count_ = parameter_count; |
11100 local_count_ = local_count; | 11106 local_count_ = local_count; |
11101 | 11107 |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11691 } | 11697 } |
11692 } | 11698 } |
11693 | 11699 |
11694 #ifdef DEBUG | 11700 #ifdef DEBUG |
11695 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11701 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
11696 if (allocator_ != NULL) allocator_->Verify(); | 11702 if (allocator_ != NULL) allocator_->Verify(); |
11697 #endif | 11703 #endif |
11698 } | 11704 } |
11699 | 11705 |
11700 } } // namespace v8::internal | 11706 } } // namespace v8::internal |
OLD | NEW |