diff options
author | 2018-01-24 21:26:25 +0000 | |
---|---|---|
committer | 2018-01-24 21:26:25 +0000 | |
commit | d3233abdf14f173bb99e3905e8543ffff845230e (patch) | |
tree | e1fd1abd81da728cd004b1982f7c04cccfa7d6b0 /compiler/driver/compiler_driver.cc | |
parent | 0e920facfcc1cdc12f08ef269746563f8f801f9b (diff) | |
parent | 718e8319c728e9ee2ec15b1d56ca96baa4393028 (diff) |
Merge "ART: Use the bitstring type check for AOT app compilation."
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 3720dda0f8..5c649855b6 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -878,6 +878,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); @@ -946,6 +954,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. |