diff options
author | 2014-03-06 12:13:39 -0800 | |
---|---|---|
committer | 2014-03-06 19:16:01 -0800 | |
commit | 719d1a33f6569864f529e5a3fff59e7bca97aad0 (patch) | |
tree | fcd84efd7b9806b93ec1a44e2317e6f882e7fe0e /runtime/base/mutex.cc | |
parent | 5365eea9940269b662cfbe103caa348816ff1558 (diff) |
Enable annotalysis on clang ART builds.
Fix clang build errors aswell as restructure locking/mutex code for correct
thread safety analysis support.
Reorder make dependencies so that host builds build first as they should
provide better compilation errors than target.
Remove host's use of -fno-omit-frame-pointer as it has no value with correct
use of CFI, which we should have.
Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
Diffstat (limited to 'runtime/base/mutex.cc')
-rw-r--r-- | runtime/base/mutex.cc | 82 |
1 files changed, 73 insertions, 9 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index ff72d16908..fdf5763c3f 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -29,6 +29,30 @@ namespace art { +Mutex* Locks::abort_lock_ = nullptr; +Mutex* Locks::breakpoint_lock_ = nullptr; +Mutex* Locks::deoptimization_lock_ = nullptr; +ReaderWriterMutex* Locks::classlinker_classes_lock_ = nullptr; +ReaderWriterMutex* Locks::heap_bitmap_lock_ = nullptr; +Mutex* Locks::logging_lock_ = nullptr; +ReaderWriterMutex* Locks::mutator_lock_ = nullptr; +Mutex* Locks::runtime_shutdown_lock_ = nullptr; +Mutex* Locks::thread_list_lock_ = nullptr; +Mutex* Locks::thread_suspend_count_lock_ = nullptr; +Mutex* Locks::trace_lock_ = nullptr; +Mutex* Locks::profiler_lock_ = nullptr; +Mutex* Locks::unexpected_signal_lock_ = nullptr; +Mutex* Locks::intern_table_lock_ = nullptr; + +struct AllMutexData { + // A guard for all_mutexes_ that's not a mutex (Mutexes must CAS to acquire and busy wait). + Atomic<const BaseMutex*> all_mutexes_guard; + // All created mutexes guarded by all_mutexes_guard_. + std::set<BaseMutex*>* all_mutexes; + AllMutexData() : all_mutexes(NULL) {} +}; +static struct AllMutexData gAllMutexData[kAllMutexDataSize]; + #if ART_USE_FUTEXES static bool ComputeRelativeTimeSpec(timespec* result_ts, const timespec& lhs, const timespec& rhs) { const int32_t one_sec = 1000 * 1000 * 1000; // one second in nanoseconds. @@ -45,15 +69,6 @@ static bool ComputeRelativeTimeSpec(timespec* result_ts, const timespec& lhs, co } #endif -struct AllMutexData { - // A guard for all_mutexes_ that's not a mutex (Mutexes must CAS to acquire and busy wait). - Atomic<const BaseMutex*> all_mutexes_guard; - // All created mutexes guarded by all_mutexes_guard_. - std::set<BaseMutex*>* all_mutexes; - AllMutexData() : all_mutexes(NULL) {} -}; -static struct AllMutexData gAllMutexData[kAllMutexDataSize]; - class ScopedAllMutexesLock { public: explicit ScopedAllMutexesLock(const BaseMutex* mutex) : mutex_(mutex) { @@ -792,4 +807,53 @@ void ConditionVariable::TimedWait(Thread* self, int64_t ms, int32_t ns) { guard_.recursion_count_ = old_recursion_count; } +void Locks::Init() { + if (logging_lock_ != nullptr) { + // Already initialized. + DCHECK(abort_lock_ != nullptr); + DCHECK(breakpoint_lock_ != nullptr); + DCHECK(deoptimization_lock_ != nullptr); + DCHECK(classlinker_classes_lock_ != nullptr); + DCHECK(heap_bitmap_lock_ != nullptr); + DCHECK(logging_lock_ != nullptr); + DCHECK(mutator_lock_ != nullptr); + DCHECK(thread_list_lock_ != nullptr); + DCHECK(thread_suspend_count_lock_ != nullptr); + DCHECK(trace_lock_ != nullptr); + DCHECK(profiler_lock_ != nullptr); + DCHECK(unexpected_signal_lock_ != nullptr); + DCHECK(intern_table_lock_ != nullptr); + } else { + logging_lock_ = new Mutex("logging lock", kLoggingLock, true); + abort_lock_ = new Mutex("abort lock", kAbortLock, true); + + DCHECK(breakpoint_lock_ == nullptr); + breakpoint_lock_ = new Mutex("breakpoint lock", kBreakpointLock); + DCHECK(deoptimization_lock_ == nullptr); + deoptimization_lock_ = new Mutex("deoptimization lock", kDeoptimizationLock); + DCHECK(classlinker_classes_lock_ == nullptr); + classlinker_classes_lock_ = new ReaderWriterMutex("ClassLinker classes lock", + kClassLinkerClassesLock); + DCHECK(heap_bitmap_lock_ == nullptr); + heap_bitmap_lock_ = new ReaderWriterMutex("heap bitmap lock", kHeapBitmapLock); + DCHECK(mutator_lock_ == nullptr); + mutator_lock_ = new ReaderWriterMutex("mutator lock", kMutatorLock); + DCHECK(runtime_shutdown_lock_ == nullptr); + runtime_shutdown_lock_ = new Mutex("runtime shutdown lock", kRuntimeShutdownLock); + DCHECK(thread_list_lock_ == nullptr); + thread_list_lock_ = new Mutex("thread list lock", kThreadListLock); + DCHECK(thread_suspend_count_lock_ == nullptr); + thread_suspend_count_lock_ = new Mutex("thread suspend count lock", kThreadSuspendCountLock); + DCHECK(trace_lock_ == nullptr); + trace_lock_ = new Mutex("trace lock", kTraceLock); + DCHECK(profiler_lock_ == nullptr); + profiler_lock_ = new Mutex("profiler lock", kProfilerLock); + DCHECK(unexpected_signal_lock_ == nullptr); + unexpected_signal_lock_ = new Mutex("unexpected signal lock", kUnexpectedSignalLock, true); + DCHECK(intern_table_lock_ == nullptr); + intern_table_lock_ = new Mutex("InternTable lock", kInternTableLock); + } +} + + } // namespace art |