summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-06-15 18:52:54 +0100
committer Vladimir Marko <vmarko@google.com> 2015-06-18 12:44:51 +0100
commit07785bb98dc8bbe192970e0f4c2cafd338a8dc68 (patch)
treed12a20d7790fffc8648d7da6a7944595516c1d89 /compiler/driver/compiler_driver.cc
parent6ebf70ec61eff097e1bdddb1b887316389e34dde (diff)
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 Change-Id: I6fee5ef9c05c2e5190ab8a9fe61365d5119011c5
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 22fcf87524..84b6a52bda 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_))) {