summaryrefslogtreecommitdiffstats
path: root/runtime/thread_list.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-07-17 11:09:10 -0700
committerIan Rogers <irogers@google.com>2014-08-08 08:29:53 -0700
commit68d8b42ddec39ec0174162d90d4abaa004d1983e (patch)
tree0bb6ccf3b996bb8363c10d07aa39cde221980602 /runtime/thread_list.cc
parent9c522c2cbbf50dc687728747b37ad59985750b65 (diff)
downloadart-68d8b42ddec39ec0174162d90d4abaa004d1983e.zip
art-68d8b42ddec39ec0174162d90d4abaa004d1983e.tar.gz
art-68d8b42ddec39ec0174162d90d4abaa004d1983e.tar.bz2
Wire up check JNI force copy mode.
Increase check JNI checks. Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h. Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case of VM routines. Make class loader override and shared library class loader JNI global references rather than mirror pointers. Clean-ups to native bridge. Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
Diffstat (limited to 'runtime/thread_list.cc')
-rw-r--r--runtime/thread_list.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 7cf26e6..5077a89 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -801,6 +801,8 @@ void ThreadList::Register(Thread* self) {
void ThreadList::Unregister(Thread* self) {
DCHECK_EQ(self, Thread::Current());
+ CHECK_NE(self->GetState(), kRunnable);
+ Locks::mutator_lock_->AssertNotHeld(self);
VLOG(threads) << "ThreadList::Unregister() " << *self;
@@ -815,14 +817,18 @@ void ThreadList::Unregister(Thread* self) {
// Note: deliberately not using MutexLock that could hold a stale self pointer.
Locks::thread_list_lock_->ExclusiveLock(self);
CHECK(Contains(self));
- // Note: we don't take the thread_suspend_count_lock_ here as to be suspending a thread other
- // than yourself you need to hold the thread_list_lock_ (see Thread::ModifySuspendCount).
+ Locks::thread_suspend_count_lock_->ExclusiveLock(self);
+ bool removed = false;
if (!self->IsSuspended()) {
list_.remove(self);
+ removed = true;
+ }
+ Locks::thread_suspend_count_lock_->ExclusiveUnlock(self);
+ Locks::thread_list_lock_->ExclusiveUnlock(self);
+ if (removed) {
delete self;
self = nullptr;
}
- Locks::thread_list_lock_->ExclusiveUnlock(self);
}
// Release the thread ID after the thread is finished and deleted to avoid cases where we can
// temporarily have multiple threads with the same thread id. When this occurs, it causes