| 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 <limits> |
| 8 |
| 7 #include "src/compiler/operator-properties-inl.h" | 9 #include "src/compiler/operator-properties-inl.h" |
| 8 #include "src/test/test-utils.h" | 10 #include "src/test/test-utils.h" |
| 9 | 11 |
| 10 namespace v8 { | 12 namespace v8 { |
| 11 namespace internal { | 13 namespace internal { |
| 12 namespace compiler { | 14 namespace compiler { |
| 13 | 15 |
| 14 | 16 |
| 15 // ----------------------------------------------------------------------------- | 17 // ----------------------------------------------------------------------------- |
| 16 // Shared operators. | 18 // Shared operators. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 127 |
| 126 CommonOperatorBuilder* common() { return &common_; } | 128 CommonOperatorBuilder* common() { return &common_; } |
| 127 | 129 |
| 128 private: | 130 private: |
| 129 CommonOperatorBuilder common_; | 131 CommonOperatorBuilder common_; |
| 130 }; | 132 }; |
| 131 | 133 |
| 132 | 134 |
| 133 const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt}; | 135 const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt}; |
| 134 | 136 |
| 137 const float kFloat32Values[] = { |
| 138 std::numeric_limits<float>::min(), -1.0f, -0.0f, 0.0f, 1.0f, |
| 139 std::numeric_limits<float>::max()}; |
| 140 |
| 135 } // namespace | 141 } // namespace |
| 136 | 142 |
| 137 | 143 |
| 144 TEST_F(CommonOperatorTest, Float32Constant) { |
| 145 TRACED_FOREACH(float, value, kFloat32Values) { |
| 146 const Operator* op = common()->Float32Constant(value); |
| 147 EXPECT_FLOAT_EQ(value, OpParameter<float>(op)); |
| 148 EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op)); |
| 149 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op)); |
| 150 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); |
| 151 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); |
| 152 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); |
| 153 } |
| 154 } |
| 155 |
| 156 |
| 138 TEST_F(CommonOperatorTest, ValueEffect) { | 157 TEST_F(CommonOperatorTest, ValueEffect) { |
| 139 TRACED_FOREACH(int, arguments, kArguments) { | 158 TRACED_FOREACH(int, arguments, kArguments) { |
| 140 const Operator* op = common()->ValueEffect(arguments); | 159 const Operator* op = common()->ValueEffect(arguments); |
| 141 EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op)); | 160 EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op)); |
| 142 EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op)); | 161 EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op)); |
| 143 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | 162 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); |
| 144 EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op)); | 163 EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op)); |
| 145 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); | 164 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); |
| 146 } | 165 } |
| 147 } | 166 } |
| 148 | 167 |
| 149 | 168 |
| 150 TEST_F(CommonOperatorTest, Finish) { | 169 TEST_F(CommonOperatorTest, Finish) { |
| 151 TRACED_FOREACH(int, arguments, kArguments) { | 170 TRACED_FOREACH(int, arguments, kArguments) { |
| 152 const Operator* op = common()->Finish(arguments); | 171 const Operator* op = common()->Finish(arguments); |
| 153 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); | 172 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); |
| 154 EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op)); | 173 EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op)); |
| 155 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 174 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
| 156 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | 175 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); |
| 157 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); | 176 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); |
| 158 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); | 177 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); |
| 159 } | 178 } |
| 160 } | 179 } |
| 161 | 180 |
| 162 } // namespace compiler | 181 } // namespace compiler |
| 163 } // namespace internal | 182 } // namespace internal |
| 164 } // namespace v8 | 183 } // namespace v8 |
| OLD | NEW |