From 1a088d440a3fac4e477a11af68adae9dcd3afd00 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 18 Jul 2017 11:43:57 -0700 Subject: Use AtomicDexRefMap for compiled classes Changed compiled_classes_ to use an AtomicDexRefMap and deleted the lock since it was no longer necessary. This map is more compact than a SafeMap. RAM numbers for verify filter on a large app (host arm compile): Maximum resident set size (kbytes): 250012->243472 native alloc: 19284128B->13951600B Bug: 6346774 Test: test-art-host Change-Id: Iace66945b49433f353603a713593c53be6893cc5 --- compiler/driver/compiler_driver.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index a3272d331d..93234cbdc4 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -117,12 +117,12 @@ class CompilerDriver { void CompileAll(jobject class_loader, const std::vector& dex_files, TimingLogger* timings) - REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_, !dex_to_dex_references_lock_); + REQUIRES(!Locks::mutator_lock_, !dex_to_dex_references_lock_); // Compile a single Method. void CompileOne(Thread* self, ArtMethod* method, TimingLogger* timings) REQUIRES_SHARED(Locks::mutator_lock_) - REQUIRES(!compiled_classes_lock_, !dex_to_dex_references_lock_); + REQUIRES(!dex_to_dex_references_lock_); VerificationResults* GetVerificationResults() const; @@ -153,8 +153,7 @@ class CompilerDriver { std::unique_ptr> CreateQuickResolutionTrampoline() const; std::unique_ptr> CreateQuickToInterpreterBridge() const; - bool GetCompiledClass(ClassReference ref, mirror::Class::Status* status) const - REQUIRES(!compiled_classes_lock_); + bool GetCompiledClass(ClassReference ref, mirror::Class::Status* status) const; CompiledMethod* GetCompiledMethod(MethodReference ref) const; size_t GetNonRelativeLinkerPatchCount() const; @@ -337,8 +336,7 @@ class CompilerDriver { // according to the profile file. bool ShouldVerifyClassBasedOnProfile(const DexFile& dex_file, uint16_t class_idx) const; - void RecordClassStatus(ClassReference ref, mirror::Class::Status status) - REQUIRES(!compiled_classes_lock_); + void RecordClassStatus(ClassReference ref, mirror::Class::Status status); // Checks if the specified method has been verified without failures. Returns // false if the method is not in the verification results (GetVerificationResults). @@ -387,7 +385,7 @@ class CompilerDriver { void PreCompile(jobject class_loader, const std::vector& dex_files, TimingLogger* timings) - REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_); + REQUIRES(!Locks::mutator_lock_); void LoadImageClasses(TimingLogger* timings) REQUIRES(!Locks::mutator_lock_); @@ -408,12 +406,9 @@ class CompilerDriver { // Do fast verification through VerifierDeps if possible. Return whether // verification was successful. - // NO_THREAD_SAFETY_ANALYSIS as the method accesses a guarded value in a - // single-threaded way. bool FastVerify(jobject class_loader, const std::vector& dex_files, - TimingLogger* timings) - NO_THREAD_SAFETY_ANALYSIS; + TimingLogger* timings); void Verify(jobject class_loader, const std::vector& dex_files, @@ -441,12 +436,12 @@ class CompilerDriver { void InitializeClasses(jobject class_loader, const std::vector& dex_files, TimingLogger* timings) - REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_); + REQUIRES(!Locks::mutator_lock_); void InitializeClasses(jobject class_loader, const DexFile& dex_file, const std::vector& dex_files, TimingLogger* timings) - REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_); + REQUIRES(!Locks::mutator_lock_); void UpdateImageClasses(TimingLogger* timings) REQUIRES(!Locks::mutator_lock_); @@ -484,10 +479,9 @@ class CompilerDriver { std::map requires_constructor_barrier_ GUARDED_BY(requires_constructor_barrier_lock_); - using ClassStateTable = SafeMap; - // All class references that this compiler has compiled. - mutable Mutex compiled_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; - ClassStateTable compiled_classes_ GUARDED_BY(compiled_classes_lock_); + // All class references that this compiler has compiled. Indexed by class defs. + using ClassStateTable = AtomicDexRefMap; + ClassStateTable compiled_classes_; typedef AtomicDexRefMap MethodTable; -- cgit v1.2.3-59-g8ed1b