OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/simplified-operator.h" | 5 #include "src/compiler/simplified-operator.h" |
6 | 6 |
7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 #include "src/types-inl.h" | 10 #include "src/types-inl.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ | 133 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ |
134 V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \ | 134 V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \ |
135 V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \ | 135 V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \ |
136 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \ | 136 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \ |
137 V(ChangeBoolToBit, Operator::kNoProperties, 1) \ | 137 V(ChangeBoolToBit, Operator::kNoProperties, 1) \ |
138 V(ChangeBitToBool, Operator::kNoProperties, 1) \ | 138 V(ChangeBitToBool, Operator::kNoProperties, 1) \ |
139 V(ObjectIsSmi, Operator::kNoProperties, 1) \ | 139 V(ObjectIsSmi, Operator::kNoProperties, 1) \ |
140 V(ObjectIsNonNegativeSmi, Operator::kNoProperties, 1) | 140 V(ObjectIsNonNegativeSmi, Operator::kNoProperties, 1) |
141 | 141 |
142 | 142 |
143 #define ACCESS_OP_LIST(V) \ | 143 struct SimplifiedOperatorGlobalCache FINAL { |
144 V(LoadField, FieldAccess, Operator::kNoWrite, 1, 1) \ | 144 #define PURE(Name, properties, input_count) \ |
145 V(StoreField, FieldAccess, Operator::kNoRead, 2, 0) \ | 145 struct Name##Operator FINAL : public Operator { \ |
146 V(LoadElement, ElementAccess, Operator::kNoWrite, 3, 1) \ | 146 Name##Operator() \ |
147 V(StoreElement, ElementAccess, Operator::kNoRead, 4, 0) | 147 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
148 | 148 input_count, 0, 0, 1, 0, 0) {} \ |
149 | 149 }; \ |
150 struct SimplifiedOperatorBuilderImpl FINAL { | |
151 #define PURE(Name, properties, input_count) \ | |
152 struct Name##Operator FINAL : public SimpleOperator { \ | |
153 Name##Operator() \ | |
154 : SimpleOperator(IrOpcode::k##Name, Operator::kPure | properties, \ | |
155 input_count, 1, #Name) {} \ | |
156 }; \ | |
157 Name##Operator k##Name; | 150 Name##Operator k##Name; |
158 PURE_OP_LIST(PURE) | 151 PURE_OP_LIST(PURE) |
159 #undef PURE | 152 #undef PURE |
160 }; | 153 }; |
161 | 154 |
162 | 155 |
163 static base::LazyInstance<SimplifiedOperatorBuilderImpl>::type kImpl = | 156 static base::LazyInstance<SimplifiedOperatorGlobalCache>::type kCache = |
164 LAZY_INSTANCE_INITIALIZER; | 157 LAZY_INSTANCE_INITIALIZER; |
165 | 158 |
166 | 159 |
167 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 160 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
168 : impl_(kImpl.Get()), zone_(zone) {} | 161 : cache_(kCache.Get()), zone_(zone) {} |
169 | 162 |
170 | 163 |
171 #define PURE(Name, properties, input_count) \ | 164 #define PURE(Name, properties, input_count) \ |
172 const Operator* SimplifiedOperatorBuilder::Name() { return &impl_.k##Name; } | 165 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
173 PURE_OP_LIST(PURE) | 166 PURE_OP_LIST(PURE) |
174 #undef PURE | 167 #undef PURE |
175 | 168 |
176 | 169 |
177 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 170 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
178 // TODO(titzer): What about the type parameter? | 171 // TODO(titzer): What about the type parameter? |
179 return new (zone()) SimpleOperator(IrOpcode::kReferenceEqual, | 172 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
180 Operator::kCommutative | Operator::kPure, | 173 Operator::kCommutative | Operator::kPure, |
181 2, 1, "ReferenceEqual"); | 174 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
182 } | 175 } |
183 | 176 |
184 | 177 |
185 #define ACCESS(Name, Type, properties, input_count, output_count) \ | 178 #define ACCESS_OP_LIST(V) \ |
186 const Operator* SimplifiedOperatorBuilder::Name(const Type& access) { \ | 179 V(LoadField, FieldAccess, Operator::kNoWrite, 1, 1, 1) \ |
187 return new (zone()) \ | 180 V(StoreField, FieldAccess, Operator::kNoRead, 2, 1, 0) \ |
188 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 181 V(LoadElement, ElementAccess, Operator::kNoWrite, 3, 0, 1) \ |
189 input_count, output_count, #Name, access); \ | 182 V(StoreElement, ElementAccess, Operator::kNoRead, 4, 1, 0) |
| 183 |
| 184 |
| 185 #define ACCESS(Name, Type, properties, value_input_count, control_input_count, \ |
| 186 output_count) \ |
| 187 const Operator* SimplifiedOperatorBuilder::Name(const Type& access) { \ |
| 188 return new (zone()) \ |
| 189 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
| 190 #Name, value_input_count, 1, control_input_count, \ |
| 191 output_count, 1, 0, access); \ |
190 } | 192 } |
191 ACCESS_OP_LIST(ACCESS) | 193 ACCESS_OP_LIST(ACCESS) |
192 #undef ACCESS | 194 #undef ACCESS |
193 | 195 |
194 } // namespace compiler | 196 } // namespace compiler |
195 } // namespace internal | 197 } // namespace internal |
196 } // namespace v8 | 198 } // namespace v8 |
OLD | NEW |