Small cleanups after latest verifier change.
During AOT, the inliner can also look at whether the class needs to be
verified at runtime. We know the class doesn't hard fail otherwise its
status would be ErrorResolved.
Also un-negate IsUnverified -> IsVerified.
Also make isVerifiedNeedsAccessCheck only return true if the class has
that exact state.
Test: test.py and golem numbers
Bug: 28313047
Change-Id: I2ee0024a380225e1aa120b69069a5a34d3f81113
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 74eae43..2ecdd10 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -379,25 +379,29 @@
return single_impl;
}
-static bool IsMethodUnverified(const CompilerOptions& compiler_options, ArtMethod* method)
+static bool IsMethodVerified(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_) {
- if (!method->GetDeclaringClass()->IsVerified()) {
- if (compiler_options.IsJitCompiler()) {
- // We're at runtime, we know this is cold code if the class
- // is not verified, so don't bother analyzing.
- return true;
- } else if (!method->GetDeclaringClass()->IsVerifiedNeedsAccessChecks()) {
+ if (method->GetDeclaringClass()->IsVerified()) {
+ return true;
+ }
+ // For AOT, we check if the class has a verification status that allows us to
+ // inline / analyze.
+ // At runtime, we know this is cold code if the class is not verified, so don't
+ // bother analyzing.
+ if (Runtime::Current()->IsAotCompiler()) {
+ if (method->GetDeclaringClass()->IsVerifiedNeedsAccessChecks() ||
+ method->GetDeclaringClass()->ShouldVerifyAtRuntime()) {
return true;
}
}
return false;
}
-static bool AlwaysThrows(const CompilerOptions& compiler_options, ArtMethod* method)
+static bool AlwaysThrows(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(method != nullptr);
// Skip non-compilable and unverified methods.
- if (!method->IsCompilable() || IsMethodUnverified(compiler_options, method)) {
+ if (!method->IsCompilable() || !IsMethodVerified(method)) {
return false;
}
// Skip native methods, methods with try blocks, and methods that are too large.
@@ -476,7 +480,7 @@
}
// Set always throws property for non-inlined method call with single
// target.
- if (AlwaysThrows(codegen_->GetCompilerOptions(), actual_method)) {
+ if (AlwaysThrows(actual_method)) {
invoke_to_analyze->SetAlwaysThrows(true);
}
}
@@ -1329,7 +1333,7 @@
return false;
}
- if (IsMethodUnverified(codegen_->GetCompilerOptions(), method)) {
+ if (!IsMethodVerified(method)) {
LOG_FAIL(stats_, MethodCompilationStat::kNotInlinedNotVerified)
<< "Method " << method->PrettyMethod()
<< " couldn't be verified, so it cannot be inlined";
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 35ef358..131dc77 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -179,7 +179,7 @@
// executed with access checks.
template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
bool IsVerifiedNeedsAccessChecks() REQUIRES_SHARED(Locks::mutator_lock_) {
- return GetStatus<kVerifyFlags>() >= ClassStatus::kVerifiedNeedsAccessChecks;
+ return GetStatus<kVerifyFlags>() == ClassStatus::kVerifiedNeedsAccessChecks;
}
// Returns true if the class has been verified.