OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 V(CheckFunction) \ | 91 V(CheckFunction) \ |
92 V(CheckInstanceType) \ | 92 V(CheckInstanceType) \ |
93 V(CheckMap) \ | 93 V(CheckMap) \ |
94 V(CheckNonSmi) \ | 94 V(CheckNonSmi) \ |
95 V(CheckPrototypeMaps) \ | 95 V(CheckPrototypeMaps) \ |
96 V(CheckSmi) \ | 96 V(CheckSmi) \ |
97 V(Compare) \ | 97 V(Compare) \ |
98 V(CompareJSObjectEq) \ | 98 V(CompareJSObjectEq) \ |
99 V(CompareMap) \ | 99 V(CompareMap) \ |
100 V(Constant) \ | 100 V(Constant) \ |
| 101 V(Context) \ |
101 V(DeleteProperty) \ | 102 V(DeleteProperty) \ |
102 V(Deoptimize) \ | 103 V(Deoptimize) \ |
103 V(Div) \ | 104 V(Div) \ |
104 V(EnterInlined) \ | 105 V(EnterInlined) \ |
105 V(FixedArrayLength) \ | 106 V(FixedArrayLength) \ |
106 V(FunctionLiteral) \ | 107 V(FunctionLiteral) \ |
107 V(GlobalObject) \ | 108 V(GlobalObject) \ |
108 V(GlobalReceiver) \ | 109 V(GlobalReceiver) \ |
109 V(Goto) \ | 110 V(Goto) \ |
110 V(InstanceOf) \ | 111 V(InstanceOf) \ |
(...skipping 11 matching lines...) Expand all Loading... |
122 V(LoadFunctionPrototype) \ | 123 V(LoadFunctionPrototype) \ |
123 V(LoadGlobal) \ | 124 V(LoadGlobal) \ |
124 V(LoadKeyedFastElement) \ | 125 V(LoadKeyedFastElement) \ |
125 V(LoadKeyedGeneric) \ | 126 V(LoadKeyedGeneric) \ |
126 V(LoadNamedField) \ | 127 V(LoadNamedField) \ |
127 V(LoadNamedGeneric) \ | 128 V(LoadNamedGeneric) \ |
128 V(Mod) \ | 129 V(Mod) \ |
129 V(Mul) \ | 130 V(Mul) \ |
130 V(ObjectLiteral) \ | 131 V(ObjectLiteral) \ |
131 V(OsrEntry) \ | 132 V(OsrEntry) \ |
| 133 V(OuterContext) \ |
132 V(Parameter) \ | 134 V(Parameter) \ |
133 V(Power) \ | 135 V(Power) \ |
134 V(PushArgument) \ | 136 V(PushArgument) \ |
135 V(RegExpLiteral) \ | 137 V(RegExpLiteral) \ |
136 V(Return) \ | 138 V(Return) \ |
137 V(Sar) \ | 139 V(Sar) \ |
138 V(Shl) \ | 140 V(Shl) \ |
139 V(Shr) \ | 141 V(Shr) \ |
140 V(Simulate) \ | 142 V(Simulate) \ |
141 V(StackCheck) \ | 143 V(StackCheck) \ |
| 144 V(StoreContextSlot) \ |
142 V(StoreGlobal) \ | 145 V(StoreGlobal) \ |
143 V(StoreKeyedFastElement) \ | 146 V(StoreKeyedFastElement) \ |
144 V(StoreKeyedGeneric) \ | 147 V(StoreKeyedGeneric) \ |
145 V(StoreNamedField) \ | 148 V(StoreNamedField) \ |
146 V(StoreNamedGeneric) \ | 149 V(StoreNamedGeneric) \ |
147 V(StringCharCodeAt) \ | 150 V(StringCharCodeAt) \ |
148 V(StringLength) \ | 151 V(StringLength) \ |
149 V(Sub) \ | 152 V(Sub) \ |
150 V(Test) \ | 153 V(Test) \ |
151 V(Throw) \ | 154 V(Throw) \ |
152 V(Typeof) \ | 155 V(Typeof) \ |
153 V(TypeofIs) \ | 156 V(TypeofIs) \ |
154 V(UnaryMathOperation) \ | 157 V(UnaryMathOperation) \ |
155 V(UnknownOSRValue) \ | 158 V(UnknownOSRValue) \ |
156 V(ValueOf) | 159 V(ValueOf) |
157 | 160 |
158 #define GVN_FLAG_LIST(V) \ | 161 #define GVN_FLAG_LIST(V) \ |
159 V(Calls) \ | 162 V(Calls) \ |
160 V(InobjectFields) \ | 163 V(InobjectFields) \ |
161 V(BackingStoreFields) \ | 164 V(BackingStoreFields) \ |
162 V(ArrayElements) \ | 165 V(ArrayElements) \ |
163 V(GlobalVars) \ | 166 V(GlobalVars) \ |
164 V(Maps) \ | 167 V(Maps) \ |
165 V(ArrayLengths) \ | 168 V(ArrayLengths) \ |
| 169 V(ContextSlots) \ |
166 V(OsrEntries) | 170 V(OsrEntries) |
167 | 171 |
168 #define DECLARE_INSTRUCTION(type) \ | 172 #define DECLARE_INSTRUCTION(type) \ |
169 virtual bool Is##type() const { return true; } \ | 173 virtual bool Is##type() const { return true; } \ |
170 static H##type* cast(HValue* value) { \ | 174 static H##type* cast(HValue* value) { \ |
171 ASSERT(value->Is##type()); \ | 175 ASSERT(value->Is##type()); \ |
172 return reinterpret_cast<H##type*>(value); \ | 176 return reinterpret_cast<H##type*>(value); \ |
173 } \ | 177 } \ |
174 Opcode opcode() const { return HValue::k##type; } | 178 Opcode opcode() const { return HValue::k##type; } |
175 | 179 |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 argument_index_ = index; | 1057 argument_index_ = index; |
1054 } | 1058 } |
1055 | 1059 |
1056 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument") | 1060 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument") |
1057 | 1061 |
1058 private: | 1062 private: |
1059 int argument_index_; | 1063 int argument_index_; |
1060 }; | 1064 }; |
1061 | 1065 |
1062 | 1066 |
1063 class HGlobalObject: public HInstruction { | 1067 class HContext: public HInstruction { |
1064 public: | 1068 public: |
1065 HGlobalObject() { | 1069 HContext() { |
1066 set_representation(Representation::Tagged()); | 1070 set_representation(Representation::Tagged()); |
1067 SetFlag(kUseGVN); | 1071 SetFlag(kUseGVN); |
1068 SetFlag(kDependsOnCalls); | 1072 } |
| 1073 |
| 1074 DECLARE_CONCRETE_INSTRUCTION(Context, "context"); |
| 1075 |
| 1076 protected: |
| 1077 virtual bool DataEquals(HValue* other) const { return true; } |
| 1078 }; |
| 1079 |
| 1080 |
| 1081 class HOuterContext: public HUnaryOperation { |
| 1082 public: |
| 1083 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { |
| 1084 set_representation(Representation::Tagged()); |
| 1085 SetFlag(kUseGVN); |
| 1086 } |
| 1087 |
| 1088 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer_context"); |
| 1089 |
| 1090 protected: |
| 1091 virtual bool DataEquals(HValue* other) const { return true; } |
| 1092 }; |
| 1093 |
| 1094 |
| 1095 class HGlobalObject: public HUnaryOperation { |
| 1096 public: |
| 1097 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { |
| 1098 set_representation(Representation::Tagged()); |
| 1099 SetFlag(kUseGVN); |
1069 } | 1100 } |
1070 | 1101 |
1071 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object") | 1102 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object") |
1072 | 1103 |
1073 protected: | 1104 protected: |
1074 virtual bool DataEquals(HValue* other) const { return true; } | 1105 virtual bool DataEquals(HValue* other) const { return true; } |
1075 }; | 1106 }; |
1076 | 1107 |
1077 | 1108 |
1078 class HGlobalReceiver: public HInstruction { | 1109 class HGlobalReceiver: public HUnaryOperation { |
1079 public: | 1110 public: |
1080 HGlobalReceiver() { | 1111 explicit HGlobalReceiver(HValue* global_object) |
| 1112 : HUnaryOperation(global_object) { |
1081 set_representation(Representation::Tagged()); | 1113 set_representation(Representation::Tagged()); |
1082 SetFlag(kUseGVN); | 1114 SetFlag(kUseGVN); |
1083 SetFlag(kDependsOnCalls); | |
1084 } | 1115 } |
1085 | 1116 |
1086 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver") | 1117 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver") |
1087 | 1118 |
1088 protected: | 1119 protected: |
1089 virtual bool DataEquals(HValue* other) const { return true; } | 1120 virtual bool DataEquals(HValue* other) const { return true; } |
1090 }; | 1121 }; |
1091 | 1122 |
1092 | 1123 |
1093 class HCall: public HInstruction { | 1124 class HCall: public HInstruction { |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 virtual void PrintDataTo(StringStream* stream) const; | 2637 virtual void PrintDataTo(StringStream* stream) const; |
2607 | 2638 |
2608 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global") | 2639 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global") |
2609 | 2640 |
2610 private: | 2641 private: |
2611 Handle<JSGlobalPropertyCell> cell_; | 2642 Handle<JSGlobalPropertyCell> cell_; |
2612 bool check_hole_value_; | 2643 bool check_hole_value_; |
2613 }; | 2644 }; |
2614 | 2645 |
2615 | 2646 |
2616 class HLoadContextSlot: public HInstruction { | 2647 class HLoadContextSlot: public HUnaryOperation { |
2617 public: | 2648 public: |
2618 HLoadContextSlot(int context_chain_length , int slot_index) | 2649 HLoadContextSlot(HValue* context , int slot_index) |
2619 : context_chain_length_(context_chain_length), slot_index_(slot_index) { | 2650 : HUnaryOperation(context), slot_index_(slot_index) { |
2620 set_representation(Representation::Tagged()); | 2651 set_representation(Representation::Tagged()); |
2621 SetFlag(kUseGVN); | 2652 SetFlag(kUseGVN); |
2622 SetFlag(kDependsOnCalls); | 2653 SetFlag(kDependsOnContextSlots); |
2623 } | 2654 } |
2624 | 2655 |
2625 int context_chain_length() const { return context_chain_length_; } | |
2626 int slot_index() const { return slot_index_; } | 2656 int slot_index() const { return slot_index_; } |
2627 | 2657 |
| 2658 virtual Representation RequiredInputRepresentation(int index) const { |
| 2659 return Representation::Tagged(); |
| 2660 } |
| 2661 |
2628 virtual void PrintDataTo(StringStream* stream) const; | 2662 virtual void PrintDataTo(StringStream* stream) const; |
2629 | 2663 |
2630 virtual intptr_t Hashcode() const { | |
2631 return context_chain_length() * 29 + slot_index(); | |
2632 } | |
2633 | |
2634 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot") | 2664 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot") |
2635 | 2665 |
2636 protected: | 2666 protected: |
2637 virtual bool DataEquals(HValue* other) const { | 2667 virtual bool DataEquals(HValue* other) const { |
2638 HLoadContextSlot* b = HLoadContextSlot::cast(other); | 2668 HLoadContextSlot* b = HLoadContextSlot::cast(other); |
2639 return (context_chain_length() == b->context_chain_length()) | 2669 return (slot_index() == b->slot_index()); |
2640 && (slot_index() == b->slot_index()); | |
2641 } | 2670 } |
2642 | 2671 |
2643 private: | 2672 private: |
2644 int context_chain_length_; | |
2645 int slot_index_; | 2673 int slot_index_; |
2646 }; | 2674 }; |
2647 | 2675 |
| 2676 |
| 2677 static inline bool StoringValueNeedsWriteBarrier(HValue* value) { |
| 2678 return !value->type().IsSmi() && |
| 2679 !(value->IsConstant() && HConstant::cast(value)->InOldSpace()); |
| 2680 } |
| 2681 |
| 2682 |
| 2683 class HStoreContextSlot: public HBinaryOperation { |
| 2684 public: |
| 2685 HStoreContextSlot(HValue* context, int slot_index, HValue* value) |
| 2686 : HBinaryOperation(context, value), slot_index_(slot_index) { |
| 2687 SetFlag(kChangesContextSlots); |
| 2688 } |
| 2689 |
| 2690 HValue* context() const { return OperandAt(0); } |
| 2691 HValue* value() const { return OperandAt(1); } |
| 2692 int slot_index() const { return slot_index_; } |
| 2693 |
| 2694 bool NeedsWriteBarrier() const { |
| 2695 return StoringValueNeedsWriteBarrier(value()); |
| 2696 } |
| 2697 |
| 2698 virtual Representation RequiredInputRepresentation(int index) const { |
| 2699 return Representation::Tagged(); |
| 2700 } |
| 2701 |
| 2702 virtual void PrintDataTo(StringStream* stream) const; |
| 2703 |
| 2704 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store_context_slot") |
| 2705 |
| 2706 private: |
| 2707 int slot_index_; |
| 2708 }; |
| 2709 |
2648 | 2710 |
2649 class HLoadNamedField: public HUnaryOperation { | 2711 class HLoadNamedField: public HUnaryOperation { |
2650 public: | 2712 public: |
2651 HLoadNamedField(HValue* object, bool is_in_object, int offset) | 2713 HLoadNamedField(HValue* object, bool is_in_object, int offset) |
2652 : HUnaryOperation(object), | 2714 : HUnaryOperation(object), |
2653 is_in_object_(is_in_object), | 2715 is_in_object_(is_in_object), |
2654 offset_(offset) { | 2716 offset_(offset) { |
2655 set_representation(Representation::Tagged()); | 2717 set_representation(Representation::Tagged()); |
2656 SetFlag(kUseGVN); | 2718 SetFlag(kUseGVN); |
2657 if (is_in_object) { | 2719 if (is_in_object) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 class HLoadKeyedGeneric: public HLoadKeyed { | 2832 class HLoadKeyedGeneric: public HLoadKeyed { |
2771 public: | 2833 public: |
2772 HLoadKeyedGeneric(HValue* obj, HValue* key) : HLoadKeyed(obj, key) { | 2834 HLoadKeyedGeneric(HValue* obj, HValue* key) : HLoadKeyed(obj, key) { |
2773 SetAllSideEffects(); | 2835 SetAllSideEffects(); |
2774 } | 2836 } |
2775 | 2837 |
2776 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load_keyed_generic") | 2838 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load_keyed_generic") |
2777 }; | 2839 }; |
2778 | 2840 |
2779 | 2841 |
2780 static inline bool StoringValueNeedsWriteBarrier(HValue* value) { | |
2781 return !value->type().IsSmi() && | |
2782 !(value->IsConstant() && HConstant::cast(value)->InOldSpace()); | |
2783 } | |
2784 | |
2785 | |
2786 class HStoreNamed: public HBinaryOperation { | 2842 class HStoreNamed: public HBinaryOperation { |
2787 public: | 2843 public: |
2788 HStoreNamed(HValue* obj, Handle<Object> name, HValue* val) | 2844 HStoreNamed(HValue* obj, Handle<Object> name, HValue* val) |
2789 : HBinaryOperation(obj, val), name_(name) { | 2845 : HBinaryOperation(obj, val), name_(name) { |
2790 } | 2846 } |
2791 | 2847 |
2792 virtual Representation RequiredInputRepresentation(int index) const { | 2848 virtual Representation RequiredInputRepresentation(int index) const { |
2793 return Representation::Tagged(); | 2849 return Representation::Tagged(); |
2794 } | 2850 } |
2795 | 2851 |
2796 virtual void PrintDataTo(StringStream* stream) const; | 2852 virtual void PrintDataTo(StringStream* stream) const; |
2797 | 2853 |
2798 HValue* object() const { return OperandAt(0); } | 2854 HValue* object() const { return OperandAt(0); } |
2799 Handle<Object> name() const { return name_; } | 2855 Handle<Object> name() const { return name_; } |
2800 HValue* value() const { return OperandAt(1); } | 2856 HValue* value() const { return OperandAt(1); } |
2801 void set_value(HValue* value) { SetOperandAt(1, value); } | 2857 void set_value(HValue* value) { SetOperandAt(1, value); } |
2802 | 2858 |
2803 bool NeedsWriteBarrier() const { | |
2804 return StoringValueNeedsWriteBarrier(value()); | |
2805 } | |
2806 | |
2807 DECLARE_INSTRUCTION(StoreNamed) | 2859 DECLARE_INSTRUCTION(StoreNamed) |
2808 | 2860 |
2809 private: | 2861 private: |
2810 Handle<Object> name_; | 2862 Handle<Object> name_; |
2811 }; | 2863 }; |
2812 | 2864 |
2813 | 2865 |
2814 class HStoreNamedField: public HStoreNamed { | 2866 class HStoreNamedField: public HStoreNamed { |
2815 public: | 2867 public: |
2816 HStoreNamedField(HValue* obj, | 2868 HStoreNamedField(HValue* obj, |
2817 Handle<Object> name, | 2869 Handle<Object> name, |
2818 HValue* val, | 2870 HValue* val, |
2819 bool in_object, | 2871 bool in_object, |
2820 int offset) | 2872 int offset) |
2821 : HStoreNamed(obj, name, val), | 2873 : HStoreNamed(obj, name, val), |
2822 is_in_object_(in_object), | 2874 is_in_object_(in_object), |
2823 offset_(offset) { | 2875 offset_(offset) { |
2824 if (is_in_object_) { | 2876 if (is_in_object_) { |
2825 SetFlag(kChangesInobjectFields); | 2877 SetFlag(kChangesInobjectFields); |
2826 } else { | 2878 } else { |
2827 SetFlag(kChangesBackingStoreFields); | 2879 SetFlag(kChangesBackingStoreFields); |
2828 } | 2880 } |
2829 } | 2881 } |
2830 | 2882 |
2831 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field") | 2883 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field") |
2832 | 2884 |
2833 virtual Representation RequiredInputRepresentation(int index) const { | 2885 virtual Representation RequiredInputRepresentation(int index) const { |
2834 return Representation::Tagged(); | 2886 return Representation::Tagged(); |
2835 } | 2887 } |
2836 virtual void PrintDataTo(StringStream* stream) const; | 2888 virtual void PrintDataTo(StringStream* stream) const; |
2837 | 2889 |
2838 bool is_in_object() const { return is_in_object_; } | 2890 bool is_in_object() const { return is_in_object_; } |
2839 int offset() const { return offset_; } | 2891 int offset() const { return offset_; } |
2840 Handle<Map> transition() const { return transition_; } | 2892 Handle<Map> transition() const { return transition_; } |
2841 void set_transition(Handle<Map> map) { transition_ = map; } | 2893 void set_transition(Handle<Map> map) { transition_ = map; } |
2842 | 2894 |
| 2895 bool NeedsWriteBarrier() const { |
| 2896 return StoringValueNeedsWriteBarrier(value()); |
| 2897 } |
| 2898 |
2843 private: | 2899 private: |
2844 bool is_in_object_; | 2900 bool is_in_object_; |
2845 int offset_; | 2901 int offset_; |
2846 Handle<Map> transition_; | 2902 Handle<Map> transition_; |
2847 }; | 2903 }; |
2848 | 2904 |
2849 | 2905 |
2850 class HStoreNamedGeneric: public HStoreNamed { | 2906 class HStoreNamedGeneric: public HStoreNamed { |
2851 public: | 2907 public: |
2852 HStoreNamedGeneric(HValue* obj, Handle<Object> name, HValue* val) | 2908 HStoreNamedGeneric(HValue* obj, Handle<Object> name, HValue* val) |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3121 HValue* object() const { return left(); } | 3177 HValue* object() const { return left(); } |
3122 HValue* key() const { return right(); } | 3178 HValue* key() const { return right(); } |
3123 }; | 3179 }; |
3124 | 3180 |
3125 #undef DECLARE_INSTRUCTION | 3181 #undef DECLARE_INSTRUCTION |
3126 #undef DECLARE_CONCRETE_INSTRUCTION | 3182 #undef DECLARE_CONCRETE_INSTRUCTION |
3127 | 3183 |
3128 } } // namespace v8::internal | 3184 } } // namespace v8::internal |
3129 | 3185 |
3130 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 3186 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |