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

Side by Side Diff: src/hydrogen.cc

Issue 16365004: Don't force representations in the loop builder. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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') | src/hydrogen-instructions.cc » ('j') | 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 finished_(false) { 891 finished_(false) {
892 header_block_ = builder->CreateLoopHeaderBlock(); 892 header_block_ = builder->CreateLoopHeaderBlock();
893 body_block_ = NULL; 893 body_block_ = NULL;
894 exit_block_ = NULL; 894 exit_block_ = NULL;
895 } 895 }
896 896
897 897
898 HValue* HGraphBuilder::LoopBuilder::BeginBody( 898 HValue* HGraphBuilder::LoopBuilder::BeginBody(
899 HValue* initial, 899 HValue* initial,
900 HValue* terminating, 900 HValue* terminating,
901 Token::Value token, 901 Token::Value token) {
902 Representation input_representation) {
903 HEnvironment* env = builder_->environment(); 902 HEnvironment* env = builder_->environment();
904 phi_ = new(zone()) HPhi(env->values()->length(), zone()); 903 phi_ = new(zone()) HPhi(env->values()->length(), zone());
905 header_block_->AddPhi(phi_); 904 header_block_->AddPhi(phi_);
906 phi_->AddInput(initial); 905 phi_->AddInput(initial);
907 phi_->AssumeRepresentation(Representation::Integer32());
908 env->Push(initial); 906 env->Push(initial);
909 builder_->current_block()->GotoNoSimulate(header_block_); 907 builder_->current_block()->GotoNoSimulate(header_block_);
910 908
911 HEnvironment* body_env = env->Copy(); 909 HEnvironment* body_env = env->Copy();
912 HEnvironment* exit_env = env->Copy(); 910 HEnvironment* exit_env = env->Copy();
913 body_block_ = builder_->CreateBasicBlock(body_env); 911 body_block_ = builder_->CreateBasicBlock(body_env);
914 exit_block_ = builder_->CreateBasicBlock(exit_env); 912 exit_block_ = builder_->CreateBasicBlock(exit_env);
915 // Remove the phi from the expression stack 913 // Remove the phi from the expression stack
916 body_env->Pop(); 914 body_env->Pop();
917 915
918 builder_->set_current_block(header_block_); 916 builder_->set_current_block(header_block_);
919 HCompareIDAndBranch* compare = 917 HCompareIDAndBranch* compare =
920 new(zone()) HCompareIDAndBranch(phi_, terminating, token); 918 new(zone()) HCompareIDAndBranch(phi_, terminating, token);
921 compare->set_observed_input_representation(input_representation,
922 input_representation);
923 compare->AssumeRepresentation(input_representation);
924 compare->SetSuccessorAt(0, body_block_); 919 compare->SetSuccessorAt(0, body_block_);
925 compare->SetSuccessorAt(1, exit_block_); 920 compare->SetSuccessorAt(1, exit_block_);
926 builder_->current_block()->Finish(compare); 921 builder_->current_block()->Finish(compare);
927 922
928 builder_->set_current_block(body_block_); 923 builder_->set_current_block(body_block_);
929 if (direction_ == kPreIncrement || direction_ == kPreDecrement) { 924 if (direction_ == kPreIncrement || direction_ == kPreDecrement) {
930 HValue* one = builder_->graph()->GetConstant1(); 925 HValue* one = builder_->graph()->GetConstant1();
931 if (direction_ == kPreIncrement) { 926 if (direction_ == kPreIncrement) {
932 increment_ = HAdd::New(zone(), context_, phi_, one); 927 increment_ = HAdd::New(zone(), context_, phi_, one);
933 } else { 928 } else {
934 increment_ = HSub::New(zone(), context_, phi_, one); 929 increment_ = HSub::New(zone(), context_, phi_, one);
935 } 930 }
936 increment_->ClearFlag(HValue::kCanOverflow); 931 increment_->ClearFlag(HValue::kCanOverflow);
937 increment_->AssumeRepresentation(Representation::Integer32());
938 builder_->AddInstruction(increment_); 932 builder_->AddInstruction(increment_);
939 return increment_; 933 return increment_;
940 } else { 934 } else {
941 return phi_; 935 return phi_;
942 } 936 }
943 } 937 }
944 938
945 939
946 void HGraphBuilder::LoopBuilder::EndBody() { 940 void HGraphBuilder::LoopBuilder::EndBody() {
947 ASSERT(!finished_); 941 ASSERT(!finished_);
948 942
949 if (direction_ == kPostIncrement || direction_ == kPostDecrement) { 943 if (direction_ == kPostIncrement || direction_ == kPostDecrement) {
950 HValue* one = builder_->graph()->GetConstant1(); 944 HValue* one = builder_->graph()->GetConstant1();
951 if (direction_ == kPostIncrement) { 945 if (direction_ == kPostIncrement) {
952 increment_ = HAdd::New(zone(), context_, phi_, one); 946 increment_ = HAdd::New(zone(), context_, phi_, one);
953 } else { 947 } else {
954 increment_ = HSub::New(zone(), context_, phi_, one); 948 increment_ = HSub::New(zone(), context_, phi_, one);
955 } 949 }
956 increment_->ClearFlag(HValue::kCanOverflow); 950 increment_->ClearFlag(HValue::kCanOverflow);
957 increment_->AssumeRepresentation(Representation::Integer32());
958 builder_->AddInstruction(increment_); 951 builder_->AddInstruction(increment_);
959 } 952 }
960 953
961 // Push the new increment value on the expression stack to merge into the phi. 954 // Push the new increment value on the expression stack to merge into the phi.
962 builder_->environment()->Push(increment_); 955 builder_->environment()->Push(increment_);
963 builder_->current_block()->GotoNoSimulate(header_block_); 956 builder_->current_block()->GotoNoSimulate(header_block_);
964 header_block_->loop_information()->RegisterBackEdge(body_block_); 957 header_block_->loop_information()->RegisterBackEdge(body_block_);
965 958
966 builder_->set_current_block(exit_block_); 959 builder_->set_current_block(exit_block_);
967 // Pop the phi from the expression stack 960 // Pop the phi from the expression stack
(...skipping 10642 matching lines...) Expand 10 before | Expand all | Expand 10 after
11610 } 11603 }
11611 } 11604 }
11612 11605
11613 #ifdef DEBUG 11606 #ifdef DEBUG
11614 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11607 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11615 if (allocator_ != NULL) allocator_->Verify(); 11608 if (allocator_ != NULL) allocator_->Verify();
11616 #endif 11609 #endif
11617 } 11610 }
11618 11611
11619 } } // namespace v8::internal 11612 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698