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