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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 control_output_count) \ | 45 control_output_count) \ |
46 { \ | 46 { \ |
47 &CommonOperatorBuilder::Name, IrOpcode::k##Name, properties, \ | 47 &CommonOperatorBuilder::Name, IrOpcode::k##Name, properties, \ |
48 value_input_count, effect_input_count, control_input_count, \ | 48 value_input_count, effect_input_count, control_input_count, \ |
49 value_output_count, effect_output_count, control_output_count \ | 49 value_output_count, effect_output_count, control_output_count \ |
50 } | 50 } |
51 SHARED(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1), | 51 SHARED(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1), |
52 SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1), | 52 SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1), |
53 SHARED(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1), | 53 SHARED(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1), |
54 SHARED(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1), | 54 SHARED(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1), |
55 SHARED(IfException, Operator::kKontrol, 0, 0, 1, 1, 0, 1), | |
56 SHARED(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1), | 55 SHARED(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1), |
57 SHARED(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1), | 56 SHARED(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1), |
58 SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) | 57 SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) |
59 #undef SHARED | 58 #undef SHARED |
60 }; | 59 }; |
61 | 60 |
62 | 61 |
63 class CommonSharedOperatorTest | 62 class CommonSharedOperatorTest |
64 : public TestWithZone, | 63 : public TestWithZone, |
65 public ::testing::WithParamInterface<SharedOperator> {}; | 64 public ::testing::WithParamInterface<SharedOperator> {}; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 -453036354, -433622833, -282638793, -28375, -27788, -22770, -18806, -14173, | 170 -453036354, -433622833, -282638793, -28375, -27788, -22770, -18806, -14173, |
172 -11956, -11200, -10212, -8160, -3751, -2758, -1522, -121, -120, -118, -117, | 171 -11956, -11200, -10212, -8160, -3751, -2758, -1522, -121, -120, -118, -117, |
173 -106, -84, -80, -74, -59, -52, -48, -39, -35, -17, -11, -10, -9, -7, -5, 0, | 172 -106, -84, -80, -74, -59, -52, -48, -39, -35, -17, -11, -10, -9, -7, -5, 0, |
174 9, 12, 17, 23, 29, 31, 33, 35, 40, 47, 55, 56, 62, 64, 67, 68, 69, 74, 79, | 173 9, 12, 17, 23, 29, 31, 33, 35, 40, 47, 55, 56, 62, 64, 67, 68, 69, 74, 79, |
175 84, 89, 90, 97, 104, 118, 124, 126, 127, 7278, 17787, 24136, 24202, 25570, | 174 84, 89, 90, 97, 104, 118, 124, 126, 127, 7278, 17787, 24136, 24202, 25570, |
176 26680, 30242, 32399, 420886487, 642166225, 821912648, 822577803, 851385718, | 175 26680, 30242, 32399, 420886487, 642166225, 821912648, 822577803, 851385718, |
177 1212241078, 1411419304, 1589626102, 1596437184, 1876245816, 1954730266, | 176 1212241078, 1411419304, 1589626102, 1596437184, 1876245816, 1954730266, |
178 2008792749, 2045320228, std::numeric_limits<int32_t>::max()}; | 177 2008792749, 2045320228, std::numeric_limits<int32_t>::max()}; |
179 | 178 |
180 | 179 |
181 const BranchHint kHints[] = {BranchHint::kNone, BranchHint::kTrue, | 180 const BranchHint kBranchHints[] = {BranchHint::kNone, BranchHint::kTrue, |
182 BranchHint::kFalse}; | 181 BranchHint::kFalse}; |
183 | 182 |
184 } // namespace | 183 } // namespace |
185 | 184 |
186 | 185 |
187 TEST_F(CommonOperatorTest, End) { | 186 TEST_F(CommonOperatorTest, End) { |
188 TRACED_FOREACH(size_t, input_count, kInputCounts) { | 187 TRACED_FOREACH(size_t, input_count, kInputCounts) { |
189 const Operator* const op = common()->End(input_count); | 188 const Operator* const op = common()->End(input_count); |
190 EXPECT_EQ(IrOpcode::kEnd, op->opcode()); | 189 EXPECT_EQ(IrOpcode::kEnd, op->opcode()); |
191 EXPECT_EQ(Operator::kKontrol, op->properties()); | 190 EXPECT_EQ(Operator::kKontrol, op->properties()); |
192 EXPECT_EQ(0, op->ValueInputCount()); | 191 EXPECT_EQ(0, op->ValueInputCount()); |
193 EXPECT_EQ(0, op->EffectInputCount()); | 192 EXPECT_EQ(0, op->EffectInputCount()); |
194 EXPECT_EQ(input_count, op->ControlInputCount()); | 193 EXPECT_EQ(input_count, op->ControlInputCount()); |
195 EXPECT_EQ(input_count, OperatorProperties::GetTotalInputCount(op)); | 194 EXPECT_EQ(input_count, OperatorProperties::GetTotalInputCount(op)); |
196 EXPECT_EQ(0, op->ValueOutputCount()); | 195 EXPECT_EQ(0, op->ValueOutputCount()); |
197 EXPECT_EQ(0, op->EffectOutputCount()); | 196 EXPECT_EQ(0, op->EffectOutputCount()); |
198 EXPECT_EQ(0, op->ControlOutputCount()); | 197 EXPECT_EQ(0, op->ControlOutputCount()); |
199 } | 198 } |
200 } | 199 } |
201 | 200 |
202 | 201 |
203 TEST_F(CommonOperatorTest, Branch) { | 202 TEST_F(CommonOperatorTest, Branch) { |
204 TRACED_FOREACH(BranchHint, hint, kHints) { | 203 TRACED_FOREACH(BranchHint, hint, kBranchHints) { |
205 const Operator* const op = common()->Branch(hint); | 204 const Operator* const op = common()->Branch(hint); |
206 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); | 205 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); |
207 EXPECT_EQ(Operator::kKontrol, op->properties()); | 206 EXPECT_EQ(Operator::kKontrol, op->properties()); |
208 EXPECT_EQ(hint, BranchHintOf(op)); | 207 EXPECT_EQ(hint, BranchHintOf(op)); |
209 EXPECT_EQ(1, op->ValueInputCount()); | 208 EXPECT_EQ(1, op->ValueInputCount()); |
210 EXPECT_EQ(0, op->EffectInputCount()); | 209 EXPECT_EQ(0, op->EffectInputCount()); |
211 EXPECT_EQ(1, op->ControlInputCount()); | 210 EXPECT_EQ(1, op->ControlInputCount()); |
212 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 211 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
213 EXPECT_EQ(0, op->ValueOutputCount()); | 212 EXPECT_EQ(0, op->ValueOutputCount()); |
214 EXPECT_EQ(0, op->EffectOutputCount()); | 213 EXPECT_EQ(0, op->EffectOutputCount()); |
215 EXPECT_EQ(2, op->ControlOutputCount()); | 214 EXPECT_EQ(2, op->ControlOutputCount()); |
216 } | 215 } |
217 } | 216 } |
218 | 217 |
219 | 218 |
| 219 TEST_F(CommonOperatorTest, IfException) { |
| 220 static const IfExceptionHint kIfExceptionHints[] = { |
| 221 IfExceptionHint::kLocallyCaught, IfExceptionHint::kLocallyUncaught}; |
| 222 TRACED_FOREACH(IfExceptionHint, hint, kIfExceptionHints) { |
| 223 const Operator* const op = common()->IfException(hint); |
| 224 EXPECT_EQ(IrOpcode::kIfException, op->opcode()); |
| 225 EXPECT_EQ(Operator::kKontrol, op->properties()); |
| 226 EXPECT_EQ(0, op->ValueInputCount()); |
| 227 EXPECT_EQ(0, op->EffectInputCount()); |
| 228 EXPECT_EQ(1, op->ControlInputCount()); |
| 229 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); |
| 230 EXPECT_EQ(1, op->ValueOutputCount()); |
| 231 EXPECT_EQ(0, op->EffectOutputCount()); |
| 232 EXPECT_EQ(1, op->ControlOutputCount()); |
| 233 } |
| 234 } |
| 235 |
| 236 |
220 TEST_F(CommonOperatorTest, Switch) { | 237 TEST_F(CommonOperatorTest, Switch) { |
221 TRACED_FOREACH(size_t, cases, kCases) { | 238 TRACED_FOREACH(size_t, cases, kCases) { |
222 const Operator* const op = common()->Switch(cases); | 239 const Operator* const op = common()->Switch(cases); |
223 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); | 240 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); |
224 EXPECT_EQ(Operator::kKontrol, op->properties()); | 241 EXPECT_EQ(Operator::kKontrol, op->properties()); |
225 EXPECT_EQ(1, op->ValueInputCount()); | 242 EXPECT_EQ(1, op->ValueInputCount()); |
226 EXPECT_EQ(0, op->EffectInputCount()); | 243 EXPECT_EQ(0, op->EffectInputCount()); |
227 EXPECT_EQ(1, op->ControlInputCount()); | 244 EXPECT_EQ(1, op->ControlInputCount()); |
228 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 245 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
229 EXPECT_EQ(0, op->ValueOutputCount()); | 246 EXPECT_EQ(0, op->ValueOutputCount()); |
(...skipping 19 matching lines...) Expand all Loading... |
249 } | 266 } |
250 } | 267 } |
251 | 268 |
252 | 269 |
253 TEST_F(CommonOperatorTest, Select) { | 270 TEST_F(CommonOperatorTest, Select) { |
254 static const MachineType kTypes[] = { | 271 static const MachineType kTypes[] = { |
255 kMachInt8, kMachUint8, kMachInt16, kMachUint16, | 272 kMachInt8, kMachUint8, kMachInt16, kMachUint16, |
256 kMachInt32, kMachUint32, kMachInt64, kMachUint64, | 273 kMachInt32, kMachUint32, kMachInt64, kMachUint64, |
257 kMachFloat32, kMachFloat64, kMachAnyTagged}; | 274 kMachFloat32, kMachFloat64, kMachAnyTagged}; |
258 TRACED_FOREACH(MachineType, type, kTypes) { | 275 TRACED_FOREACH(MachineType, type, kTypes) { |
259 TRACED_FOREACH(BranchHint, hint, kHints) { | 276 TRACED_FOREACH(BranchHint, hint, kBranchHints) { |
260 const Operator* const op = common()->Select(type, hint); | 277 const Operator* const op = common()->Select(type, hint); |
261 EXPECT_EQ(IrOpcode::kSelect, op->opcode()); | 278 EXPECT_EQ(IrOpcode::kSelect, op->opcode()); |
262 EXPECT_EQ(Operator::kPure, op->properties()); | 279 EXPECT_EQ(Operator::kPure, op->properties()); |
263 EXPECT_EQ(type, SelectParametersOf(op).type()); | 280 EXPECT_EQ(type, SelectParametersOf(op).type()); |
264 EXPECT_EQ(hint, SelectParametersOf(op).hint()); | 281 EXPECT_EQ(hint, SelectParametersOf(op).hint()); |
265 EXPECT_EQ(3, op->ValueInputCount()); | 282 EXPECT_EQ(3, op->ValueInputCount()); |
266 EXPECT_EQ(0, op->EffectInputCount()); | 283 EXPECT_EQ(0, op->EffectInputCount()); |
267 EXPECT_EQ(0, op->ControlInputCount()); | 284 EXPECT_EQ(0, op->ControlInputCount()); |
268 EXPECT_EQ(3, OperatorProperties::GetTotalInputCount(op)); | 285 EXPECT_EQ(3, OperatorProperties::GetTotalInputCount(op)); |
269 EXPECT_EQ(1, op->ValueOutputCount()); | 286 EXPECT_EQ(1, op->ValueOutputCount()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 374 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
358 EXPECT_EQ(0, op->ControlOutputCount()); | 375 EXPECT_EQ(0, op->ControlOutputCount()); |
359 EXPECT_EQ(0, op->EffectOutputCount()); | 376 EXPECT_EQ(0, op->EffectOutputCount()); |
360 EXPECT_EQ(1, op->ValueOutputCount()); | 377 EXPECT_EQ(1, op->ValueOutputCount()); |
361 } | 378 } |
362 } | 379 } |
363 | 380 |
364 } // namespace compiler | 381 } // namespace compiler |
365 } // namespace internal | 382 } // namespace internal |
366 } // namespace v8 | 383 } // namespace v8 |
OLD | NEW |