summaryrefslogtreecommitdiffstats
path: root/runtime/thread_list.cc
diff options
context:
space:
mode:
authorLei Li <lei.l.li@intel.com>2015-02-02 14:24:44 +0800
committerHaitao Feng <haitao.feng@intel.com>2015-02-03 17:48:45 +0800
commitdd9943d4466b052ef6c5ee5b32187adb48cbce74 (patch)
treeea1651e8990706b62e9d1375f635c6ec5d6066fd /runtime/thread_list.cc
parent28acb6feb50951645c37c077bd3897ea760ca322 (diff)
downloadart-dd9943d4466b052ef6c5ee5b32187adb48cbce74.zip
art-dd9943d4466b052ef6c5ee5b32187adb48cbce74.tar.gz
art-dd9943d4466b052ef6c5ee5b32187adb48cbce74.tar.bz2
ART: checkpoint mechanism optimization
GC thread and trim thread are both using checkpoint mechanism. GC thread will request java threads to mark their thread roots by themselves. Trim thread will request java threads to trim their jni local reference tables by themselves. The checkpint mechanism semantics is that the runnable java threads will run checkpoint function itself at safepoint, and finally the java threads and gc thread or trim thread is synchronized via barrier. If the java threads are not runnable, gc thread or trim thread will suspend them and then run their checkpoint functions one by one on behalf of them. If all the java threads are not runnable, then gc thread or trim thread will do all the work itself. In this case, there is no need synchronization. This will save unnecessary synchronization and thread state transitions. Change-Id: If55940946cb3f8b1af42c7237c334f09c8ec7a9f
Diffstat (limited to 'runtime/thread_list.cc')
-rw-r--r--runtime/thread_list.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 58e5b9d..ef24efc 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -174,7 +174,9 @@ class DumpCheckpoint FINAL : public Closure {
MutexLock mu(self, *Locks::logging_lock_);
*os_ << local_os.str();
}
- barrier_.Pass(self);
+ if (thread->GetState() == kRunnable) {
+ barrier_.Pass(self);
+ }
}
void WaitForThreadsToRunThroughCheckpoint(size_t threads_running_checkpoint) {
@@ -202,7 +204,9 @@ void ThreadList::Dump(std::ostream& os) {
}
DumpCheckpoint checkpoint(&os);
size_t threads_running_checkpoint = RunCheckpoint(&checkpoint);
- checkpoint.WaitForThreadsToRunThroughCheckpoint(threads_running_checkpoint);
+ if (threads_running_checkpoint != 0) {
+ checkpoint.WaitForThreadsToRunThroughCheckpoint(threads_running_checkpoint);
+ }
}
void ThreadList::AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread* ignore2) {
@@ -324,8 +328,7 @@ size_t ThreadList::RunCheckpoint(Closure* checkpoint_function) {
Thread::resume_cond_->Broadcast(self);
}
- // Add one for self.
- return count + suspended_count_modified_threads.size() + 1;
+ return count;
}
// Request that a checkpoint function be run on all active (non-suspended)