From e093b6d34aa7731425b1bd432f0cf722488d889b Mon Sep 17 00:00:00 2001 From: bmeurer Date: Wed, 18 Mar 2015 02:46:06 -0700 Subject: [PATCH] [turbofan] Cache more common operators. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/1015053002 Cr-Commit-Position: refs/heads/master@{#27260} --- src/compiler/common-operator.cc | 149 ++++++++++++++++++++++++++++++-- src/compiler/common-operator.h | 4 +- 2 files changed, 145 insertions(+), 8 deletions(-) diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc index aba43fa1bc..27a9d63f48 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 kBranchTrueOperator; BranchOperator kBranchFalseOperator; + template + 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 kEffectPhi##input_count##Operator; + CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI) +#undef CACHED_EFFECT_PHI + template struct LoopOperator FINAL : public Operator { LoopOperator() @@ -205,6 +261,20 @@ struct CommonOperatorGlobalCache FINAL { CACHED_MERGE_LIST(CACHED_MERGE) #undef CACHED_MERGE + template + struct PhiOperator FINAL : public Operator1 { + PhiOperator() + : Operator1( //-- + IrOpcode::kPhi, Operator::kPure, // opcode + "Phi", // name + kInputCount, 0, 1, 1, 0, 0, // counts + kType) {} // parameter + }; +#define CACHED_PHI(type, input_count) \ + PhiOperator kPhi##type##input_count##Operator; + CACHED_PHI_LIST(CACHED_PHI) +#undef CACHED_PHI + template struct ParameterOperator FINAL : public Operator1 { ParameterOperator() @@ -218,6 +288,35 @@ struct CommonOperatorGlobalCache FINAL { ParameterOperator kParameter##index##Operator; CACHED_PARAMETER_LIST(CACHED_PARAMETER) #undef CACHED_PARAMETER + + template + struct ProjectionOperator FINAL : public Operator1 { + ProjectionOperator() + : Operator1( // -- + IrOpcode::kProjection, // opcode + Operator::kFoldable | Operator::kNoThrow, // flags + "Projection", // name + 1, 0, 0, 1, 0, 0, // counts, + kIndex) {} // parameter + }; +#define CACHED_PROJECTION(index) \ + ProjectionOperator kProjection##index##Operator; + CACHED_PROJECTION_LIST(CACHED_PROJECTION) +#undef CACHED_PROJECTION + + template + 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 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( // -- 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( // -- IrOpcode::kProjection, // opcode Operator::kFoldable | Operator::kNoThrow, // flags diff --git a/src/compiler/common-operator.h b/src/compiler/common-operator.h index aab6a193e4..f28ea8b51f 100644 --- a/src/compiler/common-operator.h +++ b/src/compiler/common-operator.h @@ -199,8 +199,8 @@ class CommonOperatorBuilder FINAL : public ZoneObject { const Operator* HeapConstant(const Unique&); const Operator* Select(MachineType, BranchHint = BranchHint::kNone); - const Operator* Phi(MachineType type, int arguments); - const Operator* EffectPhi(int arguments); + const Operator* Phi(MachineType type, int value_input_count); + const Operator* EffectPhi(int effect_input_count); const Operator* EffectSet(int arguments); const Operator* ValueEffect(int arguments); const Operator* Finish(int arguments);