OLD | NEW |
---|---|
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/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/json.h" | 9 #include "platform/json.h" |
10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1425 | 1425 |
1426 void Isolate::Shutdown() { | 1426 void Isolate::Shutdown() { |
1427 ASSERT(this == Isolate::Current()); | 1427 ASSERT(this == Isolate::Current()); |
1428 ASSERT(top_resource() == NULL); | 1428 ASSERT(top_resource() == NULL); |
1429 #if defined(DEBUG) | 1429 #if defined(DEBUG) |
1430 if (heap_ != NULL) { | 1430 if (heap_ != NULL) { |
1431 // The VM isolate keeps all objects marked. | 1431 // The VM isolate keeps all objects marked. |
1432 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); | 1432 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); |
1433 } | 1433 } |
1434 #endif // DEBUG | 1434 #endif // DEBUG |
1435 if (heap_ != NULL) { | |
1436 // Wait for any concurrent GC tasks to finish before shutting down. | |
1437 PageSpace* old_space = heap_->old_space(); | |
1438 MonitorLocker ml(old_space->tasks_lock()); | |
1439 while (old_space->tasks() > 0) { | |
1440 ml.Wait(); | |
1441 } | |
1442 } | |
siva
2015/07/13 23:37:00
I am wondering if we should do this wait after rem
koda
2015/07/14 00:41:40
Done.
| |
1435 | 1443 |
1436 // Remove this isolate from the list *before* we start tearing it down, to | 1444 // Remove this isolate from the list *before* we start tearing it down, to |
1437 // avoid exposing it in a state of decay. | 1445 // avoid exposing it in a state of decay. |
1438 RemoveIsolateFromList(this); | 1446 RemoveIsolateFromList(this); |
1439 | 1447 |
1440 // Create an area where we do have a zone and a handle scope so that we can | 1448 // Create an area where we do have a zone and a handle scope so that we can |
1441 // call VM functions while tearing this isolate down. | 1449 // call VM functions while tearing this isolate down. |
1442 { | 1450 { |
1443 StackZone stack_zone(this); | 1451 StackZone stack_zone(this); |
1444 HandleScope handle_scope(this); | 1452 HandleScope handle_scope(this); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1483 | 1491 |
1484 if ((timeline_event_recorder_ != NULL) && | 1492 if ((timeline_event_recorder_ != NULL) && |
1485 (FLAG_timeline_trace_dir != NULL)) { | 1493 (FLAG_timeline_trace_dir != NULL)) { |
1486 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); | 1494 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); |
1487 } | 1495 } |
1488 } | 1496 } |
1489 | 1497 |
1490 // TODO(5411455): For now just make sure there are no current isolates | 1498 // TODO(5411455): For now just make sure there are no current isolates |
1491 // as we are shutting down the isolate. | 1499 // as we are shutting down the isolate. |
1492 Thread::ExitIsolate(); | 1500 Thread::ExitIsolate(); |
1501 // All threads should have exited by now. | |
1502 thread_registry()->CheckNotScheduled(this); | |
1493 Profiler::ShutdownProfilingForIsolate(this); | 1503 Profiler::ShutdownProfilingForIsolate(this); |
1494 } | 1504 } |
1495 | 1505 |
1496 | 1506 |
1497 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1507 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
1498 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | 1508 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; |
1499 Dart_IsolateUnhandledExceptionCallback | 1509 Dart_IsolateUnhandledExceptionCallback |
1500 Isolate::unhandled_exception_callback_ = NULL; | 1510 Isolate::unhandled_exception_callback_ = NULL; |
1501 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 1511 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
1502 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 1512 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2087 serialized_message_, serialized_message_len_); | 2097 serialized_message_, serialized_message_len_); |
2088 } | 2098 } |
2089 | 2099 |
2090 | 2100 |
2091 void IsolateSpawnState::Cleanup() { | 2101 void IsolateSpawnState::Cleanup() { |
2092 SwitchIsolateScope switch_scope(I); | 2102 SwitchIsolateScope switch_scope(I); |
2093 Dart::ShutdownIsolate(); | 2103 Dart::ShutdownIsolate(); |
2094 } | 2104 } |
2095 | 2105 |
2096 } // namespace dart | 2106 } // namespace dart |
OLD | NEW |