diff options
| author | 2015-04-24 15:20:27 +0000 | |
|---|---|---|
| committer | 2015-04-24 15:20:28 +0000 | |
| commit | f16d7b3824b2777b95fb509c1d2a95bef89f65a4 (patch) | |
| tree | c9a0aaf0fa17cabdb5bea88bc80a11b3d8bf499b /compiler/optimizing/nodes.h | |
| parent | 9f3565a632d12c9cadd7d966da308fd26dbc899c (diff) | |
| parent | 2d7352ba5311b8f57427b91b7a891e61497373c1 (diff) | |
Merge "ART: Dead block removal"
Diffstat (limited to 'compiler/optimizing/nodes.h')
| -rw-r--r-- | compiler/optimizing/nodes.h | 30 | 
1 files changed, 21 insertions, 9 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index b89487f4f6..18a8225f55 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -97,6 +97,9 @@ class HInstructionList {    void AddAfter(HInstruction* cursor, const HInstructionList& instruction_list);    void Add(const HInstructionList& instruction_list); +  // Return the number of instructions in the list. This is an expensive operation. +  size_t CountSize() const; +   private:    HInstruction* first_instruction_;    HInstruction* last_instruction_; @@ -168,7 +171,8 @@ class HGraph : public ArenaObject<kArenaAllocMisc> {    // Inline this graph in `outer_graph`, replacing the given `invoke` instruction.    void InlineInto(HGraph* outer_graph, HInvoke* invoke); -  void MergeEmptyBranches(HBasicBlock* start_block, HBasicBlock* end_block); +  // Removes `block` from the graph. +  void DeleteDeadBlock(HBasicBlock* block);    void SplitCriticalEdge(HBasicBlock* block, HBasicBlock* successor);    void SimplifyLoop(HBasicBlock* header); @@ -248,8 +252,9 @@ class HGraph : public ArenaObject<kArenaAllocMisc> {      return CreateConstant(value, &cached_long_constants_);    } - private:    HBasicBlock* FindCommonDominator(HBasicBlock* first, HBasicBlock* second) const; + + private:    void VisitBlockForDominatorTree(HBasicBlock* block,                                    HBasicBlock* predecessor,                                    GrowableArray<size_t>* visits); @@ -451,6 +456,7 @@ class HBasicBlock : public ArenaObject<kArenaAllocMisc> {    HBasicBlock* GetDominator() const { return dominator_; }    void SetDominator(HBasicBlock* dominator) { dominator_ = dominator; }    void AddDominatedBlock(HBasicBlock* block) { dominated_blocks_.Add(block); } +  void RemoveDominatedBlock(HBasicBlock* block) { dominated_blocks_.Delete(block); }    void ReplaceDominatedBlock(HBasicBlock* existing, HBasicBlock* new_block) {      for (size_t i = 0, e = dominated_blocks_.Size(); i < e; ++i) {        if (dominated_blocks_.Get(i) == existing) { @@ -550,7 +556,7 @@ class HBasicBlock : public ArenaObject<kArenaAllocMisc> {    // that this method does not update the graph, reverse post order, loop    // information, nor make sure the blocks are consistent (for example ending    // with a control flow instruction). -  void MergeWith(HBasicBlock* other); +  void MergeWithInlined(HBasicBlock* other);    // Replace `this` with `other`. Predecessors, successors, and dominated blocks    // of `this` are moved to `other`. @@ -559,12 +565,17 @@ class HBasicBlock : public ArenaObject<kArenaAllocMisc> {    // with a control flow instruction).    void ReplaceWith(HBasicBlock* other); -  // Disconnects `this` from all its predecessors, successors and the dominator. -  // It assumes that `this` does not dominate any blocks. -  // Note that this method does not update the graph, reverse post order, loop -  // information, nor make sure the blocks are consistent (for example ending -  // with a control flow instruction). -  void DisconnectFromAll(); +  // Merge `other` at the end of `this`. This method updates loops, reverse post +  // order, links to predecessors, successors, dominators and deletes the block +  // from the graph. The two blocks must be successive, i.e. `this` the only +  // predecessor of `other` and vice versa. +  void MergeWith(HBasicBlock* other); + +  // Disconnects `this` from all its predecessors, successors and dominator, +  // removes it from all loops it is included in and eventually from the graph. +  // The block must not dominate any other block. Predecessors and successors +  // are safely updated. +  void DisconnectAndDelete();    void AddInstruction(HInstruction* instruction);    void InsertInstructionBefore(HInstruction* instruction, HInstruction* cursor); @@ -2746,6 +2757,7 @@ class HPhi : public HInstruction {    size_t InputCount() const OVERRIDE { return inputs_.Size(); }    void AddInput(HInstruction* input); +  void RemoveInputAt(size_t index);    Primitive::Type GetType() const OVERRIDE { return type_; }    void SetType(Primitive::Type type) { type_ = type; }  |