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

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

Issue 1233563004: Avoid race in isolate shutdown; add assertions, error messages (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Move wait per suggestion; port to all platforms. Created 5 years, 5 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_registry.h » ('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/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/os_thread.h" 11 #include "vm/os_thread.h"
12 #include "vm/profiler.h" 12 #include "vm/profiler.h"
13 #include "vm/stub_code.h" 13 #include "vm/stub_code.h"
14 #include "vm/thread_interrupter.h" 14 #include "vm/thread_interrupter.h"
15 #include "vm/thread_registry.h" 15 #include "vm/thread_registry.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 // The single thread local key which stores all the thread local data 19 // The single thread local key which stores all the thread local data
20 // for a thread. 20 // for a thread.
21 // TODO(koda): Can we merge this with ThreadInterrupter::thread_state_key_? 21 // TODO(koda): Can we merge this with ThreadInterrupter::thread_state_key_?
22 ThreadLocalKey Thread::thread_key_ = OSThread::kUnsetThreadLocalKey; 22 ThreadLocalKey Thread::thread_key_ = OSThread::kUnsetThreadLocalKey;
23 23
24 24
25 static void DeleteThread(void* thread) { 25 static void DeleteThread(void* thread) {
26 delete reinterpret_cast<Thread*>(thread); 26 delete reinterpret_cast<Thread*>(thread);
27 } 27 }
28 28
29 29
30 Thread::~Thread() {
31 // We should cleanly exit any isolate before destruction.
32 ASSERT(isolate_ == NULL);
33 }
34
35
30 void Thread::InitOnceBeforeIsolate() { 36 void Thread::InitOnceBeforeIsolate() {
31 ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey); 37 ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey);
32 thread_key_ = OSThread::CreateThreadLocal(DeleteThread); 38 thread_key_ = OSThread::CreateThreadLocal(DeleteThread);
33 ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey); 39 ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey);
34 ASSERT(Thread::Current() == NULL); 40 ASSERT(Thread::Current() == NULL);
35 // Postpone initialization of VM constants for this first thread. 41 // Postpone initialization of VM constants for this first thread.
36 SetCurrent(new Thread(false)); 42 SetCurrent(new Thread(false));
37 } 43 }
38 44
39 45
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ 252 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \
247 ASSERT((expr)->IsVMHeapObject()); \ 253 ASSERT((expr)->IsVMHeapObject()); \
248 if (object.raw() == expr) return Thread::member_name##offset(); 254 if (object.raw() == expr) return Thread::member_name##offset();
249 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET) 255 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET)
250 #undef COMPUTE_OFFSET 256 #undef COMPUTE_OFFSET
251 UNREACHABLE(); 257 UNREACHABLE();
252 return -1; 258 return -1;
253 } 259 }
254 260
255 } // namespace dart 261 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698