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

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

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 4 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
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"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 isolate->MakeCurrentThreadMutator(thread); 127 isolate->MakeCurrentThreadMutator(thread);
128 isolate->set_vm_tag(VMTag::kVMTagId); 128 isolate->set_vm_tag(VMTag::kVMTagId);
129 ASSERT(thread->store_buffer_block_ == NULL); 129 ASSERT(thread->store_buffer_block_ == NULL);
130 thread->store_buffer_block_ = isolate->store_buffer()->PopNonFullBlock(); 130 thread->store_buffer_block_ = isolate->store_buffer()->PopNonFullBlock();
131 ASSERT(isolate->heap() != NULL); 131 ASSERT(isolate->heap() != NULL);
132 thread->heap_ = isolate->heap(); 132 thread->heap_ = isolate->heap();
133 thread->Schedule(isolate); 133 thread->Schedule(isolate);
134 ASSERT(thread->thread_state() == NULL); 134 ASSERT(thread->thread_state() == NULL);
135 InterruptableThreadState* thread_state = 135 InterruptableThreadState* thread_state =
136 ThreadInterrupter::GetCurrentThreadState(); 136 ThreadInterrupter::GetCurrentThreadState();
137 #if defined(DEBUG) 137 // TODO(koda): Calling Isolate::CheckForDuplicateThreadState(thread_state)
138 thread->set_thread_state(NULL); // Exclude thread itself from the dupe check. 138 // here can lead to deadlock. Isolate::KillAllIsolates(), takes the isolate
139 Isolate::CheckForDuplicateThreadState(thread_state); 139 // list lock and posts the kill message to the target isolate, entering the
140 thread->set_thread_state(thread_state); 140 // monitor at the top of MessageHandler::PostMessage() to do so. That monitor
141 #endif 141 // is also entered before calling MessageHandler::HandleMessages(), which
142 // enters a StartIsolateScope, which calls Thread::EnterIsolate(), which would
143 // call Isolate::CheckForDuplicateThreadState(), which attempts to take the
144 // isolate list lock, potentially creating a cycle.
145 // Evaluate doing this check some other way.
142 ASSERT(thread_state != NULL); 146 ASSERT(thread_state != NULL);
143 // TODO(koda): Migrate profiler interface to use Thread. 147 // TODO(koda): Migrate profiler interface to use Thread.
144 Profiler::BeginExecution(isolate); 148 Profiler::BeginExecution(isolate);
145 } 149 }
146 150
147 151
148 void Thread::ExitIsolate() { 152 void Thread::ExitIsolate() {
149 Thread* thread = Thread::Current(); 153 Thread* thread = Thread::Current();
150 // TODO(koda): Audit callers; they should know whether they're in an isolate. 154 // TODO(koda): Audit callers; they should know whether they're in an isolate.
151 if (thread == NULL || thread->isolate() == NULL) return; 155 if (thread == NULL || thread->isolate() == NULL) return;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ 263 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \
260 ASSERT((expr)->IsVMHeapObject()); \ 264 ASSERT((expr)->IsVMHeapObject()); \
261 if (object.raw() == expr) return Thread::member_name##offset(); 265 if (object.raw() == expr) return Thread::member_name##offset();
262 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET) 266 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET)
263 #undef COMPUTE_OFFSET 267 #undef COMPUTE_OFFSET
264 UNREACHABLE(); 268 UNREACHABLE();
265 return -1; 269 return -1;
266 } 270 }
267 271
268 } // namespace dart 272 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698