Index: src/compiler/common-operator.cc |
diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc |
index 460c47b1803fe8e4e83c7000a6c2c966790b21e8..a6cca456d2bf219bf0c1639c47ef960b11416a48 100644 |
--- a/src/compiler/common-operator.cc |
+++ b/src/compiler/common-operator.cc |
@@ -112,6 +112,32 @@ std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) { |
V(Return, Operator::kNoProperties, 1, 1, 1, 1) |
+#define CACHED_LOOP_LIST(V) \ |
+ V(1) \ |
+ V(2) |
+ |
+ |
+#define CACHED_MERGE_LIST(V) \ |
+ V(1) \ |
+ V(2) \ |
+ V(3) \ |
+ V(4) \ |
+ V(5) \ |
+ V(6) \ |
+ V(7) \ |
+ V(8) |
+ |
+ |
+#define CACHED_PARAMETER_LIST(V) \ |
+ V(0) \ |
+ V(1) \ |
+ V(2) \ |
+ V(3) \ |
+ V(4) \ |
+ V(5) \ |
+ V(6) |
+ |
+ |
struct CommonOperatorGlobalCache FINAL { |
#define CACHED(Name, properties, value_input_count, effect_input_count, \ |
control_input_count, control_output_count) \ |
@@ -137,6 +163,46 @@ struct CommonOperatorGlobalCache FINAL { |
BranchOperator<BranchHint::kNone> kBranchNoneOperator; |
BranchOperator<BranchHint::kTrue> kBranchTrueOperator; |
BranchOperator<BranchHint::kFalse> kBranchFalseOperator; |
+ |
+ 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 |
+ }; |
+#define CACHED_LOOP(input_count) \ |
+ LoopOperator<input_count> kLoop##input_count##Operator; |
+ CACHED_LOOP_LIST(CACHED_LOOP) |
+#undef CACHED_LOOP |
+ |
+ 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 |
+ }; |
+#define CACHED_MERGE(input_count) \ |
+ MergeOperator<input_count> kMerge##input_count##Operator; |
+ CACHED_MERGE_LIST(CACHED_MERGE) |
+#undef CACHED_MERGE |
+ |
+ template <int kIndex> |
+ struct ParameterOperator FINAL : public Operator1<int> { |
+ ParameterOperator() |
+ : 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; |
+ CACHED_PARAMETER_LIST(CACHED_PARAMETER) |
+#undef CACHED_PARAMETER |
}; |
@@ -181,19 +247,39 @@ const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) { |
} |
-const Operator* CommonOperatorBuilder::Merge(int controls) { |
- return new (zone()) Operator( // -- |
- IrOpcode::kMerge, Operator::kFoldable, // opcode |
- "Merge", // name |
- 0, 0, controls, 0, 0, 1); // counts |
-} |
- |
- |
-const Operator* CommonOperatorBuilder::Loop(int controls) { |
+const Operator* CommonOperatorBuilder::Loop(int control_input_count) { |
+ switch (control_input_count) { |
+#define CACHED_LOOP(input_count) \ |
+ case input_count: \ |
+ return &cache_.kLoop##input_count##Operator; |
+ CACHED_LOOP_LIST(CACHED_LOOP) |
+#undef CACHED_LOOP |
+ default: |
+ break; |
+ } |
+ // Uncached. |
return new (zone()) Operator( // -- |
IrOpcode::kLoop, Operator::kFoldable, // opcode |
"Loop", // name |
- 0, 0, controls, 0, 0, 1); // counts |
+ 0, 0, control_input_count, 0, 0, 1); // counts |
+} |
+ |
+ |
+const Operator* CommonOperatorBuilder::Merge(int control_input_count) { |
+ switch (control_input_count) { |
+#define CACHED_MERGE(input_count) \ |
+ case input_count: \ |
+ return &cache_.kMerge##input_count##Operator; |
+ CACHED_MERGE_LIST(CACHED_MERGE) |
+#undef CACHED_MERGE |
+ default: |
+ break; |
+ } |
+ // Uncached. |
+ return new (zone()) Operator( // -- |
+ IrOpcode::kMerge, Operator::kFoldable, // opcode |
+ "Merge", // name |
+ 0, 0, control_input_count, 0, 0, 1); // counts |
} |
@@ -206,6 +292,16 @@ const Operator* CommonOperatorBuilder::Terminate(int effects) { |
const Operator* CommonOperatorBuilder::Parameter(int index) { |
+ switch (index) { |
+#define CACHED_PARAMETER(index) \ |
+ case index: \ |
+ return &cache_.kParameter##index##Operator; |
+ CACHED_PARAMETER_LIST(CACHED_PARAMETER) |
+#undef CACHED_PARAMETER |
+ default: |
+ break; |
+ } |
+ // Uncached. |
return new (zone()) Operator1<int>( // -- |
IrOpcode::kParameter, Operator::kPure, // opcode |
"Parameter", // name |