Chromium Code Reviews| 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 } | 669 } |
| 670 | 670 |
| 671 | 671 |
| 672 void HValue::ComputeInitialRange(Zone* zone) { | 672 void HValue::ComputeInitialRange(Zone* zone) { |
| 673 ASSERT(!HasRange()); | 673 ASSERT(!HasRange()); |
| 674 range_ = InferRange(zone); | 674 range_ = InferRange(zone); |
| 675 ASSERT(HasRange()); | 675 ASSERT(HasRange()); |
| 676 } | 676 } |
| 677 | 677 |
| 678 | 678 |
| 679 bool HValue::DecomposeValuePlusConstant(HValue** value, int32_t* constant) { | |
| 680 if (IsAdd()) { | |
| 681 HAdd* add = HAdd::cast(this); | |
| 682 if (add->right()->IsConstant() && | |
| 683 HConstant::cast(add->right())->HasInteger32Value()) { | |
| 684 *value = add->left(); | |
| 685 *constant = HConstant::cast(add->right())->Integer32Value(); | |
| 686 return true; | |
| 687 } else if (add->left()->IsConstant() && | |
| 688 HConstant::cast(add->left())->HasInteger32Value()) { | |
| 689 *value = add->right(); | |
| 690 *constant = HConstant::cast(add->left())->Integer32Value(); | |
| 691 return true; | |
| 692 } | |
| 693 } else if (IsSub()) { | |
| 694 HSub* sub = HSub::cast(this); | |
| 695 if (sub->right()->IsConstant() && | |
| 696 HConstant::cast(sub->right())->HasInteger32Value()) { | |
| 697 *value = sub->left(); | |
| 698 *constant = -HConstant::cast(sub->right())->Integer32Value(); | |
| 699 return true; | |
| 700 } | |
| 701 } | |
| 702 *value = NULL; | |
| 703 *constant = 0; | |
| 704 return false; | |
| 705 } | |
| 706 | |
| 707 | |
| 708 HValue* HValue::InsertNumericConstraint(HInstruction* insertion_point, | |
| 709 NumericRelation relation, | |
| 710 HValue* other, | |
| 711 int32_t offset) { | |
| 712 return HNumericConstraint::New( | |
| 713 insertion_point, this, relation, other, offset); | |
| 714 } | |
| 715 | |
| 716 | |
| 679 void HInstruction::PrintTo(StringStream* stream) { | 717 void HInstruction::PrintTo(StringStream* stream) { |
| 680 PrintMnemonicTo(stream); | 718 PrintMnemonicTo(stream); |
| 681 PrintDataTo(stream); | 719 PrintDataTo(stream); |
| 682 PrintRangeTo(stream); | 720 PrintRangeTo(stream); |
| 683 PrintChangesTo(stream); | 721 PrintChangesTo(stream); |
| 684 PrintTypeTo(stream); | 722 PrintTypeTo(stream); |
| 685 } | 723 } |
| 686 | 724 |
| 687 | 725 |
| 688 void HInstruction::PrintMnemonicTo(StringStream* stream) { | 726 void HInstruction::PrintMnemonicTo(StringStream* stream) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 } | 825 } |
| 788 | 826 |
| 789 // Verify that instructions that can be eliminated by GVN have overridden | 827 // Verify that instructions that can be eliminated by GVN have overridden |
| 790 // HValue::DataEquals. The default implementation is UNREACHABLE. We | 828 // HValue::DataEquals. The default implementation is UNREACHABLE. We |
| 791 // don't actually care whether DataEquals returns true or false here. | 829 // don't actually care whether DataEquals returns true or false here. |
| 792 if (CheckFlag(kUseGVN)) DataEquals(this); | 830 if (CheckFlag(kUseGVN)) DataEquals(this); |
| 793 } | 831 } |
| 794 #endif | 832 #endif |
| 795 | 833 |
| 796 | 834 |
| 835 HNumericConstraint::HNumericConstraint(HInstruction* insertion_point, | |
| 836 HValue* input, | |
| 837 NumericRelation constraint, | |
| 838 HValue* value, | |
| 839 int delta) | |
| 840 : constraint_(constraint), | |
| 841 delta_(delta) { | |
| 842 SetOperandAt(0, input); | |
| 843 SetOperandAt(1, value); | |
| 844 set_representation(input->representation()); | |
| 845 InsertAfter(insertion_point); | |
| 846 } | |
| 847 | |
| 848 | |
| 849 HNumericConstraint* HNumericConstraint::Create( | |
| 850 HInstruction* insertion_point, | |
| 851 HValue* input, | |
| 852 NumericRelation constraint, | |
| 853 HValue* value, | |
| 854 int delta) { | |
| 855 return new (previous_definition->block()->zone()) HNumericConstraint( | |
|
Jakob Kummerow
2013/02/04 17:06:09
what's previous_definition?
| |
| 856 insertion_point, input, constraint, value, delta); | |
| 857 } | |
| 858 | |
| 859 | |
| 860 HNumericConstraint* HNumericConstraint::New( | |
| 861 HInstruction* insertion_point, | |
| 862 HValue* input, | |
| 863 NumericRelation constraint, | |
| 864 HValue* value, | |
| 865 int delta) { | |
| 866 HNumericConstraint* result = Create( | |
| 867 insertion_point, input, constraint, value, delta); | |
| 868 AddImpliedConstraints(input, input, constraint, value, delta); | |
| 869 return result; | |
| 870 } | |
| 871 | |
| 872 | |
| 873 | |
| 874 void HNumericConstraint::AddInformativeDefinitions() {} | |
| 875 | |
| 876 void HNumericConstraint::PrintDataTo(StringStream* stream) { | |
| 877 stream->Add("("); | |
| 878 input()->PrintNameTo(stream); | |
| 879 stream->Add(" %s ", constraint().Mnemonic()); | |
| 880 value()->PrintNameTo(stream); | |
| 881 if (delta() > 0) { | |
| 882 stream->Add(" + %d", delta()); | |
| 883 } else if (delta() < 0) { | |
| 884 stream->Add(" - %d", -delta()); | |
| 885 } | |
| 886 stream->Add(")"); | |
| 887 } | |
| 888 | |
| 889 | |
| 890 bool HNumericConstraint::CheckRelation(NumericRelation relation, | |
| 891 HValue* other, | |
| 892 int32_t offset) { | |
| 893 if (other == value() && relation.Includes(constraint(), offset, delta())) { | |
|
Jakob Kummerow
2013/02/04 17:06:09
I don't see "Includes()" defined anywhere. Do you
| |
| 894 return true; | |
| 895 } | |
| 896 return input()->IsRelationTrue(relation, other, offset); | |
|
Jakob Kummerow
2013/02/04 17:06:09
When you have two methods recursively calling each
| |
| 897 } | |
| 898 | |
| 899 | |
| 797 void HDummyUse::PrintDataTo(StringStream* stream) { | 900 void HDummyUse::PrintDataTo(StringStream* stream) { |
| 798 value()->PrintNameTo(stream); | 901 value()->PrintNameTo(stream); |
| 799 } | 902 } |
| 800 | 903 |
| 801 | 904 |
| 802 void HUnaryCall::PrintDataTo(StringStream* stream) { | 905 void HUnaryCall::PrintDataTo(StringStream* stream) { |
| 803 value()->PrintNameTo(stream); | 906 value()->PrintNameTo(stream); |
| 804 stream->Add(" "); | 907 stream->Add(" "); |
| 805 stream->Add("#%d", argument_count()); | 908 stream->Add("#%d", argument_count()); |
| 806 } | 909 } |
| (...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2909 | 3012 |
| 2910 | 3013 |
| 2911 void HCheckFunction::Verify() { | 3014 void HCheckFunction::Verify() { |
| 2912 HInstruction::Verify(); | 3015 HInstruction::Verify(); |
| 2913 ASSERT(HasNoUses()); | 3016 ASSERT(HasNoUses()); |
| 2914 } | 3017 } |
| 2915 | 3018 |
| 2916 #endif | 3019 #endif |
| 2917 | 3020 |
| 2918 } } // namespace v8::internal | 3021 } } // namespace v8::internal |
| OLD | NEW |