2014-08-18 06:54:07 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-09-22 11:42:10 +00:00
|
|
|
#include <limits>
|
|
|
|
|
2014-12-23 12:50:43 +00:00
|
|
|
#include "src/compiler/common-operator.h"
|
|
|
|
#include "src/compiler/opcodes.h"
|
|
|
|
#include "src/compiler/operator.h"
|
|
|
|
#include "src/compiler/operator-properties.h"
|
2014-10-01 08:34:25 +00:00
|
|
|
#include "test/unittests/test-utils.h"
|
2014-08-18 06:54:07 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
2017-09-28 17:55:52 +00:00
|
|
|
namespace common_operator_unittest {
|
2014-09-12 11:59:26 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Shared operators.
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct SharedOperator {
|
|
|
|
const Operator* (CommonOperatorBuilder::*constructor)();
|
|
|
|
IrOpcode::Value opcode;
|
|
|
|
Operator::Properties properties;
|
|
|
|
int value_input_count;
|
|
|
|
int effect_input_count;
|
|
|
|
int control_input_count;
|
2015-01-27 14:02:21 +00:00
|
|
|
int value_output_count;
|
2014-09-12 11:59:26 +00:00
|
|
|
int effect_output_count;
|
|
|
|
int control_output_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const SharedOperator& fop) {
|
|
|
|
return os << IrOpcode::Mnemonic(fop.opcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SharedOperator kSharedOperators[] = {
|
2015-01-27 14:02:21 +00:00
|
|
|
#define SHARED(Name, properties, value_input_count, effect_input_count, \
|
|
|
|
control_input_count, value_output_count, effect_output_count, \
|
|
|
|
control_output_count) \
|
|
|
|
{ \
|
|
|
|
&CommonOperatorBuilder::Name, IrOpcode::k##Name, properties, \
|
|
|
|
value_input_count, effect_input_count, control_input_count, \
|
|
|
|
value_output_count, effect_output_count, control_output_count \
|
2014-09-12 11:59:26 +00:00
|
|
|
}
|
[turbofan] Proper dead code elimination as regular reducer.
The three different concerns that the ControlReducer used to deal with
are now properly separated into
a.) DeadCodeElimination, which is a regular AdvancedReducer, that
propagates Dead via control edges,
b.) CommonOperatorReducer, which does strength reduction on common
operators (i.e. Branch, Phi, and friends), and
c.) GraphTrimming, which removes dead->live edges from the graph.
This will make it possible to run the DeadCodeElimination together with
other passes that actually introduce Dead nodes, i.e. typed lowering;
and it opens the door for general inlining without two stage fix point
iteration.
To make the DeadCodeElimination easier and more uniform, we basically
reverted the introduction of DeadValue and DeadEffect, and changed the
Dead operator to produce control, value and effect. Note however that
this is not a requirement, but merely a way to make dead propagation
easier and more uniform. We could always go back and decide to have
different Dead operators if some other change requires that.
Note that there are several additional opportunities for cleanup now,
i.e. OSR deconstruction could be a regular reducer now, and we don't
need to use TheHole as dead value marker in the GraphReducer. And we can
actually run the dead code elimination together with the other passes
instead of using separate passes over the graph. We will do this in
follow up CLs.
R=jarin@chromium.org, mstarzinger@chromium.org
Review URL: https://codereview.chromium.org/1193833002
Cr-Commit-Position: refs/heads/master@{#29146}
2015-06-19 12:07:17 +00:00
|
|
|
SHARED(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1),
|
2015-02-11 15:02:32 +00:00
|
|
|
SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1),
|
|
|
|
SHARED(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1),
|
2015-02-20 09:54:49 +00:00
|
|
|
SHARED(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1),
|
2016-08-02 14:48:21 +00:00
|
|
|
SHARED(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1),
|
2017-02-27 10:57:58 +00:00
|
|
|
SHARED(Throw, Operator::kKontrol, 0, 1, 1, 0, 0, 1),
|
[turbofan] Proper dead code elimination as regular reducer.
The three different concerns that the ControlReducer used to deal with
are now properly separated into
a.) DeadCodeElimination, which is a regular AdvancedReducer, that
propagates Dead via control edges,
b.) CommonOperatorReducer, which does strength reduction on common
operators (i.e. Branch, Phi, and friends), and
c.) GraphTrimming, which removes dead->live edges from the graph.
This will make it possible to run the DeadCodeElimination together with
other passes that actually introduce Dead nodes, i.e. typed lowering;
and it opens the door for general inlining without two stage fix point
iteration.
To make the DeadCodeElimination easier and more uniform, we basically
reverted the introduction of DeadValue and DeadEffect, and changed the
Dead operator to produce control, value and effect. Note however that
this is not a requirement, but merely a way to make dead propagation
easier and more uniform. We could always go back and decide to have
different Dead operators if some other change requires that.
Note that there are several additional opportunities for cleanup now,
i.e. OSR deconstruction could be a regular reducer now, and we don't
need to use TheHole as dead value marker in the GraphReducer. And we can
actually run the dead code elimination together with the other passes
instead of using separate passes over the graph. We will do this in
follow up CLs.
R=jarin@chromium.org, mstarzinger@chromium.org
Review URL: https://codereview.chromium.org/1193833002
Cr-Commit-Position: refs/heads/master@{#29146}
2015-06-19 12:07:17 +00:00
|
|
|
SHARED(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1)
|
2014-09-12 11:59:26 +00:00
|
|
|
#undef SHARED
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CommonSharedOperatorTest
|
|
|
|
: public TestWithZone,
|
|
|
|
public ::testing::WithParamInterface<SharedOperator> {};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(CommonSharedOperatorTest, InstancesAreGloballyShared) {
|
|
|
|
const SharedOperator& sop = GetParam();
|
|
|
|
CommonOperatorBuilder common1(zone());
|
|
|
|
CommonOperatorBuilder common2(zone());
|
|
|
|
EXPECT_EQ((common1.*sop.constructor)(), (common2.*sop.constructor)());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(CommonSharedOperatorTest, NumberOfInputsAndOutputs) {
|
|
|
|
CommonOperatorBuilder common(zone());
|
|
|
|
const SharedOperator& sop = GetParam();
|
|
|
|
const Operator* op = (common.*sop.constructor)();
|
|
|
|
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(sop.value_input_count, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(sop.effect_input_count, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(sop.control_input_count, op->ControlInputCount());
|
2014-09-12 11:59:26 +00:00
|
|
|
EXPECT_EQ(
|
|
|
|
sop.value_input_count + sop.effect_input_count + sop.control_input_count,
|
|
|
|
OperatorProperties::GetTotalInputCount(op));
|
|
|
|
|
2015-01-27 14:02:21 +00:00
|
|
|
EXPECT_EQ(sop.value_output_count, op->ValueOutputCount());
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(sop.control_output_count, op->ControlOutputCount());
|
2014-09-12 11:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(CommonSharedOperatorTest, OpcodeIsCorrect) {
|
|
|
|
CommonOperatorBuilder common(zone());
|
|
|
|
const SharedOperator& sop = GetParam();
|
|
|
|
const Operator* op = (common.*sop.constructor)();
|
|
|
|
EXPECT_EQ(sop.opcode, op->opcode());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(CommonSharedOperatorTest, Properties) {
|
|
|
|
CommonOperatorBuilder common(zone());
|
|
|
|
const SharedOperator& sop = GetParam();
|
|
|
|
const Operator* op = (common.*sop.constructor)();
|
|
|
|
EXPECT_EQ(sop.properties, op->properties());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(CommonOperatorTest, CommonSharedOperatorTest,
|
|
|
|
::testing::ValuesIn(kSharedOperators));
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Other operators.
|
|
|
|
|
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
namespace {
|
|
|
|
|
2014-09-04 08:44:03 +00:00
|
|
|
class CommonOperatorTest : public TestWithZone {
|
2014-09-01 10:26:12 +00:00
|
|
|
public:
|
|
|
|
CommonOperatorTest() : common_(zone()) {}
|
2015-04-20 13:08:11 +00:00
|
|
|
~CommonOperatorTest() override {}
|
2014-09-01 10:26:12 +00:00
|
|
|
|
|
|
|
CommonOperatorBuilder* common() { return &common_; }
|
2014-08-19 04:54:06 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
private:
|
|
|
|
CommonOperatorBuilder common_;
|
|
|
|
};
|
2014-08-19 04:54:06 +00:00
|
|
|
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2014-10-29 14:40:47 +00:00
|
|
|
const int kArguments[] = {1, 5, 6, 42, 100, 10000, 65000};
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2014-10-08 07:32:07 +00:00
|
|
|
|
2015-02-17 13:29:31 +00:00
|
|
|
const size_t kCases[] = {3, 4, 100, 255, 1024, 65000};
|
2015-02-09 08:56:01 +00:00
|
|
|
|
|
|
|
|
2014-10-08 07:32:07 +00:00
|
|
|
const float kFloatValues[] = {-std::numeric_limits<float>::infinity(),
|
|
|
|
std::numeric_limits<float>::min(),
|
|
|
|
-1.0f,
|
|
|
|
-0.0f,
|
|
|
|
0.0f,
|
|
|
|
1.0f,
|
|
|
|
std::numeric_limits<float>::max(),
|
|
|
|
std::numeric_limits<float>::infinity(),
|
|
|
|
std::numeric_limits<float>::quiet_NaN(),
|
|
|
|
std::numeric_limits<float>::signaling_NaN()};
|
|
|
|
|
|
|
|
|
2015-05-26 10:31:55 +00:00
|
|
|
const size_t kInputCounts[] = {3, 4, 100, 255, 1024, 65000};
|
|
|
|
|
|
|
|
|
2015-02-17 13:29:31 +00:00
|
|
|
const int32_t kInt32Values[] = {
|
|
|
|
std::numeric_limits<int32_t>::min(), -1914954528, -1698749618, -1578693386,
|
|
|
|
-1577976073, -1573998034, -1529085059, -1499540537, -1299205097,
|
|
|
|
-1090814845, -938186388, -806828902, -750927650, -520676892, -513661538,
|
|
|
|
-453036354, -433622833, -282638793, -28375, -27788, -22770, -18806, -14173,
|
|
|
|
-11956, -11200, -10212, -8160, -3751, -2758, -1522, -121, -120, -118, -117,
|
|
|
|
-106, -84, -80, -74, -59, -52, -48, -39, -35, -17, -11, -10, -9, -7, -5, 0,
|
|
|
|
9, 12, 17, 23, 29, 31, 33, 35, 40, 47, 55, 56, 62, 64, 67, 68, 69, 74, 79,
|
|
|
|
84, 89, 90, 97, 104, 118, 124, 126, 127, 7278, 17787, 24136, 24202, 25570,
|
|
|
|
26680, 30242, 32399, 420886487, 642166225, 821912648, 822577803, 851385718,
|
|
|
|
1212241078, 1411419304, 1589626102, 1596437184, 1876245816, 1954730266,
|
|
|
|
2008792749, 2045320228, std::numeric_limits<int32_t>::max()};
|
|
|
|
|
|
|
|
|
2015-05-28 13:22:48 +00:00
|
|
|
const BranchHint kBranchHints[] = {BranchHint::kNone, BranchHint::kTrue,
|
|
|
|
BranchHint::kFalse};
|
2014-10-29 14:16:32 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
} // namespace
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2014-08-18 11:36:06 +00:00
|
|
|
|
2015-05-26 10:31:55 +00:00
|
|
|
TEST_F(CommonOperatorTest, End) {
|
|
|
|
TRACED_FOREACH(size_t, input_count, kInputCounts) {
|
|
|
|
const Operator* const op = common()->End(input_count);
|
|
|
|
EXPECT_EQ(IrOpcode::kEnd, op->opcode());
|
|
|
|
EXPECT_EQ(Operator::kKontrol, op->properties());
|
|
|
|
EXPECT_EQ(0, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectInputCount());
|
2015-06-04 01:28:14 +00:00
|
|
|
EXPECT_EQ(input_count, static_cast<uint32_t>(op->ControlInputCount()));
|
|
|
|
EXPECT_EQ(input_count, static_cast<uint32_t>(
|
|
|
|
OperatorProperties::GetTotalInputCount(op)));
|
2015-05-26 10:31:55 +00:00
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-08 18:27:30 +00:00
|
|
|
TEST_F(CommonOperatorTest, Return) {
|
|
|
|
TRACED_FOREACH(int, input_count, kArguments) {
|
|
|
|
const Operator* const op = common()->Return(input_count);
|
|
|
|
EXPECT_EQ(IrOpcode::kReturn, op->opcode());
|
|
|
|
EXPECT_EQ(Operator::kNoThrow, op->properties());
|
2016-11-02 13:15:39 +00:00
|
|
|
EXPECT_EQ(input_count + 1, op->ValueInputCount());
|
2015-10-08 18:27:30 +00:00
|
|
|
EXPECT_EQ(1, op->EffectInputCount());
|
2015-10-09 20:03:56 +00:00
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
2016-11-02 13:15:39 +00:00
|
|
|
EXPECT_EQ(3 + input_count, OperatorProperties::GetTotalInputCount(op));
|
2015-10-08 18:27:30 +00:00
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlOutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-22 11:24:55 +00:00
|
|
|
TEST_F(CommonOperatorTest, Branch) {
|
2015-05-28 13:22:48 +00:00
|
|
|
TRACED_FOREACH(BranchHint, hint, kBranchHints) {
|
2014-10-22 11:24:55 +00:00
|
|
|
const Operator* const op = common()->Branch(hint);
|
|
|
|
EXPECT_EQ(IrOpcode::kBranch, op->opcode());
|
2015-02-11 15:02:32 +00:00
|
|
|
EXPECT_EQ(Operator::kKontrol, op->properties());
|
2014-10-29 14:16:32 +00:00
|
|
|
EXPECT_EQ(hint, BranchHintOf(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(1, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
2014-10-22 11:24:55 +00:00
|
|
|
EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(2, op->ControlOutputCount());
|
2014-10-22 11:24:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-09 08:56:01 +00:00
|
|
|
TEST_F(CommonOperatorTest, Switch) {
|
|
|
|
TRACED_FOREACH(size_t, cases, kCases) {
|
|
|
|
const Operator* const op = common()->Switch(cases);
|
|
|
|
EXPECT_EQ(IrOpcode::kSwitch, op->opcode());
|
2015-02-11 15:02:32 +00:00
|
|
|
EXPECT_EQ(Operator::kKontrol, op->properties());
|
2015-02-09 08:56:01 +00:00
|
|
|
EXPECT_EQ(1, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
|
|
|
EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(static_cast<int>(cases), op->ControlOutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 13:29:31 +00:00
|
|
|
TEST_F(CommonOperatorTest, IfValue) {
|
|
|
|
TRACED_FOREACH(int32_t, value, kInt32Values) {
|
2018-03-02 10:54:30 +00:00
|
|
|
TRACED_FOREACH(int32_t, order, kInt32Values) {
|
|
|
|
const Operator* const op = common()->IfValue(value, order);
|
|
|
|
EXPECT_EQ(IrOpcode::kIfValue, op->opcode());
|
|
|
|
EXPECT_EQ(Operator::kKontrol, op->properties());
|
|
|
|
EXPECT_EQ(IfValueParameters(value, order), IfValueParametersOf(op));
|
|
|
|
EXPECT_EQ(0, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlOutputCount());
|
|
|
|
}
|
2015-02-09 08:56:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-29 14:16:32 +00:00
|
|
|
TEST_F(CommonOperatorTest, Select) {
|
2015-12-10 09:03:30 +00:00
|
|
|
static const MachineRepresentation kMachineRepresentations[] = {
|
|
|
|
MachineRepresentation::kBit, MachineRepresentation::kWord8,
|
|
|
|
MachineRepresentation::kWord16, MachineRepresentation::kWord32,
|
|
|
|
MachineRepresentation::kWord64, MachineRepresentation::kFloat32,
|
|
|
|
MachineRepresentation::kFloat64, MachineRepresentation::kTagged};
|
|
|
|
|
|
|
|
|
|
|
|
TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) {
|
2015-05-28 13:22:48 +00:00
|
|
|
TRACED_FOREACH(BranchHint, hint, kBranchHints) {
|
2015-12-10 09:03:30 +00:00
|
|
|
const Operator* const op = common()->Select(rep, hint);
|
2014-10-29 14:16:32 +00:00
|
|
|
EXPECT_EQ(IrOpcode::kSelect, op->opcode());
|
|
|
|
EXPECT_EQ(Operator::kPure, op->properties());
|
2015-12-10 09:03:30 +00:00
|
|
|
EXPECT_EQ(rep, SelectParametersOf(op).representation());
|
2014-10-29 14:16:32 +00:00
|
|
|
EXPECT_EQ(hint, SelectParametersOf(op).hint());
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(3, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(0, op->ControlInputCount());
|
2014-10-29 14:16:32 +00:00
|
|
|
EXPECT_EQ(3, OperatorProperties::GetTotalInputCount(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
2014-10-29 14:16:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-22 11:42:10 +00:00
|
|
|
TEST_F(CommonOperatorTest, Float32Constant) {
|
2014-10-08 07:32:07 +00:00
|
|
|
TRACED_FOREACH(float, value, kFloatValues) {
|
2014-09-22 11:42:10 +00:00
|
|
|
const Operator* op = common()->Float32Constant(value);
|
2014-10-08 07:32:07 +00:00
|
|
|
EXPECT_PRED2(base::bit_equal_to<float>(), value, OpParameter<float>(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ValueInputCount());
|
2014-10-08 07:32:07 +00:00
|
|
|
EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
2014-10-08 07:32:07 +00:00
|
|
|
}
|
|
|
|
TRACED_FOREACH(float, v1, kFloatValues) {
|
|
|
|
TRACED_FOREACH(float, v2, kFloatValues) {
|
|
|
|
const Operator* op1 = common()->Float32Constant(v1);
|
|
|
|
const Operator* op2 = common()->Float32Constant(v2);
|
|
|
|
EXPECT_EQ(bit_cast<uint32_t>(v1) == bit_cast<uint32_t>(v2),
|
|
|
|
op1->Equals(op2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(CommonOperatorTest, Float64Constant) {
|
|
|
|
TRACED_FOREACH(double, value, kFloatValues) {
|
|
|
|
const Operator* op = common()->Float64Constant(value);
|
|
|
|
EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ValueInputCount());
|
2014-09-22 11:42:10 +00:00
|
|
|
EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
2014-09-22 11:42:10 +00:00
|
|
|
}
|
2014-10-08 07:32:07 +00:00
|
|
|
TRACED_FOREACH(double, v1, kFloatValues) {
|
|
|
|
TRACED_FOREACH(double, v2, kFloatValues) {
|
|
|
|
const Operator* op1 = common()->Float64Constant(v1);
|
|
|
|
const Operator* op2 = common()->Float64Constant(v2);
|
|
|
|
EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2),
|
|
|
|
op1->Equals(op2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(CommonOperatorTest, NumberConstant) {
|
|
|
|
TRACED_FOREACH(double, value, kFloatValues) {
|
|
|
|
const Operator* op = common()->NumberConstant(value);
|
|
|
|
EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ValueInputCount());
|
2014-10-08 07:32:07 +00:00
|
|
|
EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
|
2014-10-29 18:46:44 +00:00
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
2014-10-08 07:32:07 +00:00
|
|
|
}
|
|
|
|
TRACED_FOREACH(double, v1, kFloatValues) {
|
|
|
|
TRACED_FOREACH(double, v2, kFloatValues) {
|
|
|
|
const Operator* op1 = common()->NumberConstant(v1);
|
|
|
|
const Operator* op2 = common()->NumberConstant(v2);
|
|
|
|
EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2),
|
|
|
|
op1->Equals(op2));
|
|
|
|
}
|
|
|
|
}
|
2014-09-22 11:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-14 14:53:04 +00:00
|
|
|
TEST_F(CommonOperatorTest, BeginRegion) {
|
2016-06-20 10:46:12 +00:00
|
|
|
{
|
|
|
|
const Operator* op =
|
|
|
|
common()->BeginRegion(RegionObservability::kObservable);
|
|
|
|
EXPECT_EQ(1, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const Operator* op =
|
|
|
|
common()->BeginRegion(RegionObservability::kNotObservable);
|
|
|
|
EXPECT_EQ(1, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(0, op->ValueOutputCount());
|
|
|
|
}
|
2014-08-19 04:54:06 +00:00
|
|
|
}
|
|
|
|
|
2015-10-14 14:53:04 +00:00
|
|
|
TEST_F(CommonOperatorTest, FinishRegion) {
|
|
|
|
const Operator* op = common()->FinishRegion();
|
|
|
|
EXPECT_EQ(1, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectInputCount());
|
|
|
|
EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(1, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
2014-08-18 11:36:06 +00:00
|
|
|
}
|
|
|
|
|
2016-06-21 15:46:10 +00:00
|
|
|
TEST_F(CommonOperatorTest, Projection) {
|
|
|
|
TRACED_FORRANGE(size_t, index, 0, 3) {
|
|
|
|
const Operator* op = common()->Projection(index);
|
|
|
|
EXPECT_EQ(index, ProjectionIndexOf(op));
|
|
|
|
EXPECT_EQ(1, op->ValueInputCount());
|
|
|
|
EXPECT_EQ(1, op->ControlInputCount());
|
|
|
|
EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, op->ControlOutputCount());
|
|
|
|
EXPECT_EQ(0, op->EffectOutputCount());
|
|
|
|
EXPECT_EQ(1, op->ValueOutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 17:55:52 +00:00
|
|
|
} // namespace common_operator_unittest
|
2014-08-18 06:54:07 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|