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/compiler/types.h" | 10 #include "src/compiler/types.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 UNREACHABLE(); | 365 UNREACHABLE(); |
366 return os; | 366 return os; |
367 } | 367 } |
368 | 368 |
369 size_t hash_value(NumberOperationHint hint) { | 369 size_t hash_value(NumberOperationHint hint) { |
370 return static_cast<uint8_t>(hint); | 370 return static_cast<uint8_t>(hint); |
371 } | 371 } |
372 | 372 |
373 NumberOperationHint NumberOperationHintOf(const Operator* op) { | 373 NumberOperationHint NumberOperationHintOf(const Operator* op) { |
374 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd || | 374 DCHECK(op->opcode() == IrOpcode::kSpeculativeToNumber || |
| 375 op->opcode() == IrOpcode::kSpeculativeNumberAdd || |
375 op->opcode() == IrOpcode::kSpeculativeNumberSubtract || | 376 op->opcode() == IrOpcode::kSpeculativeNumberSubtract || |
376 op->opcode() == IrOpcode::kSpeculativeNumberMultiply || | 377 op->opcode() == IrOpcode::kSpeculativeNumberMultiply || |
377 op->opcode() == IrOpcode::kSpeculativeNumberDivide || | 378 op->opcode() == IrOpcode::kSpeculativeNumberDivide || |
378 op->opcode() == IrOpcode::kSpeculativeNumberModulus || | 379 op->opcode() == IrOpcode::kSpeculativeNumberModulus || |
379 op->opcode() == IrOpcode::kSpeculativeNumberShiftLeft || | 380 op->opcode() == IrOpcode::kSpeculativeNumberShiftLeft || |
380 op->opcode() == IrOpcode::kSpeculativeNumberShiftRight || | 381 op->opcode() == IrOpcode::kSpeculativeNumberShiftRight || |
381 op->opcode() == IrOpcode::kSpeculativeNumberShiftRightLogical || | 382 op->opcode() == IrOpcode::kSpeculativeNumberShiftRightLogical || |
382 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseAnd || | 383 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseAnd || |
383 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseOr || | 384 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseOr || |
384 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseXor || | 385 op->opcode() == IrOpcode::kSpeculativeNumberBitwiseXor || |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 }; \ | 678 }; \ |
678 Name##Operator<NumberOperationHint::kSignedSmall> \ | 679 Name##Operator<NumberOperationHint::kSignedSmall> \ |
679 k##Name##SignedSmallOperator; \ | 680 k##Name##SignedSmallOperator; \ |
680 Name##Operator<NumberOperationHint::kSigned32> k##Name##Signed32Operator; \ | 681 Name##Operator<NumberOperationHint::kSigned32> k##Name##Signed32Operator; \ |
681 Name##Operator<NumberOperationHint::kNumber> k##Name##NumberOperator; \ | 682 Name##Operator<NumberOperationHint::kNumber> k##Name##NumberOperator; \ |
682 Name##Operator<NumberOperationHint::kNumberOrOddball> \ | 683 Name##Operator<NumberOperationHint::kNumberOrOddball> \ |
683 k##Name##NumberOrOddballOperator; | 684 k##Name##NumberOrOddballOperator; |
684 SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP) | 685 SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP) |
685 #undef SPECULATIVE_NUMBER_BINOP | 686 #undef SPECULATIVE_NUMBER_BINOP |
686 | 687 |
| 688 template <NumberOperationHint kHint> |
| 689 struct SpeculativeToNumberOperator final |
| 690 : public Operator1<NumberOperationHint> { |
| 691 SpeculativeToNumberOperator() |
| 692 : Operator1<NumberOperationHint>( |
| 693 IrOpcode::kSpeculativeToNumber, // opcode |
| 694 Operator::kFoldable | Operator::kNoThrow, // flags |
| 695 "SpeculativeToNumber", // name |
| 696 1, 1, 1, 1, 1, 0, // counts |
| 697 kHint) {} // parameter |
| 698 }; |
| 699 SpeculativeToNumberOperator<NumberOperationHint::kSignedSmall> |
| 700 kSpeculativeToNumberSignedSmallOperator; |
| 701 SpeculativeToNumberOperator<NumberOperationHint::kSigned32> |
| 702 kSpeculativeToNumberSigned32Operator; |
| 703 SpeculativeToNumberOperator<NumberOperationHint::kNumber> |
| 704 kSpeculativeToNumberNumberOperator; |
| 705 SpeculativeToNumberOperator<NumberOperationHint::kNumberOrOddball> |
| 706 kSpeculativeToNumberNumberOrOddballOperator; |
| 707 |
687 #define BUFFER_ACCESS(Type, type, TYPE, ctype, size) \ | 708 #define BUFFER_ACCESS(Type, type, TYPE, ctype, size) \ |
688 struct LoadBuffer##Type##Operator final : public Operator1<BufferAccess> { \ | 709 struct LoadBuffer##Type##Operator final : public Operator1<BufferAccess> { \ |
689 LoadBuffer##Type##Operator() \ | 710 LoadBuffer##Type##Operator() \ |
690 : Operator1<BufferAccess>( \ | 711 : Operator1<BufferAccess>( \ |
691 IrOpcode::kLoadBuffer, \ | 712 IrOpcode::kLoadBuffer, \ |
692 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ | 713 Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoWrite, \ |
693 "LoadBuffer", 3, 1, 1, 1, 1, 0, \ | 714 "LoadBuffer", 3, 1, 1, 1, 1, 0, \ |
694 BufferAccess(kExternal##Type##Array)) {} \ | 715 BufferAccess(kExternal##Type##Array)) {} \ |
695 }; \ | 716 }; \ |
696 struct StoreBuffer##Type##Operator final : public Operator1<BufferAccess> { \ | 717 struct StoreBuffer##Type##Operator final : public Operator1<BufferAccess> { \ |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 switch (mode) { | 809 switch (mode) { |
789 case CheckFloat64HoleMode::kAllowReturnHole: | 810 case CheckFloat64HoleMode::kAllowReturnHole: |
790 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; | 811 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; |
791 case CheckFloat64HoleMode::kNeverReturnHole: | 812 case CheckFloat64HoleMode::kNeverReturnHole: |
792 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; | 813 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; |
793 } | 814 } |
794 UNREACHABLE(); | 815 UNREACHABLE(); |
795 return nullptr; | 816 return nullptr; |
796 } | 817 } |
797 | 818 |
| 819 const Operator* SimplifiedOperatorBuilder::SpeculativeToNumber( |
| 820 NumberOperationHint hint) { |
| 821 switch (hint) { |
| 822 case NumberOperationHint::kSignedSmall: |
| 823 return &cache_.kSpeculativeToNumberSignedSmallOperator; |
| 824 case NumberOperationHint::kSigned32: |
| 825 return &cache_.kSpeculativeToNumberSigned32Operator; |
| 826 case NumberOperationHint::kNumber: |
| 827 return &cache_.kSpeculativeToNumberNumberOperator; |
| 828 case NumberOperationHint::kNumberOrOddball: |
| 829 return &cache_.kSpeculativeToNumberNumberOrOddballOperator; |
| 830 } |
| 831 UNREACHABLE(); |
| 832 return nullptr; |
| 833 } |
| 834 |
798 const Operator* SimplifiedOperatorBuilder::EnsureWritableFastElements() { | 835 const Operator* SimplifiedOperatorBuilder::EnsureWritableFastElements() { |
799 return &cache_.kEnsureWritableFastElements; | 836 return &cache_.kEnsureWritableFastElements; |
800 } | 837 } |
801 | 838 |
802 const Operator* SimplifiedOperatorBuilder::MaybeGrowFastElements( | 839 const Operator* SimplifiedOperatorBuilder::MaybeGrowFastElements( |
803 GrowFastElementsFlags flags) { | 840 GrowFastElementsFlags flags) { |
804 return new (zone()) Operator1<GrowFastElementsFlags>( // -- | 841 return new (zone()) Operator1<GrowFastElementsFlags>( // -- |
805 IrOpcode::kMaybeGrowFastElements, // opcode | 842 IrOpcode::kMaybeGrowFastElements, // opcode |
806 Operator::kNoThrow, // flags | 843 Operator::kNoThrow, // flags |
807 "MaybeGrowFastElements", // name | 844 "MaybeGrowFastElements", // name |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 984 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
948 #Name, value_input_count, 1, control_input_count, \ | 985 #Name, value_input_count, 1, control_input_count, \ |
949 output_count, 1, 0, access); \ | 986 output_count, 1, 0, access); \ |
950 } | 987 } |
951 ACCESS_OP_LIST(ACCESS) | 988 ACCESS_OP_LIST(ACCESS) |
952 #undef ACCESS | 989 #undef ACCESS |
953 | 990 |
954 } // namespace compiler | 991 } // namespace compiler |
955 } // namespace internal | 992 } // namespace internal |
956 } // namespace v8 | 993 } // namespace v8 |
OLD | NEW |