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

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

Issue 1309033007: Old-gen marking on separate thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert static method change. Created 5 years, 3 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 #ifndef VM_THREAD_REGISTRY_H_ 5 #ifndef VM_THREAD_REGISTRY_H_
6 #define VM_THREAD_REGISTRY_H_ 6 #define VM_THREAD_REGISTRY_H_
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 30 matching lines...) Expand all
41 // TODO(koda): Consider adding a scope helper to avoid omitting this call. 41 // TODO(koda): Consider adding a scope helper to avoid omitting this call.
42 void ResumeAllThreads(); 42 void ResumeAllThreads();
43 43
44 // Indicate that the current thread is at a safepoint, and offer to wait for 44 // Indicate that the current thread is at a safepoint, and offer to wait for
45 // any pending rendezvous request (if none, returns immediately). 45 // any pending rendezvous request (if none, returns immediately).
46 void CheckSafepoint() { 46 void CheckSafepoint() {
47 MonitorLocker ml(monitor_); 47 MonitorLocker ml(monitor_);
48 CheckSafepointLocked(); 48 CheckSafepointLocked();
49 } 49 }
50 50
51 bool RestoreStateTo(Thread* thread, Thread::State* state) { 51 bool RestoreStateTo(Thread* thread, Thread::State* state,
52 bool bypass_safepoint) {
52 MonitorLocker ml(monitor_); 53 MonitorLocker ml(monitor_);
53 // Wait for any rendezvous in progress. 54 // Wait for any rendezvous in progress.
54 while (in_rendezvous_) { 55 while (!bypass_safepoint && in_rendezvous_) {
55 ml.Wait(Monitor::kNoTimeout); 56 ml.Wait(Monitor::kNoTimeout);
56 } 57 }
57 Entry* entry = FindEntry(thread); 58 Entry* entry = FindEntry(thread);
58 if (entry != NULL) { 59 if (entry != NULL) {
59 Thread::State st = entry->state; 60 Thread::State st = entry->state;
60 // TODO(koda): Support same thread re-entering same isolate with 61 // TODO(koda): Support same thread re-entering same isolate with
61 // Dart frames in between. For now, just assert it doesn't happen. 62 // Dart frames in between. For now, just assert it doesn't happen.
62 if (st.top_exit_frame_info != thread->top_exit_frame_info()) { 63 if (st.top_exit_frame_info != thread->top_exit_frame_info()) {
63 ASSERT(thread->top_exit_frame_info() == 0 || 64 ASSERT(thread->top_exit_frame_info() == 0 ||
64 thread->top_exit_frame_info() > st.top_exit_frame_info); 65 thread->top_exit_frame_info() > st.top_exit_frame_info);
(...skipping 11 matching lines...) Expand all
76 new_entry.thread = thread; 77 new_entry.thread = thread;
77 new_entry.scheduled = true; 78 new_entry.scheduled = true;
78 #if defined(DEBUG) 79 #if defined(DEBUG)
79 // State field is not in use, so zap it. 80 // State field is not in use, so zap it.
80 memset(&new_entry.state, 0xda, sizeof(new_entry.state)); 81 memset(&new_entry.state, 0xda, sizeof(new_entry.state));
81 #endif 82 #endif
82 entries_.Add(new_entry); 83 entries_.Add(new_entry);
83 return false; 84 return false;
84 } 85 }
85 86
86 void SaveStateFrom(Thread* thread, const Thread::State& state) { 87 void SaveStateFrom(Thread* thread, const Thread::State& state,
88 bool bypass_safepoint) {
87 MonitorLocker ml(monitor_); 89 MonitorLocker ml(monitor_);
88 Entry* entry = FindEntry(thread); 90 Entry* entry = FindEntry(thread);
89 ASSERT(entry != NULL); 91 ASSERT(entry != NULL);
90 ASSERT(entry->scheduled); 92 ASSERT(entry->scheduled);
91 entry->scheduled = false; 93 entry->scheduled = false;
92 entry->state = state; 94 entry->state = state;
93 if (in_rendezvous_) { 95 if (!bypass_safepoint && in_rendezvous_) {
94 // Don't wait for this thread. 96 // Don't wait for this thread.
95 ASSERT(remaining_ > 0); 97 ASSERT(remaining_ > 0);
96 if (--remaining_ == 0) { 98 if (--remaining_ == 0) {
97 ml.NotifyAll(); 99 ml.NotifyAll();
98 } 100 }
99 } 101 }
100 } 102 }
101 103
102 bool Contains(Thread* thread) { 104 bool Contains(Thread* thread) {
103 MonitorLocker ml(monitor_); 105 MonitorLocker ml(monitor_);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 intptr_t remaining_; // Number of threads yet to reach their safepoint. 197 intptr_t remaining_; // Number of threads yet to reach their safepoint.
196 int64_t round_; // Counter, to prevent missing updates to remaining_ 198 int64_t round_; // Counter, to prevent missing updates to remaining_
197 // (see comments in CheckSafepointLocked). 199 // (see comments in CheckSafepointLocked).
198 200
199 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); 201 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry);
200 }; 202 };
201 203
202 } // namespace dart 204 } // namespace dart
203 205
204 #endif // VM_THREAD_REGISTRY_H_ 206 #endif // VM_THREAD_REGISTRY_H_
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