| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 295 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
| 296 input_count, 0, 0, 1, 0, 0) {} \ | 296 input_count, 0, 0, 1, 0, 0) {} \ |
| 297 }; \ | 297 }; \ |
| 298 Name##Operator k##Name; | 298 Name##Operator k##Name; |
| 299 PURE_OP_LIST(PURE) | 299 PURE_OP_LIST(PURE) |
| 300 #undef PURE | 300 #undef PURE |
| 301 | 301 |
| 302 #define CHECKED(Name) \ | 302 #define CHECKED(Name) \ |
| 303 struct Name##Operator final : public Operator { \ | 303 struct Name##Operator final : public Operator { \ |
| 304 Name##Operator() \ | 304 Name##Operator() \ |
| 305 : Operator(IrOpcode::k##Name, Operator::kNoThrow, #Name, 1, 1, 1, 1, \ | 305 : Operator(IrOpcode::k##Name, Operator::kPure, #Name, 1, 1, 1, 1, 1, \ |
| 306 1, 0) {} \ | 306 0) {} \ |
| 307 }; \ | 307 }; \ |
| 308 Name##Operator k##Name; | 308 Name##Operator k##Name; |
| 309 CHECKED_OP_LIST(CHECKED) | 309 CHECKED_OP_LIST(CHECKED) |
| 310 #undef CHECKED | 310 #undef CHECKED |
| 311 | 311 |
| 312 template <CheckFloat64HoleMode kMode> | 312 template <CheckFloat64HoleMode kMode> |
| 313 struct CheckFloat64HoleNaNOperatortor final | 313 struct CheckFloat64HoleNaNOperatortor final |
| 314 : public Operator1<CheckFloat64HoleMode> { | 314 : public Operator1<CheckFloat64HoleMode> { |
| 315 CheckFloat64HoleNaNOperatortor() | 315 CheckFloat64HoleNaNOperatortor() |
| 316 : Operator1<CheckFloat64HoleMode>( | 316 : Operator1<CheckFloat64HoleMode>(IrOpcode::kCheckFloat64Hole, |
| 317 IrOpcode::kCheckFloat64Hole, Operator::kFoldable, | 317 Operator::kPure, "CheckFloat64Hole", |
| 318 "CheckFloat64Hole", 1, 1, 1, 1, 1, 0, kMode) {} | 318 1, 1, 1, 1, 1, 0, kMode) {} |
| 319 }; | 319 }; |
| 320 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kAllowReturnHole> | 320 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kAllowReturnHole> |
| 321 kCheckFloat64HoleAllowReturnHoleOperator; | 321 kCheckFloat64HoleAllowReturnHoleOperator; |
| 322 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kNeverReturnHole> | 322 CheckFloat64HoleNaNOperatortor<CheckFloat64HoleMode::kNeverReturnHole> |
| 323 kCheckFloat64HoleNeverReturnHoleOperator; | 323 kCheckFloat64HoleNeverReturnHoleOperator; |
| 324 | 324 |
| 325 template <CheckTaggedHoleMode kMode> | 325 template <CheckTaggedHoleMode kMode> |
| 326 struct CheckTaggedHoleOperator final : public Operator1<CheckTaggedHoleMode> { | 326 struct CheckTaggedHoleOperator final : public Operator1<CheckTaggedHoleMode> { |
| 327 CheckTaggedHoleOperator() | 327 CheckTaggedHoleOperator() |
| 328 : Operator1<CheckTaggedHoleMode>(IrOpcode::kCheckTaggedHole, | 328 : Operator1<CheckTaggedHoleMode>(IrOpcode::kCheckTaggedHole, |
| 329 Operator::kFoldable, "CheckTaggedHole", | 329 Operator::kPure, "CheckTaggedHole", 1, |
| 330 1, 1, 1, 1, 1, 0, kMode) {} | 330 1, 1, 1, 1, 0, kMode) {} |
| 331 }; | 331 }; |
| 332 CheckTaggedHoleOperator<CheckTaggedHoleMode::kConvertHoleToUndefined> | 332 CheckTaggedHoleOperator<CheckTaggedHoleMode::kConvertHoleToUndefined> |
| 333 kCheckTaggedHoleConvertHoleToUndefinedOperator; | 333 kCheckTaggedHoleConvertHoleToUndefinedOperator; |
| 334 CheckTaggedHoleOperator<CheckTaggedHoleMode::kNeverReturnHole> | 334 CheckTaggedHoleOperator<CheckTaggedHoleMode::kNeverReturnHole> |
| 335 kCheckTaggedHoleNeverReturnHoleOperator; | 335 kCheckTaggedHoleNeverReturnHoleOperator; |
| 336 | 336 |
| 337 struct CheckIfOperator final : public Operator { | 337 struct CheckIfOperator final : public Operator { |
| 338 CheckIfOperator() | 338 CheckIfOperator() |
| 339 : Operator(IrOpcode::kCheckIf, Operator::kFoldable, "CheckIf", 1, 1, 1, | 339 : Operator(IrOpcode::kCheckIf, Operator::kPure, "CheckIf", 1, 1, 1, 0, |
| 340 0, 1, 0) {} | 340 1, 0) {} |
| 341 }; | 341 }; |
| 342 CheckIfOperator kCheckIf; | 342 CheckIfOperator kCheckIf; |
| 343 | 343 |
| 344 template <PretenureFlag kPretenure> | 344 template <PretenureFlag kPretenure> |
| 345 struct AllocateOperator final : public Operator1<PretenureFlag> { | 345 struct AllocateOperator final : public Operator1<PretenureFlag> { |
| 346 AllocateOperator() | 346 AllocateOperator() |
| 347 : Operator1<PretenureFlag>(IrOpcode::kAllocate, Operator::kNoThrow, | 347 : Operator1<PretenureFlag>(IrOpcode::kAllocate, Operator::kNoThrow, |
| 348 "Allocate", 1, 1, 1, 1, 1, 0, kPretenure) {} | 348 "Allocate", 1, 1, 1, 1, 1, 0, kPretenure) {} |
| 349 }; | 349 }; |
| 350 AllocateOperator<NOT_TENURED> kAllocateNotTenuredOperator; | 350 AllocateOperator<NOT_TENURED> kAllocateNotTenuredOperator; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 418 } |
| 419 | 419 |
| 420 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 420 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
| 421 return new (zone()) Operator(IrOpcode::kReferenceEqual, | 421 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
| 422 Operator::kCommutative | Operator::kPure, | 422 Operator::kCommutative | Operator::kPure, |
| 423 "ReferenceEqual", 2, 0, 0, 1, 0, 0); | 423 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
| 424 } | 424 } |
| 425 | 425 |
| 426 const Operator* SimplifiedOperatorBuilder::CheckBounds() { | 426 const Operator* SimplifiedOperatorBuilder::CheckBounds() { |
| 427 // TODO(bmeurer): Cache this operator. Make it pure! | 427 // TODO(bmeurer): Cache this operator. Make it pure! |
| 428 return new (zone()) Operator(IrOpcode::kCheckBounds, Operator::kEliminatable, | 428 return new (zone()) Operator(IrOpcode::kCheckBounds, Operator::kPure, |
| 429 "CheckBounds", 2, 1, 1, 1, 1, 0); | 429 "CheckBounds", 2, 1, 1, 1, 1, 0); |
| 430 } | 430 } |
| 431 | 431 |
| 432 const Operator* SimplifiedOperatorBuilder::TypeGuard(Type* type) { | 432 const Operator* SimplifiedOperatorBuilder::TypeGuard(Type* type) { |
| 433 class TypeGuardOperator final : public Operator1<Type*> { | 433 class TypeGuardOperator final : public Operator1<Type*> { |
| 434 public: | 434 public: |
| 435 explicit TypeGuardOperator(Type* type) | 435 explicit TypeGuardOperator(Type* type) |
| 436 : Operator1<Type*>( // -- | 436 : Operator1<Type*>( // -- |
| 437 IrOpcode::kTypeGuard, Operator::kPure, // opcode | 437 IrOpcode::kTypeGuard, Operator::kPure, // opcode |
| 438 "TypeGuard", // name | 438 "TypeGuard", // name |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 TYPED_ARRAYS(STORE_BUFFER) | 479 TYPED_ARRAYS(STORE_BUFFER) |
| 480 #undef STORE_BUFFER | 480 #undef STORE_BUFFER |
| 481 } | 481 } |
| 482 UNREACHABLE(); | 482 UNREACHABLE(); |
| 483 return nullptr; | 483 return nullptr; |
| 484 } | 484 } |
| 485 | 485 |
| 486 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberAdd( | 486 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberAdd( |
| 487 BinaryOperationHints::Hint hint) { | 487 BinaryOperationHints::Hint hint) { |
| 488 return new (zone()) Operator1<BinaryOperationHints::Hint>( | 488 return new (zone()) Operator1<BinaryOperationHints::Hint>( |
| 489 IrOpcode::kSpeculativeNumberAdd, Operator::kNoThrow, | 489 IrOpcode::kSpeculativeNumberAdd, Operator::kPure, "SpeculativeNumberAdd", |
| 490 "SpeculativeNumberAdd", 2, 1, 1, 1, 1, 1, hint); | 490 2, 1, 1, 1, 1, 1, hint); |
| 491 } | 491 } |
| 492 | 492 |
| 493 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberSubtract( | 493 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberSubtract( |
| 494 BinaryOperationHints::Hint hint) { | 494 BinaryOperationHints::Hint hint) { |
| 495 return new (zone()) Operator1<BinaryOperationHints::Hint>( | 495 return new (zone()) Operator1<BinaryOperationHints::Hint>( |
| 496 IrOpcode::kSpeculativeNumberSubtract, Operator::kNoThrow, | 496 IrOpcode::kSpeculativeNumberSubtract, Operator::kPure, |
| 497 "SpeculativeNumberSubtract", 2, 1, 1, 1, 1, 1, hint); | 497 "SpeculativeNumberSubtract", 2, 1, 1, 1, 1, 1, hint); |
| 498 } | 498 } |
| 499 | 499 |
| 500 #define ACCESS_OP_LIST(V) \ | 500 #define ACCESS_OP_LIST(V) \ |
| 501 V(LoadField, FieldAccess, Operator::kNoWrite, 1, 1, 1) \ | 501 V(LoadField, FieldAccess, Operator::kNoWrite, 1, 1, 1) \ |
| 502 V(StoreField, FieldAccess, Operator::kNoRead, 2, 1, 0) \ | 502 V(StoreField, FieldAccess, Operator::kNoRead, 2, 1, 0) \ |
| 503 V(LoadElement, ElementAccess, Operator::kNoWrite, 2, 1, 1) \ | 503 V(LoadElement, ElementAccess, Operator::kNoWrite, 2, 1, 1) \ |
| 504 V(StoreElement, ElementAccess, Operator::kNoRead, 3, 1, 0) | 504 V(StoreElement, ElementAccess, Operator::kNoRead, 3, 1, 0) |
| 505 | 505 |
| 506 | 506 |
| 507 #define ACCESS(Name, Type, properties, value_input_count, control_input_count, \ | 507 #define ACCESS(Name, Type, properties, value_input_count, control_input_count, \ |
| 508 output_count) \ | 508 output_count) \ |
| 509 const Operator* SimplifiedOperatorBuilder::Name(const Type& access) { \ | 509 const Operator* SimplifiedOperatorBuilder::Name(const Type& access) { \ |
| 510 return new (zone()) \ | 510 return new (zone()) \ |
| 511 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 511 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
| 512 #Name, value_input_count, 1, control_input_count, \ | 512 #Name, value_input_count, 1, control_input_count, \ |
| 513 output_count, 1, 0, access); \ | 513 output_count, 1, 0, access); \ |
| 514 } | 514 } |
| 515 ACCESS_OP_LIST(ACCESS) | 515 ACCESS_OP_LIST(ACCESS) |
| 516 #undef ACCESS | 516 #undef ACCESS |
| 517 | 517 |
| 518 } // namespace compiler | 518 } // namespace compiler |
| 519 } // namespace internal | 519 } // namespace internal |
| 520 } // namespace v8 | 520 } // namespace v8 |
| OLD | NEW |