summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-03-28 14:14:12 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-03-28 14:14:12 +0000
commita708e32a9f764a48175e705ec4bcd2201c84f492 (patch)
treed9eb06938691196a2537ab3d2e7c21f0aab0f86b
parent6d65a2fae299e3ff4597c668e0cae4f1d3a47694 (diff)
parent757b304a2dfaeaee01071c9e2ee5e5a18ea18545 (diff)
downloadart-a708e32a9f764a48175e705ec4bcd2201c84f492.zip
art-a708e32a9f764a48175e705ec4bcd2201c84f492.tar.gz
art-a708e32a9f764a48175e705ec4bcd2201c84f492.tar.bz2
Merge "Properly dump register type in verifier failure messages"
-rw-r--r--runtime/verifier/method_verifier.cc15
-rw-r--r--runtime/verifier/reg_type_test.cc6
2 files changed, 12 insertions, 9 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index fb2d29f..21e3e44 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3377,7 +3377,7 @@ void MethodVerifier::VerifyPrimitivePut(const RegType& target_type, const RegTyp
}
void MethodVerifier::VerifyAPut(const Instruction* inst,
- const RegType& insn_type, bool is_primitive) {
+ const RegType& insn_type, bool is_primitive) {
const RegType& index_type = work_line_->GetRegisterType(inst->VRegC_23x());
if (!index_type.IsArrayIndexTypes()) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Invalid reg type for array index (" << index_type << ")";
@@ -3533,6 +3533,7 @@ void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_ty
const char* descriptor = dex_file_->GetFieldTypeDescriptor(field_id);
field_type = &reg_types_.FromDescriptor(class_loader_->get(), descriptor, false);
}
+ DCHECK(field_type != nullptr);
const uint32_t vregA = (is_static) ? inst->VRegA_21c() : inst->VRegA_22c();
if (is_primitive) {
if (field_type->Equals(insn_type) ||
@@ -3546,14 +3547,14 @@ void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_ty
// compile time
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << PrettyField(field)
<< " to be of type '" << insn_type
- << "' but found type '" << field_type << "' in get";
+ << "' but found type '" << *field_type << "' in get";
return;
}
} else {
if (!insn_type.IsAssignableFrom(*field_type)) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
- << "' but found type '" << field_type
+ << "' but found type '" << *field_type
<< "' in get-object";
work_line_->SetRegisterType(vregA, reg_types_.Conflict());
return;
@@ -3599,6 +3600,7 @@ void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_ty
const char* descriptor = dex_file_->GetFieldTypeDescriptor(field_id);
field_type = &reg_types_.FromDescriptor(class_loader_->get(), descriptor, false);
}
+ DCHECK(field_type != nullptr);
const uint32_t vregA = (is_static) ? inst->VRegA_21c() : inst->VRegA_22c();
if (is_primitive) {
VerifyPrimitivePut(*field_type, insn_type, vregA);
@@ -3606,7 +3608,7 @@ void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_ty
if (!insn_type.IsAssignableFrom(*field_type)) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
- << "' but found type '" << field_type
+ << "' but found type '" << *field_type
<< "' in put-object";
return;
}
@@ -3692,6 +3694,7 @@ void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& ins
field_type = &reg_types_.FromDescriptor(field->GetDeclaringClass()->GetClassLoader(),
fh.GetTypeDescriptor(), false);
}
+ DCHECK(field_type != nullptr);
const uint32_t vregA = inst->VRegA_22c();
if (is_primitive) {
if (field_type->Equals(insn_type) ||
@@ -3705,14 +3708,14 @@ void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& ins
// compile time
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << PrettyField(field)
<< " to be of type '" << insn_type
- << "' but found type '" << field_type << "' in get";
+ << "' but found type '" << *field_type << "' in get";
return;
}
} else {
if (!insn_type.IsAssignableFrom(*field_type)) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
- << "' but found type '" << field_type
+ << "' but found type '" << *field_type
<< "' in get-object";
work_line_->SetRegisterType(vregA, reg_types_.Conflict());
return;
diff --git a/runtime/verifier/reg_type_test.cc b/runtime/verifier/reg_type_test.cc
index 1695fc5..1935a5b 100644
--- a/runtime/verifier/reg_type_test.cc
+++ b/runtime/verifier/reg_type_test.cc
@@ -471,7 +471,7 @@ TEST_F(RegTypeReferenceTest, Merging) {
EXPECT_EQ(ref_type_1.GetId(), *((++merged_ids.begin())));
}
-TEST_F(RegTypeReferenceTest, MergingFloat) {
+TEST_F(RegTypeTest, MergingFloat) {
// Testing merging logic with float and float constants.
ScopedObjectAccess soa(Thread::Current());
RegTypeCache cache_new(true);
@@ -502,7 +502,7 @@ TEST_F(RegTypeReferenceTest, MergingFloat) {
}
}
-TEST_F(RegTypeReferenceTest, MergingLong) {
+TEST_F(RegTypeTest, MergingLong) {
// Testing merging logic with long and long constants.
ScopedObjectAccess soa(Thread::Current());
RegTypeCache cache_new(true);
@@ -556,7 +556,7 @@ TEST_F(RegTypeReferenceTest, MergingLong) {
}
}
-TEST_F(RegTypeReferenceTest, MergingDouble) {
+TEST_F(RegTypeTest, MergingDouble) {
// Testing merging logic with double and double constants.
ScopedObjectAccess soa(Thread::Current());
RegTypeCache cache_new(true);