| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 bool kBooleans[] = {false, true}; |
| 221 TRACED_FOREACH(bool, caught, kBooleans) { |
| 222 const Operator* const op = common()->IfException(caught); |
| 223 EXPECT_EQ(IrOpcode::kIfException, op->opcode()); |
| 224 EXPECT_EQ(Operator::kKontrol, op->properties()); |
| 225 EXPECT_EQ(0, op->ValueInputCount()); |
| 226 EXPECT_EQ(0, op->EffectInputCount()); |
| 227 EXPECT_EQ(1, op->ControlInputCount()); |
| 228 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); |
| 229 EXPECT_EQ(1, op->ValueOutputCount()); |
| 230 EXPECT_EQ(0, op->EffectOutputCount()); |
| 231 EXPECT_EQ(1, op->ControlOutputCount()); |
| 232 } |
| 233 } |
| 234 |
| 235 |
| 220 TEST_F(CommonOperatorTest, Switch) { | 236 TEST_F(CommonOperatorTest, Switch) { |
| 221 TRACED_FOREACH(size_t, cases, kCases) { | 237 TRACED_FOREACH(size_t, cases, kCases) { |
| 222 const Operator* const op = common()->Switch(cases); | 238 const Operator* const op = common()->Switch(cases); |
| 223 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); | 239 EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); |
| 224 EXPECT_EQ(Operator::kKontrol, op->properties()); | 240 EXPECT_EQ(Operator::kKontrol, op->properties()); |
| 225 EXPECT_EQ(1, op->ValueInputCount()); | 241 EXPECT_EQ(1, op->ValueInputCount()); |
| 226 EXPECT_EQ(0, op->EffectInputCount()); | 242 EXPECT_EQ(0, op->EffectInputCount()); |
| 227 EXPECT_EQ(1, op->ControlInputCount()); | 243 EXPECT_EQ(1, op->ControlInputCount()); |
| 228 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 244 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
| 229 EXPECT_EQ(0, op->ValueOutputCount()); | 245 EXPECT_EQ(0, op->ValueOutputCount()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 373 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
| 358 EXPECT_EQ(0, op->ControlOutputCount()); | 374 EXPECT_EQ(0, op->ControlOutputCount()); |
| 359 EXPECT_EQ(0, op->EffectOutputCount()); | 375 EXPECT_EQ(0, op->EffectOutputCount()); |
| 360 EXPECT_EQ(1, op->ValueOutputCount()); | 376 EXPECT_EQ(1, op->ValueOutputCount()); |
| 361 } | 377 } |
| 362 } | 378 } |
| 363 | 379 |
| 364 } // namespace compiler | 380 } // namespace compiler |
| 365 } // namespace internal | 381 } // namespace internal |
| 366 } // namespace v8 | 382 } // namespace v8 |
| OLD | NEW |