| 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 #ifndef V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 5 #ifndef V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| 6 #define V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 6 #define V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 kAllInstructions, | 32 kAllInstructions, |
| 33 kTargetInstructions, | 33 kTargetInstructions, |
| 34 kAllExceptNopInstructions | 34 kAllExceptNopInstructions |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class StreamBuilder final : public RawMachineAssembler { | 37 class StreamBuilder final : public RawMachineAssembler { |
| 38 public: | 38 public: |
| 39 StreamBuilder(InstructionSelectorTest* test, MachineType return_type) | 39 StreamBuilder(InstructionSelectorTest* test, MachineType return_type) |
| 40 : RawMachineAssembler( | 40 : RawMachineAssembler( |
| 41 test->isolate(), new (test->zone()) Graph(test->zone()), | 41 test->isolate(), new (test->zone()) Graph(test->zone()), |
| 42 MakeMachineSignature(test->zone(), return_type), kMachPtr, | 42 MakeCallDescriptor(test->zone(), return_type), kMachPtr, |
| 43 MachineOperatorBuilder::kAllOptionalOps), | 43 MachineOperatorBuilder::kAllOptionalOps), |
| 44 test_(test) {} | 44 test_(test) {} |
| 45 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, | 45 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 46 MachineType parameter0_type) | 46 MachineType parameter0_type) |
| 47 : RawMachineAssembler( | 47 : RawMachineAssembler( |
| 48 test->isolate(), new (test->zone()) Graph(test->zone()), | 48 test->isolate(), new (test->zone()) Graph(test->zone()), |
| 49 MakeMachineSignature(test->zone(), return_type, parameter0_type), | 49 MakeCallDescriptor(test->zone(), return_type, parameter0_type), |
| 50 kMachPtr, MachineOperatorBuilder::kAllOptionalOps), | 50 kMachPtr, MachineOperatorBuilder::kAllOptionalOps), |
| 51 test_(test) {} | 51 test_(test) {} |
| 52 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, | 52 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 53 MachineType parameter0_type, MachineType parameter1_type) | 53 MachineType parameter0_type, MachineType parameter1_type) |
| 54 : RawMachineAssembler( | 54 : RawMachineAssembler( |
| 55 test->isolate(), new (test->zone()) Graph(test->zone()), | 55 test->isolate(), new (test->zone()) Graph(test->zone()), |
| 56 MakeMachineSignature(test->zone(), return_type, parameter0_type, | 56 MakeCallDescriptor(test->zone(), return_type, parameter0_type, |
| 57 parameter1_type), | 57 parameter1_type), |
| 58 kMachPtr, MachineOperatorBuilder::kAllOptionalOps), | 58 kMachPtr, MachineOperatorBuilder::kAllOptionalOps), |
| 59 test_(test) {} | 59 test_(test) {} |
| 60 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, | 60 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 61 MachineType parameter0_type, MachineType parameter1_type, | 61 MachineType parameter0_type, MachineType parameter1_type, |
| 62 MachineType parameter2_type) | 62 MachineType parameter2_type) |
| 63 : RawMachineAssembler( | 63 : RawMachineAssembler( |
| 64 test->isolate(), new (test->zone()) Graph(test->zone()), | 64 test->isolate(), new (test->zone()) Graph(test->zone()), |
| 65 MakeMachineSignature(test->zone(), return_type, parameter0_type, | 65 MakeCallDescriptor(test->zone(), return_type, parameter0_type, |
| 66 parameter1_type, parameter2_type), | 66 parameter1_type, parameter2_type), |
| 67 kMachPtr, MachineOperatorBuilder::kAllOptionalOps), | 67 kMachPtr, MachineOperatorBuilder::kAllOptionalOps), |
| 68 test_(test) {} | 68 test_(test) {} |
| 69 | 69 |
| 70 Stream Build(CpuFeature feature) { | 70 Stream Build(CpuFeature feature) { |
| 71 return Build(InstructionSelector::Features(feature)); | 71 return Build(InstructionSelector::Features(feature)); |
| 72 } | 72 } |
| 73 Stream Build(CpuFeature feature1, CpuFeature feature2) { | 73 Stream Build(CpuFeature feature1, CpuFeature feature2) { |
| 74 return Build(InstructionSelector::Features(feature1, feature2)); | 74 return Build(InstructionSelector::Features(feature1, feature2)); |
| 75 } | 75 } |
| 76 Stream Build(StreamBuilderMode mode = kTargetInstructions) { | 76 Stream Build(StreamBuilderMode mode = kTargetInstructions) { |
| 77 return Build(InstructionSelector::Features(), mode); | 77 return Build(InstructionSelector::Features(), mode); |
| 78 } | 78 } |
| 79 Stream Build(InstructionSelector::Features features, | 79 Stream Build(InstructionSelector::Features features, |
| 80 StreamBuilderMode mode = kTargetInstructions, | 80 StreamBuilderMode mode = kTargetInstructions, |
| 81 InstructionSelector::SourcePositionMode source_position_mode = | 81 InstructionSelector::SourcePositionMode source_position_mode = |
| 82 InstructionSelector::kAllSourcePositions); | 82 InstructionSelector::kAllSourcePositions); |
| 83 | 83 |
| 84 const FrameStateFunctionInfo* GetFrameStateFunctionInfo(int parameter_count, | 84 const FrameStateFunctionInfo* GetFrameStateFunctionInfo(int parameter_count, |
| 85 int local_count); | 85 int local_count); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 MachineSignature* MakeMachineSignature(Zone* zone, | 88 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type) { |
| 89 MachineType return_type) { | |
| 90 MachineSignature::Builder builder(zone, 1, 0); | 89 MachineSignature::Builder builder(zone, 1, 0); |
| 91 builder.AddReturn(return_type); | 90 builder.AddReturn(return_type); |
| 92 return builder.Build(); | 91 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); |
| 93 } | 92 } |
| 94 | 93 |
| 95 MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, | 94 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, |
| 96 MachineType parameter0_type) { | 95 MachineType parameter0_type) { |
| 97 MachineSignature::Builder builder(zone, 1, 1); | 96 MachineSignature::Builder builder(zone, 1, 1); |
| 98 builder.AddReturn(return_type); | 97 builder.AddReturn(return_type); |
| 99 builder.AddParam(parameter0_type); | 98 builder.AddParam(parameter0_type); |
| 100 return builder.Build(); | 99 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); |
| 101 } | 100 } |
| 102 | 101 |
| 103 MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, | 102 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, |
| 104 MachineType parameter0_type, | 103 MachineType parameter0_type, |
| 105 MachineType parameter1_type) { | 104 MachineType parameter1_type) { |
| 106 MachineSignature::Builder builder(zone, 1, 2); | 105 MachineSignature::Builder builder(zone, 1, 2); |
| 107 builder.AddReturn(return_type); | 106 builder.AddReturn(return_type); |
| 108 builder.AddParam(parameter0_type); | 107 builder.AddParam(parameter0_type); |
| 109 builder.AddParam(parameter1_type); | 108 builder.AddParam(parameter1_type); |
| 110 return builder.Build(); | 109 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); |
| 111 } | 110 } |
| 112 | 111 |
| 113 MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, | 112 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, |
| 114 MachineType parameter0_type, | 113 MachineType parameter0_type, |
| 115 MachineType parameter1_type, | 114 MachineType parameter1_type, |
| 116 MachineType parameter2_type) { | 115 MachineType parameter2_type) { |
| 117 MachineSignature::Builder builder(zone, 1, 3); | 116 MachineSignature::Builder builder(zone, 1, 3); |
| 118 builder.AddReturn(return_type); | 117 builder.AddReturn(return_type); |
| 119 builder.AddParam(parameter0_type); | 118 builder.AddParam(parameter0_type); |
| 120 builder.AddParam(parameter1_type); | 119 builder.AddParam(parameter1_type); |
| 121 builder.AddParam(parameter2_type); | 120 builder.AddParam(parameter2_type); |
| 122 return builder.Build(); | 121 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); |
| 123 } | 122 } |
| 124 | 123 |
| 125 private: | 124 private: |
| 126 InstructionSelectorTest* test_; | 125 InstructionSelectorTest* test_; |
| 127 }; | 126 }; |
| 128 | 127 |
| 129 class Stream final { | 128 class Stream final { |
| 130 public: | 129 public: |
| 131 size_t size() const { return instructions_.size(); } | 130 size_t size() const { return instructions_.size(); } |
| 132 const Instruction* operator[](size_t index) const { | 131 const Instruction* operator[](size_t index) const { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 template <typename T> | 249 template <typename T> |
| 251 class InstructionSelectorTestWithParam | 250 class InstructionSelectorTestWithParam |
| 252 : public InstructionSelectorTest, | 251 : public InstructionSelectorTest, |
| 253 public ::testing::WithParamInterface<T> {}; | 252 public ::testing::WithParamInterface<T> {}; |
| 254 | 253 |
| 255 } // namespace compiler | 254 } // namespace compiler |
| 256 } // namespace internal | 255 } // namespace internal |
| 257 } // namespace v8 | 256 } // namespace v8 |
| 258 | 257 |
| 259 #endif // V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 258 #endif // V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| OLD | NEW |