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.h" | 10 #include "src/types.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 V(NumberIsHoleNaN, Operator::kNoProperties, 1) \ | 179 V(NumberIsHoleNaN, Operator::kNoProperties, 1) \ |
180 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \ | 180 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \ |
181 V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \ | 181 V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \ |
182 V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \ | 182 V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \ |
183 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ | 183 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ |
184 V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \ | 184 V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \ |
185 V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \ | 185 V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \ |
186 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \ | 186 V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \ |
187 V(ChangeBoolToBit, Operator::kNoProperties, 1) \ | 187 V(ChangeBoolToBit, Operator::kNoProperties, 1) \ |
188 V(ChangeBitToBool, Operator::kNoProperties, 1) \ | 188 V(ChangeBitToBool, Operator::kNoProperties, 1) \ |
189 V(ObjectIsNumber, Operator::kNoProperties, 1) \ | |
190 V(ObjectIsReceiver, Operator::kNoProperties, 1) \ | 189 V(ObjectIsReceiver, Operator::kNoProperties, 1) \ |
191 V(ObjectIsSmi, Operator::kNoProperties, 1) | 190 V(ObjectIsSmi, Operator::kNoProperties, 1) |
192 | 191 |
193 #define NO_THROW_OP_LIST(V) \ | 192 #define NO_THROW_OP_LIST(V) \ |
194 V(StringEqual, Operator::kCommutative, 2) \ | 193 V(StringEqual, Operator::kCommutative, 2) \ |
195 V(StringLessThan, Operator::kNoThrow, 2) \ | 194 V(StringLessThan, Operator::kNoThrow, 2) \ |
196 V(StringLessThanOrEqual, Operator::kNoThrow, 2) | 195 V(StringLessThanOrEqual, Operator::kNoThrow, 2) |
197 | 196 |
| 197 #define STATEFUL_OP_LIST(V) V(ObjectIsNumber) |
| 198 |
198 struct SimplifiedOperatorGlobalCache final { | 199 struct SimplifiedOperatorGlobalCache final { |
199 #define PURE(Name, properties, input_count) \ | 200 #define PURE(Name, properties, input_count) \ |
200 struct Name##Operator final : public Operator { \ | 201 struct Name##Operator final : public Operator { \ |
201 Name##Operator() \ | 202 Name##Operator() \ |
202 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 203 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
203 input_count, 0, 0, 1, 0, 0) {} \ | 204 input_count, 0, 0, 1, 0, 0) {} \ |
204 }; \ | 205 }; \ |
205 Name##Operator k##Name; | 206 Name##Operator k##Name; |
206 PURE_OP_LIST(PURE) | 207 PURE_OP_LIST(PURE) |
207 #undef PURE | 208 #undef PURE |
208 | 209 |
| 210 #define STATEFUL(Name) \ |
| 211 struct Name##Operator final : public Operator { \ |
| 212 Name##Operator() \ |
| 213 : Operator(IrOpcode::k##Name, Operator::kNoProperties, #Name, 1, 1, 1, \ |
| 214 1, 1, 1) {} \ |
| 215 }; \ |
| 216 Name##Operator k##Name; |
| 217 STATEFUL_OP_LIST(STATEFUL) |
| 218 #undef STATEFUL |
| 219 |
209 #define NO_THROW(Name, properties, input_count) \ | 220 #define NO_THROW(Name, properties, input_count) \ |
210 struct Name##Operator final : public Operator { \ | 221 struct Name##Operator final : public Operator { \ |
211 Name##Operator() \ | 222 Name##Operator() \ |
212 : Operator(IrOpcode::k##Name, Operator::kNoThrow | properties, #Name, \ | 223 : Operator(IrOpcode::k##Name, Operator::kNoThrow | properties, #Name, \ |
213 input_count, 1, 1, 1, 1, 0) {} \ | 224 input_count, 1, 1, 1, 1, 0) {} \ |
214 }; \ | 225 }; \ |
215 Name##Operator k##Name; | 226 Name##Operator k##Name; |
216 NO_THROW_OP_LIST(NO_THROW) | 227 NO_THROW_OP_LIST(NO_THROW) |
217 #undef NO_THROW | 228 #undef NO_THROW |
218 | 229 |
(...skipping 26 matching lines...) Expand all Loading... |
245 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 256 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
246 : cache_(kCache.Get()), zone_(zone) {} | 257 : cache_(kCache.Get()), zone_(zone) {} |
247 | 258 |
248 | 259 |
249 #define GET_FROM_CACHE(Name, properties, input_count) \ | 260 #define GET_FROM_CACHE(Name, properties, input_count) \ |
250 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 261 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
251 PURE_OP_LIST(GET_FROM_CACHE) | 262 PURE_OP_LIST(GET_FROM_CACHE) |
252 NO_THROW_OP_LIST(GET_FROM_CACHE) | 263 NO_THROW_OP_LIST(GET_FROM_CACHE) |
253 #undef GET_FROM_CACHE | 264 #undef GET_FROM_CACHE |
254 | 265 |
| 266 #define GET_FROM_CACHE(Name) \ |
| 267 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
| 268 STATEFUL_OP_LIST(GET_FROM_CACHE) |
| 269 #undef GET_FROM_CACHE |
255 | 270 |
256 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 271 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
257 return new (zone()) Operator(IrOpcode::kReferenceEqual, | 272 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
258 Operator::kCommutative | Operator::kPure, | 273 Operator::kCommutative | Operator::kPure, |
259 "ReferenceEqual", 2, 0, 0, 1, 0, 0); | 274 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
260 } | 275 } |
261 | 276 |
262 | 277 |
263 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { | 278 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { |
264 return new (zone()) | 279 return new (zone()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 322 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
308 #Name, value_input_count, 1, control_input_count, \ | 323 #Name, value_input_count, 1, control_input_count, \ |
309 output_count, 1, 0, access); \ | 324 output_count, 1, 0, access); \ |
310 } | 325 } |
311 ACCESS_OP_LIST(ACCESS) | 326 ACCESS_OP_LIST(ACCESS) |
312 #undef ACCESS | 327 #undef ACCESS |
313 | 328 |
314 } // namespace compiler | 329 } // namespace compiler |
315 } // namespace internal | 330 } // namespace internal |
316 } // namespace v8 | 331 } // namespace v8 |
OLD | NEW |