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

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

Issue 1270323002: Revert VM thread cleanup (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/dart_api_impl.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/code_observers.h" 7 #include "vm/code_observers.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
11 #include "vm/debugger.h" 11 #include "vm/debugger.h"
12 #include "vm/flags.h" 12 #include "vm/flags.h"
13 #include "vm/freelist.h" 13 #include "vm/freelist.h"
14 #include "vm/handles.h" 14 #include "vm/handles.h"
15 #include "vm/heap.h" 15 #include "vm/heap.h"
16 #include "vm/isolate.h" 16 #include "vm/isolate.h"
17 #include "vm/message.h"
18 #include "vm/metrics.h" 17 #include "vm/metrics.h"
19 #include "vm/object.h" 18 #include "vm/object.h"
20 #include "vm/object_store.h" 19 #include "vm/object_store.h"
21 #include "vm/object_id_ring.h" 20 #include "vm/object_id_ring.h"
22 #include "vm/port.h" 21 #include "vm/port.h"
23 #include "vm/profiler.h" 22 #include "vm/profiler.h"
24 #include "vm/service_isolate.h" 23 #include "vm/service_isolate.h"
25 #include "vm/simulator.h" 24 #include "vm/simulator.h"
26 #include "vm/snapshot.h" 25 #include "vm/snapshot.h"
27 #include "vm/stub_code.h" 26 #include "vm/stub_code.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 Isolate::SetUnhandledExceptionCallback(unhandled); 177 Isolate::SetUnhandledExceptionCallback(unhandled);
179 Isolate::SetShutdownCallback(shutdown); 178 Isolate::SetShutdownCallback(shutdown);
180 179
181 ServiceIsolate::Run(); 180 ServiceIsolate::Run();
182 181
183 return NULL; 182 return NULL;
184 } 183 }
185 184
186 185
187 const char* Dart::Cleanup() { 186 const char* Dart::Cleanup() {
188 ASSERT(Isolate::Current() == NULL); 187 // Shutdown the service isolate before shutting down the thread pool.
188 ServiceIsolate::Shutdown();
189 #if 0
190 // Ideally we should shutdown the VM isolate here, but the thread pool
191 // shutdown does not seem to ensure that all the threads have stopped
192 // execution before it terminates, this results in racing isolates.
189 if (vm_isolate_ == NULL) { 193 if (vm_isolate_ == NULL) {
190 return "VM already terminated."; 194 return "VM already terminated.";
191 } 195 }
192 196
193 // Disable the creation of new isolates. 197 ASSERT(Isolate::Current() == NULL);
194 Isolate::DisableIsolateCreation();
195 198
196 // Send the OOB Kill message to all remaining isolates.
197 Isolate::KillAllIsolates();
198
199 // Shutdown the service isolate before shutting down the thread pool.
200 ServiceIsolate::Shutdown();
201
202 // Shutdown the thread pool. On return, all thread pool threads have exited.
203 delete thread_pool_; 199 delete thread_pool_;
204 thread_pool_ = NULL; 200 thread_pool_ = NULL;
205 201
206 // Set the VM isolate as current isolate. 202 // Set the VM isolate as current isolate.
207 Thread::EnsureInit(); 203 Thread::EnsureInit();
208 Thread::EnterIsolate(vm_isolate_); 204 Thread::EnterIsolate(vm_isolate_);
209 205
206 // There is a planned and known asymmetry here: We exit one scope for the VM
207 // isolate to account for the scope that was entered in Dart_InitOnce.
208 Dart_ExitScope();
209
210 ShutdownIsolate(); 210 ShutdownIsolate();
211 vm_isolate_ = NULL; 211 vm_isolate_ = NULL;
212 212
213 TargetCPUFeatures::Cleanup(); 213 TargetCPUFeatures::Cleanup();
214 #endif
215
214 Profiler::Shutdown(); 216 Profiler::Shutdown();
215 CodeObservers::DeleteAll(); 217 CodeObservers::DeleteAll();
216 218
217 ASSERT(Isolate::IsolateCount() == 0);
218 return NULL; 219 return NULL;
219 } 220 }
220 221
221 222
222 Isolate* Dart::CreateIsolate(const char* name_prefix, 223 Isolate* Dart::CreateIsolate(const char* name_prefix,
223 const Dart_IsolateFlags& api_flags) { 224 const Dart_IsolateFlags& api_flags) {
224 // Create a new isolate. 225 // Create a new isolate.
225 Isolate* isolate = Isolate::Init(name_prefix, api_flags); 226 Isolate* isolate = Isolate::Init(name_prefix, api_flags);
227 ASSERT(isolate != NULL);
226 return isolate; 228 return isolate;
227 } 229 }
228 230
229 231
230 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { 232 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
231 // Initialize the new isolate. 233 // Initialize the new isolate.
232 Isolate* isolate = Isolate::Current(); 234 Isolate* isolate = Isolate::Current();
233 TIMERSCOPE(isolate, time_isolate_initialization); 235 TIMERSCOPE(isolate, time_isolate_initialization);
234 ASSERT(isolate != NULL); 236 ASSERT(isolate != NULL);
235 StackZone zone(isolate); 237 StackZone zone(isolate);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return predefined_handles_->handles_.IsValidScopedHandle(address); 355 return predefined_handles_->handles_.IsValidScopedHandle(address);
354 } 356 }
355 357
356 358
357 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 359 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
358 ASSERT(predefined_handles_ != NULL); 360 ASSERT(predefined_handles_ != NULL);
359 return predefined_handles_->api_handles_.IsValidHandle(handle); 361 return predefined_handles_->api_handles_.IsValidHandle(handle);
360 } 362 }
361 363
362 } // namespace dart 364 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698