From df707e406877e9c0426dd051c00933ebb331673e Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Tue, 2 Feb 2016 16:56:50 -0800 Subject: runtime: Don't skip verification for -Xverify:soft-fail When forcing the interpreter into access checks mode, make sure that the regular verification is still run, giving the verifier an opportunity to throw a VerifyError. If verification would've succeeded (without -Xverify:soft-fail flag), override this and soft-fail, to force the interpreter-with-access-checks to be run instead of the normal faster interpreter. This fixes the following run-tests under the interpeter-access-checks: * 135 * 412 * 471 * 506 * 800 Bug: 22414682 Change-Id: I5cb86a8bba71c7af9361a63c0802786c852b857b --- runtime/mirror/class.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'runtime/mirror/class.h') diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index ea614fd2c0..8092db4fbf 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -287,14 +287,19 @@ class MANAGED Class FINAL : public Object { return (GetAccessFlags() & kAccSynthetic) != 0; } - // Returns true if the class can avoid access checks. - bool IsPreverified() SHARED_REQUIRES(Locks::mutator_lock_) { - return (GetAccessFlags() & kAccPreverified) != 0; + // Returns true if the class had run the verifier at least once. + // This does not necessarily mean that access checks are avoidable, + // since the class methods might still need to be run with access checks. + // If this bit returns false, then the methods are not to be trusted with skipping access checks. + bool WasVerificationAttempted() SHARED_REQUIRES(Locks::mutator_lock_) { + return (GetAccessFlags() & kAccSkipAccessChecks) != 0; } - void SetPreverified() SHARED_REQUIRES(Locks::mutator_lock_) { + // Mark the class as having gone through a verification attempt. + // Mutually exclusive from whether or not each method is allowed to skip access checks. + void SetVerificationAttempted() SHARED_REQUIRES(Locks::mutator_lock_) { uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_)); - SetAccessFlags(flags | kAccPreverified); + SetAccessFlags(flags | kAccVerificationAttempted); } template @@ -1127,8 +1132,8 @@ class MANAGED Class FINAL : public Object { void VisitNativeRoots(Visitor& visitor, size_t pointer_size) SHARED_REQUIRES(Locks::mutator_lock_); - // When class is verified, set the kAccPreverified flag on each method. - void SetPreverifiedFlagOnAllMethods(size_t pointer_size) + // When class is verified, set the kAccSkipAccessChecks flag on each method. + void SetSkipAccessChecksFlagOnAllMethods(size_t pointer_size) SHARED_REQUIRES(Locks::mutator_lock_); // Get the descriptor of the class. In a few cases a std::string is required, rather than -- cgit v1.2.3-59-g8ed1b