Mark some common operator with Property::kNoThrow.
R=bmeurer@chromium.org TEST=unittests/CommonOperatorTest Review URL: https://codereview.chromium.org/912393002 Cr-Commit-Position: refs/heads/master@{#26584}
This commit is contained in:
parent
688dcc3aa9
commit
ec4305e48b
@ -118,11 +118,11 @@ size_t ProjectionIndexOf(const Operator* const op) {
|
||||
#define CACHED_OP_LIST(V) \
|
||||
V(Always, Operator::kPure, 0, 0, 0, 1, 0, 0) \
|
||||
V(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1) \
|
||||
V(End, Operator::kFoldable, 0, 0, 1, 0, 0, 0) \
|
||||
V(IfTrue, Operator::kFoldable, 0, 0, 1, 0, 0, 1) \
|
||||
V(IfFalse, Operator::kFoldable, 0, 0, 1, 0, 0, 1) \
|
||||
V(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0) \
|
||||
V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
|
||||
V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
|
||||
V(Throw, Operator::kFoldable, 1, 1, 1, 0, 0, 1) \
|
||||
V(Return, Operator::kNoProperties, 1, 1, 1, 0, 0, 1) \
|
||||
V(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \
|
||||
V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \
|
||||
V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1)
|
||||
|
||||
@ -171,11 +171,11 @@ struct CommonOperatorGlobalCache FINAL {
|
||||
template <BranchHint kBranchHint>
|
||||
struct BranchOperator FINAL : public Operator1<BranchHint> {
|
||||
BranchOperator()
|
||||
: Operator1<BranchHint>( // --
|
||||
IrOpcode::kBranch, Operator::kFoldable, // opcode
|
||||
"Branch", // name
|
||||
1, 0, 1, 0, 0, 2, // counts
|
||||
kBranchHint) {} // parameter
|
||||
: Operator1<BranchHint>( // --
|
||||
IrOpcode::kBranch, Operator::kKontrol, // opcode
|
||||
"Branch", // name
|
||||
1, 0, 1, 0, 0, 2, // counts
|
||||
kBranchHint) {} // parameter
|
||||
};
|
||||
BranchOperator<BranchHint::kNone> kBranchNoneOperator;
|
||||
BranchOperator<BranchHint::kTrue> kBranchTrueOperator;
|
||||
@ -184,10 +184,10 @@ struct CommonOperatorGlobalCache FINAL {
|
||||
template <size_t kInputCount>
|
||||
struct LoopOperator FINAL : public Operator {
|
||||
LoopOperator()
|
||||
: Operator( // --
|
||||
IrOpcode::kLoop, Operator::kFoldable, // opcode
|
||||
"Loop", // name
|
||||
0, 0, kInputCount, 0, 0, 1) {} // counts
|
||||
: Operator( // --
|
||||
IrOpcode::kLoop, Operator::kKontrol, // opcode
|
||||
"Loop", // name
|
||||
0, 0, kInputCount, 0, 0, 1) {} // counts
|
||||
};
|
||||
#define CACHED_LOOP(input_count) \
|
||||
LoopOperator<input_count> kLoop##input_count##Operator;
|
||||
@ -197,10 +197,10 @@ struct CommonOperatorGlobalCache FINAL {
|
||||
template <size_t kInputCount>
|
||||
struct MergeOperator FINAL : public Operator {
|
||||
MergeOperator()
|
||||
: Operator( // --
|
||||
IrOpcode::kMerge, Operator::kFoldable, // opcode
|
||||
"Merge", // name
|
||||
0, 0, kInputCount, 0, 0, 1) {} // counts
|
||||
: Operator( // --
|
||||
IrOpcode::kMerge, Operator::kKontrol, // opcode
|
||||
"Merge", // name
|
||||
0, 0, kInputCount, 0, 0, 1) {} // counts
|
||||
};
|
||||
#define CACHED_MERGE(input_count) \
|
||||
MergeOperator<input_count> kMerge##input_count##Operator;
|
||||
@ -210,12 +210,11 @@ struct CommonOperatorGlobalCache FINAL {
|
||||
template <int kIndex>
|
||||
struct ParameterOperator FINAL : public Operator1<int> {
|
||||
ParameterOperator()
|
||||
: Operator1<int>( // --
|
||||
IrOpcode::kParameter, // opcode
|
||||
Operator::kFoldable | Operator::kNoThrow, // flags
|
||||
"Parameter", // name
|
||||
1, 0, 0, 1, 0, 0, // counts,
|
||||
kIndex) {} // parameter
|
||||
: Operator1<int>( // --
|
||||
IrOpcode::kParameter, Operator::kPure, // opcode
|
||||
"Parameter", // name
|
||||
1, 0, 0, 1, 0, 0, // counts,
|
||||
kIndex) {} // parameter
|
||||
};
|
||||
#define CACHED_PARAMETER(index) \
|
||||
ParameterOperator<index> kParameter##index##Operator;
|
||||
@ -257,20 +256,20 @@ const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
|
||||
|
||||
|
||||
const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) {
|
||||
DCHECK_GE(control_output_count, 2u); // Disallow trivial switches.
|
||||
return new (zone()) Operator( // --
|
||||
IrOpcode::kSwitch, Operator::kFoldable, // opcode
|
||||
"Switch", // name
|
||||
1, 0, 1, 0, 0, control_output_count); // counts
|
||||
DCHECK_GE(control_output_count, 2u); // Disallow trivial switches.
|
||||
return new (zone()) Operator( // --
|
||||
IrOpcode::kSwitch, Operator::kKontrol, // opcode
|
||||
"Switch", // name
|
||||
1, 0, 1, 0, 0, control_output_count); // counts
|
||||
}
|
||||
|
||||
|
||||
const Operator* CommonOperatorBuilder::Case(size_t index) {
|
||||
return new (zone()) Operator1<size_t>( // --
|
||||
IrOpcode::kCase, Operator::kFoldable, // opcode
|
||||
"Case", // name
|
||||
0, 0, 1, 0, 0, 1, // counts
|
||||
index); // parameter
|
||||
return new (zone()) Operator1<size_t>( // --
|
||||
IrOpcode::kCase, Operator::kKontrol, // opcode
|
||||
"Case", // name
|
||||
0, 0, 1, 0, 0, 1, // counts
|
||||
index); // parameter
|
||||
}
|
||||
|
||||
|
||||
@ -295,10 +294,10 @@ const Operator* CommonOperatorBuilder::Loop(int control_input_count) {
|
||||
break;
|
||||
}
|
||||
// Uncached.
|
||||
return new (zone()) Operator( // --
|
||||
IrOpcode::kLoop, Operator::kFoldable, // opcode
|
||||
"Loop", // name
|
||||
0, 0, control_input_count, 0, 0, 1); // counts
|
||||
return new (zone()) Operator( // --
|
||||
IrOpcode::kLoop, Operator::kKontrol, // opcode
|
||||
"Loop", // name
|
||||
0, 0, control_input_count, 0, 0, 1); // counts
|
||||
}
|
||||
|
||||
|
||||
@ -313,10 +312,10 @@ const Operator* CommonOperatorBuilder::Merge(int control_input_count) {
|
||||
break;
|
||||
}
|
||||
// Uncached.
|
||||
return new (zone()) Operator( // --
|
||||
IrOpcode::kMerge, Operator::kFoldable, // opcode
|
||||
"Merge", // name
|
||||
0, 0, control_input_count, 0, 0, 1); // counts
|
||||
return new (zone()) Operator( // --
|
||||
IrOpcode::kMerge, Operator::kKontrol, // opcode
|
||||
"Merge", // name
|
||||
0, 0, control_input_count, 0, 0, 1); // counts
|
||||
}
|
||||
|
||||
|
||||
@ -331,12 +330,11 @@ const Operator* CommonOperatorBuilder::Parameter(int index) {
|
||||
break;
|
||||
}
|
||||
// Uncached.
|
||||
return new (zone()) Operator1<int>( // --
|
||||
IrOpcode::kParameter, // opcode
|
||||
Operator::kFoldable | Operator::kNoThrow, // flags
|
||||
"Parameter", // name
|
||||
1, 0, 0, 1, 0, 0, // counts
|
||||
index); // parameter
|
||||
return new (zone()) Operator1<int>( // --
|
||||
IrOpcode::kParameter, Operator::kPure, // opcode
|
||||
"Parameter", // name
|
||||
1, 0, 0, 1, 0, 0, // counts
|
||||
index); // parameter
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,6 +44,7 @@ class Operator : public ZoneObject {
|
||||
// create new scheduling dependencies.
|
||||
kNoThrow = 1 << 6, // Can never generate an exception.
|
||||
kFoldable = kNoRead | kNoWrite,
|
||||
kKontrol = kFoldable | kNoThrow,
|
||||
kEliminatable = kNoWrite | kNoThrow,
|
||||
kPure = kNoRead | kNoWrite | kNoThrow | kIdempotent
|
||||
};
|
||||
|
@ -518,7 +518,7 @@ struct ChangeLoweringPhase {
|
||||
MachineOperatorReducer machine_reducer(data->jsgraph());
|
||||
CommonOperatorReducer common_reducer;
|
||||
GraphReducer graph_reducer(data->graph(), temp_zone);
|
||||
graph_reducer.AddReducer(&vn_reducer);
|
||||
AddReducer(data, &graph_reducer, &vn_reducer);
|
||||
AddReducer(data, &graph_reducer, &simple_reducer);
|
||||
AddReducer(data, &graph_reducer, &lowering);
|
||||
AddReducer(data, &graph_reducer, &machine_reducer);
|
||||
|
@ -50,7 +50,7 @@ ValueNumberingReducer::~ValueNumberingReducer() {}
|
||||
|
||||
|
||||
Reduction ValueNumberingReducer::Reduce(Node* node) {
|
||||
if (!node->op()->HasProperty(Operator::kEliminatable)) return NoChange();
|
||||
if (!node->op()->HasProperty(Operator::kIdempotent)) return NoChange();
|
||||
|
||||
const size_t hash = HashCode(node);
|
||||
if (!entries_) {
|
||||
|
@ -50,11 +50,11 @@ const SharedOperator kSharedOperators[] = {
|
||||
}
|
||||
SHARED(Always, Operator::kPure, 0, 0, 0, 1, 0, 0),
|
||||
SHARED(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1),
|
||||
SHARED(End, Operator::kFoldable, 0, 0, 1, 0, 0, 0),
|
||||
SHARED(IfTrue, Operator::kFoldable, 0, 0, 1, 0, 0, 1),
|
||||
SHARED(IfFalse, Operator::kFoldable, 0, 0, 1, 0, 0, 1),
|
||||
SHARED(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0),
|
||||
SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1),
|
||||
SHARED(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1),
|
||||
SHARED(Throw, Operator::kFoldable, 1, 1, 1, 0, 0, 1),
|
||||
SHARED(Return, Operator::kNoProperties, 1, 1, 1, 0, 0, 1)
|
||||
SHARED(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1)
|
||||
#undef SHARED
|
||||
};
|
||||
|
||||
@ -170,7 +170,7 @@ TEST_F(CommonOperatorTest, Branch) {
|
||||
TRACED_FOREACH(BranchHint, hint, kHints) {
|
||||
const Operator* const op = common()->Branch(hint);
|
||||
EXPECT_EQ(IrOpcode::kBranch, op->opcode());
|
||||
EXPECT_EQ(Operator::kFoldable, op->properties());
|
||||
EXPECT_EQ(Operator::kKontrol, op->properties());
|
||||
EXPECT_EQ(hint, BranchHintOf(op));
|
||||
EXPECT_EQ(1, op->ValueInputCount());
|
||||
EXPECT_EQ(0, op->EffectInputCount());
|
||||
@ -187,7 +187,7 @@ TEST_F(CommonOperatorTest, Switch) {
|
||||
TRACED_FOREACH(size_t, cases, kCases) {
|
||||
const Operator* const op = common()->Switch(cases);
|
||||
EXPECT_EQ(IrOpcode::kSwitch, op->opcode());
|
||||
EXPECT_EQ(Operator::kFoldable, op->properties());
|
||||
EXPECT_EQ(Operator::kKontrol, op->properties());
|
||||
EXPECT_EQ(1, op->ValueInputCount());
|
||||
EXPECT_EQ(0, op->EffectInputCount());
|
||||
EXPECT_EQ(1, op->ControlInputCount());
|
||||
@ -203,7 +203,7 @@ TEST_F(CommonOperatorTest, Case) {
|
||||
TRACED_FORRANGE(size_t, index, 0, 1024) {
|
||||
const Operator* const op = common()->Case(index);
|
||||
EXPECT_EQ(IrOpcode::kCase, op->opcode());
|
||||
EXPECT_EQ(Operator::kFoldable, op->properties());
|
||||
EXPECT_EQ(Operator::kKontrol, op->properties());
|
||||
EXPECT_EQ(index, CaseIndexOf(op));
|
||||
EXPECT_EQ(0, op->ValueInputCount());
|
||||
EXPECT_EQ(0, op->EffectInputCount());
|
||||
|
@ -22,8 +22,8 @@ struct TestOperator : public Operator {
|
||||
};
|
||||
|
||||
|
||||
static const TestOperator kOp0(0, Operator::kEliminatable, 0, 1);
|
||||
static const TestOperator kOp1(1, Operator::kEliminatable, 1, 1);
|
||||
static const TestOperator kOp0(0, Operator::kIdempotent, 0, 1);
|
||||
static const TestOperator kOp1(1, Operator::kIdempotent, 1, 1);
|
||||
|
||||
|
||||
class ValueNumberingReducerTest : public TestWithZone {
|
||||
@ -76,17 +76,17 @@ TEST_F(ValueNumberingReducerTest, OperatorEqualityNotIdentity) {
|
||||
Operator::Opcode opcode = static_cast<Operator::Opcode>(
|
||||
std::numeric_limits<Operator::Opcode>::max() - i);
|
||||
inputs[i] = graph()->NewNode(
|
||||
new (zone()) TestOperator(opcode, Operator::kEliminatable, 0, 1));
|
||||
new (zone()) TestOperator(opcode, Operator::kIdempotent, 0, 1));
|
||||
}
|
||||
TRACED_FORRANGE(size_t, input_count, 0, arraysize(inputs)) {
|
||||
const TestOperator op1(static_cast<Operator::Opcode>(input_count),
|
||||
Operator::kEliminatable, input_count, 1);
|
||||
Operator::kIdempotent, input_count, 1);
|
||||
Node* n1 = graph()->NewNode(&op1, static_cast<int>(input_count), inputs);
|
||||
Reduction r1 = Reduce(n1);
|
||||
EXPECT_FALSE(r1.Changed());
|
||||
|
||||
const TestOperator op2(static_cast<Operator::Opcode>(input_count),
|
||||
Operator::kEliminatable, input_count, 1);
|
||||
Operator::kIdempotent, input_count, 1);
|
||||
Node* n2 = graph()->NewNode(&op2, static_cast<int>(input_count), inputs);
|
||||
Reduction r2 = Reduce(n2);
|
||||
EXPECT_TRUE(r2.Changed());
|
||||
@ -102,10 +102,10 @@ TEST_F(ValueNumberingReducerTest, SubsequentReductionsYieldTheSameNode) {
|
||||
Operator::Opcode opcode = static_cast<Operator::Opcode>(
|
||||
std::numeric_limits<Operator::Opcode>::max() - i);
|
||||
inputs[i] = graph()->NewNode(
|
||||
new (zone()) TestOperator(opcode, Operator::kEliminatable, 0, 1));
|
||||
new (zone()) TestOperator(opcode, Operator::kIdempotent, 0, 1));
|
||||
}
|
||||
TRACED_FORRANGE(size_t, input_count, 0, arraysize(inputs)) {
|
||||
const TestOperator op1(1, Operator::kEliminatable, input_count, 1);
|
||||
const TestOperator op1(1, Operator::kIdempotent, input_count, 1);
|
||||
Node* n = graph()->NewNode(&op1, static_cast<int>(input_count), inputs);
|
||||
Reduction r = Reduce(n);
|
||||
EXPECT_FALSE(r.Changed());
|
||||
|
Loading…
Reference in New Issue
Block a user