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 20 matching lines...) Expand all Loading... |
31 int value_output_count; | 31 int value_output_count; |
32 int effect_output_count; | 32 int effect_output_count; |
33 int control_output_count; | 33 int control_output_count; |
34 }; | 34 }; |
35 | 35 |
36 | 36 |
37 std::ostream& operator<<(std::ostream& os, const SharedOperator& fop) { | 37 std::ostream& operator<<(std::ostream& os, const SharedOperator& fop) { |
38 return os << IrOpcode::Mnemonic(fop.opcode); | 38 return os << IrOpcode::Mnemonic(fop.opcode); |
39 } | 39 } |
40 | 40 |
41 | |
42 const SharedOperator kSharedOperators[] = { | 41 const SharedOperator kSharedOperators[] = { |
43 #define SHARED(Name, properties, value_input_count, effect_input_count, \ | 42 #define SHARED(Name, properties, value_input_count, effect_input_count, \ |
44 control_input_count, value_output_count, effect_output_count, \ | 43 control_input_count, value_output_count, effect_output_count, \ |
45 control_output_count) \ | 44 control_output_count) \ |
46 { \ | 45 { \ |
47 &CommonOperatorBuilder::Name, IrOpcode::k##Name, properties, \ | 46 &CommonOperatorBuilder::Name, IrOpcode::k##Name, properties, \ |
48 value_input_count, effect_input_count, control_input_count, \ | 47 value_input_count, effect_input_count, control_input_count, \ |
49 value_output_count, effect_output_count, control_output_count \ | 48 value_output_count, effect_output_count, control_output_count \ |
50 } | 49 } |
51 SHARED(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1), | 50 SHARED(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1), |
52 SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1), | 51 SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1), |
53 SHARED(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1), | 52 SHARED(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1), |
54 SHARED(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1), | 53 SHARED(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1), |
| 54 SHARED(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1), |
55 SHARED(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1), | 55 SHARED(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1), |
56 SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) | 56 SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) |
57 #undef SHARED | 57 #undef SHARED |
58 }; | 58 }; |
59 | 59 |
60 | 60 |
61 class CommonSharedOperatorTest | 61 class CommonSharedOperatorTest |
62 : public TestWithZone, | 62 : public TestWithZone, |
63 public ::testing::WithParamInterface<SharedOperator> {}; | 63 public ::testing::WithParamInterface<SharedOperator> {}; |
64 | 64 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 EXPECT_EQ(0, op->EffectInputCount()); | 213 EXPECT_EQ(0, op->EffectInputCount()); |
214 EXPECT_EQ(1, op->ControlInputCount()); | 214 EXPECT_EQ(1, op->ControlInputCount()); |
215 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 215 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
216 EXPECT_EQ(0, op->ValueOutputCount()); | 216 EXPECT_EQ(0, op->ValueOutputCount()); |
217 EXPECT_EQ(0, op->EffectOutputCount()); | 217 EXPECT_EQ(0, op->EffectOutputCount()); |
218 EXPECT_EQ(2, op->ControlOutputCount()); | 218 EXPECT_EQ(2, op->ControlOutputCount()); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 | 222 |
223 TEST_F(CommonOperatorTest, IfException) { | |
224 static const IfExceptionHint kIfExceptionHints[] = { | |
225 IfExceptionHint::kLocallyCaught, IfExceptionHint::kLocallyUncaught}; | |
226 TRACED_FOREACH(IfExceptionHint, hint, kIfExceptionHints) { | |
227 const Operator* const op = common()->IfException(hint); | |
228 EXPECT_EQ(IrOpcode::kIfException, op->opcode()); | |
229 EXPECT_EQ(Operator::kKontrol, op->properties()); | |
230 EXPECT_EQ(0, op->ValueInputCount()); | |
231 EXPECT_EQ(1, op->EffectInputCount()); | |
232 EXPECT_EQ(1, op->ControlInputCount()); | |
233 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | |
234 EXPECT_EQ(1, op->ValueOutputCount()); | |
235 EXPECT_EQ(1, op->EffectOutputCount()); | |
236 EXPECT_EQ(1, op->ControlOutputCount()); | |
237 } | |
238 } | |
239 | |
240 | |
241 TEST_F(CommonOperatorTest, Switch) { | 223 TEST_F(CommonOperatorTest, Switch) { |
242 TRACED_FOREACH(size_t, cases, kCases) { | 224 TRACED_FOREACH(size_t, cases, kCases) { |
243 const Operator* const op = common()->Switch(cases); | 225 const Operator* const op = common()->Switch(cases); |
244 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); | 226 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); |
245 EXPECT_EQ(Operator::kKontrol, op->properties()); | 227 EXPECT_EQ(Operator::kKontrol, op->properties()); |
246 EXPECT_EQ(1, op->ValueInputCount()); | 228 EXPECT_EQ(1, op->ValueInputCount()); |
247 EXPECT_EQ(0, op->EffectInputCount()); | 229 EXPECT_EQ(0, op->EffectInputCount()); |
248 EXPECT_EQ(1, op->ControlInputCount()); | 230 EXPECT_EQ(1, op->ControlInputCount()); |
249 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 231 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
250 EXPECT_EQ(0, op->ValueOutputCount()); | 232 EXPECT_EQ(0, op->ValueOutputCount()); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 383 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
402 EXPECT_EQ(0, op->ControlOutputCount()); | 384 EXPECT_EQ(0, op->ControlOutputCount()); |
403 EXPECT_EQ(0, op->EffectOutputCount()); | 385 EXPECT_EQ(0, op->EffectOutputCount()); |
404 EXPECT_EQ(1, op->ValueOutputCount()); | 386 EXPECT_EQ(1, op->ValueOutputCount()); |
405 } | 387 } |
406 } | 388 } |
407 | 389 |
408 } // namespace compiler | 390 } // namespace compiler |
409 } // namespace internal | 391 } // namespace internal |
410 } // namespace v8 | 392 } // namespace v8 |
OLD | NEW |