summaryrefslogtreecommitdiffstats
path: root/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2015-06-15 18:52:54 +0100
committerVladimir Marko <vmarko@google.com>2015-06-18 15:20:17 +0100
commita8b41003a717ecf399b890c18e9b0df49f55472f (patch)
treeab2a83ac36bd902322e7948c0d67fe5073563c3d /compiler/driver/compiler_driver.cc
parentf61ab97807441935cab89ebe6e24279e03d62bfe (diff)
downloadandroid_art-a8b41003a717ecf399b890c18e9b0df49f55472f.tar.gz
android_art-a8b41003a717ecf399b890c18e9b0df49f55472f.tar.bz2
android_art-a8b41003a717ecf399b890c18e9b0df49f55472f.zip
ART: Fix reporting initialized classes by CompilerDriver.
Fix a bug where the CompilerDriver was erroneously reporting classes as initialized during AOT compilation when they were not guaranteed to be initialized at runtime. This fix prevents the Quick compiler from inlining calls to static methods in classes that are not guaranteed to be initialized, so that the runtime performs the initialization required for correctness. Bug: 21847756 (cherry picked from commit 07785bb98dc8bbe192970e0f4c2cafd338a8dc68) Change-Id: I60c7361cb6e8f51be20a3cbfcae19f3240bdfbed
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
-rw-r--r--compiler/driver/compiler_driver.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index e963c12402..55fabcc369 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -659,7 +659,8 @@ void CompilerDriver::PreCompile(jobject class_loader, const std::vector<const De
bool CompilerDriver::IsImageClass(const char* descriptor) const {
if (!IsImage()) {
- return true;
+ // NOTE: Currently unreachable, all callers check IsImage().
+ return false;
} else {
return image_classes_->find(descriptor) != image_classes_->end();
}
@@ -992,6 +993,24 @@ void CompilerDriver::UpdateImageClasses(TimingLogger* timings) {
}
}
+bool CompilerDriver::CanAssumeClassIsLoaded(mirror::Class* klass) {
+ Runtime* runtime = Runtime::Current();
+ if (!runtime->IsAotCompiler()) {
+ DCHECK(runtime->UseJit());
+ // Having the klass reference here implies that the klass is already loaded.
+ return true;
+ }
+ if (!IsImage()) {
+ // Assume loaded only if klass is in the boot image. App classes cannot be assumed
+ // loaded because we don't even know what class loader will be used to load them.
+ bool class_in_image = runtime->GetHeap()->FindSpaceFromObject(klass, false)->IsImageSpace();
+ return class_in_image;
+ }
+ std::string temp;
+ const char* descriptor = klass->GetDescriptor(&temp);
+ return IsImageClass(descriptor);
+}
+
bool CompilerDriver::CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, uint32_t type_idx) {
if (IsImage() &&
IsImageClass(dex_file.StringDataByIdx(dex_file.GetTypeId(type_idx).descriptor_idx_))) {