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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 UNREACHABLE(); | 243 UNREACHABLE(); |
244 return os; | 244 return os; |
245 } | 245 } |
246 | 246 |
247 CheckTaggedHoleMode CheckTaggedHoleModeOf(const Operator* op) { | 247 CheckTaggedHoleMode CheckTaggedHoleModeOf(const Operator* op) { |
248 DCHECK_EQ(IrOpcode::kCheckTaggedHole, op->opcode()); | 248 DCHECK_EQ(IrOpcode::kCheckTaggedHole, op->opcode()); |
249 return OpParameter<CheckTaggedHoleMode>(op); | 249 return OpParameter<CheckTaggedHoleMode>(op); |
250 } | 250 } |
251 | 251 |
| 252 size_t hash_value(CheckTaggedInputMode mode) { |
| 253 return static_cast<size_t>(mode); |
| 254 } |
| 255 |
| 256 std::ostream& operator<<(std::ostream& os, CheckTaggedInputMode mode) { |
| 257 switch (mode) { |
| 258 case CheckTaggedInputMode::kNumber: |
| 259 return os << "Number"; |
| 260 case CheckTaggedInputMode::kNumberOrOddball: |
| 261 return os << "NumberOrOddball"; |
| 262 } |
| 263 UNREACHABLE(); |
| 264 return os; |
| 265 } |
| 266 |
| 267 CheckTaggedInputMode CheckTaggedInputModeOf(const Operator* op) { |
| 268 DCHECK_EQ(IrOpcode::kCheckedTaggedToFloat64, op->opcode()); |
| 269 return OpParameter<CheckTaggedInputMode>(op); |
| 270 } |
| 271 |
252 std::ostream& operator<<(std::ostream& os, GrowFastElementsFlags flags) { | 272 std::ostream& operator<<(std::ostream& os, GrowFastElementsFlags flags) { |
253 bool empty = true; | 273 bool empty = true; |
254 if (flags & GrowFastElementsFlag::kArrayObject) { | 274 if (flags & GrowFastElementsFlag::kArrayObject) { |
255 os << "ArrayObject"; | 275 os << "ArrayObject"; |
256 empty = false; | 276 empty = false; |
257 } | 277 } |
258 if (flags & GrowFastElementsFlag::kDoubleElements) { | 278 if (flags & GrowFastElementsFlag::kDoubleElements) { |
259 if (!empty) os << "|"; | 279 if (!empty) os << "|"; |
260 os << "DoubleElements"; | 280 os << "DoubleElements"; |
261 empty = false; | 281 empty = false; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 DCHECK_EQ(IrOpcode::kTransitionElementsKind, op->opcode()); | 313 DCHECK_EQ(IrOpcode::kTransitionElementsKind, op->opcode()); |
294 return OpParameter<ElementsTransition>(op); | 314 return OpParameter<ElementsTransition>(op); |
295 } | 315 } |
296 | 316 |
297 std::ostream& operator<<(std::ostream& os, NumberOperationHint hint) { | 317 std::ostream& operator<<(std::ostream& os, NumberOperationHint hint) { |
298 switch (hint) { | 318 switch (hint) { |
299 case NumberOperationHint::kSignedSmall: | 319 case NumberOperationHint::kSignedSmall: |
300 return os << "SignedSmall"; | 320 return os << "SignedSmall"; |
301 case NumberOperationHint::kSigned32: | 321 case NumberOperationHint::kSigned32: |
302 return os << "Signed32"; | 322 return os << "Signed32"; |
| 323 case NumberOperationHint::kNumber: |
| 324 return os << "Number"; |
303 case NumberOperationHint::kNumberOrOddball: | 325 case NumberOperationHint::kNumberOrOddball: |
304 return os << "NumberOrOddball"; | 326 return os << "NumberOrOddball"; |
305 } | 327 } |
306 UNREACHABLE(); | 328 UNREACHABLE(); |
307 return os; | 329 return os; |
308 } | 330 } |
309 | 331 |
310 size_t hash_value(NumberOperationHint hint) { | 332 size_t hash_value(NumberOperationHint hint) { |
311 return static_cast<uint8_t>(hint); | 333 return static_cast<uint8_t>(hint); |
312 } | 334 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 V(CheckTaggedPointer, 1, 1) \ | 444 V(CheckTaggedPointer, 1, 1) \ |
423 V(CheckTaggedSigned, 1, 1) \ | 445 V(CheckTaggedSigned, 1, 1) \ |
424 V(CheckedInt32Add, 2, 1) \ | 446 V(CheckedInt32Add, 2, 1) \ |
425 V(CheckedInt32Sub, 2, 1) \ | 447 V(CheckedInt32Sub, 2, 1) \ |
426 V(CheckedInt32Div, 2, 1) \ | 448 V(CheckedInt32Div, 2, 1) \ |
427 V(CheckedInt32Mod, 2, 1) \ | 449 V(CheckedInt32Mod, 2, 1) \ |
428 V(CheckedUint32Div, 2, 1) \ | 450 V(CheckedUint32Div, 2, 1) \ |
429 V(CheckedUint32Mod, 2, 1) \ | 451 V(CheckedUint32Mod, 2, 1) \ |
430 V(CheckedUint32ToInt32, 1, 1) \ | 452 V(CheckedUint32ToInt32, 1, 1) \ |
431 V(CheckedTaggedSignedToInt32, 1, 1) \ | 453 V(CheckedTaggedSignedToInt32, 1, 1) \ |
432 V(CheckedTaggedToFloat64, 1, 1) \ | |
433 V(CheckedTruncateTaggedToWord32, 1, 1) | 454 V(CheckedTruncateTaggedToWord32, 1, 1) |
434 | 455 |
435 struct SimplifiedOperatorGlobalCache final { | 456 struct SimplifiedOperatorGlobalCache final { |
436 #define PURE(Name, properties, value_input_count, control_input_count) \ | 457 #define PURE(Name, properties, value_input_count, control_input_count) \ |
437 struct Name##Operator final : public Operator { \ | 458 struct Name##Operator final : public Operator { \ |
438 Name##Operator() \ | 459 Name##Operator() \ |
439 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 460 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
440 value_input_count, 0, control_input_count, 1, 0, 0) {} \ | 461 value_input_count, 0, control_input_count, 1, 0, 0) {} \ |
441 }; \ | 462 }; \ |
442 Name##Operator k##Name; | 463 Name##Operator k##Name; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 : Operator1<CheckForMinusZeroMode>( | 510 : Operator1<CheckForMinusZeroMode>( |
490 IrOpcode::kCheckedTaggedToInt32, | 511 IrOpcode::kCheckedTaggedToInt32, |
491 Operator::kFoldable | Operator::kNoThrow, "CheckedTaggedToInt32", | 512 Operator::kFoldable | Operator::kNoThrow, "CheckedTaggedToInt32", |
492 1, 1, 1, 1, 1, 0, kMode) {} | 513 1, 1, 1, 1, 1, 0, kMode) {} |
493 }; | 514 }; |
494 CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kCheckForMinusZero> | 515 CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kCheckForMinusZero> |
495 kCheckedTaggedToInt32CheckForMinusZeroOperator; | 516 kCheckedTaggedToInt32CheckForMinusZeroOperator; |
496 CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kDontCheckForMinusZero> | 517 CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kDontCheckForMinusZero> |
497 kCheckedTaggedToInt32DontCheckForMinusZeroOperator; | 518 kCheckedTaggedToInt32DontCheckForMinusZeroOperator; |
498 | 519 |
| 520 template <CheckTaggedInputMode kMode> |
| 521 struct CheckedTaggedToFloat64Operator final |
| 522 : public Operator1<CheckTaggedInputMode> { |
| 523 CheckedTaggedToFloat64Operator() |
| 524 : Operator1<CheckTaggedInputMode>( |
| 525 IrOpcode::kCheckedTaggedToFloat64, |
| 526 Operator::kFoldable | Operator::kNoThrow, |
| 527 "CheckedTaggedToFloat64", 1, 1, 1, 1, 1, 0, kMode) {} |
| 528 }; |
| 529 CheckedTaggedToFloat64Operator<CheckTaggedInputMode::kNumber> |
| 530 kCheckedTaggedToFloat64NumberOperator; |
| 531 CheckedTaggedToFloat64Operator<CheckTaggedInputMode::kNumberOrOddball> |
| 532 kCheckedTaggedToFloat64NumberOrOddballOperator; |
| 533 |
499 template <CheckFloat64HoleMode kMode> | 534 template <CheckFloat64HoleMode kMode> |
500 struct CheckFloat64HoleNaNOperator final | 535 struct CheckFloat64HoleNaNOperator final |
501 : public Operator1<CheckFloat64HoleMode> { | 536 : public Operator1<CheckFloat64HoleMode> { |
502 CheckFloat64HoleNaNOperator() | 537 CheckFloat64HoleNaNOperator() |
503 : Operator1<CheckFloat64HoleMode>( | 538 : Operator1<CheckFloat64HoleMode>( |
504 IrOpcode::kCheckFloat64Hole, | 539 IrOpcode::kCheckFloat64Hole, |
505 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, | 540 Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1, |
506 1, 1, 1, 1, 0, kMode) {} | 541 1, 1, 1, 1, 0, kMode) {} |
507 }; | 542 }; |
508 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> | 543 CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 template <NumberOperationHint kHint> \ | 583 template <NumberOperationHint kHint> \ |
549 struct Name##Operator final : public Operator1<NumberOperationHint> { \ | 584 struct Name##Operator final : public Operator1<NumberOperationHint> { \ |
550 Name##Operator() \ | 585 Name##Operator() \ |
551 : Operator1<NumberOperationHint>( \ | 586 : Operator1<NumberOperationHint>( \ |
552 IrOpcode::k##Name, Operator::kFoldable | Operator::kNoThrow, \ | 587 IrOpcode::k##Name, Operator::kFoldable | Operator::kNoThrow, \ |
553 #Name, 2, 1, 1, 1, 1, 0, kHint) {} \ | 588 #Name, 2, 1, 1, 1, 1, 0, kHint) {} \ |
554 }; \ | 589 }; \ |
555 Name##Operator<NumberOperationHint::kSignedSmall> \ | 590 Name##Operator<NumberOperationHint::kSignedSmall> \ |
556 k##Name##SignedSmallOperator; \ | 591 k##Name##SignedSmallOperator; \ |
557 Name##Operator<NumberOperationHint::kSigned32> k##Name##Signed32Operator; \ | 592 Name##Operator<NumberOperationHint::kSigned32> k##Name##Signed32Operator; \ |
| 593 Name##Operator<NumberOperationHint::kNumber> k##Name##NumberOperator; \ |
558 Name##Operator<NumberOperationHint::kNumberOrOddball> \ | 594 Name##Operator<NumberOperationHint::kNumberOrOddball> \ |
559 k##Name##NumberOrOddballOperator; | 595 k##Name##NumberOrOddballOperator; |
560 SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP) | 596 SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP) |
561 #undef SPECULATIVE_NUMBER_BINOP | 597 #undef SPECULATIVE_NUMBER_BINOP |
562 | 598 |
563 #define BUFFER_ACCESS(Type, type, TYPE, ctype, size) \ | 599 #define BUFFER_ACCESS(Type, type, TYPE, ctype, size) \ |
564 struct LoadBuffer##Type##Operator final : public Operator1<BufferAccess> { \ | 600 struct LoadBuffer##Type##Operator final : public Operator1<BufferAccess> { \ |
565 LoadBuffer##Type##Operator() \ | 601 LoadBuffer##Type##Operator() \ |
566 : Operator1<BufferAccess>( \ | 602 : Operator1<BufferAccess>( \ |
567 IrOpcode::kLoadBuffer, \ | 603 IrOpcode::kLoadBuffer, \ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 switch (mode) { | 662 switch (mode) { |
627 case CheckForMinusZeroMode::kCheckForMinusZero: | 663 case CheckForMinusZeroMode::kCheckForMinusZero: |
628 return &cache_.kCheckedTaggedToInt32CheckForMinusZeroOperator; | 664 return &cache_.kCheckedTaggedToInt32CheckForMinusZeroOperator; |
629 case CheckForMinusZeroMode::kDontCheckForMinusZero: | 665 case CheckForMinusZeroMode::kDontCheckForMinusZero: |
630 return &cache_.kCheckedTaggedToInt32DontCheckForMinusZeroOperator; | 666 return &cache_.kCheckedTaggedToInt32DontCheckForMinusZeroOperator; |
631 } | 667 } |
632 UNREACHABLE(); | 668 UNREACHABLE(); |
633 return nullptr; | 669 return nullptr; |
634 } | 670 } |
635 | 671 |
| 672 const Operator* SimplifiedOperatorBuilder::CheckedTaggedToFloat64( |
| 673 CheckTaggedInputMode mode) { |
| 674 switch (mode) { |
| 675 case CheckTaggedInputMode::kNumber: |
| 676 return &cache_.kCheckedTaggedToFloat64NumberOperator; |
| 677 case CheckTaggedInputMode::kNumberOrOddball: |
| 678 return &cache_.kCheckedTaggedToFloat64NumberOrOddballOperator; |
| 679 } |
| 680 UNREACHABLE(); |
| 681 return nullptr; |
| 682 } |
| 683 |
636 const Operator* SimplifiedOperatorBuilder::CheckMaps(int map_input_count) { | 684 const Operator* SimplifiedOperatorBuilder::CheckMaps(int map_input_count) { |
637 // TODO(bmeurer): Cache the most important versions of this operator. | 685 // TODO(bmeurer): Cache the most important versions of this operator. |
638 DCHECK_LT(0, map_input_count); | 686 DCHECK_LT(0, map_input_count); |
639 int const value_input_count = 1 + map_input_count; | 687 int const value_input_count = 1 + map_input_count; |
640 return new (zone()) Operator1<int>( // -- | 688 return new (zone()) Operator1<int>( // -- |
641 IrOpcode::kCheckMaps, // opcode | 689 IrOpcode::kCheckMaps, // opcode |
642 Operator::kNoThrow | Operator::kNoWrite, // flags | 690 Operator::kNoThrow | Operator::kNoWrite, // flags |
643 "CheckMaps", // name | 691 "CheckMaps", // name |
644 value_input_count, 1, 1, 0, 1, 0, // counts | 692 value_input_count, 1, 1, 0, 1, 0, // counts |
645 map_input_count); // parameter | 693 map_input_count); // parameter |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return nullptr; | 784 return nullptr; |
737 } | 785 } |
738 | 786 |
739 #define SPECULATIVE_NUMBER_BINOP(Name) \ | 787 #define SPECULATIVE_NUMBER_BINOP(Name) \ |
740 const Operator* SimplifiedOperatorBuilder::Name(NumberOperationHint hint) { \ | 788 const Operator* SimplifiedOperatorBuilder::Name(NumberOperationHint hint) { \ |
741 switch (hint) { \ | 789 switch (hint) { \ |
742 case NumberOperationHint::kSignedSmall: \ | 790 case NumberOperationHint::kSignedSmall: \ |
743 return &cache_.k##Name##SignedSmallOperator; \ | 791 return &cache_.k##Name##SignedSmallOperator; \ |
744 case NumberOperationHint::kSigned32: \ | 792 case NumberOperationHint::kSigned32: \ |
745 return &cache_.k##Name##Signed32Operator; \ | 793 return &cache_.k##Name##Signed32Operator; \ |
| 794 case NumberOperationHint::kNumber: \ |
| 795 return &cache_.k##Name##NumberOperator; \ |
746 case NumberOperationHint::kNumberOrOddball: \ | 796 case NumberOperationHint::kNumberOrOddball: \ |
747 return &cache_.k##Name##NumberOrOddballOperator; \ | 797 return &cache_.k##Name##NumberOrOddballOperator; \ |
748 } \ | 798 } \ |
749 UNREACHABLE(); \ | 799 UNREACHABLE(); \ |
750 return nullptr; \ | 800 return nullptr; \ |
751 } | 801 } |
752 SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP) | 802 SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP) |
753 #undef SPECULATIVE_NUMBER_BINOP | 803 #undef SPECULATIVE_NUMBER_BINOP |
754 | 804 |
755 #define ACCESS_OP_LIST(V) \ | 805 #define ACCESS_OP_LIST(V) \ |
(...skipping 12 matching lines...) Expand all Loading... |
768 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 818 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
769 #Name, value_input_count, 1, control_input_count, \ | 819 #Name, value_input_count, 1, control_input_count, \ |
770 output_count, 1, 0, access); \ | 820 output_count, 1, 0, access); \ |
771 } | 821 } |
772 ACCESS_OP_LIST(ACCESS) | 822 ACCESS_OP_LIST(ACCESS) |
773 #undef ACCESS | 823 #undef ACCESS |
774 | 824 |
775 } // namespace compiler | 825 } // namespace compiler |
776 } // namespace internal | 826 } // namespace internal |
777 } // namespace v8 | 827 } // namespace v8 |
OLD | NEW |