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 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 1435 |
1436 // Remove this isolate from the list *before* we start tearing it down, to | 1436 // Remove this isolate from the list *before* we start tearing it down, to |
1437 // avoid exposing it in a state of decay. | 1437 // avoid exposing it in a state of decay. |
1438 RemoveIsolateFromList(this); | 1438 RemoveIsolateFromList(this); |
1439 | 1439 |
| 1440 if (heap_ != NULL) { |
| 1441 // Wait for any concurrent GC tasks to finish before shutting down. |
| 1442 PageSpace* old_space = heap_->old_space(); |
| 1443 MonitorLocker ml(old_space->tasks_lock()); |
| 1444 while (old_space->tasks() > 0) { |
| 1445 ml.Wait(); |
| 1446 } |
| 1447 } |
| 1448 |
1440 // Create an area where we do have a zone and a handle scope so that we can | 1449 // 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. | 1450 // call VM functions while tearing this isolate down. |
1442 { | 1451 { |
1443 StackZone stack_zone(this); | 1452 StackZone stack_zone(this); |
1444 HandleScope handle_scope(this); | 1453 HandleScope handle_scope(this); |
1445 | 1454 |
1446 if (compiler_stats_ != NULL) { | 1455 if (compiler_stats_ != NULL) { |
1447 compiler_stats()->Print(); | 1456 compiler_stats()->Print(); |
1448 } | 1457 } |
1449 | 1458 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 | 1492 |
1484 if ((timeline_event_recorder_ != NULL) && | 1493 if ((timeline_event_recorder_ != NULL) && |
1485 (FLAG_timeline_trace_dir != NULL)) { | 1494 (FLAG_timeline_trace_dir != NULL)) { |
1486 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); | 1495 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); |
1487 } | 1496 } |
1488 } | 1497 } |
1489 | 1498 |
1490 // TODO(5411455): For now just make sure there are no current isolates | 1499 // TODO(5411455): For now just make sure there are no current isolates |
1491 // as we are shutting down the isolate. | 1500 // as we are shutting down the isolate. |
1492 Thread::ExitIsolate(); | 1501 Thread::ExitIsolate(); |
| 1502 // All threads should have exited by now. |
| 1503 thread_registry()->CheckNotScheduled(this); |
1493 Profiler::ShutdownProfilingForIsolate(this); | 1504 Profiler::ShutdownProfilingForIsolate(this); |
1494 } | 1505 } |
1495 | 1506 |
1496 | 1507 |
1497 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1508 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
1498 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | 1509 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; |
1499 Dart_IsolateUnhandledExceptionCallback | 1510 Dart_IsolateUnhandledExceptionCallback |
1500 Isolate::unhandled_exception_callback_ = NULL; | 1511 Isolate::unhandled_exception_callback_ = NULL; |
1501 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 1512 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
1502 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 1513 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_); | 2098 serialized_message_, serialized_message_len_); |
2088 } | 2099 } |
2089 | 2100 |
2090 | 2101 |
2091 void IsolateSpawnState::Cleanup() { | 2102 void IsolateSpawnState::Cleanup() { |
2092 SwitchIsolateScope switch_scope(I); | 2103 SwitchIsolateScope switch_scope(I); |
2093 Dart::ShutdownIsolate(); | 2104 Dart::ShutdownIsolate(); |
2094 } | 2105 } |
2095 | 2106 |
2096 } // namespace dart | 2107 } // namespace dart |
OLD | NEW |