summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2014-05-07 15:15:46 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-05-07 15:15:46 +0000
commit221b86d96f6e1971d24e3d6a283352c58cedbd32 (patch)
treef80439dc10bf971004472a7aa609aa0a9cff65eb
parent60280e50c1ef4a7ef286670975a81f8384138f42 (diff)
parentb5c9b4008760c9042061490f22aaff990ed04c9a (diff)
downloadandroid_art-221b86d96f6e1971d24e3d6a283352c58cedbd32.tar.gz
android_art-221b86d96f6e1971d24e3d6a283352c58cedbd32.tar.bz2
android_art-221b86d96f6e1971d24e3d6a283352c58cedbd32.zip
Merge "ART: BitVector and Optimization changes"
-rw-r--r--compiler/dex/mir_optimization.cc28
-rw-r--r--runtime/base/bit_vector.cc11
2 files changed, 21 insertions, 18 deletions
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 5cc994f692..413b4e0f75 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -735,18 +735,20 @@ bool MIRGraph::EliminateNullChecksAndInferTypes(BasicBlock* bb) {
if (pred_bb->block_type == kDalvikByteCode) {
// Check to see if predecessor had an explicit null-check.
MIR* last_insn = pred_bb->last_mir_insn;
- Instruction::Code last_opcode = last_insn->dalvikInsn.opcode;
- if (last_opcode == Instruction::IF_EQZ) {
- if (pred_bb->fall_through == bb->id) {
- // The fall-through of a block following a IF_EQZ, set the vA of the IF_EQZ to show that
- // it can't be null.
- ssa_regs_to_check->ClearBit(last_insn->ssa_rep->uses[0]);
- }
- } else if (last_opcode == Instruction::IF_NEZ) {
- if (pred_bb->taken == bb->id) {
- // The taken block following a IF_NEZ, set the vA of the IF_NEZ to show that it can't be
- // null.
- ssa_regs_to_check->ClearBit(last_insn->ssa_rep->uses[0]);
+ if (last_insn != nullptr) {
+ Instruction::Code last_opcode = last_insn->dalvikInsn.opcode;
+ if (last_opcode == Instruction::IF_EQZ) {
+ if (pred_bb->fall_through == bb->id) {
+ // The fall-through of a block following a IF_EQZ, set the vA of the IF_EQZ to show that
+ // it can't be null.
+ ssa_regs_to_check->ClearBit(last_insn->ssa_rep->uses[0]);
+ }
+ } else if (last_opcode == Instruction::IF_NEZ) {
+ if (pred_bb->taken == bb->id) {
+ // The taken block following a IF_NEZ, set the vA of the IF_NEZ to show that it can't be
+ // null.
+ ssa_regs_to_check->ClearBit(last_insn->ssa_rep->uses[0]);
+ }
}
}
}
@@ -895,7 +897,7 @@ bool MIRGraph::EliminateNullChecksAndInferTypes(BasicBlock* bb) {
temp_scoped_alloc_.get(), temp_bit_vector_size_, false, kBitMapNullCheck);
nce_changed = ssa_regs_to_check->GetHighestBitSet() != -1;
bb->data_flow_info->ending_check_v->Copy(ssa_regs_to_check);
- } else if (!ssa_regs_to_check->Equal(bb->data_flow_info->ending_check_v)) {
+ } else if (!ssa_regs_to_check->SameBitsSet(bb->data_flow_info->ending_check_v)) {
nce_changed = true;
bb->data_flow_info->ending_check_v->Copy(ssa_regs_to_check);
}
diff --git a/runtime/base/bit_vector.cc b/runtime/base/bit_vector.cc
index 47e85a3b79..0e01dc2349 100644
--- a/runtime/base/bit_vector.cc
+++ b/runtime/base/bit_vector.cc
@@ -115,23 +115,24 @@ bool BitVector::SameBitsSet(const BitVector *src) {
// If the highest bit set is different, we are different.
if (our_highest != src_highest) {
- return true;
+ return false;
}
// If the highest bit set is -1, both are cleared, we are the same.
// If the highest bit set is 0, both have a unique bit set, we are the same.
- if (our_highest >= 0) {
+ if (our_highest <= 0) {
return true;
}
- // Get the highest bit set's cell's index.
- int our_highest_index = (our_highest >> 5);
+ // Get the highest bit set's cell's index
+ // No need of highest + 1 here because it can't be 0 so BitsToWords will work here.
+ int our_highest_index = BitsToWords(our_highest);
// This memcmp is enough: we know that the highest bit set is the same for both:
// - Therefore, min_size goes up to at least that, we are thus comparing at least what we need to, but not less.
// ie. we are comparing all storage cells that could have difference, if both vectors have cells above our_highest_index,
// they are automatically at 0.
- return (memcmp(storage_, src->GetRawStorage(), our_highest_index * sizeof(*storage_)) != 0);
+ return (memcmp(storage_, src->GetRawStorage(), our_highest_index * sizeof(*storage_)) == 0);
}
// Intersect with another bit vector.