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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 V(CompareIDAndBranch) \ | 97 V(CompareIDAndBranch) \ |
98 V(CompareGeneric) \ | 98 V(CompareGeneric) \ |
99 V(CompareObjectEqAndBranch) \ | 99 V(CompareObjectEqAndBranch) \ |
100 V(CompareMap) \ | 100 V(CompareMap) \ |
101 V(CompareConstantEqAndBranch) \ | 101 V(CompareConstantEqAndBranch) \ |
102 V(Constant) \ | 102 V(Constant) \ |
103 V(Context) \ | 103 V(Context) \ |
104 V(DeclareGlobals) \ | 104 V(DeclareGlobals) \ |
105 V(DeleteProperty) \ | 105 V(DeleteProperty) \ |
106 V(Deoptimize) \ | 106 V(Deoptimize) \ |
107 V(DeoptimizeIfTaggedIsNotSmi) \ | |
107 V(Div) \ | 108 V(Div) \ |
108 V(DummyUse) \ | 109 V(DummyUse) \ |
109 V(ElementsKind) \ | 110 V(ElementsKind) \ |
110 V(EnterInlined) \ | 111 V(EnterInlined) \ |
111 V(FastLiteral) \ | 112 V(FastLiteral) \ |
112 V(FixedArrayBaseLength) \ | 113 V(FixedArrayBaseLength) \ |
113 V(ForceRepresentation) \ | 114 V(ForceRepresentation) \ |
114 V(FunctionLiteral) \ | 115 V(FunctionLiteral) \ |
115 V(GetCachedArrayIndex) \ | 116 V(GetCachedArrayIndex) \ |
116 V(GlobalObject) \ | 117 V(GlobalObject) \ |
(...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2605 virtual void Verify(); | 2606 virtual void Verify(); |
2606 #endif | 2607 #endif |
2607 | 2608 |
2608 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) | 2609 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) |
2609 | 2610 |
2610 protected: | 2611 protected: |
2611 virtual bool DataEquals(HValue* other) { return true; } | 2612 virtual bool DataEquals(HValue* other) { return true; } |
2612 }; | 2613 }; |
2613 | 2614 |
2614 | 2615 |
2616 class HDeoptimizeIfTaggedIsNotSmi: public HUnaryOperation { | |
Jakob Kummerow
2013/02/06 13:43:59
For consistency with HCheckSmi, I'd call this HChe
Massi
2013/02/06 19:12:31
Done.
| |
2617 public: | |
2618 explicit HDeoptimizeIfTaggedIsNotSmi( | |
Jakob Kummerow
2013/02/06 13:43:59
no "explicit" necessary (unless you remove the Rep
Massi
2013/02/06 19:12:31
Done.
| |
2619 HValue* value, | |
2620 Representation r = Representation::None()) | |
2621 : HUnaryOperation(value) { | |
2622 if (r.IsNone()) { | |
2623 // In the normal compilation pipeline the representation is flexible | |
2624 // (see InferRepresentation). | |
2625 SetFlag(kFlexibleRepresentation); | |
2626 } else { | |
Jakob Kummerow
2013/02/06 13:43:59
I don't think we need this case. This instruction
Massi
2013/02/06 19:12:31
Done.
| |
2627 // When compiling stubs we want to set the representation explicitly | |
2628 // so the compilation pipeline can skip the HInferRepresentation phase. | |
2629 set_representation(r); | |
2630 } | |
2631 SetFlag(kUseGVN); | |
2632 } | |
2633 | |
2634 virtual int RedefinedOperandIndex() { return 0; } | |
2635 virtual Representation RequiredInputRepresentation(int index) { | |
2636 return representation(); | |
2637 } | |
2638 virtual void InferRepresentation(HInferRepresentation* h_infer); | |
2639 | |
2640 #ifdef DEBUG | |
2641 virtual void Verify(); | |
2642 #endif | |
2643 | |
2644 DECLARE_CONCRETE_INSTRUCTION(DeoptimizeIfTaggedIsNotSmi) | |
2645 | |
2646 protected: | |
2647 virtual bool DataEquals(HValue* other) { return true; } | |
2648 }; | |
2649 | |
2650 | |
2615 class HPhi: public HValue { | 2651 class HPhi: public HValue { |
2616 public: | 2652 public: |
2617 HPhi(int merged_index, Zone* zone) | 2653 HPhi(int merged_index, Zone* zone) |
2618 : inputs_(2, zone), | 2654 : inputs_(2, zone), |
2619 merged_index_(merged_index), | 2655 merged_index_(merged_index), |
2620 phi_id_(-1), | 2656 phi_id_(-1), |
2621 is_live_(false), | 2657 is_live_(false), |
2622 is_convertible_to_integer_(true) { | 2658 is_convertible_to_integer_(true) { |
2623 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 2659 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
2624 non_phi_uses_[i] = 0; | 2660 non_phi_uses_[i] = 0; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2800 virtual void PrintDataTo(StringStream* stream); | 2836 virtual void PrintDataTo(StringStream* stream); |
2801 virtual HType CalculateInferredType(); | 2837 virtual HType CalculateInferredType(); |
2802 bool IsInteger() { return handle()->IsSmi(); } | 2838 bool IsInteger() { return handle()->IsSmi(); } |
2803 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; | 2839 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
2804 HConstant* CopyToTruncatedInt32(Zone* zone) const; | 2840 HConstant* CopyToTruncatedInt32(Zone* zone) const; |
2805 bool HasInteger32Value() const { return has_int32_value_; } | 2841 bool HasInteger32Value() const { return has_int32_value_; } |
2806 int32_t Integer32Value() const { | 2842 int32_t Integer32Value() const { |
2807 ASSERT(HasInteger32Value()); | 2843 ASSERT(HasInteger32Value()); |
2808 return int32_value_; | 2844 return int32_value_; |
2809 } | 2845 } |
2846 bool HasSmiValue() const { | |
2847 return HasInteger32Value() && Smi::IsValid(Integer32Value()); | |
2848 } | |
2810 bool HasDoubleValue() const { return has_double_value_; } | 2849 bool HasDoubleValue() const { return has_double_value_; } |
2811 double DoubleValue() const { | 2850 double DoubleValue() const { |
2812 ASSERT(HasDoubleValue()); | 2851 ASSERT(HasDoubleValue()); |
2813 return double_value_; | 2852 return double_value_; |
2814 } | 2853 } |
2815 bool HasNumberValue() const { return has_double_value_; } | 2854 bool HasNumberValue() const { return has_double_value_; } |
2816 int32_t NumberValueAsInteger32() const { | 2855 int32_t NumberValueAsInteger32() const { |
2817 ASSERT(HasNumberValue()); | 2856 ASSERT(HasNumberValue()); |
2818 // Irrespective of whether a numeric HConstant can be safely | 2857 // Irrespective of whether a numeric HConstant can be safely |
2819 // represented as an int32, we store the (in some cases lossy) | 2858 // represented as an int32, we store the (in some cases lossy) |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3079 virtual bool DataEquals(HValue* other) { return true; } | 3118 virtual bool DataEquals(HValue* other) { return true; } |
3080 }; | 3119 }; |
3081 | 3120 |
3082 | 3121 |
3083 enum BoundsCheckKeyMode { | 3122 enum BoundsCheckKeyMode { |
3084 DONT_ALLOW_SMI_KEY, | 3123 DONT_ALLOW_SMI_KEY, |
3085 ALLOW_SMI_KEY | 3124 ALLOW_SMI_KEY |
3086 }; | 3125 }; |
3087 | 3126 |
3088 | 3127 |
3128 class HGraphBuilder; | |
Jakob Kummerow
2013/02/06 13:43:59
Please don't do this. Instead, move the insertion
Massi
2013/02/06 19:12:31
Done.
| |
3129 | |
3130 | |
3089 class HBoundsCheck: public HTemplateInstruction<2> { | 3131 class HBoundsCheck: public HTemplateInstruction<2> { |
3090 public: | 3132 public: |
3091 HBoundsCheck(HValue* index, HValue* length, | 3133 static HBoundsCheck* AddAfter( |
3092 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | 3134 HInstruction* insertion_point, HValue* index, HValue* length, |
3093 Representation r = Representation::None()) | 3135 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
3094 : key_mode_(key_mode) { | 3136 Representation r = Representation::None()); |
3095 SetOperandAt(0, index); | 3137 static HBoundsCheck* AddToGraph( |
3096 SetOperandAt(1, length); | 3138 HGraphBuilder* graph_builder, HValue* index, HValue* length, |
3097 if (r.IsNone()) { | 3139 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
3098 // In the normal compilation pipeline the representation is flexible | 3140 Representation r = Representation::None()); |
3099 // (see comment to RequiredInputRepresentation). | 3141 bool skip_check() { return skip_check_; } |
3100 SetFlag(kFlexibleRepresentation); | 3142 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } |
3101 } else { | |
3102 // When compiling stubs we want to set the representation explicitly | |
3103 // so the compilation pipeline can skip the HInferRepresentation phase. | |
3104 set_representation(r); | |
3105 } | |
3106 SetFlag(kUseGVN); | |
3107 } | |
3108 | 3143 |
3109 virtual Representation RequiredInputRepresentation(int arg_index) { | 3144 virtual Representation RequiredInputRepresentation(int arg_index) { |
3110 return representation(); | 3145 return representation(); |
3111 } | 3146 } |
3112 virtual Representation observed_input_representation(int index) { | 3147 virtual Representation observed_input_representation(int index) { |
3113 return Representation::Integer32(); | 3148 return Representation::Integer32(); |
3114 } | 3149 } |
3115 | 3150 |
3116 virtual void PrintDataTo(StringStream* stream); | 3151 virtual void PrintDataTo(StringStream* stream); |
3117 virtual void InferRepresentation(HInferRepresentation* h_infer); | 3152 virtual void InferRepresentation(HInferRepresentation* h_infer); |
3118 | 3153 |
3119 HValue* index() { return OperandAt(0); } | 3154 HValue* index() { return OperandAt(0); } |
3120 HValue* length() { return OperandAt(1); } | 3155 HValue* length() { return OperandAt(1); } |
3121 | 3156 |
3122 virtual int RedefinedOperandIndex() { return 0; } | 3157 virtual int RedefinedOperandIndex() { return 0; } |
3123 | 3158 |
3124 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) | 3159 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
3125 | 3160 |
3126 protected: | 3161 protected: |
3162 HBoundsCheck(HValue* index, HValue* length, | |
3163 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | |
3164 Representation r = Representation::None()) | |
3165 : key_mode_(key_mode), skip_check_(false) { | |
Jakob Kummerow
2013/02/06 13:43:59
nit: more indentation
Massi
2013/02/06 19:12:31
Done.
| |
3166 SetOperandAt(0, index); | |
3167 SetOperandAt(1, length); | |
3168 if (r.IsNone()) { | |
3169 // In the normal compilation pipeline the representation is flexible | |
3170 // (see InferRepresentation). | |
3171 SetFlag(kFlexibleRepresentation); | |
3172 } else { | |
3173 // When compiling stubs we want to set the representation explicitly | |
3174 // so the compilation pipeline can skip the HInferRepresentation phase. | |
3175 set_representation(r); | |
3176 } | |
3177 SetFlag(kUseGVN); | |
3178 } | |
3179 | |
3127 virtual bool DataEquals(HValue* other) { return true; } | 3180 virtual bool DataEquals(HValue* other) { return true; } |
3128 BoundsCheckKeyMode key_mode_; | 3181 BoundsCheckKeyMode key_mode_; |
3182 bool skip_check_; | |
3129 }; | 3183 }; |
3130 | 3184 |
3131 | 3185 |
3132 class HBitwiseBinaryOperation: public HBinaryOperation { | 3186 class HBitwiseBinaryOperation: public HBinaryOperation { |
3133 public: | 3187 public: |
3134 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) | 3188 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) |
3135 : HBinaryOperation(context, left, right) { | 3189 : HBinaryOperation(context, left, right) { |
3136 SetFlag(kFlexibleRepresentation); | 3190 SetFlag(kFlexibleRepresentation); |
3137 SetFlag(kTruncatingToInt32); | 3191 SetFlag(kTruncatingToInt32); |
3138 SetAllSideEffects(); | 3192 SetAllSideEffects(); |
(...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5743 virtual bool IsDeletable() const { return true; } | 5797 virtual bool IsDeletable() const { return true; } |
5744 }; | 5798 }; |
5745 | 5799 |
5746 | 5800 |
5747 #undef DECLARE_INSTRUCTION | 5801 #undef DECLARE_INSTRUCTION |
5748 #undef DECLARE_CONCRETE_INSTRUCTION | 5802 #undef DECLARE_CONCRETE_INSTRUCTION |
5749 | 5803 |
5750 } } // namespace v8::internal | 5804 } } // namespace v8::internal |
5751 | 5805 |
5752 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5806 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |