Merge "Intrinsify String.compareTo."
diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc
index bd479be..df72830 100644
--- a/compiler/dex/quick/codegen_util.cc
+++ b/compiler/dex/quick/codegen_util.cc
@@ -1378,11 +1378,16 @@
// In Mir2Lir::MethodBlockCodeGen() we have artificially moved the throwing
// instruction to the previous block. However, the MIRGraph data used above
// doesn't reflect that, so we still need to process that MIR insn here.
- DCHECK_EQ(bb->predecessors.size(), 1u);
- BasicBlock* pred_bb = mir_graph_->GetBasicBlock(bb->predecessors[0]);
- DCHECK(pred_bb != nullptr);
- DCHECK(pred_bb->last_mir_insn != nullptr);
- UpdateReferenceVRegsLocal(nullptr, pred_bb->last_mir_insn, references);
+ MIR* mir = nullptr;
+ BasicBlock* pred_bb = bb;
+ // Traverse empty blocks.
+ while (mir == nullptr && pred_bb->predecessors.size() == 1u) {
+ pred_bb = mir_graph_->GetBasicBlock(bb->predecessors[0]);
+ DCHECK(pred_bb != nullptr);
+ mir = pred_bb->last_mir_insn;
+ }
+ DCHECK(mir != nullptr);
+ UpdateReferenceVRegsLocal(nullptr, mir, references);
}
}
diff --git a/runtime/utils.h b/runtime/utils.h
index 1a7fdfb..e6a6b1d 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -109,12 +109,17 @@
DCHECK(::art::IsAlignedParam(value, alignment)) << reinterpret_cast<const void*>(value)
// Check whether an N-bit two's-complement representation can hold value.
-static inline bool IsInt(int N, intptr_t value) {
- if (N == kBitsPerIntPtrT) return true;
- CHECK_LT(0, N);
- CHECK_LT(N, kBitsPerIntPtrT);
- intptr_t limit = static_cast<intptr_t>(1) << (N - 1);
- return (-limit <= value) && (value < limit);
+template <typename T>
+static inline bool IsInt(int N, T value) {
+ int bitsPerT = sizeof(T) * kBitsPerByte;
+ if (N == bitsPerT) {
+ return true;
+ } else {
+ CHECK_LT(0, N);
+ CHECK_LT(N, bitsPerT);
+ T limit = static_cast<T>(1) << (N - 1);
+ return (-limit <= value) && (value < limit);
+ }
}
template <typename T>
diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc
index 6b36c19..833427e 100644
--- a/runtime/utils_test.cc
+++ b/runtime/utils_test.cc
@@ -432,4 +432,79 @@
EXPECT_EQ(32u, MinimumBitsToStore(~static_cast<uint32_t>(0)));
}
+static constexpr int64_t INT_MIN_minus1 = static_cast<int64_t>(INT_MIN) - 1;
+static constexpr int64_t INT_MAX_plus1 = static_cast<int64_t>(INT_MAX) + 1;
+static constexpr int64_t UINT_MAX_plus1 = static_cast<int64_t>(UINT_MAX) + 1;
+
+TEST_F(UtilsTest, IsInt) {
+ EXPECT_FALSE(IsInt(1, -2));
+ EXPECT_TRUE(IsInt(1, -1));
+ EXPECT_TRUE(IsInt(1, 0));
+ EXPECT_FALSE(IsInt(1, 1));
+
+ EXPECT_FALSE(IsInt(4, -9));
+ EXPECT_TRUE(IsInt(4, -8));
+ EXPECT_TRUE(IsInt(4, 7));
+ EXPECT_FALSE(IsInt(4, 8));
+
+ EXPECT_FALSE(IsInt(32, INT_MIN_minus1));
+ EXPECT_TRUE(IsInt(32, INT_MIN));
+ EXPECT_TRUE(IsInt(32, INT_MAX));
+ EXPECT_FALSE(IsInt(32, INT_MAX_plus1));
+}
+
+TEST_F(UtilsTest, IsInt_Static) {
+ EXPECT_FALSE(IsInt<1>(-2));
+ EXPECT_TRUE(IsInt<1>(-1));
+ EXPECT_TRUE(IsInt<1>(0));
+ EXPECT_FALSE(IsInt<1>(1));
+
+ EXPECT_FALSE(IsInt<4>(-9));
+ EXPECT_TRUE(IsInt<4>(-8));
+ EXPECT_TRUE(IsInt<4>(7));
+ EXPECT_FALSE(IsInt<4>(8));
+
+ EXPECT_FALSE(IsInt<32>(INT_MIN_minus1));
+ EXPECT_TRUE(IsInt<32>(INT_MIN));
+ EXPECT_TRUE(IsInt<32>(INT_MAX));
+ EXPECT_FALSE(IsInt<32>(INT_MAX_plus1));
+}
+
+TEST_F(UtilsTest, IsUint) {
+ EXPECT_FALSE(IsUint<1>(-1));
+ EXPECT_TRUE(IsUint<1>(0));
+ EXPECT_TRUE(IsUint<1>(1));
+ EXPECT_FALSE(IsUint<1>(2));
+
+ EXPECT_FALSE(IsUint<4>(-1));
+ EXPECT_TRUE(IsUint<4>(0));
+ EXPECT_TRUE(IsUint<4>(15));
+ EXPECT_FALSE(IsUint<4>(16));
+
+ EXPECT_FALSE(IsUint<32>(-1));
+ EXPECT_TRUE(IsUint<32>(0));
+ EXPECT_TRUE(IsUint<32>(UINT_MAX));
+ EXPECT_FALSE(IsUint<32>(UINT_MAX_plus1));
+}
+
+TEST_F(UtilsTest, IsAbsoluteUint) {
+ EXPECT_FALSE(IsAbsoluteUint<1>(-2));
+ EXPECT_TRUE(IsAbsoluteUint<1>(-1));
+ EXPECT_TRUE(IsAbsoluteUint<32>(0));
+ EXPECT_TRUE(IsAbsoluteUint<1>(1));
+ EXPECT_FALSE(IsAbsoluteUint<1>(2));
+
+ EXPECT_FALSE(IsAbsoluteUint<4>(-16));
+ EXPECT_TRUE(IsAbsoluteUint<4>(-15));
+ EXPECT_TRUE(IsAbsoluteUint<32>(0));
+ EXPECT_TRUE(IsAbsoluteUint<4>(15));
+ EXPECT_FALSE(IsAbsoluteUint<4>(16));
+
+ EXPECT_FALSE(IsAbsoluteUint<32>(-UINT_MAX_plus1));
+ EXPECT_TRUE(IsAbsoluteUint<32>(-UINT_MAX));
+ EXPECT_TRUE(IsAbsoluteUint<32>(0));
+ EXPECT_TRUE(IsAbsoluteUint<32>(UINT_MAX));
+ EXPECT_FALSE(IsAbsoluteUint<32>(UINT_MAX_plus1));
+}
+
} // namespace art
diff --git a/test/run-all-tests b/test/run-all-tests
index d0b3cf9..13490c4 100755
--- a/test/run-all-tests
+++ b/test/run-all-tests
@@ -112,6 +112,7 @@
shift;
elif [ "x$1" = "x--always-clean" ]; then
run_args="${run_args} --always-clean"
+ shift
elif expr "x$1" : "x--" >/dev/null 2>&1; then
echo "unknown $0 option: $1" 1>&2
usage="yes"