summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2017-02-03 11:47:34 +0000
committer Vladimir Marko <vmarko@google.com> 2017-02-09 10:10:29 +0000
commitcd556b003adbb53739d4b3f43135e6a0ae69509a (patch)
treea30c9f03071d87e1f75a0d0b8c2961d113ea767d /compiler/driver/compiler_driver.cc
parent357dcb73934356239292c46d6fbedba734da5e00 (diff)
Fix dex cache resolved types and class table mismatch.
Record class table in ClassLinker::DexCacheData and use it in DexCache.setResolvedType() to store the type also in the initiating loader's class table if the dex file has been registered. Also throw InternalError when trying to register the same DexFile with multiple class loaders. (Different DexFile instances referencing the same file are OK.) Test: 155-java-set-resolved-type Test: m test-art-host Bug: 30627598 Bug: 34193123 Bug: 34839984 Change-Id: Ia48acb300337c45880ea1459d2d32789546d67f4
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
-rw-r--r--compiler/driver/compiler_driver.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 1d4eaf8c5a..7af850a263 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -878,7 +878,7 @@ static void ResolveConstStrings(CompilerDriver* driver,
MutableHandle<mirror::DexCache> dex_cache(hs.NewHandle<mirror::DexCache>(nullptr));
for (const DexFile* dex_file : dex_files) {
- dex_cache.Assign(class_linker->FindDexCache(soa.Self(), *dex_file, false));
+ dex_cache.Assign(class_linker->FindDexCache(soa.Self(), *dex_file));
TimingLogger::ScopedTiming t("Resolve const-string Strings", timings);
size_t class_def_count = dex_file->NumClassDefs();
@@ -1182,10 +1182,12 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings) {
Handle<mirror::DexCache> dex_cache(hs2.NewHandle(class_linker->RegisterDexFile(*dex_file,
nullptr)));
Handle<mirror::Class> klass(hs2.NewHandle(
- class_linker->ResolveType(*dex_file,
- exception_type_idx,
- dex_cache,
- ScopedNullHandle<mirror::ClassLoader>())));
+ (dex_cache.Get() != nullptr)
+ ? class_linker->ResolveType(*dex_file,
+ exception_type_idx,
+ dex_cache,
+ ScopedNullHandle<mirror::ClassLoader>())
+ : nullptr));
if (klass.Get() == nullptr) {
const DexFile::TypeId& type_id = dex_file->GetTypeId(exception_type_idx);
const char* descriptor = dex_file->GetTypeDescriptor(type_id);
@@ -1776,7 +1778,7 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor {
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader)));
Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(
- soa.Self(), dex_file, false)));
+ soa.Self(), dex_file)));
// Resolve the class.
mirror::Class* klass = class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache,
class_loader);
@@ -1875,10 +1877,9 @@ class ResolveTypeVisitor : public CompilationVisitor {
Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->RegisterDexFile(
dex_file,
class_loader.Get())));
- mirror::Class* klass = class_linker->ResolveType(dex_file,
- dex::TypeIndex(type_idx),
- dex_cache,
- class_loader);
+ ObjPtr<mirror::Class> klass = (dex_cache.Get() != nullptr)
+ ? class_linker->ResolveType(dex_file, dex::TypeIndex(type_idx), dex_cache, class_loader)
+ : nullptr;
if (klass == nullptr) {
soa.Self()->AssertPendingException();
@@ -2135,7 +2136,7 @@ class VerifyClassVisitor : public CompilationVisitor {
* will be rejected by the verifier and later skipped during compilation in the compiler.
*/
Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(
- soa.Self(), dex_file, false)));
+ soa.Self(), dex_file)));
std::string error_msg;
failure_kind =
verifier::MethodVerifier::VerifyClass(soa.Self(),