| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, 1, 1, 1), | 51 SHARED(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 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(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1), | 55 SHARED(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1), |
| 56 SHARED(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1), | |
| 57 SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) | 56 SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) |
| 58 #undef SHARED | 57 #undef SHARED |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 | 60 |
| 62 class CommonSharedOperatorTest | 61 class CommonSharedOperatorTest |
| 63 : public TestWithZone, | 62 : public TestWithZone, |
| 64 public ::testing::WithParamInterface<SharedOperator> {}; | 63 public ::testing::WithParamInterface<SharedOperator> {}; |
| 65 | 64 |
| 66 } // namespace | 65 } // namespace |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 EXPECT_EQ(input_count, static_cast<uint32_t>(op->ControlInputCount())); | 180 EXPECT_EQ(input_count, static_cast<uint32_t>(op->ControlInputCount())); |
| 182 EXPECT_EQ(input_count, static_cast<uint32_t>( | 181 EXPECT_EQ(input_count, static_cast<uint32_t>( |
| 183 OperatorProperties::GetTotalInputCount(op))); | 182 OperatorProperties::GetTotalInputCount(op))); |
| 184 EXPECT_EQ(0, op->ValueOutputCount()); | 183 EXPECT_EQ(0, op->ValueOutputCount()); |
| 185 EXPECT_EQ(0, op->EffectOutputCount()); | 184 EXPECT_EQ(0, op->EffectOutputCount()); |
| 186 EXPECT_EQ(0, op->ControlOutputCount()); | 185 EXPECT_EQ(0, op->ControlOutputCount()); |
| 187 } | 186 } |
| 188 } | 187 } |
| 189 | 188 |
| 190 | 189 |
| 190 TEST_F(CommonOperatorTest, Return) { |
| 191 TRACED_FOREACH(int, input_count, kArguments) { |
| 192 const Operator* const op = common()->Return(input_count); |
| 193 EXPECT_EQ(IrOpcode::kReturn, op->opcode()); |
| 194 EXPECT_EQ(Operator::kNoThrow, op->properties()); |
| 195 EXPECT_EQ(input_count, op->ValueInputCount()); |
| 196 EXPECT_EQ(1, op->EffectInputCount()); |
| 197 EXPECT_EQ(1, static_cast<uint32_t>(op->ControlInputCount())); |
| 198 EXPECT_EQ(2 + input_count, static_cast<uint32_t>( |
| 199 OperatorProperties::GetTotalInputCount(op))); |
| 200 EXPECT_EQ(0, op->ValueOutputCount()); |
| 201 EXPECT_EQ(0, op->EffectOutputCount()); |
| 202 EXPECT_EQ(1, op->ControlOutputCount()); |
| 203 } |
| 204 } |
| 205 |
| 206 |
| 191 TEST_F(CommonOperatorTest, Branch) { | 207 TEST_F(CommonOperatorTest, Branch) { |
| 192 TRACED_FOREACH(BranchHint, hint, kBranchHints) { | 208 TRACED_FOREACH(BranchHint, hint, kBranchHints) { |
| 193 const Operator* const op = common()->Branch(hint); | 209 const Operator* const op = common()->Branch(hint); |
| 194 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); | 210 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); |
| 195 EXPECT_EQ(Operator::kKontrol, op->properties()); | 211 EXPECT_EQ(Operator::kKontrol, op->properties()); |
| 196 EXPECT_EQ(hint, BranchHintOf(op)); | 212 EXPECT_EQ(hint, BranchHintOf(op)); |
| 197 EXPECT_EQ(1, op->ValueInputCount()); | 213 EXPECT_EQ(1, op->ValueInputCount()); |
| 198 EXPECT_EQ(0, op->EffectInputCount()); | 214 EXPECT_EQ(0, op->EffectInputCount()); |
| 199 EXPECT_EQ(1, op->ControlInputCount()); | 215 EXPECT_EQ(1, op->ControlInputCount()); |
| 200 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); | 216 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 379 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
| 364 EXPECT_EQ(0, op->ControlOutputCount()); | 380 EXPECT_EQ(0, op->ControlOutputCount()); |
| 365 EXPECT_EQ(0, op->EffectOutputCount()); | 381 EXPECT_EQ(0, op->EffectOutputCount()); |
| 366 EXPECT_EQ(1, op->ValueOutputCount()); | 382 EXPECT_EQ(1, op->ValueOutputCount()); |
| 367 } | 383 } |
| 368 } | 384 } |
| 369 | 385 |
| 370 } // namespace compiler | 386 } // namespace compiler |
| 371 } // namespace internal | 387 } // namespace internal |
| 372 } // namespace v8 | 388 } // namespace v8 |
| OLD | NEW |