From c1c3452e465e473df499196b387330a793b89680 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 31 Oct 2018 13:56:49 +0000 Subject: Do not cache RequiresConstructorBarrier() results. Avoid caching the results. Caching was broken for JIT in the presence of class unloading; entries for unloaded dex files were leaked and potentially used erroneously with a newly loaded dex file. Test: m test-art-host-gtest Test: testrunner.py --host Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target Bug: 118808764 Change-Id: Ic1163601170364e060c2e3009752f543c9bb37b7 --- compiler/driver/compiler_driver.h | 52 --------------------------------------- 1 file changed, 52 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 9a83e55c96..f42e555410 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -151,50 +151,6 @@ class CompilerDriver { void AddCompiledMethod(const MethodReference& method_ref, CompiledMethod* const compiled_method); CompiledMethod* RemoveCompiledMethod(const MethodReference& method_ref); - void SetRequiresConstructorBarrier(Thread* self, - const DexFile* dex_file, - uint16_t class_def_index, - bool requires) - REQUIRES(!requires_constructor_barrier_lock_); - - // Do the methods for this class require a constructor barrier (prior to the return)? - // The answer is "yes", if and only if this class has any instance final fields. - // (This must not be called for any non- methods; the answer would be "no"). - // - // --- - // - // JLS 17.5.1 "Semantics of final fields" mandates that all final fields are frozen at the end - // of the invoked constructor. The constructor barrier is a conservative implementation means of - // enforcing the freezes happen-before the object being constructed is observable by another - // thread. - // - // Note: This question only makes sense for instance constructors; - // static constructors (despite possibly having finals) never need - // a barrier. - // - // JLS 12.4.2 "Detailed Initialization Procedure" approximately describes - // class initialization as: - // - // lock(class.lock) - // class.state = initializing - // unlock(class.lock) - // - // invoke - // - // lock(class.lock) - // class.state = initialized - // unlock(class.lock) <-- acts as a release - // - // The last operation in the above example acts as an atomic release - // for any stores in , which ends up being stricter - // than what a constructor barrier needs. - // - // See also QuasiAtomic::ThreadFenceForConstructor(). - bool RequiresConstructorBarrier(Thread* self, - const DexFile* dex_file, - uint16_t class_def_index) - REQUIRES(!requires_constructor_barrier_lock_); - // Resolve compiling method's class. Returns null on failure. ObjPtr ResolveCompilingMethodsClass(const ScopedObjectAccess& soa, Handle dex_cache, @@ -407,20 +363,12 @@ class CompilerDriver { void FreeThreadPools(); void CheckThreadPools(); - bool RequiresConstructorBarrier(const DexFile& dex_file, uint16_t class_def_idx) const; - const CompilerOptions* const compiler_options_; VerificationResults* const verification_results_; std::unique_ptr compiler_; Compiler::Kind compiler_kind_; - // All class references that require constructor barriers. If the class reference is not in the - // set then the result has not yet been computed. - mutable ReaderWriterMutex requires_constructor_barrier_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; - std::map requires_constructor_barrier_ - GUARDED_BY(requires_constructor_barrier_lock_); - // All class references that this compiler has compiled. Indexed by class defs. using ClassStateTable = AtomicDexRefMap; ClassStateTable compiled_classes_; -- cgit v1.2.3-59-g8ed1b