Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: src/compiler/common-operator.cc

Issue 1015053002: [turbofan] Cache more common operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/common-operator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/common-operator.cc
diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc
index aba43fa1bc667378f27e83e9e017be5821b20ffe..27a9d63f48626cc7339faf202c25f534c35d612e 100644
--- a/src/compiler/common-operator.cc
+++ b/src/compiler/common-operator.cc
@@ -125,6 +125,15 @@ size_t ProjectionIndexOf(const Operator* const op) {
V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1)
+#define CACHED_EFFECT_PHI_LIST(V) \
+ V(1) \
+ V(2) \
+ V(3) \
+ V(4) \
+ V(5) \
+ V(6)
+
+
#define CACHED_LOOP_LIST(V) \
V(1) \
V(2)
@@ -151,6 +160,40 @@ size_t ProjectionIndexOf(const Operator* const op) {
V(6)
+#define CACHED_PHI_LIST(V) \
+ V(kMachAnyTagged, 1) \
+ V(kMachAnyTagged, 2) \
+ V(kMachAnyTagged, 3) \
+ V(kMachAnyTagged, 4) \
+ V(kMachAnyTagged, 5) \
+ V(kMachAnyTagged, 6) \
+ V(kMachBool, 2) \
+ V(kMachFloat64, 2) \
+ V(kMachInt32, 2)
+
+
+#define CACHED_PROJECTION_LIST(V) \
+ V(0) \
+ V(1)
+
+
+#define CACHED_STATE_VALUES_LIST(V) \
+ V(0) \
+ V(1) \
+ V(2) \
+ V(3) \
+ V(4) \
+ V(5) \
+ V(6) \
+ V(7) \
+ V(8) \
+ V(10) \
+ V(11) \
+ V(12) \
+ V(13) \
+ V(14)
+
+
struct CommonOperatorGlobalCache FINAL {
#define CACHED(Name, properties, value_input_count, effect_input_count, \
control_input_count, value_output_count, effect_output_count, \
@@ -179,6 +222,19 @@ struct CommonOperatorGlobalCache FINAL {
BranchOperator<BranchHint::kTrue> kBranchTrueOperator;
BranchOperator<BranchHint::kFalse> kBranchFalseOperator;
+ template <int kEffectInputCount>
+ struct EffectPhiOperator FINAL : public Operator {
+ EffectPhiOperator()
+ : Operator( // --
+ IrOpcode::kEffectPhi, Operator::kPure, // opcode
+ "EffectPhi", // name
+ 0, kEffectInputCount, 1, 0, 1, 0) {} // counts
+ };
+#define CACHED_EFFECT_PHI(input_count) \
+ EffectPhiOperator<input_count> kEffectPhi##input_count##Operator;
+ CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
+#undef CACHED_EFFECT_PHI
+
template <size_t kInputCount>
struct LoopOperator FINAL : public Operator {
LoopOperator()
@@ -205,6 +261,20 @@ struct CommonOperatorGlobalCache FINAL {
CACHED_MERGE_LIST(CACHED_MERGE)
#undef CACHED_MERGE
+ template <MachineType kType, int kInputCount>
+ struct PhiOperator FINAL : public Operator1<MachineType> {
+ PhiOperator()
+ : Operator1<MachineType>( //--
+ IrOpcode::kPhi, Operator::kPure, // opcode
+ "Phi", // name
+ kInputCount, 0, 1, 1, 0, 0, // counts
+ kType) {} // parameter
+ };
+#define CACHED_PHI(type, input_count) \
+ PhiOperator<type, input_count> kPhi##type##input_count##Operator;
+ CACHED_PHI_LIST(CACHED_PHI)
+#undef CACHED_PHI
+
template <int kIndex>
struct ParameterOperator FINAL : public Operator1<int> {
ParameterOperator()
@@ -218,6 +288,35 @@ struct CommonOperatorGlobalCache FINAL {
ParameterOperator<index> kParameter##index##Operator;
CACHED_PARAMETER_LIST(CACHED_PARAMETER)
#undef CACHED_PARAMETER
+
+ template <size_t kIndex>
+ struct ProjectionOperator FINAL : public Operator1<size_t> {
+ ProjectionOperator()
+ : Operator1<size_t>( // --
+ IrOpcode::kProjection, // opcode
+ Operator::kFoldable | Operator::kNoThrow, // flags
+ "Projection", // name
+ 1, 0, 0, 1, 0, 0, // counts,
+ kIndex) {} // parameter
+ };
+#define CACHED_PROJECTION(index) \
+ ProjectionOperator<index> kProjection##index##Operator;
+ CACHED_PROJECTION_LIST(CACHED_PROJECTION)
+#undef CACHED_PROJECTION
+
+ template <int kInputCount>
+ struct StateValuesOperator FINAL : public Operator {
+ StateValuesOperator()
+ : Operator( // --
+ IrOpcode::kStateValues, // opcode
+ Operator::kPure, // flags
+ "StateValues", // name
+ kInputCount, 0, 0, 1, 0, 0) {} // counts
+ };
+#define CACHED_STATE_VALUES(input_count) \
+ StateValuesOperator<input_count> kStateValues##input_count##Operator;
+ CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
+#undef CACHED_STATE_VALUES
};
@@ -423,22 +522,40 @@ const Operator* CommonOperatorBuilder::Select(MachineType type,
}
-const Operator* CommonOperatorBuilder::Phi(MachineType type, int arguments) {
- DCHECK(arguments > 0); // Disallow empty phis.
+const Operator* CommonOperatorBuilder::Phi(MachineType type,
+ int value_input_count) {
+ DCHECK(value_input_count > 0); // Disallow empty phis.
+#define CACHED_PHI(kType, kValueInputCount) \
+ if (kType == type && kValueInputCount == value_input_count) { \
+ return &cache_.kPhi##kType##kValueInputCount##Operator; \
+ }
+ CACHED_PHI_LIST(CACHED_PHI)
+#undef CACHED_PHI
+ // Uncached.
return new (zone()) Operator1<MachineType>( // --
IrOpcode::kPhi, Operator::kPure, // opcode
"Phi", // name
- arguments, 0, 1, 1, 0, 0, // counts
+ value_input_count, 0, 1, 1, 0, 0, // counts
type); // parameter
}
-const Operator* CommonOperatorBuilder::EffectPhi(int arguments) {
- DCHECK(arguments > 0); // Disallow empty phis.
+const Operator* CommonOperatorBuilder::EffectPhi(int effect_input_count) {
+ DCHECK(effect_input_count > 0); // Disallow empty effect phis.
+ switch (effect_input_count) {
+#define CACHED_EFFECT_PHI(input_count) \
+ case input_count: \
+ return &cache_.kEffectPhi##input_count##Operator;
+ CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
+#undef CACHED_EFFECT_PHI
+ default:
+ break;
+ }
+ // Uncached.
return new (zone()) Operator( // --
IrOpcode::kEffectPhi, Operator::kPure, // opcode
"EffectPhi", // name
- 0, arguments, 1, 0, 1, 0); // counts
+ 0, effect_input_count, 1, 0, 1, 0); // counts
}
@@ -470,6 +587,16 @@ const Operator* CommonOperatorBuilder::Finish(int arguments) {
const Operator* CommonOperatorBuilder::StateValues(int arguments) {
+ switch (arguments) {
+#define CACHED_STATE_VALUES(arguments) \
+ case arguments: \
+ return &cache_.kStateValues##arguments##Operator;
+ CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
+#undef CACHED_STATE_VALUES
+ default:
+ break;
+ }
+ // Uncached.
return new (zone()) Operator( // --
IrOpcode::kStateValues, Operator::kPure, // opcode
"StateValues", // name
@@ -510,6 +637,16 @@ const Operator* CommonOperatorBuilder::Call(const CallDescriptor* descriptor) {
const Operator* CommonOperatorBuilder::Projection(size_t index) {
+ switch (index) {
+#define CACHED_PROJECTION(index) \
+ case index: \
+ return &cache_.kProjection##index##Operator;
+ CACHED_PROJECTION_LIST(CACHED_PROJECTION)
+#undef CACHED_PROJECTION
+ default:
+ break;
+ }
+ // Uncached.
return new (zone()) Operator1<size_t>( // --
IrOpcode::kProjection, // opcode
Operator::kFoldable | Operator::kNoThrow, // flags
« no previous file with comments | « src/compiler/common-operator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698