Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: runtime/vm/thread_registry.cc

Issue 1806093002: Clear reusable handles of helper threads as well. Visit mutator_thread_ even if it is not active (a… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!is_mutator) { 58 if (!is_mutator) {
59 ASSERT(thread->api_top_scope() == NULL); 59 ASSERT(thread->api_top_scope() == NULL);
60 ReturnToFreelistLocked(thread); 60 ReturnToFreelistLocked(thread);
61 } 61 }
62 } 62 }
63 63
64 64
65 void ThreadRegistry::VisitObjectPointers(ObjectPointerVisitor* visitor, 65 void ThreadRegistry::VisitObjectPointers(ObjectPointerVisitor* visitor,
66 bool validate_frames) { 66 bool validate_frames) {
67 MonitorLocker ml(threads_lock()); 67 MonitorLocker ml(threads_lock());
68 bool mutator_thread_visited = false;
68 Thread* thread = active_list_; 69 Thread* thread = active_list_;
69 while (thread != NULL) { 70 while (thread != NULL) {
70 if (thread->zone() != NULL) { 71 if (thread->zone() != NULL) {
71 thread->zone()->VisitObjectPointers(visitor); 72 thread->zone()->VisitObjectPointers(visitor);
72 } 73 }
73 thread->VisitObjectPointers(visitor); 74 thread->VisitObjectPointers(visitor);
75 if (mutator_thread_ == thread) {
76 mutator_thread_visited = true;
77 }
74 // Iterate over all the stack frames and visit objects on the stack. 78 // Iterate over all the stack frames and visit objects on the stack.
75 StackFrameIterator frames_iterator(thread->top_exit_frame_info(), 79 StackFrameIterator frames_iterator(thread->top_exit_frame_info(),
76 validate_frames); 80 validate_frames);
77 StackFrame* frame = frames_iterator.NextFrame(); 81 StackFrame* frame = frames_iterator.NextFrame();
78 while (frame != NULL) { 82 while (frame != NULL) {
79 frame->VisitObjectPointers(visitor); 83 frame->VisitObjectPointers(visitor);
80 frame = frames_iterator.NextFrame(); 84 frame = frames_iterator.NextFrame();
81 } 85 }
82 thread = thread->next_; 86 thread = thread->next_;
83 } 87 }
88 // Visit mutator thread even if it is not in the active list because of
89 // api handles.
90 if (!mutator_thread_visited && (mutator_thread_ != NULL)) {
91 mutator_thread_->VisitObjectPointers(visitor);
92 }
84 } 93 }
85 94
86 95
87 void ThreadRegistry::PrepareForGC() { 96 void ThreadRegistry::PrepareForGC() {
88 MonitorLocker ml(threads_lock()); 97 MonitorLocker ml(threads_lock());
89 Thread* thread = active_list_; 98 Thread* thread = active_list_;
90 while (thread != NULL) { 99 while (thread != NULL) {
91 thread->PrepareForGC(); 100 thread->PrepareForGC();
92 thread = thread->next_; 101 thread = thread->next_;
93 } 102 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ASSERT(thread->os_thread_ == NULL); 149 ASSERT(thread->os_thread_ == NULL);
141 ASSERT(thread->isolate_ == NULL); 150 ASSERT(thread->isolate_ == NULL);
142 ASSERT(thread->heap_ == NULL); 151 ASSERT(thread->heap_ == NULL);
143 ASSERT(threads_lock()->IsOwnedByCurrentThread()); 152 ASSERT(threads_lock()->IsOwnedByCurrentThread());
144 // Add thread to the free list. 153 // Add thread to the free list.
145 thread->next_ = free_list_; 154 thread->next_ = free_list_;
146 free_list_ = thread; 155 free_list_ = thread;
147 } 156 }
148 157
149 } // namespace dart 158 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698