diff options
Diffstat (limited to 'compiler/optimizing/nodes.h')
| -rw-r--r-- | compiler/optimizing/nodes.h | 51 | 
1 files changed, 24 insertions, 27 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index ab53e63300..7ea6176e96 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -35,6 +35,7 @@  #include "mirror/class.h"  #include "offsets.h"  #include "primitive.h" +#include "utils/array_ref.h"  namespace art { @@ -240,8 +241,9 @@ class HGraph : public ArenaObject<kArenaAllocGraph> {    // put deoptimization instructions, etc.    void TransformLoopHeaderForBCE(HBasicBlock* header); -  // Removes `block` from the graph. -  void DeleteDeadBlock(HBasicBlock* block); +  // Removes `block` from the graph. Assumes `block` has been disconnected from +  // other blocks and has no instructions or phis. +  void DeleteDeadEmptyBlock(HBasicBlock* block);    // Splits the edge between `block` and `successor` while preserving the    // indices in the predecessor/successor lists. If there are multiple edges @@ -659,6 +661,9 @@ class HBasicBlock : public ArenaObject<kArenaAllocBasicBlock> {      return successors_;    } +  ArrayRef<HBasicBlock* const> GetNormalSuccessors() const; +  ArrayRef<HBasicBlock* const> GetExceptionalSuccessors() const; +    bool HasSuccessor(const HBasicBlock* block, size_t start_from = 0u) {      return ContainsElement(successors_, block, start_from);    } @@ -809,12 +814,6 @@ class HBasicBlock : public ArenaObject<kArenaAllocBasicBlock> {      return GetPredecessorIndexOf(predecessor) == idx;    } -  // Returns the number of non-exceptional successors. SsaChecker ensures that -  // these are stored at the beginning of the successor list. -  size_t NumberOfNormalSuccessors() const { -    return EndsWithTryBoundary() ? 1 : GetSuccessors().size(); -  } -    // Create a new block between this block and its predecessors. The new block    // is added to the graph, all predecessor edges are relinked to it and an edge    // is created to `this`. Returns the new empty block. Reverse post order or @@ -2397,6 +2396,10 @@ class HTryBoundary : public HTemplateInstruction<0> {    // Returns the block's non-exceptional successor (index zero).    HBasicBlock* GetNormalFlowSuccessor() const { return GetBlock()->GetSuccessors()[0]; } +  ArrayRef<HBasicBlock* const> GetExceptionHandlers() const { +    return ArrayRef<HBasicBlock* const>(GetBlock()->GetSuccessors()).SubArray(1u); +  } +    // Returns whether `handler` is among its exception handlers (non-zero index    // successors).    bool HasExceptionHandler(const HBasicBlock& handler) const { @@ -2424,25 +2427,6 @@ class HTryBoundary : public HTemplateInstruction<0> {    DISALLOW_COPY_AND_ASSIGN(HTryBoundary);  }; -// Iterator over exception handlers of a given HTryBoundary, i.e. over -// exceptional successors of its basic block. -class HExceptionHandlerIterator : public ValueObject { - public: -  explicit HExceptionHandlerIterator(const HTryBoundary& try_boundary) -    : block_(*try_boundary.GetBlock()), index_(block_.NumberOfNormalSuccessors()) {} - -  bool Done() const { return index_ == block_.GetSuccessors().size(); } -  HBasicBlock* Current() const { return block_.GetSuccessors()[index_]; } -  size_t CurrentSuccessorIndex() const { return index_; } -  void Advance() { ++index_; } - - private: -  const HBasicBlock& block_; -  size_t index_; - -  DISALLOW_COPY_AND_ASSIGN(HExceptionHandlerIterator); -}; -  // Deoptimize to interpreter, upon checking a condition.  class HDeoptimize : public HTemplateInstruction<1> {   public: @@ -2611,6 +2595,11 @@ class HBinaryOperation : public HExpression<2> {      VLOG(compiler) << DebugName() << " is not defined for the (long, int) case.";      return nullptr;    } +  virtual HConstant* Evaluate(HNullConstant* x ATTRIBUTE_UNUSED, +                              HNullConstant* y ATTRIBUTE_UNUSED) const { +    VLOG(compiler) << DebugName() << " is not defined for the (null, null) case."; +    return nullptr; +  }    // Returns an input that can legally be used as the right input and is    // constant, or null. @@ -2701,6 +2690,10 @@ class HEqual : public HCondition {      return GetBlock()->GetGraph()->GetIntConstant(          Compute(x->GetValue(), y->GetValue()), GetDexPc());    } +  HConstant* Evaluate(HNullConstant* x ATTRIBUTE_UNUSED, +                      HNullConstant* y ATTRIBUTE_UNUSED) const OVERRIDE { +    return GetBlock()->GetGraph()->GetConstant(GetType(), 1); +  }    DECLARE_INSTRUCTION(Equal); @@ -2733,6 +2726,10 @@ class HNotEqual : public HCondition {      return GetBlock()->GetGraph()->GetIntConstant(          Compute(x->GetValue(), y->GetValue()), GetDexPc());    } +  HConstant* Evaluate(HNullConstant* x ATTRIBUTE_UNUSED, +                      HNullConstant* y ATTRIBUTE_UNUSED) const OVERRIDE { +    return GetBlock()->GetGraph()->GetConstant(GetType(), 0); +  }    DECLARE_INSTRUCTION(NotEqual);  |