From 2c64a837e62c2839521c89060b5bb0dcb237ddda Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 4 Jan 2018 11:31:56 +0000 Subject: Change ClassStatus to fit into 4 bits. In preparation for extending the type check bit string from 24 to 28 bits, rewrite ClassStatus to fit into 4 bits. Also perform a proper cleanup of the ClassStatus, i.e. change it to an enum class, remove the "Status" word from enumerator names, replace "Max" with "Last" in line with other enumerations and remove aliases from mirror::Class. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 64692057 Bug: 65318848 Change-Id: Iec1610ba5dac2c527b36c12819f132e1a77f2d45 --- compiler/driver/compiler_driver_test.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'compiler/driver/compiler_driver_test.cc') diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 278358b250..2698574084 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -16,11 +16,13 @@ #include "driver/compiler_driver.h" +#include #include #include #include #include "art_method-inl.h" +#include "base/casts.h" #include "class_linker-inl.h" #include "common_compiler_test.h" #include "compiler_callbacks.h" @@ -344,11 +346,11 @@ class CompilerDriverVerifyTest : public CompilerDriverTest { ASSERT_NE(klass, nullptr); EXPECT_TRUE(klass->IsVerified()); - mirror::Class::Status status; + ClassStatus status; bool found = compiler_driver_->GetCompiledClass( ClassReference(&klass->GetDexFile(), klass->GetDexTypeIndex().index_), &status); ASSERT_TRUE(found); - EXPECT_EQ(status, mirror::Class::kStatusVerified); + EXPECT_EQ(status, ClassStatus::kVerified); } }; @@ -367,8 +369,8 @@ TEST_F(CompilerDriverVerifyTest, VerifyCompilation) { CheckVerifiedClass(class_loader, "LSecond;"); } -// Test that a class of status kStatusRetryVerificationAtRuntime is indeed recorded that way in the -// driver. +// Test that a class of status ClassStatus::kRetryVerificationAtRuntime is indeed +// recorded that way in the driver. TEST_F(CompilerDriverVerifyTest, RetryVerifcationStatusCheckVerified) { Thread* const self = Thread::Current(); jobject class_loader; @@ -386,17 +388,19 @@ TEST_F(CompilerDriverVerifyTest, RetryVerifcationStatusCheckVerified) { callbacks_->SetDoesClassUnloading(true, compiler_driver_.get()); ClassReference ref(dex_file, 0u); // Test that the status is read from the compiler driver as expected. - for (size_t i = mirror::Class::kStatusRetryVerificationAtRuntime; - i < mirror::Class::kStatusMax; - ++i) { - const mirror::Class::Status expected_status = static_cast(i); + static_assert(enum_cast(ClassStatus::kLast) < std::numeric_limits::max(), + "Make sure incrementing the class status does not overflow."); + for (size_t i = enum_cast(ClassStatus::kRetryVerificationAtRuntime); + i <= enum_cast(ClassStatus::kLast); + ++i) { + const ClassStatus expected_status = enum_cast(i); // Skip unsupported status that are not supposed to be ever recorded. - if (expected_status == mirror::Class::kStatusVerifyingAtRuntime || - expected_status == mirror::Class::kStatusInitializing) { + if (expected_status == ClassStatus::kVerifyingAtRuntime || + expected_status == ClassStatus::kInitializing) { continue; } compiler_driver_->RecordClassStatus(ref, expected_status); - mirror::Class::Status status = {}; + ClassStatus status = {}; ASSERT_TRUE(compiler_driver_->GetCompiledClass(ref, &status)); EXPECT_EQ(status, expected_status); } -- cgit v1.2.3