diff options
author | Ian Rogers <irogers@google.com> | 2014-04-02 15:49:42 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-04-02 15:49:42 +0000 |
commit | 0807e7bbbafc4b4e8e7fb1d2d54fbcb011c05c82 (patch) | |
tree | ce13371288e4a08e8b627eeafd18a5b9746ecec4 /runtime/thread_list.cc | |
parent | 161f71ab4449047157ad3d967a3ed4f7c6e17249 (diff) | |
parent | 2966e13d504a72d55c62bf864e183ec80703c699 (diff) | |
download | android_art-0807e7bbbafc4b4e8e7fb1d2d54fbcb011c05c82.tar.gz android_art-0807e7bbbafc4b4e8e7fb1d2d54fbcb011c05c82.tar.bz2 android_art-0807e7bbbafc4b4e8e7fb1d2d54fbcb011c05c82.zip |
Merge "Avoid debug check violation in thread registration."
Diffstat (limited to 'runtime/thread_list.cc')
-rw-r--r-- | runtime/thread_list.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 09337802bf..7de9433b24 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -750,14 +750,13 @@ void ThreadList::Register(Thread* self) { MutexLock mu(self, *Locks::thread_list_lock_); MutexLock mu2(self, *Locks::thread_suspend_count_lock_); CHECK_GE(suspend_all_count_, debug_suspend_all_count_); - if (debug_suspend_all_count_ > 0) { - self->ModifySuspendCount(self, debug_suspend_all_count_, true); + // Modify suspend count in increments of 1 to maintain invariants in ModifySuspendCount. While + // this isn't particularly efficient the suspend counts are most commonly 0 or 1. + for (int delta = debug_suspend_all_count_; delta > 0; delta--) { + self->ModifySuspendCount(self, +1, true); } - if (suspend_all_count_ > 0) { - int delta = suspend_all_count_ - debug_suspend_all_count_; - if (delta > 0) { - self->ModifySuspendCount(self, delta, false); - } + for (int delta = suspend_all_count_ - debug_suspend_all_count_; delta > 0; delta--) { + self->ModifySuspendCount(self, +1, false); } CHECK(!Contains(self)); list_.push_back(self); |