blob: fe1568da83b4f658db2cd95108e64e08c5786a0b [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "driver/compiler_driver.h"
18
Vladimir Marko2c64a832018-01-04 11:31:56 +000019#include <limits>
Brian Carlstrom7940e442013-07-12 13:46:57 -070020#include <stdint.h>
21#include <stdio.h>
Ian Rogers700a4022014-05-19 16:49:03 -070022#include <memory>
Brian Carlstrom7940e442013-07-12 13:46:57 -070023
Mathieu Chartiere401d142015-04-22 13:56:20 -070024#include "art_method-inl.h"
Vladimir Marko2c64a832018-01-04 11:31:56 +000025#include "base/casts.h"
Vladimir Marko3481ba22015-04-13 12:22:36 +010026#include "class_linker-inl.h"
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080027#include "common_compiler_test.h"
Mathieu Chartier9e050df2017-08-09 10:05:47 -070028#include "compiler_callbacks.h"
David Sehr9e734c72018-01-04 17:56:19 -080029#include "dex/dex_file.h"
30#include "dex/dex_file_types.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070031#include "gc/heap.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070032#include "handle_scope-inl.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070033#include "mirror/class-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070034#include "mirror/class_loader.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070035#include "mirror/dex_cache-inl.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070036#include "mirror/object-inl.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070037#include "mirror/object_array-inl.h"
David Sehr82d046e2018-04-23 08:14:19 -070038#include "profile/profile_compilation_info.h"
Mathieu Chartier0795f232016-09-27 18:43:30 -070039#include "scoped_thread_state_change-inl.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070040
41namespace art {
42
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080043class CompilerDriverTest : public CommonCompilerTest {
Brian Carlstrom7940e442013-07-12 13:46:57 -070044 protected:
Mathieu Chartier90443472015-07-16 20:32:27 -070045 void CompileAll(jobject class_loader) REQUIRES(!Locks::mutator_lock_) {
Ian Rogers5fe9af72013-11-14 00:17:20 -080046 TimingLogger timings("CompilerDriverTest::CompileAll", false, false);
Mathieu Chartierf5997b42014-06-20 10:37:54 -070047 TimingLogger::ScopedTiming t(__FUNCTION__, &timings);
Mathieu Chartier72041a02017-07-14 18:23:25 -070048 dex_files_ = GetDexFiles(class_loader);
Vladimir Marko213ee2d2018-06-22 11:56:34 +010049 SetDexFilesForOatFile(dex_files_);
Mathieu Chartier72041a02017-07-14 18:23:25 -070050 compiler_driver_->CompileAll(class_loader, dex_files_, &timings);
Mathieu Chartierf5997b42014-06-20 10:37:54 -070051 t.NewTiming("MakeAllExecutable");
Brian Carlstrom7940e442013-07-12 13:46:57 -070052 MakeAllExecutable(class_loader);
53 }
54
55 void EnsureCompiled(jobject class_loader, const char* class_name, const char* method,
56 const char* signature, bool is_virtual)
Mathieu Chartier90443472015-07-16 20:32:27 -070057 REQUIRES(!Locks::mutator_lock_) {
Brian Carlstrom7940e442013-07-12 13:46:57 -070058 CompileAll(class_loader);
59 Thread::Current()->TransitionFromSuspendedToRunnable();
60 bool started = runtime_->Start();
61 CHECK(started);
62 env_ = Thread::Current()->GetJniEnv();
63 class_ = env_->FindClass(class_name);
Mathieu Chartier2cebb242015-04-21 16:50:40 -070064 CHECK(class_ != nullptr) << "Class not found: " << class_name;
Brian Carlstrom7940e442013-07-12 13:46:57 -070065 if (is_virtual) {
66 mid_ = env_->GetMethodID(class_, method, signature);
67 } else {
68 mid_ = env_->GetStaticMethodID(class_, method, signature);
69 }
Mathieu Chartier2cebb242015-04-21 16:50:40 -070070 CHECK(mid_ != nullptr) << "Method not found: " << class_name << "." << method << signature;
Brian Carlstrom7940e442013-07-12 13:46:57 -070071 }
72
73 void MakeAllExecutable(jobject class_loader) {
Andreas Gampe81c6f8d2015-03-25 17:19:53 -070074 const std::vector<const DexFile*> class_path = GetDexFiles(class_loader);
Brian Carlstrom7940e442013-07-12 13:46:57 -070075 for (size_t i = 0; i != class_path.size(); ++i) {
76 const DexFile* dex_file = class_path[i];
Mathieu Chartier2cebb242015-04-21 16:50:40 -070077 CHECK(dex_file != nullptr);
Brian Carlstrom7940e442013-07-12 13:46:57 -070078 MakeDexFileExecutable(class_loader, *dex_file);
79 }
80 }
81
82 void MakeDexFileExecutable(jobject class_loader, const DexFile& dex_file) {
83 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
84 for (size_t i = 0; i < dex_file.NumClassDefs(); i++) {
85 const DexFile::ClassDef& class_def = dex_file.GetClassDef(i);
86 const char* descriptor = dex_file.GetClassDescriptor(class_def);
87 ScopedObjectAccess soa(Thread::Current());
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070088 StackHandleScope<1> hs(soa.Self());
89 Handle<mirror::ClassLoader> loader(
Mathieu Chartier0795f232016-09-27 18:43:30 -070090 hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
Vladimir Markoa8bba7d2018-05-30 15:18:48 +010091 ObjPtr<mirror::Class> c = class_linker->FindClass(soa.Self(), descriptor, loader);
Mathieu Chartier2cebb242015-04-21 16:50:40 -070092 CHECK(c != nullptr);
Mathieu Chartiere401d142015-04-22 13:56:20 -070093 const auto pointer_size = class_linker->GetImagePointerSize();
Alex Lighte64300b2015-12-15 15:02:47 -080094 for (auto& m : c->GetMethods(pointer_size)) {
Mathieu Chartiere401d142015-04-22 13:56:20 -070095 MakeExecutable(&m);
Brian Carlstrom7940e442013-07-12 13:46:57 -070096 }
97 }
98 }
99
100 JNIEnv* env_;
101 jclass class_;
102 jmethodID mid_;
Mathieu Chartier72041a02017-07-14 18:23:25 -0700103 std::vector<const DexFile*> dex_files_;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700104};
105
106// Disabled due to 10 second runtime on host
Vladimir Marko8d6768d2017-03-14 10:13:21 +0000107// TODO: Update the test for hash-based dex cache arrays. Bug: 30627598
Brian Carlstrom7940e442013-07-12 13:46:57 -0700108TEST_F(CompilerDriverTest, DISABLED_LARGE_CompileDexLibCore) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700109 CompileAll(nullptr);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700110
111 // All libcore references should resolve
112 ScopedObjectAccess soa(Thread::Current());
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700113 ASSERT_TRUE(java_lang_dex_file_ != nullptr);
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800114 const DexFile& dex = *java_lang_dex_file_;
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700115 ObjPtr<mirror::DexCache> dex_cache = class_linker_->FindDexCache(soa.Self(), dex);
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800116 EXPECT_EQ(dex.NumStringIds(), dex_cache->NumStrings());
Brian Carlstrom7940e442013-07-12 13:46:57 -0700117 for (size_t i = 0; i < dex_cache->NumStrings(); i++) {
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100118 const ObjPtr<mirror::String> string = dex_cache->GetResolvedString(dex::StringIndex(i));
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700119 EXPECT_TRUE(string != nullptr) << "string_idx=" << i;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700120 }
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800121 EXPECT_EQ(dex.NumTypeIds(), dex_cache->NumResolvedTypes());
Brian Carlstrom7940e442013-07-12 13:46:57 -0700122 for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) {
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100123 const ObjPtr<mirror::Class> type = dex_cache->GetResolvedType(dex::TypeIndex(i));
124 EXPECT_TRUE(type != nullptr)
125 << "type_idx=" << i << " " << dex.GetTypeDescriptor(dex.GetTypeId(dex::TypeIndex(i)));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700126 }
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100127 EXPECT_TRUE(dex_cache->StaticMethodSize() == dex_cache->NumResolvedMethods()
128 || dex.NumMethodIds() == dex_cache->NumResolvedMethods());
Mathieu Chartiere401d142015-04-22 13:56:20 -0700129 auto* cl = Runtime::Current()->GetClassLinker();
130 auto pointer_size = cl->GetImagePointerSize();
Brian Carlstrom7940e442013-07-12 13:46:57 -0700131 for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) {
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100132 // FIXME: This is outdated for hash-based method array.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700133 ArtMethod* method = dex_cache->GetResolvedMethod(i, pointer_size);
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700134 EXPECT_TRUE(method != nullptr) << "method_idx=" << i
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800135 << " " << dex.GetMethodDeclaringClassDescriptor(dex.GetMethodId(i))
136 << " " << dex.GetMethodName(dex.GetMethodId(i));
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700137 EXPECT_TRUE(method->GetEntryPointFromQuickCompiledCode() != nullptr) << "method_idx=" << i
138 << " " << dex.GetMethodDeclaringClassDescriptor(dex.GetMethodId(i)) << " "
139 << dex.GetMethodName(dex.GetMethodId(i));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700140 }
Vladimir Markof44d36c2017-03-14 14:18:46 +0000141 EXPECT_TRUE(dex_cache->StaticArtFieldSize() == dex_cache->NumResolvedFields()
142 || dex.NumFieldIds() == dex_cache->NumResolvedFields());
Brian Carlstrom7940e442013-07-12 13:46:57 -0700143 for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) {
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100144 // FIXME: This is outdated for hash-based field array.
Vladimir Markof44d36c2017-03-14 14:18:46 +0000145 ArtField* field = dex_cache->GetResolvedField(i, cl->GetImagePointerSize());
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700146 EXPECT_TRUE(field != nullptr) << "field_idx=" << i
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800147 << " " << dex.GetFieldDeclaringClassDescriptor(dex.GetFieldId(i))
148 << " " << dex.GetFieldName(dex.GetFieldId(i));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700149 }
150
151 // TODO check Class::IsVerified for all classes
152
153 // TODO: check that all Method::GetCode() values are non-null
154}
155
Yi Kong5dcf19d2016-04-04 17:44:59 +0100156TEST_F(CompilerDriverTest, AbstractMethodErrorStub) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700157 jobject class_loader;
158 {
159 ScopedObjectAccess soa(Thread::Current());
Brian Carlstrom7940e442013-07-12 13:46:57 -0700160 class_loader = LoadDex("AbstractMethod");
161 }
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700162 ASSERT_TRUE(class_loader != nullptr);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700163 EnsureCompiled(class_loader, "AbstractClass", "foo", "()V", true);
164
165 // Create a jobj_ of ConcreteClass, NOT AbstractClass.
166 jclass c_class = env_->FindClass("ConcreteClass");
Mathieu Chartiere401d142015-04-22 13:56:20 -0700167
Brian Carlstrom7940e442013-07-12 13:46:57 -0700168 jmethodID constructor = env_->GetMethodID(c_class, "<init>", "()V");
Mathieu Chartiere401d142015-04-22 13:56:20 -0700169
Brian Carlstrom7940e442013-07-12 13:46:57 -0700170 jobject jobj_ = env_->NewObject(c_class, constructor);
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700171 ASSERT_TRUE(jobj_ != nullptr);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700172
173 // Force non-virtual call to AbstractClass foo, will throw AbstractMethodError exception.
174 env_->CallNonvirtualVoidMethod(jobj_, class_, mid_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700175
Brian Carlstrom7940e442013-07-12 13:46:57 -0700176 EXPECT_EQ(env_->ExceptionCheck(), JNI_TRUE);
177 jthrowable exception = env_->ExceptionOccurred();
178 env_->ExceptionClear();
179 jclass jlame = env_->FindClass("java/lang/AbstractMethodError");
180 EXPECT_TRUE(env_->IsInstanceOf(exception, jlame));
Serguei Katkova309d762014-05-26 11:23:39 +0700181 {
182 ScopedObjectAccess soa(Thread::Current());
183 Thread::Current()->ClearException();
184 }
Brian Carlstrom7940e442013-07-12 13:46:57 -0700185}
186
Calin Juravle877fd962016-01-05 14:29:29 +0000187class CompilerDriverProfileTest : public CompilerDriverTest {
188 protected:
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100189 ProfileCompilationInfo* GetProfileCompilationInfo() override {
Calin Juravle877fd962016-01-05 14:29:29 +0000190 ScopedObjectAccess soa(Thread::Current());
191 std::vector<std::unique_ptr<const DexFile>> dex_files = OpenTestDexFiles("ProfileTestMultiDex");
192
193 ProfileCompilationInfo info;
194 for (const std::unique_ptr<const DexFile>& dex_file : dex_files) {
Mathieu Chartierbbe3a5e2017-06-13 16:36:17 -0700195 profile_info_.AddMethodIndex(ProfileCompilationInfo::MethodHotness::kFlagHot,
196 MethodReference(dex_file.get(), 1));
197 profile_info_.AddMethodIndex(ProfileCompilationInfo::MethodHotness::kFlagHot,
198 MethodReference(dex_file.get(), 2));
Calin Juravle877fd962016-01-05 14:29:29 +0000199 }
200 return &profile_info_;
201 }
202
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100203 CompilerFilter::Filter GetCompilerFilter() const override {
Mathieu Chartierd0af56c2017-02-17 12:56:25 -0800204 // Use a profile based filter.
205 return CompilerFilter::kSpeedProfile;
206 }
207
Calin Juravle877fd962016-01-05 14:29:29 +0000208 std::unordered_set<std::string> GetExpectedMethodsForClass(const std::string& clazz) {
209 if (clazz == "Main") {
210 return std::unordered_set<std::string>({
211 "java.lang.String Main.getA()",
212 "java.lang.String Main.getB()"});
213 } else if (clazz == "Second") {
214 return std::unordered_set<std::string>({
215 "java.lang.String Second.getX()",
216 "java.lang.String Second.getY()"});
217 } else {
218 return std::unordered_set<std::string>();
219 }
220 }
221
222 void CheckCompiledMethods(jobject class_loader,
223 const std::string& clazz,
224 const std::unordered_set<std::string>& expected_methods) {
225 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
226 Thread* self = Thread::Current();
227 ScopedObjectAccess soa(self);
228 StackHandleScope<1> hs(self);
Mathieu Chartierc4f39252016-10-05 18:32:08 -0700229 Handle<mirror::ClassLoader> h_loader(
230 hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100231 ObjPtr<mirror::Class> klass = class_linker->FindClass(self, clazz.c_str(), h_loader);
Calin Juravle877fd962016-01-05 14:29:29 +0000232 ASSERT_NE(klass, nullptr);
233
234 const auto pointer_size = class_linker->GetImagePointerSize();
235 size_t number_of_compiled_methods = 0;
236 for (auto& m : klass->GetVirtualMethods(pointer_size)) {
David Sehr709b0702016-10-13 09:12:37 -0700237 std::string name = m.PrettyMethod(true);
Calin Juravle877fd962016-01-05 14:29:29 +0000238 const void* code = m.GetEntryPointFromQuickCompiledCodePtrSize(pointer_size);
239 ASSERT_NE(code, nullptr);
240 if (expected_methods.find(name) != expected_methods.end()) {
241 number_of_compiled_methods++;
242 EXPECT_FALSE(class_linker->IsQuickToInterpreterBridge(code));
243 } else {
244 EXPECT_TRUE(class_linker->IsQuickToInterpreterBridge(code));
245 }
246 }
247 EXPECT_EQ(expected_methods.size(), number_of_compiled_methods);
248 }
249
250 private:
251 ProfileCompilationInfo profile_info_;
252};
253
254TEST_F(CompilerDriverProfileTest, ProfileGuidedCompilation) {
Calin Juravle877fd962016-01-05 14:29:29 +0000255 Thread* self = Thread::Current();
256 jobject class_loader;
257 {
258 ScopedObjectAccess soa(self);
259 class_loader = LoadDex("ProfileTestMultiDex");
260 }
261 ASSERT_NE(class_loader, nullptr);
262
263 // Need to enable dex-file writability. Methods rejected to be compiled will run through the
264 // dex-to-dex compiler.
Calin Juravle877fd962016-01-05 14:29:29 +0000265 for (const DexFile* dex_file : GetDexFiles(class_loader)) {
266 ASSERT_TRUE(dex_file->EnableWrite());
267 }
268
269 CompileAll(class_loader);
270
271 std::unordered_set<std::string> m = GetExpectedMethodsForClass("Main");
272 std::unordered_set<std::string> s = GetExpectedMethodsForClass("Second");
273 CheckCompiledMethods(class_loader, "LMain;", m);
274 CheckCompiledMethods(class_loader, "LSecond;", s);
275}
276
Nicolas Geoffrayc7da1d62017-04-19 09:36:24 +0100277// Test that a verify only compiler filter updates the CompiledClass map,
278// which will be used for OatClass.
279class CompilerDriverVerifyTest : public CompilerDriverTest {
280 protected:
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100281 CompilerFilter::Filter GetCompilerFilter() const override {
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100282 return CompilerFilter::kVerify;
Nicolas Geoffrayc7da1d62017-04-19 09:36:24 +0100283 }
284
285 void CheckVerifiedClass(jobject class_loader, const std::string& clazz) const {
286 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
287 Thread* self = Thread::Current();
288 ScopedObjectAccess soa(self);
289 StackHandleScope<1> hs(self);
290 Handle<mirror::ClassLoader> h_loader(
291 hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100292 ObjPtr<mirror::Class> klass = class_linker->FindClass(self, clazz.c_str(), h_loader);
Nicolas Geoffrayc7da1d62017-04-19 09:36:24 +0100293 ASSERT_NE(klass, nullptr);
294 EXPECT_TRUE(klass->IsVerified());
295
Vladimir Marko2c64a832018-01-04 11:31:56 +0000296 ClassStatus status;
Andreas Gampebb846102017-05-11 21:03:35 -0700297 bool found = compiler_driver_->GetCompiledClass(
298 ClassReference(&klass->GetDexFile(), klass->GetDexTypeIndex().index_), &status);
299 ASSERT_TRUE(found);
Vladimir Marko2c64a832018-01-04 11:31:56 +0000300 EXPECT_EQ(status, ClassStatus::kVerified);
Nicolas Geoffrayc7da1d62017-04-19 09:36:24 +0100301 }
302};
303
304TEST_F(CompilerDriverVerifyTest, VerifyCompilation) {
305 Thread* self = Thread::Current();
306 jobject class_loader;
307 {
308 ScopedObjectAccess soa(self);
309 class_loader = LoadDex("ProfileTestMultiDex");
310 }
311 ASSERT_NE(class_loader, nullptr);
312
313 CompileAll(class_loader);
314
315 CheckVerifiedClass(class_loader, "LMain;");
316 CheckVerifiedClass(class_loader, "LSecond;");
317}
318
Vladimir Marko2c64a832018-01-04 11:31:56 +0000319// Test that a class of status ClassStatus::kRetryVerificationAtRuntime is indeed
320// recorded that way in the driver.
Mathieu Chartier9e050df2017-08-09 10:05:47 -0700321TEST_F(CompilerDriverVerifyTest, RetryVerifcationStatusCheckVerified) {
Jeff Haof1aa2652017-08-03 17:09:33 -0700322 Thread* const self = Thread::Current();
323 jobject class_loader;
324 std::vector<const DexFile*> dex_files;
325 const DexFile* dex_file = nullptr;
326 {
327 ScopedObjectAccess soa(self);
328 class_loader = LoadDex("ProfileTestMultiDex");
329 ASSERT_NE(class_loader, nullptr);
330 dex_files = GetDexFiles(class_loader);
331 ASSERT_GT(dex_files.size(), 0u);
332 dex_file = dex_files.front();
333 }
Vladimir Marko213ee2d2018-06-22 11:56:34 +0100334 SetDexFilesForOatFile(dex_files);
Mathieu Chartier9e050df2017-08-09 10:05:47 -0700335 callbacks_->SetDoesClassUnloading(true, compiler_driver_.get());
Jeff Haof1aa2652017-08-03 17:09:33 -0700336 ClassReference ref(dex_file, 0u);
337 // Test that the status is read from the compiler driver as expected.
Vladimir Marko2c64a832018-01-04 11:31:56 +0000338 static_assert(enum_cast<size_t>(ClassStatus::kLast) < std::numeric_limits<size_t>::max(),
339 "Make sure incrementing the class status does not overflow.");
340 for (size_t i = enum_cast<size_t>(ClassStatus::kRetryVerificationAtRuntime);
341 i <= enum_cast<size_t>(ClassStatus::kLast);
342 ++i) {
343 const ClassStatus expected_status = enum_cast<ClassStatus>(i);
Jeff Haof1aa2652017-08-03 17:09:33 -0700344 // Skip unsupported status that are not supposed to be ever recorded.
Vladimir Marko2c64a832018-01-04 11:31:56 +0000345 if (expected_status == ClassStatus::kVerifyingAtRuntime ||
346 expected_status == ClassStatus::kInitializing) {
Jeff Haof1aa2652017-08-03 17:09:33 -0700347 continue;
348 }
349 compiler_driver_->RecordClassStatus(ref, expected_status);
Vladimir Marko2c64a832018-01-04 11:31:56 +0000350 ClassStatus status = {};
Jeff Haof1aa2652017-08-03 17:09:33 -0700351 ASSERT_TRUE(compiler_driver_->GetCompiledClass(ref, &status));
352 EXPECT_EQ(status, expected_status);
353 }
354}
355
Brian Carlstrom7940e442013-07-12 13:46:57 -0700356// TODO: need check-cast test (when stub complete & we can throw/catch
357
358} // namespace art