summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-03-28 14:34:28 +0100
committerSebastien Hertz <shertz@google.com>2014-03-28 14:44:56 +0100
commit757b304a2dfaeaee01071c9e2ee5e5a18ea18545 (patch)
tree572aa5a984c978b6a7054db05768b69c82d89ed3
parentad174d1b54bf2fa477bec71a0ca93595f54b8fe9 (diff)
downloadart-757b304a2dfaeaee01071c9e2ee5e5a18ea18545.zip
art-757b304a2dfaeaee01071c9e2ee5e5a18ea18545.tar.gz
art-757b304a2dfaeaee01071c9e2ee5e5a18ea18545.tar.bz2
Properly dump register type in verifier failure messages
Fixes failure messages where we miss to dereference pointer to RegType. This caused to dump the address of the reg type instead of the reg type itself. Also moves merging tests of primitive types from RegTypeReferenceTest to RegTypeTest class. Change-Id: I71cea419fdaa9ac46d7c011eb23e8746a14fb378
-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);