| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 | 6 |
| 7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
| 8 #include "src/base/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return os << "Caught"; | 66 return os << "Caught"; |
| 67 case IfExceptionHint::kLocallyUncaught: | 67 case IfExceptionHint::kLocallyUncaught: |
| 68 return os << "Uncaught"; | 68 return os << "Uncaught"; |
| 69 } | 69 } |
| 70 UNREACHABLE(); | 70 UNREACHABLE(); |
| 71 return os; | 71 return os; |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { | 75 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { |
| 76 return lhs.type() == rhs.type() && lhs.hint() == rhs.hint(); | 76 return lhs.representation() == rhs.representation() && |
| 77 lhs.hint() == rhs.hint(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 | 80 |
| 80 bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) { | 81 bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) { |
| 81 return !(lhs == rhs); | 82 return !(lhs == rhs); |
| 82 } | 83 } |
| 83 | 84 |
| 84 | 85 |
| 85 size_t hash_value(SelectParameters const& p) { | 86 size_t hash_value(SelectParameters const& p) { |
| 86 return base::hash_combine(p.type(), p.hint()); | 87 return base::hash_combine(p.representation(), p.hint()); |
| 87 } | 88 } |
| 88 | 89 |
| 89 | 90 |
| 90 std::ostream& operator<<(std::ostream& os, SelectParameters const& p) { | 91 std::ostream& operator<<(std::ostream& os, SelectParameters const& p) { |
| 91 return os << p.type() << "|" << p.hint(); | 92 return os << p.representation() << "|" << p.hint(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 | 95 |
| 95 SelectParameters const& SelectParametersOf(const Operator* const op) { | 96 SelectParameters const& SelectParametersOf(const Operator* const op) { |
| 96 DCHECK_EQ(IrOpcode::kSelect, op->opcode()); | 97 DCHECK_EQ(IrOpcode::kSelect, op->opcode()); |
| 97 return OpParameter<SelectParameters>(op); | 98 return OpParameter<SelectParameters>(op); |
| 98 } | 99 } |
| 99 | 100 |
| 100 | 101 |
| 101 size_t ProjectionIndexOf(const Operator* const op) { | 102 size_t ProjectionIndexOf(const Operator* const op) { |
| 102 DCHECK_EQ(IrOpcode::kProjection, op->opcode()); | 103 DCHECK_EQ(IrOpcode::kProjection, op->opcode()); |
| 103 return OpParameter<size_t>(op); | 104 return OpParameter<size_t>(op); |
| 104 } | 105 } |
| 105 | 106 |
| 106 | 107 |
| 108 MachineRepresentation PhiRepresentationOf(const Operator* const op) { |
| 109 DCHECK_EQ(IrOpcode::kPhi, op->opcode()); |
| 110 return OpParameter<MachineRepresentation>(op); |
| 111 } |
| 112 |
| 113 |
| 107 int ParameterIndexOf(const Operator* const op) { | 114 int ParameterIndexOf(const Operator* const op) { |
| 108 DCHECK_EQ(IrOpcode::kParameter, op->opcode()); | 115 DCHECK_EQ(IrOpcode::kParameter, op->opcode()); |
| 109 return OpParameter<ParameterInfo>(op).index(); | 116 return OpParameter<ParameterInfo>(op).index(); |
| 110 } | 117 } |
| 111 | 118 |
| 112 | 119 |
| 113 const ParameterInfo& ParameterInfoOf(const Operator* const op) { | 120 const ParameterInfo& ParameterInfoOf(const Operator* const op) { |
| 114 DCHECK_EQ(IrOpcode::kParameter, op->opcode()); | 121 DCHECK_EQ(IrOpcode::kParameter, op->opcode()); |
| 115 return OpParameter<ParameterInfo>(op); | 122 return OpParameter<ParameterInfo>(op); |
| 116 } | 123 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 V(0) \ | 203 V(0) \ |
| 197 V(1) \ | 204 V(1) \ |
| 198 V(2) \ | 205 V(2) \ |
| 199 V(3) \ | 206 V(3) \ |
| 200 V(4) \ | 207 V(4) \ |
| 201 V(5) \ | 208 V(5) \ |
| 202 V(6) | 209 V(6) |
| 203 | 210 |
| 204 | 211 |
| 205 #define CACHED_PHI_LIST(V) \ | 212 #define CACHED_PHI_LIST(V) \ |
| 206 V(kMachAnyTagged, 1) \ | 213 V(kTagged, 1) \ |
| 207 V(kMachAnyTagged, 2) \ | 214 V(kTagged, 2) \ |
| 208 V(kMachAnyTagged, 3) \ | 215 V(kTagged, 3) \ |
| 209 V(kMachAnyTagged, 4) \ | 216 V(kTagged, 4) \ |
| 210 V(kMachAnyTagged, 5) \ | 217 V(kTagged, 5) \ |
| 211 V(kMachAnyTagged, 6) \ | 218 V(kTagged, 6) \ |
| 212 V(kMachBool, 2) \ | 219 V(kBit, 2) \ |
| 213 V(kMachFloat64, 2) \ | 220 V(kFloat64, 2) \ |
| 214 V(kMachInt32, 2) | 221 V(kWord32, 2) |
| 215 | 222 |
| 216 | 223 |
| 217 #define CACHED_PROJECTION_LIST(V) \ | 224 #define CACHED_PROJECTION_LIST(V) \ |
| 218 V(0) \ | 225 V(0) \ |
| 219 V(1) | 226 V(1) |
| 220 | 227 |
| 221 | 228 |
| 222 #define CACHED_STATE_VALUES_LIST(V) \ | 229 #define CACHED_STATE_VALUES_LIST(V) \ |
| 223 V(0) \ | 230 V(0) \ |
| 224 V(1) \ | 231 V(1) \ |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 : Operator( // -- | 353 : Operator( // -- |
| 347 IrOpcode::kMerge, Operator::kKontrol, // opcode | 354 IrOpcode::kMerge, Operator::kKontrol, // opcode |
| 348 "Merge", // name | 355 "Merge", // name |
| 349 0, 0, kInputCount, 0, 0, 1) {} // counts | 356 0, 0, kInputCount, 0, 0, 1) {} // counts |
| 350 }; | 357 }; |
| 351 #define CACHED_MERGE(input_count) \ | 358 #define CACHED_MERGE(input_count) \ |
| 352 MergeOperator<input_count> kMerge##input_count##Operator; | 359 MergeOperator<input_count> kMerge##input_count##Operator; |
| 353 CACHED_MERGE_LIST(CACHED_MERGE) | 360 CACHED_MERGE_LIST(CACHED_MERGE) |
| 354 #undef CACHED_MERGE | 361 #undef CACHED_MERGE |
| 355 | 362 |
| 356 template <MachineType kType, int kInputCount> | 363 template <MachineRepresentation kRep, int kInputCount> |
| 357 struct PhiOperator final : public Operator1<MachineType> { | 364 struct PhiOperator final : public Operator1<MachineRepresentation> { |
| 358 PhiOperator() | 365 PhiOperator() |
| 359 : Operator1<MachineType>( //-- | 366 : Operator1<MachineRepresentation>( //-- |
| 360 IrOpcode::kPhi, Operator::kPure, // opcode | 367 IrOpcode::kPhi, Operator::kPure, // opcode |
| 361 "Phi", // name | 368 "Phi", // name |
| 362 kInputCount, 0, 1, 1, 0, 0, // counts | 369 kInputCount, 0, 1, 1, 0, 0, // counts |
| 363 kType) {} // parameter | 370 kRep) {} // parameter |
| 364 }; | 371 }; |
| 365 #define CACHED_PHI(type, input_count) \ | 372 #define CACHED_PHI(rep, input_count) \ |
| 366 PhiOperator<type, input_count> kPhi##type##input_count##Operator; | 373 PhiOperator<MachineRepresentation::rep, input_count> \ |
| 374 kPhi##rep##input_count##Operator; |
| 367 CACHED_PHI_LIST(CACHED_PHI) | 375 CACHED_PHI_LIST(CACHED_PHI) |
| 368 #undef CACHED_PHI | 376 #undef CACHED_PHI |
| 369 | 377 |
| 370 template <int kIndex> | 378 template <int kIndex> |
| 371 struct ParameterOperator final : public Operator1<ParameterInfo> { | 379 struct ParameterOperator final : public Operator1<ParameterInfo> { |
| 372 ParameterOperator() | 380 ParameterOperator() |
| 373 : Operator1<ParameterInfo>( // -- | 381 : Operator1<ParameterInfo>( // -- |
| 374 IrOpcode::kParameter, Operator::kPure, // opcode | 382 IrOpcode::kParameter, Operator::kPure, // opcode |
| 375 "Parameter", // name | 383 "Parameter", // name |
| 376 1, 0, 0, 1, 0, 0, // counts, | 384 1, 0, 0, 1, 0, 0, // counts, |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 const Operator* CommonOperatorBuilder::HeapConstant( | 662 const Operator* CommonOperatorBuilder::HeapConstant( |
| 655 const Handle<HeapObject>& value) { | 663 const Handle<HeapObject>& value) { |
| 656 return new (zone()) Operator1<Handle<HeapObject>>( // -- | 664 return new (zone()) Operator1<Handle<HeapObject>>( // -- |
| 657 IrOpcode::kHeapConstant, Operator::kPure, // opcode | 665 IrOpcode::kHeapConstant, Operator::kPure, // opcode |
| 658 "HeapConstant", // name | 666 "HeapConstant", // name |
| 659 0, 0, 0, 1, 0, 0, // counts | 667 0, 0, 0, 1, 0, 0, // counts |
| 660 value); // parameter | 668 value); // parameter |
| 661 } | 669 } |
| 662 | 670 |
| 663 | 671 |
| 664 const Operator* CommonOperatorBuilder::Select(MachineType type, | 672 const Operator* CommonOperatorBuilder::Select(MachineRepresentation rep, |
| 665 BranchHint hint) { | 673 BranchHint hint) { |
| 666 return new (zone()) Operator1<SelectParameters>( // -- | 674 return new (zone()) Operator1<SelectParameters>( // -- |
| 667 IrOpcode::kSelect, Operator::kPure, // opcode | 675 IrOpcode::kSelect, Operator::kPure, // opcode |
| 668 "Select", // name | 676 "Select", // name |
| 669 3, 0, 0, 1, 0, 0, // counts | 677 3, 0, 0, 1, 0, 0, // counts |
| 670 SelectParameters(type, hint)); // parameter | 678 SelectParameters(rep, hint)); // parameter |
| 671 } | 679 } |
| 672 | 680 |
| 673 | 681 |
| 674 const Operator* CommonOperatorBuilder::Phi(MachineType type, | 682 const Operator* CommonOperatorBuilder::Phi(MachineRepresentation rep, |
| 675 int value_input_count) { | 683 int value_input_count) { |
| 676 DCHECK(value_input_count > 0); // Disallow empty phis. | 684 DCHECK(value_input_count > 0); // Disallow empty phis. |
| 677 #define CACHED_PHI(kType, kValueInputCount) \ | 685 #define CACHED_PHI(kRep, kValueInputCount) \ |
| 678 if (kType == type && kValueInputCount == value_input_count) { \ | 686 if (MachineRepresentation::kRep == rep && \ |
| 679 return &cache_.kPhi##kType##kValueInputCount##Operator; \ | 687 kValueInputCount == value_input_count) { \ |
| 688 return &cache_.kPhi##kRep##kValueInputCount##Operator; \ |
| 680 } | 689 } |
| 681 CACHED_PHI_LIST(CACHED_PHI) | 690 CACHED_PHI_LIST(CACHED_PHI) |
| 682 #undef CACHED_PHI | 691 #undef CACHED_PHI |
| 683 // Uncached. | 692 // Uncached. |
| 684 return new (zone()) Operator1<MachineType>( // -- | 693 return new (zone()) Operator1<MachineRepresentation>( // -- |
| 685 IrOpcode::kPhi, Operator::kPure, // opcode | 694 IrOpcode::kPhi, Operator::kPure, // opcode |
| 686 "Phi", // name | 695 "Phi", // name |
| 687 value_input_count, 0, 1, 1, 0, 0, // counts | 696 value_input_count, 0, 1, 1, 0, 0, // counts |
| 688 type); // parameter | 697 rep); // parameter |
| 689 } | 698 } |
| 690 | 699 |
| 691 | 700 |
| 692 const Operator* CommonOperatorBuilder::EffectPhi(int effect_input_count) { | 701 const Operator* CommonOperatorBuilder::EffectPhi(int effect_input_count) { |
| 693 DCHECK(effect_input_count > 0); // Disallow empty effect phis. | 702 DCHECK(effect_input_count > 0); // Disallow empty effect phis. |
| 694 switch (effect_input_count) { | 703 switch (effect_input_count) { |
| 695 #define CACHED_EFFECT_PHI(input_count) \ | 704 #define CACHED_EFFECT_PHI(input_count) \ |
| 696 case input_count: \ | 705 case input_count: \ |
| 697 return &cache_.kEffectPhi##input_count##Operator; | 706 return &cache_.kEffectPhi##input_count##Operator; |
| 698 CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI) | 707 CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 Operator::kFoldable | Operator::kNoThrow, // flags | 834 Operator::kFoldable | Operator::kNoThrow, // flags |
| 826 "Projection", // name | 835 "Projection", // name |
| 827 1, 0, 0, 1, 0, 0, // counts | 836 1, 0, 0, 1, 0, 0, // counts |
| 828 index); // parameter | 837 index); // parameter |
| 829 } | 838 } |
| 830 | 839 |
| 831 | 840 |
| 832 const Operator* CommonOperatorBuilder::ResizeMergeOrPhi(const Operator* op, | 841 const Operator* CommonOperatorBuilder::ResizeMergeOrPhi(const Operator* op, |
| 833 int size) { | 842 int size) { |
| 834 if (op->opcode() == IrOpcode::kPhi) { | 843 if (op->opcode() == IrOpcode::kPhi) { |
| 835 return Phi(OpParameter<MachineType>(op), size); | 844 return Phi(PhiRepresentationOf(op), size); |
| 836 } else if (op->opcode() == IrOpcode::kEffectPhi) { | 845 } else if (op->opcode() == IrOpcode::kEffectPhi) { |
| 837 return EffectPhi(size); | 846 return EffectPhi(size); |
| 838 } else if (op->opcode() == IrOpcode::kMerge) { | 847 } else if (op->opcode() == IrOpcode::kMerge) { |
| 839 return Merge(size); | 848 return Merge(size); |
| 840 } else if (op->opcode() == IrOpcode::kLoop) { | 849 } else if (op->opcode() == IrOpcode::kLoop) { |
| 841 return Loop(size); | 850 return Loop(size); |
| 842 } else { | 851 } else { |
| 843 UNREACHABLE(); | 852 UNREACHABLE(); |
| 844 return nullptr; | 853 return nullptr; |
| 845 } | 854 } |
| 846 } | 855 } |
| 847 | 856 |
| 848 | 857 |
| 849 const FrameStateFunctionInfo* | 858 const FrameStateFunctionInfo* |
| 850 CommonOperatorBuilder::CreateFrameStateFunctionInfo( | 859 CommonOperatorBuilder::CreateFrameStateFunctionInfo( |
| 851 FrameStateType type, int parameter_count, int local_count, | 860 FrameStateType type, int parameter_count, int local_count, |
| 852 Handle<SharedFunctionInfo> shared_info, | 861 Handle<SharedFunctionInfo> shared_info, |
| 853 ContextCallingMode context_calling_mode) { | 862 ContextCallingMode context_calling_mode) { |
| 854 return new (zone()->New(sizeof(FrameStateFunctionInfo))) | 863 return new (zone()->New(sizeof(FrameStateFunctionInfo))) |
| 855 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info, | 864 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info, |
| 856 context_calling_mode); | 865 context_calling_mode); |
| 857 } | 866 } |
| 858 | 867 |
| 859 } // namespace compiler | 868 } // namespace compiler |
| 860 } // namespace internal | 869 } // namespace internal |
| 861 } // namespace v8 | 870 } // namespace v8 |
| OLD | NEW |