| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/thread_registry.h" | 5 #include "vm/thread_registry.h" |
| 6 | 6 |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 AddToActiveListLocked(thread); | 49 AddToActiveListLocked(thread); |
| 50 return thread; | 50 return thread; |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 void ThreadRegistry::ReturnThreadLocked(bool is_mutator, Thread* thread) { | 54 void ThreadRegistry::ReturnThreadLocked(bool is_mutator, Thread* thread) { |
| 55 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 55 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 56 // Remove thread from the active list for the isolate. | 56 // Remove thread from the active list for the isolate. |
| 57 RemoveFromActiveListLocked(thread); | 57 RemoveFromActiveListLocked(thread); |
| 58 if (!is_mutator) { | 58 if (!is_mutator) { |
| 59 ASSERT(thread->api_top_scope() == NULL); | |
| 60 ReturnToFreelistLocked(thread); | 59 ReturnToFreelistLocked(thread); |
| 61 } | 60 } |
| 62 } | 61 } |
| 63 | 62 |
| 64 | 63 |
| 65 void ThreadRegistry::VisitObjectPointers(ObjectPointerVisitor* visitor, | 64 void ThreadRegistry::VisitObjectPointers(ObjectPointerVisitor* visitor, |
| 66 bool validate_frames) { | 65 bool validate_frames) { |
| 67 MonitorLocker ml(threads_lock()); | 66 MonitorLocker ml(threads_lock()); |
| 68 bool mutator_thread_visited = false; | 67 bool mutator_thread_visited = false; |
| 69 Thread* thread = active_list_; | 68 Thread* thread = active_list_; |
| 70 while (thread != NULL) { | 69 while (thread != NULL) { |
| 71 if (thread->zone() != NULL) { | 70 thread->VisitObjectPointers(visitor, validate_frames); |
| 72 thread->zone()->VisitObjectPointers(visitor); | |
| 73 } | |
| 74 thread->VisitObjectPointers(visitor); | |
| 75 if (mutator_thread_ == thread) { | 71 if (mutator_thread_ == thread) { |
| 76 mutator_thread_visited = true; | 72 mutator_thread_visited = true; |
| 77 } | 73 } |
| 78 // Iterate over all the stack frames and visit objects on the stack. | |
| 79 StackFrameIterator frames_iterator(thread->top_exit_frame_info(), | |
| 80 validate_frames); | |
| 81 StackFrame* frame = frames_iterator.NextFrame(); | |
| 82 while (frame != NULL) { | |
| 83 frame->VisitObjectPointers(visitor); | |
| 84 frame = frames_iterator.NextFrame(); | |
| 85 } | |
| 86 thread = thread->next_; | 74 thread = thread->next_; |
| 87 } | 75 } |
| 88 // Visit mutator thread even if it is not in the active list because of | 76 // Visit mutator thread even if it is not in the active list because of |
| 89 // api handles. | 77 // api handles. |
| 90 if (!mutator_thread_visited && (mutator_thread_ != NULL)) { | 78 if (!mutator_thread_visited && (mutator_thread_ != NULL)) { |
| 91 mutator_thread_->VisitObjectPointers(visitor); | 79 mutator_thread_->VisitObjectPointers(visitor, validate_frames); |
| 92 } | 80 } |
| 93 } | 81 } |
| 94 | 82 |
| 95 | 83 |
| 96 void ThreadRegistry::PrepareForGC() { | 84 void ThreadRegistry::PrepareForGC() { |
| 97 MonitorLocker ml(threads_lock()); | 85 MonitorLocker ml(threads_lock()); |
| 98 Thread* thread = active_list_; | 86 Thread* thread = active_list_; |
| 99 while (thread != NULL) { | 87 while (thread != NULL) { |
| 100 thread->PrepareForGC(); | 88 thread->PrepareForGC(); |
| 101 thread = thread->next_; | 89 thread = thread->next_; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 ASSERT(thread->os_thread_ == NULL); | 137 ASSERT(thread->os_thread_ == NULL); |
| 150 ASSERT(thread->isolate_ == NULL); | 138 ASSERT(thread->isolate_ == NULL); |
| 151 ASSERT(thread->heap_ == NULL); | 139 ASSERT(thread->heap_ == NULL); |
| 152 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 140 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 153 // Add thread to the free list. | 141 // Add thread to the free list. |
| 154 thread->next_ = free_list_; | 142 thread->next_ = free_list_; |
| 155 free_list_ = thread; | 143 free_list_ = thread; |
| 156 } | 144 } |
| 157 | 145 |
| 158 } // namespace dart | 146 } // namespace dart |
| OLD | NEW |