Make tsan happy.
tsan was unhappy with our static Mutex, claiming a race between the constructor
writing the 'rank_' field and Mutex::Lock reading it. My understanding of the
GCC static initialization acquire/release code is that it includes memory
barriers that should make this safe, so I'm reaching out to the tsan guys. In
the meantime, let's just make this MethodVerifier lock & collection like the
other MethodVerifier locks & collections.
WARNING: Possible data race during read of size 4 at 0x1A42F09C: {{{
T2 (Compiler Worker) (L{}):
#0 art::Mutex::Lock /home/enh/local-disk/clean-dalvik-dev/art/src/mutex.cc:89
#1 art::verifier::MethodVerifier::IsClassRejected /usr/local/google/home/enh/clean-dalvik-dev/art/src/mutex.h:77
#2 art::Compiler::CompileClass /home/enh/local-disk/clean-dalvik-dev/art/src/compiler.cc:1420
#3 art::WorkerThread::Go /home/enh/local-disk/clean-dalvik-dev/art/src/compiler.cc:1013
Concurrent write(s) happened at (OR AFTER) these points:
T1 (Compiler Worker) (L{}):
#0 art::Mutex::Mutex /home/enh/local-disk/clean-dalvik-dev/art/src/mutex.cc:67
#1 art::verifier::MethodVerifier::IsClassRejected /home/enh/local-disk/clean-dalvik-dev/art/src/verifier/method_verifier.cc:3334
#2 art::Compiler::CompileClass /home/enh/local-disk/clean-dalvik-dev/art/src/compiler.cc:1420
#3 art::WorkerThread::Go /home/enh/local-disk/clean-dalvik-dev/art/src/compiler.cc:1013
Address 0x1A42F09C is 28 bytes inside data symbol "_ZZN3art8verifierL22GetRejectedClassesLockEvE21rejected_classes_lock"
Race verifier data: 0x1A198B1E,0x1A198025
}}}
(cherry picked from commit 6356df46fb0ebff5467d3103b97c3c871940e402)
Change-Id: I26a9c91f133370161ab4679e36d9a02315d28847
diff --git a/src/verifier/method_verifier.h b/src/verifier/method_verifier.h
index 2e4b33f..75dcbc7 100644
--- a/src/verifier/method_verifier.h
+++ b/src/verifier/method_verifier.h
@@ -199,13 +199,12 @@
void Dump(std::ostream& os);
static const std::vector<uint8_t>* GetGcMap(Compiler::MethodReference ref);
- static void InitGcMaps();
- static void DeleteGcMaps();
+
+ static void Init();
+ static void Shutdown();
#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
static const InferredRegCategoryMap* GetInferredRegCategoryMap(Compiler::MethodReference ref);
- static void InitInferredRegCategoryMaps();
- static void DeleteInferredRegCategoryMaps();
#endif
static bool IsClassRejected(Compiler::ClassReference ref);
@@ -577,8 +576,12 @@
static GcMapTable* gc_maps_;
static void SetGcMap(Compiler::MethodReference ref, const std::vector<uint8_t>& gc_map);
+ typedef std::set<Compiler::ClassReference> RejectedClassesTable;
+ static Mutex* rejected_classes_lock_;
+ static RejectedClassesTable* rejected_classes_;
+
#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
- // All the inferred register category maps that the verifier has created
+ // All the inferred register category maps that the verifier has created.
typedef SafeMap<const Compiler::MethodReference,
const InferredRegCategoryMap*> InferredRegCategoryMapTable;
static Mutex* inferred_reg_category_maps_lock_;