Commit ec4305e4 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

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}
parent 688dcc3a
...@@ -118,11 +118,11 @@ size_t ProjectionIndexOf(const Operator* const op) { ...@@ -118,11 +118,11 @@ size_t ProjectionIndexOf(const Operator* const op) {
#define CACHED_OP_LIST(V) \ #define CACHED_OP_LIST(V) \
V(Always, Operator::kPure, 0, 0, 0, 1, 0, 0) \ V(Always, Operator::kPure, 0, 0, 0, 1, 0, 0) \
V(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1) \ V(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1) \
V(End, Operator::kFoldable, 0, 0, 1, 0, 0, 0) \ V(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0) \
V(IfTrue, Operator::kFoldable, 0, 0, 1, 0, 0, 1) \ V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
V(IfFalse, Operator::kFoldable, 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(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(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \
V(OsrLoopEntry, 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 { ...@@ -171,11 +171,11 @@ struct CommonOperatorGlobalCache FINAL {
template <BranchHint kBranchHint> template <BranchHint kBranchHint>
struct BranchOperator FINAL : public Operator1<BranchHint> { struct BranchOperator FINAL : public Operator1<BranchHint> {
BranchOperator() BranchOperator()
: Operator1<BranchHint>( // -- : Operator1<BranchHint>( // --
IrOpcode::kBranch, Operator::kFoldable, // opcode IrOpcode::kBranch, Operator::kKontrol, // opcode
"Branch", // name "Branch", // name
1, 0, 1, 0, 0, 2, // counts 1, 0, 1, 0, 0, 2, // counts
kBranchHint) {} // parameter kBranchHint) {} // parameter
}; };
BranchOperator<BranchHint::kNone> kBranchNoneOperator; BranchOperator<BranchHint::kNone> kBranchNoneOperator;
BranchOperator<BranchHint::kTrue> kBranchTrueOperator; BranchOperator<BranchHint::kTrue> kBranchTrueOperator;
...@@ -184,10 +184,10 @@ struct CommonOperatorGlobalCache FINAL { ...@@ -184,10 +184,10 @@ struct CommonOperatorGlobalCache FINAL {
template <size_t kInputCount> template <size_t kInputCount>
struct LoopOperator FINAL : public Operator { struct LoopOperator FINAL : public Operator {
LoopOperator() LoopOperator()
: Operator( // -- : Operator( // --
IrOpcode::kLoop, Operator::kFoldable, // opcode IrOpcode::kLoop, Operator::kKontrol, // opcode
"Loop", // name "Loop", // name
0, 0, kInputCount, 0, 0, 1) {} // counts 0, 0, kInputCount, 0, 0, 1) {} // counts
}; };
#define CACHED_LOOP(input_count) \ #define CACHED_LOOP(input_count) \
LoopOperator<input_count> kLoop##input_count##Operator; LoopOperator<input_count> kLoop##input_count##Operator;
...@@ -197,10 +197,10 @@ struct CommonOperatorGlobalCache FINAL { ...@@ -197,10 +197,10 @@ struct CommonOperatorGlobalCache FINAL {
template <size_t kInputCount> template <size_t kInputCount>
struct MergeOperator FINAL : public Operator { struct MergeOperator FINAL : public Operator {
MergeOperator() MergeOperator()
: Operator( // -- : Operator( // --
IrOpcode::kMerge, Operator::kFoldable, // opcode IrOpcode::kMerge, Operator::kKontrol, // opcode
"Merge", // name "Merge", // name
0, 0, kInputCount, 0, 0, 1) {} // counts 0, 0, kInputCount, 0, 0, 1) {} // counts
}; };
#define CACHED_MERGE(input_count) \ #define CACHED_MERGE(input_count) \
MergeOperator<input_count> kMerge##input_count##Operator; MergeOperator<input_count> kMerge##input_count##Operator;
...@@ -210,12 +210,11 @@ struct CommonOperatorGlobalCache FINAL { ...@@ -210,12 +210,11 @@ struct CommonOperatorGlobalCache FINAL {
template <int kIndex> template <int kIndex>
struct ParameterOperator FINAL : public Operator1<int> { struct ParameterOperator FINAL : public Operator1<int> {
ParameterOperator() ParameterOperator()
: Operator1<int>( // -- : Operator1<int>( // --
IrOpcode::kParameter, // opcode IrOpcode::kParameter, Operator::kPure, // opcode
Operator::kFoldable | Operator::kNoThrow, // flags "Parameter", // name
"Parameter", // name 1, 0, 0, 1, 0, 0, // counts,
1, 0, 0, 1, 0, 0, // counts, kIndex) {} // parameter
kIndex) {} // parameter
}; };
#define CACHED_PARAMETER(index) \ #define CACHED_PARAMETER(index) \
ParameterOperator<index> kParameter##index##Operator; ParameterOperator<index> kParameter##index##Operator;
...@@ -257,20 +256,20 @@ const Operator* CommonOperatorBuilder::Branch(BranchHint hint) { ...@@ -257,20 +256,20 @@ const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) {
DCHECK_GE(control_output_count, 2u); // Disallow trivial switches. DCHECK_GE(control_output_count, 2u); // Disallow trivial switches.
return new (zone()) Operator( // -- return new (zone()) Operator( // --
IrOpcode::kSwitch, Operator::kFoldable, // opcode IrOpcode::kSwitch, Operator::kKontrol, // opcode
"Switch", // name "Switch", // name
1, 0, 1, 0, 0, control_output_count); // counts 1, 0, 1, 0, 0, control_output_count); // counts
} }
const Operator* CommonOperatorBuilder::Case(size_t index) { const Operator* CommonOperatorBuilder::Case(size_t index) {
return new (zone()) Operator1<size_t>( // -- return new (zone()) Operator1<size_t>( // --
IrOpcode::kCase, Operator::kFoldable, // opcode IrOpcode::kCase, Operator::kKontrol, // opcode
"Case", // name "Case", // name
0, 0, 1, 0, 0, 1, // counts 0, 0, 1, 0, 0, 1, // counts
index); // parameter index); // parameter
} }
...@@ -295,10 +294,10 @@ const Operator* CommonOperatorBuilder::Loop(int control_input_count) { ...@@ -295,10 +294,10 @@ const Operator* CommonOperatorBuilder::Loop(int control_input_count) {
break; break;
} }
// Uncached. // Uncached.
return new (zone()) Operator( // -- return new (zone()) Operator( // --
IrOpcode::kLoop, Operator::kFoldable, // opcode IrOpcode::kLoop, Operator::kKontrol, // opcode
"Loop", // name "Loop", // name
0, 0, control_input_count, 0, 0, 1); // counts 0, 0, control_input_count, 0, 0, 1); // counts
} }
...@@ -313,10 +312,10 @@ const Operator* CommonOperatorBuilder::Merge(int control_input_count) { ...@@ -313,10 +312,10 @@ const Operator* CommonOperatorBuilder::Merge(int control_input_count) {
break; break;
} }
// Uncached. // Uncached.
return new (zone()) Operator( // -- return new (zone()) Operator( // --
IrOpcode::kMerge, Operator::kFoldable, // opcode IrOpcode::kMerge, Operator::kKontrol, // opcode
"Merge", // name "Merge", // name
0, 0, control_input_count, 0, 0, 1); // counts 0, 0, control_input_count, 0, 0, 1); // counts
} }
...@@ -331,12 +330,11 @@ const Operator* CommonOperatorBuilder::Parameter(int index) { ...@@ -331,12 +330,11 @@ const Operator* CommonOperatorBuilder::Parameter(int index) {
break; break;
} }
// Uncached. // Uncached.
return new (zone()) Operator1<int>( // -- return new (zone()) Operator1<int>( // --
IrOpcode::kParameter, // opcode IrOpcode::kParameter, Operator::kPure, // opcode
Operator::kFoldable | Operator::kNoThrow, // flags "Parameter", // name
"Parameter", // name 1, 0, 0, 1, 0, 0, // counts
1, 0, 0, 1, 0, 0, // counts index); // parameter
index); // parameter
} }
......
...@@ -44,6 +44,7 @@ class Operator : public ZoneObject { ...@@ -44,6 +44,7 @@ class Operator : public ZoneObject {
// create new scheduling dependencies. // create new scheduling dependencies.
kNoThrow = 1 << 6, // Can never generate an exception. kNoThrow = 1 << 6, // Can never generate an exception.
kFoldable = kNoRead | kNoWrite, kFoldable = kNoRead | kNoWrite,
kKontrol = kFoldable | kNoThrow,
kEliminatable = kNoWrite | kNoThrow, kEliminatable = kNoWrite | kNoThrow,
kPure = kNoRead | kNoWrite | kNoThrow | kIdempotent kPure = kNoRead | kNoWrite | kNoThrow | kIdempotent
}; };
......
...@@ -518,7 +518,7 @@ struct ChangeLoweringPhase { ...@@ -518,7 +518,7 @@ struct ChangeLoweringPhase {
MachineOperatorReducer machine_reducer(data->jsgraph()); MachineOperatorReducer machine_reducer(data->jsgraph());
CommonOperatorReducer common_reducer; CommonOperatorReducer common_reducer;
GraphReducer graph_reducer(data->graph(), temp_zone); 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, &simple_reducer);
AddReducer(data, &graph_reducer, &lowering); AddReducer(data, &graph_reducer, &lowering);
AddReducer(data, &graph_reducer, &machine_reducer); AddReducer(data, &graph_reducer, &machine_reducer);
......
...@@ -50,7 +50,7 @@ ValueNumberingReducer::~ValueNumberingReducer() {} ...@@ -50,7 +50,7 @@ ValueNumberingReducer::~ValueNumberingReducer() {}
Reduction ValueNumberingReducer::Reduce(Node* node) { 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); const size_t hash = HashCode(node);
if (!entries_) { if (!entries_) {
......
...@@ -50,11 +50,11 @@ const SharedOperator kSharedOperators[] = { ...@@ -50,11 +50,11 @@ const SharedOperator kSharedOperators[] = {
} }
SHARED(Always, Operator::kPure, 0, 0, 0, 1, 0, 0), SHARED(Always, Operator::kPure, 0, 0, 0, 1, 0, 0),
SHARED(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1), SHARED(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1),
SHARED(End, Operator::kFoldable, 0, 0, 1, 0, 0, 0), SHARED(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0),
SHARED(IfTrue, Operator::kFoldable, 0, 0, 1, 0, 0, 1), SHARED(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1),
SHARED(IfFalse, Operator::kFoldable, 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(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 #undef SHARED
}; };
...@@ -170,7 +170,7 @@ TEST_F(CommonOperatorTest, Branch) { ...@@ -170,7 +170,7 @@ TEST_F(CommonOperatorTest, Branch) {
TRACED_FOREACH(BranchHint, hint, kHints) { TRACED_FOREACH(BranchHint, hint, kHints) {
const Operator* const op = common()->Branch(hint); const Operator* const op = common()->Branch(hint);
EXPECT_EQ(IrOpcode::kBranch, op->opcode()); 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(hint, BranchHintOf(op));
EXPECT_EQ(1, op->ValueInputCount()); EXPECT_EQ(1, op->ValueInputCount());
EXPECT_EQ(0, op->EffectInputCount()); EXPECT_EQ(0, op->EffectInputCount());
...@@ -187,7 +187,7 @@ TEST_F(CommonOperatorTest, Switch) { ...@@ -187,7 +187,7 @@ TEST_F(CommonOperatorTest, Switch) {
TRACED_FOREACH(size_t, cases, kCases) { TRACED_FOREACH(size_t, cases, kCases) {
const Operator* const op = common()->Switch(cases); const Operator* const op = common()->Switch(cases);
EXPECT_EQ(IrOpcode::kSwitch, op->opcode()); 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(1, op->ValueInputCount());
EXPECT_EQ(0, op->EffectInputCount()); EXPECT_EQ(0, op->EffectInputCount());
EXPECT_EQ(1, op->ControlInputCount()); EXPECT_EQ(1, op->ControlInputCount());
...@@ -203,7 +203,7 @@ TEST_F(CommonOperatorTest, Case) { ...@@ -203,7 +203,7 @@ TEST_F(CommonOperatorTest, Case) {
TRACED_FORRANGE(size_t, index, 0, 1024) { TRACED_FORRANGE(size_t, index, 0, 1024) {
const Operator* const op = common()->Case(index); const Operator* const op = common()->Case(index);
EXPECT_EQ(IrOpcode::kCase, op->opcode()); 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(index, CaseIndexOf(op));
EXPECT_EQ(0, op->ValueInputCount()); EXPECT_EQ(0, op->ValueInputCount());
EXPECT_EQ(0, op->EffectInputCount()); EXPECT_EQ(0, op->EffectInputCount());
......
...@@ -22,8 +22,8 @@ struct TestOperator : public Operator { ...@@ -22,8 +22,8 @@ struct TestOperator : public Operator {
}; };
static const TestOperator kOp0(0, Operator::kEliminatable, 0, 1); static const TestOperator kOp0(0, Operator::kIdempotent, 0, 1);
static const TestOperator kOp1(1, Operator::kEliminatable, 1, 1); static const TestOperator kOp1(1, Operator::kIdempotent, 1, 1);
class ValueNumberingReducerTest : public TestWithZone { class ValueNumberingReducerTest : public TestWithZone {
...@@ -76,17 +76,17 @@ TEST_F(ValueNumberingReducerTest, OperatorEqualityNotIdentity) { ...@@ -76,17 +76,17 @@ TEST_F(ValueNumberingReducerTest, OperatorEqualityNotIdentity) {
Operator::Opcode opcode = static_cast<Operator::Opcode>( Operator::Opcode opcode = static_cast<Operator::Opcode>(
std::numeric_limits<Operator::Opcode>::max() - i); std::numeric_limits<Operator::Opcode>::max() - i);
inputs[i] = graph()->NewNode( 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)) { TRACED_FORRANGE(size_t, input_count, 0, arraysize(inputs)) {
const TestOperator op1(static_cast<Operator::Opcode>(input_count), 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); Node* n1 = graph()->NewNode(&op1, static_cast<int>(input_count), inputs);
Reduction r1 = Reduce(n1); Reduction r1 = Reduce(n1);
EXPECT_FALSE(r1.Changed()); EXPECT_FALSE(r1.Changed());
const TestOperator op2(static_cast<Operator::Opcode>(input_count), 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); Node* n2 = graph()->NewNode(&op2, static_cast<int>(input_count), inputs);
Reduction r2 = Reduce(n2); Reduction r2 = Reduce(n2);
EXPECT_TRUE(r2.Changed()); EXPECT_TRUE(r2.Changed());
...@@ -102,10 +102,10 @@ TEST_F(ValueNumberingReducerTest, SubsequentReductionsYieldTheSameNode) { ...@@ -102,10 +102,10 @@ TEST_F(ValueNumberingReducerTest, SubsequentReductionsYieldTheSameNode) {
Operator::Opcode opcode = static_cast<Operator::Opcode>( Operator::Opcode opcode = static_cast<Operator::Opcode>(
std::numeric_limits<Operator::Opcode>::max() - i); std::numeric_limits<Operator::Opcode>::max() - i);
inputs[i] = graph()->NewNode( 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)) { 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); Node* n = graph()->NewNode(&op1, static_cast<int>(input_count), inputs);
Reduction r = Reduce(n); Reduction r = Reduce(n);
EXPECT_FALSE(r.Changed()); EXPECT_FALSE(r.Changed());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment