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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.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/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 CommonOperatorBuilder* common() { return &common_; } | 126 CommonOperatorBuilder* common() { return &common_; } |
127 | 127 |
128 private: | 128 private: |
129 CommonOperatorBuilder common_; | 129 CommonOperatorBuilder common_; |
130 }; | 130 }; |
131 | 131 |
132 | 132 |
133 const int kArguments[] = {1, 5, 6, 42, 100, 10000, 65000}; | 133 const int kArguments[] = {1, 5, 6, 42, 100, 10000, 65000}; |
134 | 134 |
135 | 135 |
136 const size_t kCases[] = {2, 3, 4, 100, 255}; | 136 const size_t kCases[] = {3, 4, 100, 255, 1024, 65000}; |
137 | 137 |
138 | 138 |
139 const float kFloatValues[] = {-std::numeric_limits<float>::infinity(), | 139 const float kFloatValues[] = {-std::numeric_limits<float>::infinity(), |
140 std::numeric_limits<float>::min(), | 140 std::numeric_limits<float>::min(), |
141 -1.0f, | 141 -1.0f, |
142 -0.0f, | 142 -0.0f, |
143 0.0f, | 143 0.0f, |
144 1.0f, | 144 1.0f, |
145 std::numeric_limits<float>::max(), | 145 std::numeric_limits<float>::max(), |
146 std::numeric_limits<float>::infinity(), | 146 std::numeric_limits<float>::infinity(), |
147 std::numeric_limits<float>::quiet_NaN(), | 147 std::numeric_limits<float>::quiet_NaN(), |
148 std::numeric_limits<float>::signaling_NaN()}; | 148 std::numeric_limits<float>::signaling_NaN()}; |
149 | 149 |
150 | 150 |
151 const double kDoubleValues[] = {-std::numeric_limits<double>::infinity(), | 151 const double kDoubleValues[] = {-std::numeric_limits<double>::infinity(), |
152 std::numeric_limits<double>::min(), | 152 std::numeric_limits<double>::min(), |
153 -1.0, | 153 -1.0, |
154 -0.0, | 154 -0.0, |
155 0.0, | 155 0.0, |
156 1.0, | 156 1.0, |
157 std::numeric_limits<double>::max(), | 157 std::numeric_limits<double>::max(), |
158 std::numeric_limits<double>::infinity(), | 158 std::numeric_limits<double>::infinity(), |
159 std::numeric_limits<double>::quiet_NaN(), | 159 std::numeric_limits<double>::quiet_NaN(), |
160 std::numeric_limits<double>::signaling_NaN()}; | 160 std::numeric_limits<double>::signaling_NaN()}; |
161 | 161 |
162 | 162 |
| 163 const int32_t kInt32Values[] = { |
| 164 std::numeric_limits<int32_t>::min(), -1914954528, -1698749618, -1578693386, |
| 165 -1577976073, -1573998034, -1529085059, -1499540537, -1299205097, |
| 166 -1090814845, -938186388, -806828902, -750927650, -520676892, -513661538, |
| 167 -453036354, -433622833, -282638793, -28375, -27788, -22770, -18806, -14173, |
| 168 -11956, -11200, -10212, -8160, -3751, -2758, -1522, -121, -120, -118, -117, |
| 169 -106, -84, -80, -74, -59, -52, -48, -39, -35, -17, -11, -10, -9, -7, -5, 0, |
| 170 9, 12, 17, 23, 29, 31, 33, 35, 40, 47, 55, 56, 62, 64, 67, 68, 69, 74, 79, |
| 171 84, 89, 90, 97, 104, 118, 124, 126, 127, 7278, 17787, 24136, 24202, 25570, |
| 172 26680, 30242, 32399, 420886487, 642166225, 821912648, 822577803, 851385718, |
| 173 1212241078, 1411419304, 1589626102, 1596437184, 1876245816, 1954730266, |
| 174 2008792749, 2045320228, std::numeric_limits<int32_t>::max()}; |
| 175 |
| 176 |
163 const BranchHint kHints[] = {BranchHint::kNone, BranchHint::kTrue, | 177 const BranchHint kHints[] = {BranchHint::kNone, BranchHint::kTrue, |
164 BranchHint::kFalse}; | 178 BranchHint::kFalse}; |
165 | 179 |
166 } // namespace | 180 } // namespace |
167 | 181 |
168 | 182 |
169 TEST_F(CommonOperatorTest, Branch) { | 183 TEST_F(CommonOperatorTest, Branch) { |
170 TRACED_FOREACH(BranchHint, hint, kHints) { | 184 TRACED_FOREACH(BranchHint, hint, kHints) { |
171 const Operator* const op = common()->Branch(hint); | 185 const Operator* const op = common()->Branch(hint); |
172 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); | 186 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); |
(...skipping 19 matching lines...) Expand all Loading... |
192 EXPECT_EQ(0, op->EffectInputCount()); | 206 EXPECT_EQ(0, op->EffectInputCount()); |
193 EXPECT_EQ(1, op->ControlInputCount()); | 207 EXPECT_EQ(1, op->ControlInputCount()); |
194 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 208 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
195 EXPECT_EQ(0, op->ValueOutputCount()); | 209 EXPECT_EQ(0, op->ValueOutputCount()); |
196 EXPECT_EQ(0, op->EffectOutputCount()); | 210 EXPECT_EQ(0, op->EffectOutputCount()); |
197 EXPECT_EQ(static_cast<int>(cases), op->ControlOutputCount()); | 211 EXPECT_EQ(static_cast<int>(cases), op->ControlOutputCount()); |
198 } | 212 } |
199 } | 213 } |
200 | 214 |
201 | 215 |
202 TEST_F(CommonOperatorTest, Case) { | 216 TEST_F(CommonOperatorTest, IfValue) { |
203 TRACED_FORRANGE(size_t, index, 0, 1024) { | 217 TRACED_FOREACH(int32_t, value, kInt32Values) { |
204 const Operator* const op = common()->Case(index); | 218 const Operator* const op = common()->IfValue(value); |
205 EXPECT_EQ(IrOpcode::kCase, op->opcode()); | 219 EXPECT_EQ(IrOpcode::kIfValue, op->opcode()); |
206 EXPECT_EQ(Operator::kKontrol, op->properties()); | 220 EXPECT_EQ(Operator::kKontrol, op->properties()); |
207 EXPECT_EQ(index, CaseIndexOf(op)); | 221 EXPECT_EQ(value, OpParameter<int32_t>(op)); |
208 EXPECT_EQ(0, op->ValueInputCount()); | 222 EXPECT_EQ(0, op->ValueInputCount()); |
209 EXPECT_EQ(0, op->EffectInputCount()); | 223 EXPECT_EQ(0, op->EffectInputCount()); |
210 EXPECT_EQ(1, op->ControlInputCount()); | 224 EXPECT_EQ(1, op->ControlInputCount()); |
211 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); | 225 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); |
212 EXPECT_EQ(0, op->ValueOutputCount()); | 226 EXPECT_EQ(0, op->ValueOutputCount()); |
213 EXPECT_EQ(0, op->EffectOutputCount()); | 227 EXPECT_EQ(0, op->EffectOutputCount()); |
214 EXPECT_EQ(1, op->ControlOutputCount()); | 228 EXPECT_EQ(1, op->ControlOutputCount()); |
215 } | 229 } |
216 } | 230 } |
217 | 231 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 337 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
324 EXPECT_EQ(0, op->ControlOutputCount()); | 338 EXPECT_EQ(0, op->ControlOutputCount()); |
325 EXPECT_EQ(0, op->EffectOutputCount()); | 339 EXPECT_EQ(0, op->EffectOutputCount()); |
326 EXPECT_EQ(1, op->ValueOutputCount()); | 340 EXPECT_EQ(1, op->ValueOutputCount()); |
327 } | 341 } |
328 } | 342 } |
329 | 343 |
330 } // namespace compiler | 344 } // namespace compiler |
331 } // namespace internal | 345 } // namespace internal |
332 } // namespace v8 | 346 } // namespace v8 |
OLD | NEW |