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 2758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2769 HBoundsCheck(HValue* index, HValue* length, | 2769 HBoundsCheck(HValue* index, HValue* length, |
2770 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY) | 2770 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY) |
2771 : key_mode_(key_mode) { | 2771 : key_mode_(key_mode) { |
2772 SetOperandAt(0, index); | 2772 SetOperandAt(0, index); |
2773 SetOperandAt(1, length); | 2773 SetOperandAt(1, length); |
2774 set_representation(Representation::Integer32()); | 2774 set_representation(Representation::Integer32()); |
2775 SetFlag(kUseGVN); | 2775 SetFlag(kUseGVN); |
2776 } | 2776 } |
2777 | 2777 |
2778 virtual Representation RequiredInputRepresentation(int arg_index) { | 2778 virtual Representation RequiredInputRepresentation(int arg_index) { |
2779 if (index()->representation().IsTagged() && | 2779 if (key_mode_ == DONT_ALLOW_SMI_KEY || |
2780 !index()->IsConstant() && | 2780 !length()->representation().IsTagged()) { |
2781 key_mode_ == ALLOW_SMI_KEY) { | |
2782 return Representation::Tagged(); | |
2783 } else { | |
2784 return Representation::Integer32(); | 2781 return Representation::Integer32(); |
2785 } | 2782 } |
| 2783 // If the index is tagged and isn't constant, then allow the length |
| 2784 // to be tagged, since it is usually already tagged from loading it out of |
| 2785 // the length field of a JSArray. This allows for direct comparison without |
| 2786 // untagging. |
| 2787 if (index()->representation().IsTagged() && !index()->IsConstant()) { |
| 2788 return Representation::Tagged(); |
| 2789 } |
| 2790 // Also allow the length to be tagged if the index is constant, because |
| 2791 // it can be tagged to allow direct comparison. |
| 2792 if (index()->IsConstant() && |
| 2793 index()->representation().IsInteger32() && |
| 2794 arg_index == 1) { |
| 2795 return Representation::Tagged(); |
| 2796 } |
| 2797 return Representation::Integer32(); |
2786 } | 2798 } |
2787 | 2799 |
2788 virtual void PrintDataTo(StringStream* stream); | 2800 virtual void PrintDataTo(StringStream* stream); |
2789 | 2801 |
2790 HValue* index() { return OperandAt(0); } | 2802 HValue* index() { return OperandAt(0); } |
2791 HValue* length() { return OperandAt(1); } | 2803 HValue* length() { return OperandAt(1); } |
2792 | 2804 |
2793 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) | 2805 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
2794 | 2806 |
2795 protected: | 2807 protected: |
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5184 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); | 5196 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); |
5185 }; | 5197 }; |
5186 | 5198 |
5187 | 5199 |
5188 #undef DECLARE_INSTRUCTION | 5200 #undef DECLARE_INSTRUCTION |
5189 #undef DECLARE_CONCRETE_INSTRUCTION | 5201 #undef DECLARE_CONCRETE_INSTRUCTION |
5190 | 5202 |
5191 } } // namespace v8::internal | 5203 } } // namespace v8::internal |
5192 | 5204 |
5193 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5205 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |