Chromium Code Reviews| Index: runtime/vm/intermediate_language.h |
| diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h |
| index 362e76bf7e9f3ef19aa57cea0035667acf362e31..3a834e23c888114f7d12fb564904cc6503586709 100644 |
| --- a/runtime/vm/intermediate_language.h |
| +++ b/runtime/vm/intermediate_language.h |
| @@ -281,6 +281,35 @@ class NotNullConstrainedCompileType : public ConstrainedCompileType { |
| }; |
| +class EffectSet : public ValueObject { |
| + public: |
| + enum Effects { |
| + kNoEffects = 0, |
| + kExternalization = 1, |
| + kLastEffect = kExternalization |
| + }; |
| + |
| + EffectSet(const EffectSet& other) |
| + : ValueObject(), effects_(other.effects_) { |
| + } |
| + |
| + bool IsNone() const { return effects_ == kNoEffects; } |
| + |
| + static EffectSet None() { return EffectSet(kNoEffects); } |
| + static EffectSet All() { |
| + ASSERT(EffectSet::kLastEffect == 1); |
| + return EffectSet(kExternalization); |
| + } |
| + |
| + bool ToInt() { return effects_; } |
| + |
| + private: |
| + explicit EffectSet(intptr_t effects) : effects_(effects) { } |
| + |
| + intptr_t effects_; |
| +}; |
| + |
| + |
| class Value : public ZoneAllocated { |
| public: |
| // A forward iterator that allows removing the current value from the |
| @@ -594,9 +623,6 @@ class Instruction : public ZoneAllocated { |
| // Returns true, if this instruction can deoptimize. |
| virtual bool CanDeoptimize() const = 0; |
| - // Returns true if the instruction may have side effects. |
| - virtual bool HasSideEffect() const = 0; |
| - |
| // Visiting support. |
| virtual void Accept(FlowGraphVisitor* visitor) = 0; |
| @@ -713,12 +739,19 @@ FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) |
| // Insert this instruction after 'prev' after use lists are computed. |
| void InsertAfter(Instruction* prev); |
| - // Returns true if the instruction is affected by side effects. |
| - // Only instructions that are not affected by side effects can participate |
| - // in redundancy elimination or loop invariant code motion. |
| - // TODO(fschneider): Make this abstract and implement for all instructions |
| - // instead of returning the safe default (true). |
| - virtual bool AffectedBySideEffect() const { return true; } |
| + // Returns true if CSE and LICM are allowed for this instruction. |
| + virtual bool AllowsCSE() const { |
| + return false; |
| + } |
| + |
| + // Returns true if the instruction may have side effects. |
|
Florian Schneider
2013/04/29 12:11:54
Returns set of effects created by this instruction
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| + virtual EffectSet Effects() const = 0; |
| + |
| + // Returns set of effects that affect this instruction. |
| + virtual EffectSet Dependencies() const { |
| + UNREACHABLE(); |
| + return EffectSet::All(); |
| + } |
| // Get the block entry for this instruction. |
| virtual BlockEntryInstr* GetBlock() const; |
| @@ -908,7 +941,15 @@ class ParallelMoveInstr : public TemplateInstruction<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { |
| + UNREACHABLE(); // This instruction never visited by optimization passes. |
| + return EffectSet::None(); |
| + } |
| + |
| + virtual EffectSet Dependencies() const { |
| + UNREACHABLE(); // This instruction never visited by optimization passes. |
| + return EffectSet::None(); |
| + } |
| MoveOperands* AddMove(Location dest, Location src) { |
| MoveOperands* move = new MoveOperands(dest, src); |
| @@ -1027,7 +1068,8 @@ class BlockEntryInstr : public Instruction { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| intptr_t try_index() const { return try_index_; } |
| @@ -1216,6 +1258,9 @@ class JoinEntryInstr : public BlockEntryInstr { |
| virtual void PrintTo(BufferFormatter* f) const; |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + |
| private: |
| // Classes that have access to predecessors_ when inlining. |
| friend class BlockEntryInstr; |
| @@ -1526,7 +1571,7 @@ class PhiInstr : public Definition { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| // Phi is alive if it reaches a non-environment use. |
| bool is_alive() const { return is_alive_; } |
| @@ -1603,7 +1648,8 @@ class ParameterInstr : public Definition { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual intptr_t Hashcode() const { |
| UNREACHABLE(); |
| @@ -1659,7 +1705,7 @@ class PushArgumentInstr : public Definition { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| @@ -1703,7 +1749,7 @@ class ReturnInstr : public TemplateInstruction<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -1724,7 +1770,7 @@ class ThrowInstr : public TemplateInstruction<0> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -1745,7 +1791,7 @@ class ReThrowInstr : public TemplateInstruction<0> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -1777,7 +1823,7 @@ class GotoInstr : public TemplateInstruction<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| ParallelMoveInstr* parallel_move() const { |
| return parallel_move_; |
| @@ -1845,7 +1891,7 @@ class BranchInstr : public ControlInstruction { |
| virtual bool CanDeoptimize() const; |
| virtual bool CanBeDeoptimizationTarget() const; |
| - virtual bool HasSideEffect() const; |
| + virtual EffectSet Effects() const; |
| ComparisonInstr* comparison() const { return comparison_; } |
| void SetComparison(ComparisonInstr* comp); |
| @@ -1918,7 +1964,7 @@ class StoreContextInstr : public TemplateInstruction<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| DISALLOW_COPY_AND_ASSIGN(StoreContextInstr); |
| @@ -2135,7 +2181,7 @@ class ConstraintInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const { |
| UNREACHABLE(); |
| @@ -2193,12 +2239,12 @@ class ConstantInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual void InferRange(); |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const; |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual void InferRange(); |
| private: |
| const Object& value_; |
| @@ -2244,13 +2290,13 @@ class AssertAssignableInstr : public TemplateDefinition<3> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| - virtual bool AffectedBySideEffect() const { return false; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const; |
| - virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| - |
| private: |
| const intptr_t token_pos_; |
| AbstractType& dst_type_; |
| @@ -2277,13 +2323,13 @@ class AssertBooleanInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| - virtual bool AffectedBySideEffect() const { return false; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| - |
| private: |
| const intptr_t token_pos_; |
| @@ -2316,7 +2362,7 @@ class ArgumentDefinitionTestInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const ArgumentDefinitionTestNode& ast_node_; |
| @@ -2336,8 +2382,8 @@ class CurrentContextInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const { return true; } |
| private: |
| @@ -2366,7 +2412,7 @@ class ClosureCallInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
| private: |
| const ClosureCallNode& ast_node_; |
| @@ -2428,7 +2474,7 @@ class InstanceCallInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
| protected: |
| friend class FlowGraphOptimizer; |
| @@ -2474,7 +2520,7 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| @@ -2542,8 +2588,8 @@ inline bool BranchInstr::CanBeDeoptimizationTarget() const { |
| } |
| -inline bool BranchInstr::HasSideEffect() const { |
| - return comparison()->HasSideEffect(); |
| +inline EffectSet BranchInstr::Effects() const { |
| + return comparison()->Effects(); |
| } |
| @@ -2585,11 +2631,6 @@ class StrictCompareInstr : public ComparisonInstr { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const; |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
| @@ -2599,6 +2640,11 @@ class StrictCompareInstr : public ComparisonInstr { |
| void set_needs_number_check(bool value) { needs_number_check_ = value; } |
| void set_kind(Token::Kind value) { kind_ = value; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const; |
| + |
| private: |
| // True if the comparison must check for double, Mint or Bigint and |
| // use value comparison instead. |
| @@ -2650,10 +2696,6 @@ class EqualityCompareInstr : public ComparisonInstr { |
| return !IsInlinedNumericComparison(); |
| } |
| - virtual bool HasSideEffect() const { |
| - return !IsInlinedNumericComparison(); |
| - } |
| - |
| virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
| BranchInstr* branch); |
| @@ -2670,6 +2712,10 @@ class EqualityCompareInstr : public ComparisonInstr { |
| bool IsPolymorphic() const; |
| + virtual EffectSet Effects() const { |
| + return IsInlinedNumericComparison() ? EffectSet::None() : EffectSet::All(); |
| + } |
| + |
| private: |
| const ICData* ic_data_; |
| const intptr_t token_pos_; |
| @@ -2724,9 +2770,6 @@ class RelationalOpInstr : public ComparisonInstr { |
| virtual bool CanDeoptimize() const { |
| return !IsInlinedNumericComparison(); |
| } |
| - virtual bool HasSideEffect() const { |
| - return !IsInlinedNumericComparison(); |
| - } |
| virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
| BranchInstr* branch); |
| @@ -2743,6 +2786,10 @@ class RelationalOpInstr : public ComparisonInstr { |
| return kTagged; |
| } |
| + virtual EffectSet Effects() const { |
| + return IsInlinedNumericComparison() ? EffectSet::None() : EffectSet::All(); |
| + } |
| + |
| private: |
| const ICData* ic_data_; |
| const intptr_t token_pos_; |
| @@ -2785,18 +2832,6 @@ class IfThenElseInstr : public TemplateDefinition<2> { |
| virtual void InferRange(); |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - IfThenElseInstr* other_if_then_else = other->AsIfThenElse(); |
| - return (kind_ == other_if_then_else->kind_) && |
| - (if_true_ == other_if_then_else->if_true_) && |
| - (if_false_ == other_if_then_else->if_false_); |
| - } |
| - |
| - virtual bool AffectedBySideEffect() const { |
| - return false; |
| - } |
| Value* left() const { return inputs_[0]; } |
| Value* right() const { return inputs_[1]; } |
| @@ -2805,6 +2840,16 @@ class IfThenElseInstr : public TemplateDefinition<2> { |
| Token::Kind kind() const { return kind_; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + IfThenElseInstr* other_if_then_else = other->AsIfThenElse(); |
| + return (kind_ == other_if_then_else->kind_) && |
| + (if_true_ == other_if_then_else->if_true_) && |
| + (if_false_ == other_if_then_else->if_false_); |
| + } |
| + |
| private: |
| const Token::Kind kind_; |
| const intptr_t if_true_; |
| @@ -2845,9 +2890,10 @@ class StaticCallInstr : public TemplateDefinition<0> { |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| + |
|
Florian Schneider
2013/04/29 12:11:54
Extra \n?
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
| void set_result_cid(intptr_t value) { result_cid_ = value; } |
| @@ -2884,9 +2930,9 @@ class LoadLocalInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { |
| + virtual EffectSet Effects() const { |
| UNREACHABLE(); |
|
Florian Schneider
2013/04/29 12:11:54
Maybe add a comment: // Never used in optimizing c
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| - return false; |
| + return EffectSet::None(); |
| } |
| void mark_last() { is_last_ = true; } |
| @@ -2917,17 +2963,17 @@ class StoreLocalInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { |
| - UNREACHABLE(); |
| - return false; |
| - } |
| - |
| void mark_dead() { is_dead_ = true; } |
| bool is_dead() const { return is_dead_; } |
| void mark_last() { is_last_ = true; } |
| bool is_last() const { return is_last_; } |
| + virtual EffectSet Effects() const { |
| + UNREACHABLE(); |
|
Florian Schneider
2013/04/29 12:11:54
Maybe add a comment: // Never used in optimizing c
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| + return EffectSet::None(); |
| + } |
| + |
| private: |
| const LocalVariable& local_; |
| bool is_dead_; |
| @@ -2960,7 +3006,7 @@ class NativeCallInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
| private: |
| const NativeBodyNode& ast_node_; |
| @@ -3003,7 +3049,7 @@ class StoreInstanceFieldInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
|
Florian Schneider
2013/04/29 12:11:54
Add a comment why stores are excluded from side ef
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| private: |
| bool CanValueBeSmi() const { |
| @@ -3030,25 +3076,24 @@ class GuardFieldInstr : public TemplateInstruction<1> { |
| SetInputAt(0, value); |
| } |
| + Value* value() const { return inputs_[0]; } |
| + |
| + const Field& field() const { return field_; } |
| + |
| DECLARE_INSTRUCTION(GuardField) |
| virtual intptr_t ArgumentCount() const { return 0; } |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const; |
| - |
| - virtual bool AffectedBySideEffect() const; |
| - |
| - Value* value() const { return inputs_[0]; } |
| - |
| virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - const Field& field() const { return field_; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const; |
| private: |
| const Field& field_; |
| @@ -3070,9 +3115,9 @@ class LoadStaticFieldInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return !field().is_final(); } |
| + virtual bool AllowsCSE() const { return field_.is_final(); } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const; |
| virtual bool AttributesEqual(Instruction* other) const; |
| private: |
| @@ -3100,7 +3145,7 @@ class StoreStaticFieldInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
|
Florian Schneider
2013/04/29 12:11:54
Add a comment why stores are excluded from side ef
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| private: |
| bool CanValueBeSmi() const { |
| @@ -3152,16 +3197,15 @@ class LoadIndexedInstr : public TemplateDefinition<2> { |
| return deopt_id_ != Isolate::kNoDeoptId; |
| } |
| - virtual bool HasSideEffect() const { return false; } |
| virtual Representation representation() const; |
| + virtual void InferRange(); |
| + virtual bool AllowsCSE() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const; |
| virtual bool AttributesEqual(Instruction* other) const; |
| - virtual bool AffectedBySideEffect() const { return true; } |
| - |
| - virtual void InferRange(); |
| - |
| private: |
| const intptr_t index_scale_; |
| const intptr_t class_id_; |
| @@ -3187,11 +3231,12 @@ class StringFromCharCodeInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return other->AsStringFromCharCode()->cid_ == cid_; |
| + } |
| private: |
| const intptr_t cid_; |
| @@ -3233,8 +3278,6 @@ class StoreIndexedInstr : public TemplateDefinition<3> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| - |
| virtual Representation RequiredInputRepresentation(intptr_t idx) const; |
| bool IsExternal() const { |
| @@ -3247,6 +3290,8 @@ class StoreIndexedInstr : public TemplateDefinition<3> { |
| return deopt_id_; |
| } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + |
| private: |
| const StoreBarrierType emit_store_barrier_; |
| const intptr_t index_scale_; |
| @@ -3270,7 +3315,7 @@ class BooleanNegateInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| DISALLOW_COPY_AND_ASSIGN(BooleanNegateInstr); |
| @@ -3311,7 +3356,7 @@ class InstanceOfInstr : public TemplateDefinition<3> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -3351,7 +3396,7 @@ class AllocateObjectInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const ConstructorCallNode& ast_node_; |
| @@ -3381,7 +3426,7 @@ class AllocateObjectWithBoundsCheckInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const ConstructorCallNode& ast_node_; |
| @@ -3418,7 +3463,7 @@ class CreateArrayInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -3453,7 +3498,7 @@ class CreateClosureInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const Function& function_; |
| @@ -3481,14 +3526,13 @@ class LoadUntaggedInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| // This instruction must not be moved without the indexed access that |
| // depends on it (e.g. out of loops). GC may cause collect |
| // the array while the external data-array is still accessed. |
| - virtual bool AffectedBySideEffect() const { return true; } |
| + virtual bool AllowsCSE() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| private: |
| intptr_t offset_; |
| @@ -3514,26 +3558,17 @@ class LoadFieldInstr : public TemplateDefinition<1> { |
| SetInputAt(0, value); |
| } |
| - DECLARE_INSTRUCTION(LoadField) |
| - virtual CompileType ComputeType() const; |
| - |
| Value* value() const { return inputs_[0]; } |
| intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| const AbstractType& type() const { return type_; } |
| void set_result_cid(intptr_t value) { result_cid_ = value; } |
| intptr_t result_cid() const { return result_cid_; } |
| - virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - |
| - virtual bool CanDeoptimize() const { return false; } |
| - |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const; |
| - |
| - virtual bool AffectedBySideEffect() const { return !immutable_; } |
| + void set_field_name(const char* name) { field_name_ = name; } |
| + const char* field_name() const { return field_name_; } |
| - virtual void InferRange(); |
| + Field* field() const { return field_; } |
| + void set_field(Field* field) { field_ = field; } |
| void set_recognized_kind(MethodRecognizer::Kind kind) { |
| recognized_kind_ = kind; |
| @@ -3543,6 +3578,15 @@ class LoadFieldInstr : public TemplateDefinition<1> { |
| return recognized_kind_; |
| } |
| + DECLARE_INSTRUCTION(LoadField) |
| + virtual CompileType ComputeType() const; |
| + |
| + virtual void PrintOperandsTo(BufferFormatter* f) const; |
| + |
| + virtual bool CanDeoptimize() const { return false; } |
| + |
| + virtual void InferRange(); |
| + |
| bool IsImmutableLengthLoad() const; |
| virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| @@ -3551,11 +3595,10 @@ class LoadFieldInstr : public TemplateDefinition<1> { |
| static bool IsFixedLengthArrayCid(intptr_t cid); |
| - void set_field_name(const char* name) { field_name_ = name; } |
| - const char* field_name() const { return field_name_; } |
| - |
| - Field* field() const { return field_; } |
| - void set_field(Field* field) { field_ = field; } |
| + virtual bool AllowsCSE() const { return immutable_; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const; |
| + virtual bool AttributesEqual(Instruction* other) const; |
| private: |
| const intptr_t offset_in_bytes_; |
| @@ -3596,7 +3639,7 @@ class StoreVMFieldInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t offset_in_bytes_; |
| @@ -3629,7 +3672,7 @@ class InstantiateTypeArgumentsInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
|
Florian Schneider
2013/04/29 12:11:54
It seems this could be ::None() as well.
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
|
| private: |
| const intptr_t token_pos_; |
| @@ -3662,7 +3705,7 @@ class ExtractConstructorTypeArgumentsInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -3691,7 +3734,7 @@ class ExtractConstructorInstantiatorInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const ConstructorCallNode& ast_node_; |
| @@ -3717,7 +3760,7 @@ class AllocateContextInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -3741,7 +3784,7 @@ class ChainContextInstr : public TemplateInstruction<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| DISALLOW_COPY_AND_ASSIGN(ChainContextInstr); |
| @@ -3763,7 +3806,7 @@ class CloneContextInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -3789,7 +3832,7 @@ class CatchEntryInstr : public TemplateInstruction<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::All(); } |
| private: |
| const LocalVariable& exception_var_; |
| @@ -3809,24 +3852,22 @@ class CheckEitherNonSmiInstr : public TemplateInstruction<2> { |
| deopt_id_ = instance_call->deopt_id(); |
| } |
| + Value* left() const { return inputs_[0]; } |
| + Value* right() const { return inputs_[1]; } |
| + |
| DECLARE_INSTRUCTION(CheckEitherNonSmi) |
| virtual intptr_t ArgumentCount() const { return 0; } |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - Value* left() const { return inputs_[0]; } |
| - |
| - Value* right() const { return inputs_[1]; } |
| - |
| - virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| - |
| private: |
| DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); |
| }; |
| @@ -3840,20 +3881,20 @@ class BoxDoubleInstr : public TemplateDefinition<1> { |
| Value* value() const { return inputs_[0]; } |
| - virtual bool CanDeoptimize() const { return false; } |
| - |
| - virtual bool HasSideEffect() const { return false; } |
| + DECLARE_INSTRUCTION(BoxDouble) |
| + virtual CompileType ComputeType() const; |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + virtual bool CanDeoptimize() const { return false; } |
| virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| ASSERT(idx == 0); |
| return kUnboxedDouble; |
| } |
| - DECLARE_INSTRUCTION(BoxDouble) |
| - virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| private: |
| DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); |
| @@ -3870,11 +3911,6 @@ class BoxFloat32x4Instr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| ASSERT(idx == 0); |
| return kUnboxedFloat32x4; |
| @@ -3883,6 +3919,11 @@ class BoxFloat32x4Instr : public TemplateDefinition<1> { |
| DECLARE_INSTRUCTION(BoxFloat32x4) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(BoxFloat32x4Instr); |
| }; |
| @@ -3898,11 +3939,6 @@ class BoxIntegerInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| ASSERT(idx == 0); |
| return kUnboxedMint; |
| @@ -3911,6 +3947,11 @@ class BoxIntegerInstr : public TemplateDefinition<1> { |
| DECLARE_INSTRUCTION(BoxInteger) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(BoxIntegerInstr); |
| }; |
| @@ -3930,18 +3971,18 @@ class UnboxDoubleInstr : public TemplateDefinition<1> { |
| && (value()->Type()->ToCid() != kSmiCid); |
| } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| virtual Representation representation() const { |
| return kUnboxedDouble; |
| } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| DECLARE_INSTRUCTION(UnboxDouble) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); |
| }; |
| @@ -3960,18 +4001,18 @@ class UnboxFloat32x4Instr : public TemplateDefinition<1> { |
| return (value()->Type()->ToCid() != kFloat32x4Cid); |
| } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| virtual Representation representation() const { |
| return kUnboxedFloat32x4; |
| } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| DECLARE_INSTRUCTION(UnboxFloat32x4) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(UnboxFloat32x4Instr); |
| }; |
| @@ -3991,19 +4032,18 @@ class UnboxIntegerInstr : public TemplateDefinition<1> { |
| && (value()->Type()->ToCid() != kMintCid); |
| } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual CompileType ComputeType() const; |
| - |
| virtual Representation representation() const { |
| return kUnboxedMint; |
| } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| DECLARE_INSTRUCTION(UnboxInteger) |
| + virtual CompileType ComputeType() const; |
| + |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| private: |
| DISALLOW_COPY_AND_ASSIGN(UnboxIntegerInstr); |
| @@ -4021,12 +4061,6 @@ class MathSqrtInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return true; |
| - } |
| - |
| virtual Representation representation() const { |
| return kUnboxedDouble; |
| } |
| @@ -4045,6 +4079,11 @@ class MathSqrtInstr : public TemplateDefinition<1> { |
| DECLARE_INSTRUCTION(MathSqrt) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr); |
| }; |
| @@ -4071,14 +4110,6 @@ class BinaryDoubleOpInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return op_kind() == other->AsBinaryDoubleOp()->op_kind(); |
| - } |
| - |
| virtual Representation representation() const { |
| return kUnboxedDouble; |
| } |
| @@ -4099,6 +4130,13 @@ class BinaryDoubleOpInstr : public TemplateDefinition<2> { |
| virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return op_kind() == other->AsBinaryDoubleOp()->op_kind(); |
| + } |
| + |
| private: |
| const Token::Kind op_kind_; |
| @@ -4127,14 +4165,6 @@ class BinaryFloat32x4OpInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return op_kind() == other->AsBinaryFloat32x4Op()->op_kind(); |
| - } |
| - |
| virtual Representation representation() const { |
| return kUnboxedFloat32x4; |
| } |
| @@ -4153,6 +4183,13 @@ class BinaryFloat32x4OpInstr : public TemplateDefinition<2> { |
| DECLARE_INSTRUCTION(BinaryFloat32x4Op) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return op_kind() == other->AsBinaryFloat32x4Op()->op_kind(); |
| + } |
| + |
| private: |
| const Token::Kind op_kind_; |
| @@ -4177,14 +4214,6 @@ class Float32x4ShuffleInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return op_kind() == other->AsFloat32x4Shuffle()->op_kind(); |
| - } |
| - |
| virtual Representation representation() const { |
| if ((op_kind_ == MethodRecognizer::kFloat32x4ShuffleX) || |
| (op_kind_ == MethodRecognizer::kFloat32x4ShuffleY) || |
| @@ -4209,6 +4238,13 @@ class Float32x4ShuffleInstr : public TemplateDefinition<1> { |
| DECLARE_INSTRUCTION(Float32x4Shuffle) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return op_kind() == other->AsFloat32x4Shuffle()->op_kind(); |
| + } |
| + |
| private: |
| const MethodRecognizer::Kind op_kind_; |
| @@ -4236,12 +4272,6 @@ class Float32x4ConstructorInstr : public TemplateDefinition<4> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| virtual Representation representation() const { |
| return kUnboxedFloat32x4; |
| } |
| @@ -4260,6 +4290,11 @@ class Float32x4ConstructorInstr : public TemplateDefinition<4> { |
| DECLARE_INSTRUCTION(Float32x4Constructor) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(Float32x4ConstructorInstr); |
| }; |
| @@ -4278,12 +4313,6 @@ class Float32x4SplatInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| virtual Representation representation() const { |
| return kUnboxedFloat32x4; |
| } |
| @@ -4302,6 +4331,11 @@ class Float32x4SplatInstr : public TemplateDefinition<1> { |
| DECLARE_INSTRUCTION(Float32x4Splat) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(Float32x4SplatInstr); |
| }; |
| @@ -4319,12 +4353,6 @@ class Float32x4ZeroInstr : public TemplateDefinition<0> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| virtual Representation representation() const { |
| return kUnboxedFloat32x4; |
| } |
| @@ -4343,6 +4371,11 @@ class Float32x4ZeroInstr : public TemplateDefinition<0> { |
| DECLARE_INSTRUCTION(Float32x4Zero) |
| virtual CompileType ComputeType() const; |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(Float32x4ZeroInstr); |
| }; |
| @@ -4374,17 +4407,6 @@ class BinaryMintOpInstr : public TemplateDefinition<2> { |
| return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); |
| } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - ASSERT(other->IsBinaryMintOp()); |
| - return op_kind() == other->AsBinaryMintOp()->op_kind(); |
| - } |
| - |
| - virtual CompileType ComputeType() const; |
| - |
| virtual Representation representation() const { |
| return kUnboxedMint; |
| } |
| @@ -4403,6 +4425,15 @@ class BinaryMintOpInstr : public TemplateDefinition<2> { |
| virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| DECLARE_INSTRUCTION(BinaryMintOp) |
| + virtual CompileType ComputeType() const; |
| + |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + ASSERT(other->IsBinaryMintOp()); |
| + return op_kind() == other->AsBinaryMintOp()->op_kind(); |
| + } |
| private: |
| const Token::Kind op_kind_; |
| @@ -4434,14 +4465,6 @@ class ShiftMintOpInstr : public TemplateDefinition<2> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return op_kind() == other->AsShiftMintOp()->op_kind(); |
| - } |
| - |
| virtual CompileType ComputeType() const; |
| virtual Representation representation() const { |
| @@ -4461,6 +4484,13 @@ class ShiftMintOpInstr : public TemplateDefinition<2> { |
| DECLARE_INSTRUCTION(ShiftMintOp) |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return op_kind() == other->AsShiftMintOp()->op_kind(); |
| + } |
| + |
| private: |
| const Token::Kind op_kind_; |
| @@ -4487,16 +4517,6 @@ class UnaryMintOpInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return op_kind() == other->AsUnaryMintOp()->op_kind(); |
| - } |
| - |
| - virtual CompileType ComputeType() const; |
| - |
| virtual Representation representation() const { |
| return kUnboxedMint; |
| } |
| @@ -4513,6 +4533,14 @@ class UnaryMintOpInstr : public TemplateDefinition<1> { |
| } |
| DECLARE_INSTRUCTION(UnaryMintOp) |
| + virtual CompileType ComputeType() const; |
| + |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return op_kind() == other->AsUnaryMintOp()->op_kind(); |
| + } |
| private: |
| const Token::Kind op_kind_; |
| @@ -4545,28 +4573,23 @@ class BinarySmiOpInstr : public TemplateDefinition<2> { |
| const ICData* ic_data() const { return instance_call()->ic_data(); } |
| + void set_overflow(bool overflow) { overflow_ = overflow; } |
| + |
| + void set_is_truncating(bool value) { is_truncating_ = value; } |
| + bool is_truncating() const { return is_truncating_; } |
| + |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| DECLARE_INSTRUCTION(BinarySmiOp) |
| - |
| virtual CompileType ComputeType() const; |
| virtual bool CanDeoptimize() const; |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const; |
| - void set_overflow(bool overflow) { |
| - overflow_ = overflow; |
| - } |
| - |
| - void set_is_truncating(bool value) { |
| - is_truncating_ = value; |
| - } |
| - bool is_truncating() const { return is_truncating_; } |
| - |
| void PrintTo(BufferFormatter* f) const; |
| virtual void InferRange(); |
| @@ -4609,7 +4632,12 @@ class UnarySmiOpInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return other->AsUnarySmiOp()->op_kind() == op_kind(); |
| + } |
| private: |
| const Token::Kind op_kind_; |
| @@ -4631,7 +4659,7 @@ class CheckStackOverflowInstr : public TemplateInstruction<0> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| const intptr_t token_pos_; |
| @@ -4659,8 +4687,9 @@ class SmiToDoubleInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| virtual bool AttributesEqual(Instruction* other) const { return true; } |
| private: |
| @@ -4685,7 +4714,7 @@ class DoubleToIntegerInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| private: |
| InstanceCallInstr* instance_call_; |
| @@ -4710,8 +4739,6 @@ class DoubleToSmiInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| ASSERT(idx == 0); |
| return kUnboxedDouble; |
| @@ -4719,6 +4746,8 @@ class DoubleToSmiInstr : public TemplateDefinition<1> { |
| virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(DoubleToSmiInstr); |
| }; |
| @@ -4743,12 +4772,6 @@ class DoubleToDoubleInstr : public TemplateDefinition<1> { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return other->AsDoubleToDouble()->recognized_kind() == recognized_kind(); |
| - } |
| - |
| virtual Representation representation() const { |
| return kUnboxedDouble; |
| } |
| @@ -4760,6 +4783,13 @@ class DoubleToDoubleInstr : public TemplateDefinition<1> { |
| virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { |
| + return other->AsDoubleToDouble()->recognized_kind() == recognized_kind(); |
| + } |
| + |
| private: |
| const MethodRecognizer::Kind recognized_kind_; |
| @@ -4785,12 +4815,6 @@ class InvokeMathCFunctionInstr : public Definition { |
| virtual bool CanDeoptimize() const { return false; } |
| - virtual bool HasSideEffect() const { return false; } |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - virtual bool AttributesEqual(Instruction* other) const { |
| - return other->AsDoubleToDouble()->recognized_kind() == recognized_kind(); |
| - } |
| - |
| virtual Representation representation() const { |
| return kUnboxedDouble; |
| } |
| @@ -4819,6 +4843,14 @@ class InvokeMathCFunctionInstr : public Definition { |
| return locs_; |
| } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) { |
| + return other->AsInvokeMathCFunction()->recognized_kind() == |
| + recognized_kind(); |
| + } |
| + |
| private: |
| virtual void RawSetInputAt(intptr_t i, Value* value) { |
| (*inputs_)[i] = value; |
| @@ -4846,12 +4878,6 @@ class CheckClassInstr : public TemplateInstruction<1> { |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const; |
| - |
| - virtual bool AffectedBySideEffect() const; |
| - |
| Value* value() const { return inputs_[0]; } |
| const ICData& unary_checks() const { return unary_checks_; } |
| @@ -4864,6 +4890,11 @@ class CheckClassInstr : public TemplateInstruction<1> { |
| bool null_check() const { return null_check_; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const; |
| + virtual bool AttributesEqual(Instruction* other) const; |
| + |
| private: |
| const ICData& unary_checks_; |
| @@ -4881,21 +4912,20 @@ class CheckSmiInstr : public TemplateInstruction<1> { |
| deopt_id_ = original_deopt_id; |
| } |
| + Value* value() const { return inputs_[0]; } |
| + |
| DECLARE_INSTRUCTION(CheckSmi) |
| virtual intptr_t ArgumentCount() const { return 0; } |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const { return true; } |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| - Value* value() const { return inputs_[0]; } |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const { return true; } |
| private: |
| DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); |
| @@ -4914,23 +4944,17 @@ class CheckArrayBoundInstr : public TemplateInstruction<2> { |
| deopt_id_ = instance_call->deopt_id(); |
| } |
| + Value* length() const { return inputs_[0]; } |
| + Value* index() const { return inputs_[1]; } |
| + |
| + intptr_t array_type() const { return array_type_; } |
| + |
| DECLARE_INSTRUCTION(CheckArrayBound) |
| virtual intptr_t ArgumentCount() const { return 0; } |
| virtual bool CanDeoptimize() const { return true; } |
| - virtual bool HasSideEffect() const { return false; } |
| - |
| - virtual bool AttributesEqual(Instruction* other) const; |
| - |
| - virtual bool AffectedBySideEffect() const { return false; } |
| - |
| - Value* length() const { return inputs_[0]; } |
| - Value* index() const { return inputs_[1]; } |
| - |
| - intptr_t array_type() const { return array_type_; } |
| - |
| bool IsRedundant(RangeBoundary length); |
| // Returns the length offset for array and string types. |
| @@ -4938,6 +4962,11 @@ class CheckArrayBoundInstr : public TemplateInstruction<2> { |
| static bool IsFixedLengthArrayType(intptr_t class_id); |
| + virtual bool AllowsCSE() const { return true; } |
| + virtual EffectSet Effects() const { return EffectSet::None(); } |
| + virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| + virtual bool AttributesEqual(Instruction* other) const; |
| + |
| private: |
| intptr_t array_type_; |