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

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

Issue 1814243002: Add Thread TaskKind (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.h ('k') | runtime/vm/thread_test.cc » ('j') | 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.h" 5 #include "vm/thread.h"
6 6
7 #include "vm/dart_api_state.h" 7 #include "vm/dart_api_state.h"
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 Thread::Thread(Isolate* isolate) 57 Thread::Thread(Isolate* isolate)
58 : BaseThread(false), 58 : BaseThread(false),
59 stack_limit_(0), 59 stack_limit_(0),
60 stack_overflow_flags_(0), 60 stack_overflow_flags_(0),
61 isolate_(NULL), 61 isolate_(NULL),
62 heap_(NULL), 62 heap_(NULL),
63 top_exit_frame_info_(0), 63 top_exit_frame_info_(0),
64 store_buffer_block_(NULL), 64 store_buffer_block_(NULL),
65 vm_tag_(0), 65 vm_tag_(0),
66 task_kind_(kUnknownTask),
66 os_thread_(NULL), 67 os_thread_(NULL),
67 thread_lock_(new Monitor()), 68 thread_lock_(new Monitor()),
68 zone_(NULL), 69 zone_(NULL),
69 api_reusable_scope_(NULL), 70 api_reusable_scope_(NULL),
70 api_top_scope_(NULL), 71 api_top_scope_(NULL),
71 top_resource_(NULL), 72 top_resource_(NULL),
72 long_jump_base_(NULL), 73 long_jump_base_(NULL),
73 no_callback_scope_depth_(0), 74 no_callback_scope_depth_(0),
74 #if defined(DEBUG) 75 #if defined(DEBUG)
75 top_handle_scope_(NULL), 76 top_handle_scope_(NULL),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void Thread::clear_sticky_error() { 218 void Thread::clear_sticky_error() {
218 sticky_error_ = Error::null(); 219 sticky_error_ = Error::null();
219 } 220 }
220 221
221 222
222 bool Thread::EnterIsolate(Isolate* isolate) { 223 bool Thread::EnterIsolate(Isolate* isolate) {
223 const bool kIsMutatorThread = true; 224 const bool kIsMutatorThread = true;
224 Thread* thread = isolate->ScheduleThread(kIsMutatorThread); 225 Thread* thread = isolate->ScheduleThread(kIsMutatorThread);
225 if (thread != NULL) { 226 if (thread != NULL) {
226 ASSERT(thread->store_buffer_block_ == NULL); 227 ASSERT(thread->store_buffer_block_ == NULL);
228 thread->task_kind_ = kMutatorTask;
227 thread->StoreBufferAcquire(); 229 thread->StoreBufferAcquire();
228 return true; 230 return true;
229 } 231 }
230 return false; 232 return false;
231 } 233 }
232 234
233 235
234 void Thread::ExitIsolate() { 236 void Thread::ExitIsolate() {
235 Thread* thread = Thread::Current(); 237 Thread* thread = Thread::Current();
236 ASSERT(thread != NULL && thread->IsMutatorThread()); 238 ASSERT(thread != NULL && thread->IsMutatorThread());
237 DEBUG_ASSERT(!thread->IsAnyReusableHandleScopeActive()); 239 DEBUG_ASSERT(!thread->IsAnyReusableHandleScopeActive());
238 240 thread->task_kind_ = kUnknownTask;
239 Isolate* isolate = thread->isolate(); 241 Isolate* isolate = thread->isolate();
240 ASSERT(isolate != NULL); 242 ASSERT(isolate != NULL);
241 ASSERT(thread->execution_state() == Thread::kThreadInVM); 243 ASSERT(thread->execution_state() == Thread::kThreadInVM);
242 // Clear since GC will not visit the thread once it is unscheduled. 244 // Clear since GC will not visit the thread once it is unscheduled.
243 thread->ClearReusableHandles(); 245 thread->ClearReusableHandles();
244 thread->StoreBufferRelease(); 246 thread->StoreBufferRelease();
245 if (isolate->is_runnable()) { 247 if (isolate->is_runnable()) {
246 thread->set_vm_tag(VMTag::kIdleTagId); 248 thread->set_vm_tag(VMTag::kIdleTagId);
247 } else { 249 } else {
248 thread->set_vm_tag(VMTag::kLoadWaitTagId); 250 thread->set_vm_tag(VMTag::kLoadWaitTagId);
249 } 251 }
250 const bool kIsMutatorThread = true; 252 const bool kIsMutatorThread = true;
251 isolate->UnscheduleThread(thread, kIsMutatorThread); 253 isolate->UnscheduleThread(thread, kIsMutatorThread);
252 } 254 }
253 255
254 256
255 bool Thread::EnterIsolateAsHelper(Isolate* isolate, bool bypass_safepoint) { 257 bool Thread::EnterIsolateAsHelper(Isolate* isolate,
258 TaskKind kind,
259 bool bypass_safepoint) {
256 const bool kIsNotMutatorThread = false; 260 const bool kIsNotMutatorThread = false;
257 Thread* thread = isolate->ScheduleThread(kIsNotMutatorThread, 261 Thread* thread = isolate->ScheduleThread(kIsNotMutatorThread,
258 bypass_safepoint); 262 bypass_safepoint);
259 if (thread != NULL) { 263 if (thread != NULL) {
260 ASSERT(thread->store_buffer_block_ == NULL); 264 ASSERT(thread->store_buffer_block_ == NULL);
261 // TODO(koda): Use StoreBufferAcquire once we properly flush 265 // TODO(koda): Use StoreBufferAcquire once we properly flush
262 // before Scavenge. 266 // before Scavenge.
263 thread->store_buffer_block_ = 267 thread->store_buffer_block_ =
264 thread->isolate()->store_buffer()->PopEmptyBlock(); 268 thread->isolate()->store_buffer()->PopEmptyBlock();
265 // This thread should not be the main mutator. 269 // This thread should not be the main mutator.
270 thread->task_kind_ = kind;
siva 2016/03/18 22:48:41 ASSERT(kind != kMutatorTask);
Cutch 2016/03/21 16:35:04 Done.
266 ASSERT(!thread->IsMutatorThread()); 271 ASSERT(!thread->IsMutatorThread());
267 return true; 272 return true;
268 } 273 }
269 return false; 274 return false;
270 } 275 }
271 276
272 277
273 void Thread::ExitIsolateAsHelper(bool bypass_safepoint) { 278 void Thread::ExitIsolateAsHelper(bool bypass_safepoint) {
274 Thread* thread = Thread::Current(); 279 Thread* thread = Thread::Current();
275 ASSERT(thread != NULL); 280 ASSERT(thread != NULL);
276 ASSERT(!thread->IsMutatorThread()); 281 ASSERT(!thread->IsMutatorThread());
277 ASSERT(thread->execution_state() == Thread::kThreadInVM); 282 ASSERT(thread->execution_state() == Thread::kThreadInVM);
283 thread->task_kind_ = kUnknownTask;
278 // Clear since GC will not visit the thread once it is unscheduled. 284 // Clear since GC will not visit the thread once it is unscheduled.
279 thread->ClearReusableHandles(); 285 thread->ClearReusableHandles();
280 thread->StoreBufferRelease(); 286 thread->StoreBufferRelease();
281 Isolate* isolate = thread->isolate(); 287 Isolate* isolate = thread->isolate();
282 ASSERT(isolate != NULL); 288 ASSERT(isolate != NULL);
283 const bool kIsNotMutatorThread = false; 289 const bool kIsNotMutatorThread = false;
284 isolate->UnscheduleThread(thread, kIsNotMutatorThread, bypass_safepoint); 290 isolate->UnscheduleThread(thread, kIsNotMutatorThread, bypass_safepoint);
285 } 291 }
286 292
287 293
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 710
705 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { 711 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() {
706 if (thread() != NULL) { 712 if (thread() != NULL) {
707 OSThread* os_thread = thread()->os_thread(); 713 OSThread* os_thread = thread()->os_thread();
708 ASSERT(os_thread != NULL); 714 ASSERT(os_thread != NULL);
709 os_thread->EnableThreadInterrupts(); 715 os_thread->EnableThreadInterrupts();
710 } 716 }
711 } 717 }
712 718
713 } // namespace dart 719 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread.h ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698