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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 12226112: Infrastructure classes for evaluating numeric relations between values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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
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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 PrintChangesTo(stream); 683 PrintChangesTo(stream);
684 PrintTypeTo(stream); 684 PrintTypeTo(stream);
685 } 685 }
686 686
687 687
688 void HInstruction::PrintMnemonicTo(StringStream* stream) { 688 void HInstruction::PrintMnemonicTo(StringStream* stream) {
689 stream->Add("%s ", Mnemonic()); 689 stream->Add("%s ", Mnemonic());
690 } 690 }
691 691
692 692
693 HValue* HValue::AddNumericConstraint(HInstruction* insertion_point,
Jakob Kummerow 2013/02/12 15:10:42 I don't think we need this. Let's just inline it e
Massi 2013/02/13 11:56:42 Done.
694 HValue* related_value,
695 NumericRelation relation) {
696 return HNumericConstraint::New(
697 insertion_point, this, related_value, relation);
698 }
699
700
693 void HInstruction::Unlink() { 701 void HInstruction::Unlink() {
694 ASSERT(IsLinked()); 702 ASSERT(IsLinked());
695 ASSERT(!IsControlInstruction()); // Must never move control instructions. 703 ASSERT(!IsControlInstruction()); // Must never move control instructions.
696 ASSERT(!IsBlockEntry()); // Doesn't make sense to delete these. 704 ASSERT(!IsBlockEntry()); // Doesn't make sense to delete these.
697 ASSERT(previous_ != NULL); 705 ASSERT(previous_ != NULL);
698 previous_->next_ = next_; 706 previous_->next_ = next_;
699 if (next_ == NULL) { 707 if (next_ == NULL) {
700 ASSERT(block()->last() == this); 708 ASSERT(block()->last() == this);
701 block()->set_last(previous_); 709 block()->set_last(previous_);
702 } else { 710 } else {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 795 }
788 796
789 // Verify that instructions that can be eliminated by GVN have overridden 797 // Verify that instructions that can be eliminated by GVN have overridden
790 // HValue::DataEquals. The default implementation is UNREACHABLE. We 798 // HValue::DataEquals. The default implementation is UNREACHABLE. We
791 // don't actually care whether DataEquals returns true or false here. 799 // don't actually care whether DataEquals returns true or false here.
792 if (CheckFlag(kUseGVN)) DataEquals(this); 800 if (CheckFlag(kUseGVN)) DataEquals(this);
793 } 801 }
794 #endif 802 #endif
795 803
796 804
805 HNumericConstraint* HNumericConstraint::New(HInstruction* insertion_point,
Jakob Kummerow 2013/02/12 15:10:42 This should probably be renamed (AddToGraph?). Als
Massi 2013/02/13 11:56:42 Done.
806 HValue* constrained_value,
807 HValue* related_value,
808 NumericRelation relation) {
809 HNumericConstraint* result =
810 new(insertion_point->block()->zone()) HNumericConstraint(
811 constrained_value, related_value, relation);
812 result->InsertAfter(insertion_point);
813 return result;
814 }
815
816
817 void HNumericConstraint::PrintDataTo(StringStream* stream) {
818 stream->Add("(");
819 constrained_value()->PrintNameTo(stream);
820 stream->Add(" %s ", relation().Mnemonic());
821 related_value()->PrintNameTo(stream);
822 stream->Add(")");
823 }
824
825
797 void HDummyUse::PrintDataTo(StringStream* stream) { 826 void HDummyUse::PrintDataTo(StringStream* stream) {
798 value()->PrintNameTo(stream); 827 value()->PrintNameTo(stream);
799 } 828 }
800 829
801 830
802 void HUnaryCall::PrintDataTo(StringStream* stream) { 831 void HUnaryCall::PrintDataTo(StringStream* stream) {
803 value()->PrintNameTo(stream); 832 value()->PrintNameTo(stream);
804 stream->Add(" "); 833 stream->Add(" ");
805 stream->Add("#%d", argument_count()); 834 stream->Add("#%d", argument_count());
806 } 835 }
807 836
808 837
809 void HBinaryCall::PrintDataTo(StringStream* stream) { 838 void HBinaryCall::PrintDataTo(StringStream* stream) {
810 first()->PrintNameTo(stream); 839 first()->PrintNameTo(stream);
811 stream->Add(" "); 840 stream->Add(" ");
812 second()->PrintNameTo(stream); 841 second()->PrintNameTo(stream);
813 stream->Add(" "); 842 stream->Add(" ");
814 stream->Add("#%d", argument_count()); 843 stream->Add("#%d", argument_count());
815 } 844 }
816 845
817 846
847 bool HBoundsCheck::CheckRelation(NumericRelation relation,
848 HValue* related_value) {
Jakob Kummerow 2013/02/12 15:10:42 nit: indentation
Massi 2013/02/13 11:56:42 Done.
849 if (related_value == length()) {
850 return NumericRelation::Lt().Implies(relation);
Jakob Kummerow 2013/02/12 15:10:42 How about a comment: // We know that a BoundsCheck
Massi 2013/02/13 11:56:42 Done.
851 } else if (related_value == block()->graph()->GetConstant0()) {
852 return NumericRelation::Ge().Implies(relation);
853 } else {
854 return false;
855 }
856 }
857
858
818 void HBoundsCheck::PrintDataTo(StringStream* stream) { 859 void HBoundsCheck::PrintDataTo(StringStream* stream) {
819 index()->PrintNameTo(stream); 860 index()->PrintNameTo(stream);
820 stream->Add(" "); 861 stream->Add(" ");
821 length()->PrintNameTo(stream); 862 length()->PrintNameTo(stream);
822 } 863 }
823 864
824 865
825 void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) { 866 void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) {
826 ASSERT(CheckFlag(kFlexibleRepresentation)); 867 ASSERT(CheckFlag(kFlexibleRepresentation));
827 Representation r; 868 Representation r;
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 2982
2942 2983
2943 void HCheckFunction::Verify() { 2984 void HCheckFunction::Verify() {
2944 HInstruction::Verify(); 2985 HInstruction::Verify();
2945 ASSERT(HasNoUses()); 2986 ASSERT(HasNoUses());
2946 } 2987 }
2947 2988
2948 #endif 2989 #endif
2949 2990
2950 } } // namespace v8::internal 2991 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698