diff options
author | 2018-01-22 16:32:29 +0000 | |
---|---|---|
committer | 2018-01-23 17:43:15 +0000 | |
commit | 718e8319c728e9ee2ec15b1d56ca96baa4393028 (patch) | |
tree | 179d05bf61f23b02001da80df30cbd89fd5b5903 /compiler/driver/compiler_driver.cc | |
parent | be2b613f5a30cdf2291b9f4f5d0acc2c1bb0b4ae (diff) |
ART: Use the bitstring type check for AOT app compilation.
For boot image target classes that have their bitstring
already assigned in the boot image.
The size of the services.odex for aosp_taimen-userdebug:
- before:
- arm64: 20988640
- after:
- arm64: 20968016 (-20KiB, -0.1%)
(There is no arm version, only arm64.)
Test: New test case in 552-checker-sharpening.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: testrunner.py --target --optimizing
Bug: 64692057
Change-Id: I9585efca8ba0df15400e7536e5e2cc76aca13e8d
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
-rw-r--r-- | compiler/driver/compiler_driver.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 70cbb01569..273bd50b9e 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -872,6 +872,14 @@ void CompilerDriver::PreCompile(jobject class_loader, TimingLogger* timings) { CheckThreadPools(); + if (kUseBitstringTypeCheck && + !compiler_options_->IsBootImage() && + compiler_options_->IsAotCompilationEnabled()) { + RecordBootImageClassesWithAssignedBitstring(); + VLOG(compiler) << "RecordBootImageClassesWithAssignedBitstring: " + << GetMemoryUsageString(false); + } + LoadImageClasses(timings); VLOG(compiler) << "LoadImageClasses: " << GetMemoryUsageString(false); @@ -940,6 +948,43 @@ void CompilerDriver::PreCompile(jobject class_loader, } } +void CompilerDriver::RecordBootImageClassesWithAssignedBitstring() { + if (boot_image_classes_with_assigned_bitstring_ != nullptr) { + return; // Already recorded. (Happens because of class unloading between dex files.) + } + + class Visitor : public ClassVisitor { + public: + explicit Visitor(std::unordered_set<mirror::Class*>* recorded_classes) + : recorded_classes_(recorded_classes) {} + + bool operator()(ObjPtr<mirror::Class> klass) OVERRIDE + REQUIRES(Locks::subtype_check_lock_) REQUIRES_SHARED(Locks::mutator_lock_) { + DCHECK(klass != nullptr); + SubtypeCheckInfo::State state = SubtypeCheck<ObjPtr<mirror::Class>>::GetState(klass); + if (state == SubtypeCheckInfo::kAssigned) { + recorded_classes_->insert(klass.Ptr()); + } + return true; + } + + private: + std::unordered_set<mirror::Class*>* const recorded_classes_; + }; + + boot_image_classes_with_assigned_bitstring_.reset(new std::unordered_set<mirror::Class*>()); + Visitor visitor(boot_image_classes_with_assigned_bitstring_.get()); + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + ScopedObjectAccess soa(Thread::Current()); + MutexLock subtype_check_lock(soa.Self(), *Locks::subtype_check_lock_); + class_linker->VisitClasses(&visitor); +} + +bool CompilerDriver::IsBootImageClassWithAssignedBitstring(ObjPtr<mirror::Class> klass) { + DCHECK(boot_image_classes_with_assigned_bitstring_ != nullptr); + return boot_image_classes_with_assigned_bitstring_->count(klass.Ptr()) != 0u; +} + bool CompilerDriver::IsImageClass(const char* descriptor) const { if (image_classes_ != nullptr) { // If we have a set of image classes, use those. |