Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/hydrogen.cc

Issue 14696015: Verify that no-side-effects scope does not add unsafe phis and does not change push-pop balance of … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename variable Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 HBasicBlock* split_edge = 745 HBasicBlock* split_edge =
746 builder_->CreateBasicBlock(env->Copy()); 746 builder_->CreateBasicBlock(env->Copy());
747 if (did_or_) { 747 if (did_or_) {
748 compare->SetSuccessorAt(0, split_edge); 748 compare->SetSuccessorAt(0, split_edge);
749 compare->SetSuccessorAt(1, first_false_block_); 749 compare->SetSuccessorAt(1, first_false_block_);
750 } else { 750 } else {
751 compare->SetSuccessorAt(0, first_true_block_); 751 compare->SetSuccessorAt(0, first_true_block_);
752 compare->SetSuccessorAt(1, split_edge); 752 compare->SetSuccessorAt(1, split_edge);
753 } 753 }
754 split_edge->GotoNoSimulate(split_edge_merge_block_); 754 split_edge->GotoNoSimulate(split_edge_merge_block_);
755 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
755 } else { 756 } else {
756 compare->SetSuccessorAt(0, first_true_block_); 757 compare->SetSuccessorAt(0, first_true_block_);
757 compare->SetSuccessorAt(1, first_false_block_); 758 compare->SetSuccessorAt(1, first_false_block_);
758 } 759 }
759 builder_->current_block()->Finish(compare); 760 builder_->current_block()->Finish(compare);
760 needs_compare_ = false; 761 needs_compare_ = false;
761 } 762 }
762 763
763 764
764 void HGraphBuilder::IfBuilder::Or() { 765 void HGraphBuilder::IfBuilder::Or() {
765 ASSERT(!did_and_); 766 ASSERT(!did_and_);
766 did_or_ = true; 767 did_or_ = true;
767 HEnvironment* env = first_false_block_->last_environment(); 768 HEnvironment* env = first_false_block_->last_environment();
768 if (split_edge_merge_block_ == NULL) { 769 if (split_edge_merge_block_ == NULL) {
769 split_edge_merge_block_ = 770 split_edge_merge_block_ =
770 builder_->CreateBasicBlock(env->Copy()); 771 builder_->CreateBasicBlock(env->Copy());
771 first_true_block_->GotoNoSimulate(split_edge_merge_block_); 772 first_true_block_->GotoNoSimulate(split_edge_merge_block_);
773 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
772 first_true_block_ = split_edge_merge_block_; 774 first_true_block_ = split_edge_merge_block_;
773 } 775 }
774 builder_->set_current_block(first_false_block_); 776 builder_->set_current_block(first_false_block_);
775 first_false_block_ = builder_->CreateBasicBlock(env->Copy()); 777 first_false_block_ = builder_->CreateBasicBlock(env->Copy());
776 } 778 }
777 779
778 780
779 void HGraphBuilder::IfBuilder::And() { 781 void HGraphBuilder::IfBuilder::And() {
780 ASSERT(!did_or_); 782 ASSERT(!did_or_);
781 did_and_ = true; 783 did_and_ = true;
782 HEnvironment* env = first_false_block_->last_environment(); 784 HEnvironment* env = first_false_block_->last_environment();
783 if (split_edge_merge_block_ == NULL) { 785 if (split_edge_merge_block_ == NULL) {
784 split_edge_merge_block_ = builder_->CreateBasicBlock(env->Copy()); 786 split_edge_merge_block_ = builder_->CreateBasicBlock(env->Copy());
785 first_false_block_->GotoNoSimulate(split_edge_merge_block_); 787 first_false_block_->GotoNoSimulate(split_edge_merge_block_);
788 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
786 first_false_block_ = split_edge_merge_block_; 789 first_false_block_ = split_edge_merge_block_;
787 } 790 }
788 builder_->set_current_block(first_true_block_); 791 builder_->set_current_block(first_true_block_);
789 first_true_block_ = builder_->CreateBasicBlock(env->Copy()); 792 first_true_block_ = builder_->CreateBasicBlock(env->Copy());
790 } 793 }
791 794
792 795
793 void HGraphBuilder::IfBuilder::CaptureContinuation( 796 void HGraphBuilder::IfBuilder::CaptureContinuation(
794 HIfContinuation* continuation) { 797 HIfContinuation* continuation) {
795 ASSERT(!finished_); 798 ASSERT(!finished_);
(...skipping 11 matching lines...) Expand all
807 810
808 811
809 void HGraphBuilder::IfBuilder::Then() { 812 void HGraphBuilder::IfBuilder::Then() {
810 ASSERT(!captured_); 813 ASSERT(!captured_);
811 ASSERT(!finished_); 814 ASSERT(!finished_);
812 did_then_ = true; 815 did_then_ = true;
813 if (needs_compare_) { 816 if (needs_compare_) {
814 // Handle if's without any expressions, they jump directly to the "else" 817 // Handle if's without any expressions, they jump directly to the "else"
815 // branch. 818 // branch.
816 builder_->current_block()->GotoNoSimulate(first_false_block_); 819 builder_->current_block()->GotoNoSimulate(first_false_block_);
820 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
817 first_true_block_ = NULL; 821 first_true_block_ = NULL;
818 } 822 }
819 builder_->set_current_block(first_true_block_); 823 builder_->set_current_block(first_true_block_);
820 } 824 }
821 825
822 826
823 void HGraphBuilder::IfBuilder::Else() { 827 void HGraphBuilder::IfBuilder::Else() {
824 ASSERT(did_then_); 828 ASSERT(did_then_);
825 ASSERT(!captured_); 829 ASSERT(!captured_);
826 ASSERT(!finished_); 830 ASSERT(!finished_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 } else { 873 } else {
870 HEnvironment* merge_env = last_true_block_->last_environment()->Copy(); 874 HEnvironment* merge_env = last_true_block_->last_environment()->Copy();
871 merge_block_ = builder_->CreateBasicBlock(merge_env); 875 merge_block_ = builder_->CreateBasicBlock(merge_env);
872 ASSERT(!finished_); 876 ASSERT(!finished_);
873 if (!did_else_) Else(); 877 if (!did_else_) Else();
874 ASSERT(!last_true_block_->IsFinished()); 878 ASSERT(!last_true_block_->IsFinished());
875 HBasicBlock* last_false_block = builder_->current_block(); 879 HBasicBlock* last_false_block = builder_->current_block();
876 ASSERT(!last_false_block->IsFinished()); 880 ASSERT(!last_false_block->IsFinished());
877 last_true_block_->GotoNoSimulate(merge_block_); 881 last_true_block_->GotoNoSimulate(merge_block_);
878 last_false_block->GotoNoSimulate(merge_block_); 882 last_false_block->GotoNoSimulate(merge_block_);
883 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
879 builder_->set_current_block(merge_block_); 884 builder_->set_current_block(merge_block_);
880 } 885 }
881 } 886 }
882 finished_ = true; 887 finished_ = true;
883 } 888 }
884 889
885 890
886 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, 891 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder,
887 HValue* context, 892 HValue* context,
888 LoopBuilder::Direction direction) 893 LoopBuilder::Direction direction)
(...skipping 12 matching lines...) Expand all
901 HValue* terminating, 906 HValue* terminating,
902 Token::Value token, 907 Token::Value token,
903 Representation input_representation) { 908 Representation input_representation) {
904 HEnvironment* env = builder_->environment(); 909 HEnvironment* env = builder_->environment();
905 phi_ = new(zone()) HPhi(env->values()->length(), zone()); 910 phi_ = new(zone()) HPhi(env->values()->length(), zone());
906 header_block_->AddPhi(phi_); 911 header_block_->AddPhi(phi_);
907 phi_->AddInput(initial); 912 phi_->AddInput(initial);
908 phi_->ChangeRepresentation(Representation::Integer32()); 913 phi_->ChangeRepresentation(Representation::Integer32());
909 env->Push(initial); 914 env->Push(initial);
910 builder_->current_block()->GotoNoSimulate(header_block_); 915 builder_->current_block()->GotoNoSimulate(header_block_);
916 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
911 917
912 HEnvironment* body_env = env->Copy(); 918 HEnvironment* body_env = env->Copy();
913 HEnvironment* exit_env = env->Copy(); 919 HEnvironment* exit_env = env->Copy();
914 body_block_ = builder_->CreateBasicBlock(body_env); 920 body_block_ = builder_->CreateBasicBlock(body_env);
915 exit_block_ = builder_->CreateBasicBlock(exit_env); 921 exit_block_ = builder_->CreateBasicBlock(exit_env);
916 // Remove the phi from the expression stack 922 // Remove the phi from the expression stack
917 body_env->Pop(); 923 body_env->Pop();
918 924
919 builder_->set_current_block(header_block_); 925 builder_->set_current_block(header_block_);
920 HCompareIDAndBranch* compare = 926 HCompareIDAndBranch* compare =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 increment_ = HSub::New(zone(), context_, phi_, one); 961 increment_ = HSub::New(zone(), context_, phi_, one);
956 } 962 }
957 increment_->ClearFlag(HValue::kCanOverflow); 963 increment_->ClearFlag(HValue::kCanOverflow);
958 increment_->ChangeRepresentation(Representation::Integer32()); 964 increment_->ChangeRepresentation(Representation::Integer32());
959 builder_->AddInstruction(increment_); 965 builder_->AddInstruction(increment_);
960 } 966 }
961 967
962 // Push the new increment value on the expression stack to merge into the phi. 968 // Push the new increment value on the expression stack to merge into the phi.
963 builder_->environment()->Push(increment_); 969 builder_->environment()->Push(increment_);
964 builder_->current_block()->GotoNoSimulate(header_block_); 970 builder_->current_block()->GotoNoSimulate(header_block_);
971 ASSERT(builder_->SafeToAddPhiInNoSideEffectsScope());
965 header_block_->loop_information()->RegisterBackEdge(body_block_); 972 header_block_->loop_information()->RegisterBackEdge(body_block_);
966 973
967 builder_->set_current_block(exit_block_); 974 builder_->set_current_block(exit_block_);
968 // Pop the phi from the expression stack 975 // Pop the phi from the expression stack
969 builder_->environment()->Pop(); 976 builder_->environment()->Pop();
970 finished_ = true; 977 finished_ = true;
971 } 978 }
972 979
973 980
974 HGraph* HGraphBuilder::CreateGraph() { 981 HGraph* HGraphBuilder::CreateGraph() {
(...skipping 7194 matching lines...) Expand 10 before | Expand all | Expand 10 after
8169 Push(access); 8176 Push(access);
8170 } 8177 }
8171 8178
8172 *has_side_effects |= access->HasObservableSideEffects(); 8179 *has_side_effects |= access->HasObservableSideEffects();
8173 // The caller will use has_side_effects and add correct Simulate. 8180 // The caller will use has_side_effects and add correct Simulate.
8174 access->SetFlag(HValue::kHasNoObservableSideEffects); 8181 access->SetFlag(HValue::kHasNoObservableSideEffects);
8175 if (position != -1) { 8182 if (position != -1) {
8176 access->set_position(position); 8183 access->set_position(position);
8177 } 8184 }
8178 if_jsarray->GotoNoSimulate(join); 8185 if_jsarray->GotoNoSimulate(join);
8186 ASSERT(SafeToAddPhiInNoSideEffectsScope());
8179 8187
8180 set_current_block(if_fastobject); 8188 set_current_block(if_fastobject);
8181 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); 8189 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
8182 checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY); 8190 checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY);
8183 access = AddInstruction(BuildFastElementAccess( 8191 access = AddInstruction(BuildFastElementAccess(
8184 elements, checked_key, val, elements_kind_branch, 8192 elements, checked_key, val, elements_kind_branch,
8185 elements_kind, is_store, STANDARD_STORE)); 8193 elements_kind, is_store, STANDARD_STORE));
8186 } else if (elements_kind == DICTIONARY_ELEMENTS) { 8194 } else if (elements_kind == DICTIONARY_ELEMENTS) {
8187 if (is_store) { 8195 if (is_store) {
8188 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val)); 8196 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val));
8189 } else { 8197 } else {
8190 access = AddInstruction(BuildLoadKeyedGeneric(object, key)); 8198 access = AddInstruction(BuildLoadKeyedGeneric(object, key));
8191 } 8199 }
8192 } else { // External array elements. 8200 } else { // External array elements.
8193 access = AddInstruction(BuildExternalArrayElementAccess( 8201 access = AddInstruction(BuildExternalArrayElementAccess(
8194 external_elements, checked_key, val, 8202 external_elements, checked_key, val,
8195 elements_kind_branch, elements_kind, is_store)); 8203 elements_kind_branch, elements_kind, is_store));
8196 } 8204 }
8197 *has_side_effects |= access->HasObservableSideEffects(); 8205 *has_side_effects |= access->HasObservableSideEffects();
8198 // The caller will use has_side_effects and add correct Simulate. 8206 // The caller will use has_side_effects and add correct Simulate.
8199 access->SetFlag(HValue::kHasNoObservableSideEffects); 8207 access->SetFlag(HValue::kHasNoObservableSideEffects);
8200 if (position != RelocInfo::kNoPosition) access->set_position(position); 8208 if (position != RelocInfo::kNoPosition) access->set_position(position);
8201 if (!is_store) { 8209 if (!is_store) {
8202 Push(access); 8210 Push(access);
8203 } 8211 }
8204 current_block()->GotoNoSimulate(join); 8212 current_block()->GotoNoSimulate(join);
8213 ASSERT(SafeToAddPhiInNoSideEffectsScope());
8205 set_current_block(if_false); 8214 set_current_block(if_false);
8206 } 8215 }
8207 } 8216 }
8208 8217
8209 // Deopt if none of the cases matched. 8218 // Deopt if none of the cases matched.
8210 current_block()->FinishExitWithDeoptimization(HDeoptimize::kNoUses); 8219 current_block()->FinishExitWithDeoptimization(HDeoptimize::kNoUses);
8211 set_current_block(join); 8220 set_current_block(join);
8212 return is_store ? NULL : Pop(); 8221 return is_store ? NULL : Pop();
8213 } 8222 }
8214 8223
(...skipping 4151 matching lines...) Expand 10 before | Expand all | Expand 10 after
12366 } 12375 }
12367 } 12376 }
12368 12377
12369 #ifdef DEBUG 12378 #ifdef DEBUG
12370 if (graph_ != NULL) graph_->Verify(false); // No full verify. 12379 if (graph_ != NULL) graph_->Verify(false); // No full verify.
12371 if (allocator_ != NULL) allocator_->Verify(); 12380 if (allocator_ != NULL) allocator_->Verify();
12372 #endif 12381 #endif
12373 } 12382 }
12374 12383
12375 } } // namespace v8::internal 12384 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698