diff options
| author | 2016-03-25 23:53:20 +0000 | |
|---|---|---|
| committer | 2016-03-25 23:53:20 +0000 | |
| commit | 782d0464ddc92fd5d55a330068d2d255336c16ba (patch) | |
| tree | 13bc06446b57ee348d4d893063bcde99ddc3288b | |
| parent | 91ac272c11775630735dde3190de9f2da8f3f3eb (diff) | |
| parent | 8d8fc48664205e433cfa5540753b38043d918873 (diff) | |
Merge "ART: Relax verifier checks"
| -rw-r--r-- | runtime/verifier/method_verifier.cc | 8 | ||||
| -rw-r--r-- | runtime/verifier/reg_type.cc | 2 | ||||
| -rw-r--r-- | runtime/verifier/reg_type_cache.cc | 2 | ||||
| -rw-r--r-- | test/800-smali/expected.txt | 1 | ||||
| -rw-r--r-- | test/800-smali/smali/b_27799205_6.smali | 24 | ||||
| -rw-r--r-- | test/800-smali/smali/b_27799205_helper.smali | 7 | ||||
| -rw-r--r-- | test/800-smali/src/Main.java | 1 |
7 files changed, 41 insertions, 4 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 9bcbdbd261..55d1720c73 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -4258,7 +4258,7 @@ void MethodVerifier::VerifyAGet(const Instruction* inst, } } else if (!array_type.IsArrayTypes()) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "not array type " << array_type << " with aget"; - } else if (array_type.IsUnresolvedTypes()) { + } else if (array_type.IsUnresolvedMergedReference()) { // Unresolved array types must be reference array types. if (is_primitive) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "reference array type " << array_type @@ -4266,6 +4266,10 @@ void MethodVerifier::VerifyAGet(const Instruction* inst, } else { Fail(VERIFY_ERROR_NO_CLASS) << "cannot verify aget for " << array_type << " because of missing class"; + // Approximate with java.lang.Object[]. + work_line_->SetRegisterType<LockOp::kClear>(this, + inst->VRegA_23x(), + reg_types_.JavaLangObject(false)); } } else { /* verify the class */ @@ -4377,7 +4381,7 @@ void MethodVerifier::VerifyAPut(const Instruction* inst, work_line_->VerifyRegisterType(this, inst->VRegA_23x(), *modified_reg_type); } else if (!array_type.IsArrayTypes()) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "not array type " << array_type << " with aput"; - } else if (array_type.IsUnresolvedTypes()) { + } else if (array_type.IsUnresolvedMergedReference()) { // Unresolved array types must be reference array types. if (is_primitive) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "put insn has type '" << insn_type diff --git a/runtime/verifier/reg_type.cc b/runtime/verifier/reg_type.cc index bd0308b0f1..308c2aa3e6 100644 --- a/runtime/verifier/reg_type.cc +++ b/runtime/verifier/reg_type.cc @@ -878,7 +878,7 @@ bool RegType::CanAssignArray(const RegType& src, RegTypeCache& reg_types, return false; } - if (IsUnresolvedTypes() || src.IsUnresolvedTypes()) { + if (IsUnresolvedMergedReference() || src.IsUnresolvedMergedReference()) { // An unresolved array type means that it's an array of some reference type. Reference arrays // can never be assigned to primitive-type arrays, and vice versa. So it is a soft error if // both arrays are reference arrays, otherwise a hard error. diff --git a/runtime/verifier/reg_type_cache.cc b/runtime/verifier/reg_type_cache.cc index 208ef51d28..71c2a90076 100644 --- a/runtime/verifier/reg_type_cache.cc +++ b/runtime/verifier/reg_type_cache.cc @@ -611,7 +611,7 @@ const RegType& RegTypeCache::GetComponentType(const RegType& array, mirror::Clas if (!array.IsArrayTypes()) { return Conflict(); } else if (array.IsUnresolvedTypes()) { - DCHECK(!array.IsUnresolvedTypes()); // Caller must make sure not to ask for this. + DCHECK(!array.IsUnresolvedMergedReference()); // Caller must make sure not to ask for this. const std::string descriptor(array.GetDescriptor().as_string()); return FromDescriptor(loader, descriptor.c_str() + 1, false); } else { diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt index 5a3857d07c..c2a9a31aeb 100644 --- a/test/800-smali/expected.txt +++ b/test/800-smali/expected.txt @@ -65,4 +65,5 @@ b/27799205 (2) b/27799205 (3) b/27799205 (4) b/27799205 (5) +b/27799205 (6) Done! diff --git a/test/800-smali/smali/b_27799205_6.smali b/test/800-smali/smali/b_27799205_6.smali new file mode 100644 index 0000000000..d0154f7b4b --- /dev/null +++ b/test/800-smali/smali/b_27799205_6.smali @@ -0,0 +1,24 @@ +.class public LB27799205_6; +.super Ljava/lang/Object; + +# A class with an unresolved array type should not fail hard (unless it's a primitive-type access). +# Make sure that non-merged types still work. + +.method public static run()V +.registers 1 + return-void +.end method + +# Use some non-resolvable array type. +.method public static test([Ldo/not/resolve/K;)Ldo/not/resolve/K; +.registers 3 + const v0, 0 + const v1, 0 + # v2 = p0 + + # v0 := v2[v1] + aget-object v0, v2, v1 + + return-object v0 + +.end method diff --git a/test/800-smali/smali/b_27799205_helper.smali b/test/800-smali/smali/b_27799205_helper.smali index 145c93db38..e6d0985b45 100644 --- a/test/800-smali/smali/b_27799205_helper.smali +++ b/test/800-smali/smali/b_27799205_helper.smali @@ -38,3 +38,10 @@ return-void .end method + +.method public static run6()V +.registers 1 + invoke-static {}, LB27799205_6;->run()V + + return-void +.end method diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java index 20c306589f..2001cb4abb 100644 --- a/test/800-smali/src/Main.java +++ b/test/800-smali/src/Main.java @@ -173,6 +173,7 @@ public class Main { new VerifyError(), null)); testCases.add(new TestCase("b/27799205 (5)", "B27799205Helper", "run5", null, new VerifyError(), null)); + testCases.add(new TestCase("b/27799205 (6)", "B27799205Helper", "run6", null, null, null)); } public void runTests() { |