summaryrefslogtreecommitdiff
path: root/compiler/dex/mir_graph.cc
diff options
context:
space:
mode:
author Bill Buzbee <buzbee@android.com> 2014-06-05 22:34:57 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2014-06-05 22:34:57 +0000
commit25c4f6a25b3de9b9d7ca5162f1629753a0b7f003 (patch)
treeea037b8bffd0568edbb835fd1ed06740734375f8 /compiler/dex/mir_graph.cc
parent86e48ce0e82c13d8af470e7c2abe1bfb3c1e0136 (diff)
parent04f4d8abe45d6e79eca983e057de76aea24b7df9 (diff)
Merge "Add an optimization for removing redundant suspend tests in ART"
Diffstat (limited to 'compiler/dex/mir_graph.cc')
-rw-r--r--compiler/dex/mir_graph.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc
index 3ef1dbfac3..a2676c82ca 100644
--- a/compiler/dex/mir_graph.cc
+++ b/compiler/dex/mir_graph.cc
@@ -111,7 +111,8 @@ MIRGraph::MIRGraph(CompilationUnit* cu, ArenaAllocator* arena)
merged_df_flags_(0u),
ifield_lowering_infos_(arena, 0u),
sfield_lowering_infos_(arena, 0u),
- method_lowering_infos_(arena, 0u) {
+ method_lowering_infos_(arena, 0u),
+ gen_suspend_test_list_(arena, 0u) {
try_block_addr_ = new (arena_) ArenaBitVector(arena_, 0, true /* expandable */);
max_available_special_compiler_temps_ = std::abs(static_cast<int>(kVRegNonSpecialTempBaseReg))
- std::abs(static_cast<int>(kVRegTempBaseReg));
@@ -1533,6 +1534,24 @@ bool BasicBlock::IsExceptionBlock() const {
return false;
}
+bool MIRGraph::HasSuspendTestBetween(BasicBlock* source, BasicBlockId target_id) {
+ BasicBlock* target = GetBasicBlock(target_id);
+
+ if (source == nullptr || target == nullptr)
+ return false;
+
+ int idx;
+ for (idx = gen_suspend_test_list_.Size() - 1; idx >= 0; idx--) {
+ BasicBlock* bb = gen_suspend_test_list_.Get(idx);
+ if (bb == source)
+ return true; // The block has been inserted by a suspend check before.
+ if (source->dominators->IsBitSet(bb->id) && bb->dominators->IsBitSet(target_id))
+ return true;
+ }
+
+ return false;
+}
+
ChildBlockIterator::ChildBlockIterator(BasicBlock* bb, MIRGraph* mir_graph)
: basic_block_(bb), mir_graph_(mir_graph), visited_fallthrough_(false),
visited_taken_(false), have_successors_(false) {