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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 1435 |
1436 // First, perform higher-level cleanup that may need to allocate. | |
1437 { | |
1438 // Ensure we have a zone and handle scope so that we can call VM functions. | |
1439 StackZone stack_zone(this); | |
1440 HandleScope handle_scope(this); | |
1441 | |
1442 // Write out the coverage data if collection has been enabled. | |
1443 CodeCoverage::Write(this); | |
1444 } | |
1445 | |
1436 // Remove this isolate from the list *before* we start tearing it down, to | 1446 // Remove this isolate from the list *before* we start tearing it down, to |
1437 // avoid exposing it in a state of decay. | 1447 // avoid exposing it in a state of decay. |
1438 RemoveIsolateFromList(this); | 1448 RemoveIsolateFromList(this); |
1439 | 1449 |
1440 if (heap_ != NULL) { | 1450 if (heap_ != NULL) { |
1441 // Wait for any concurrent GC tasks to finish before shutting down. | 1451 // Wait for any concurrent GC tasks to finish before shutting down. |
1452 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). | |
1442 PageSpace* old_space = heap_->old_space(); | 1453 PageSpace* old_space = heap_->old_space(); |
1443 MonitorLocker ml(old_space->tasks_lock()); | 1454 MonitorLocker ml(old_space->tasks_lock()); |
1444 while (old_space->tasks() > 0) { | 1455 while (old_space->tasks() > 0) { |
1445 ml.Wait(); | 1456 ml.Wait(); |
1446 } | 1457 } |
1447 } | 1458 } |
1448 | 1459 |
1449 // Create an area where we do have a zone and a handle scope so that we can | 1460 // Then, proceed with low-level teardown. |
1450 // call VM functions while tearing this isolate down. | |
1451 { | 1461 { |
1462 // Ensure we have a zone and handle scope so that we can call VM functions, | |
1463 // but we no longer allocate new heap objects. | |
1452 StackZone stack_zone(this); | 1464 StackZone stack_zone(this); |
1453 HandleScope handle_scope(this); | 1465 HandleScope handle_scope(this); |
1466 NoSafepointScope no_safepoint_scope; | |
1454 | 1467 |
1455 if (compiler_stats_ != NULL) { | 1468 if (compiler_stats_ != NULL) { |
1456 compiler_stats()->Print(); | 1469 compiler_stats()->Print(); |
1457 } | 1470 } |
1458 | 1471 |
1459 // Notify exit listeners that this isolate is shutting down. | 1472 // Notify exit listeners that this isolate is shutting down. |
1460 if (object_store() != NULL) { | 1473 if (object_store() != NULL) { |
1461 NotifyExitListeners(); | 1474 NotifyExitListeners(); |
1462 } | 1475 } |
1463 | 1476 |
1464 // Clean up debugger resources. | 1477 // Clean up debugger resources. |
1465 debugger()->Shutdown(); | 1478 debugger()->Shutdown(); |
1466 | 1479 |
1467 // Close all the ports owned by this isolate. | 1480 // Close all the ports owned by this isolate. |
1468 PortMap::ClosePorts(message_handler()); | 1481 PortMap::ClosePorts(message_handler()); |
1469 | 1482 |
1470 // Fail fast if anybody tries to post any more messsages to this isolate. | 1483 // Fail fast if anybody tries to post any more messsages to this isolate. |
1471 delete message_handler(); | 1484 delete message_handler(); |
1472 set_message_handler(NULL); | 1485 set_message_handler(NULL); |
1473 | 1486 |
1474 // Dump all accumulated timer data for the isolate. | 1487 // Dump all accumulated timer data for the isolate. |
1475 timer_list_.ReportTimers(); | 1488 timer_list_.ReportTimers(); |
1476 | 1489 |
1477 // Write out the coverage data if collection has been enabled. | |
1478 CodeCoverage::Write(this); | |
1479 | |
1480 // Finalize any weak persistent handles with a non-null referent. | 1490 // Finalize any weak persistent handles with a non-null referent. |
1481 FinalizeWeakPersistentHandlesVisitor visitor; | 1491 FinalizeWeakPersistentHandlesVisitor visitor; |
1482 api_state()->weak_persistent_handles().VisitHandles(&visitor); | 1492 api_state()->weak_persistent_handles().VisitHandles(&visitor); |
1483 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor); | 1493 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor); |
1484 | 1494 |
1485 if (FLAG_trace_isolates) { | 1495 if (FLAG_trace_isolates) { |
1486 heap()->PrintSizes(); | 1496 heap()->PrintSizes(); |
1487 megamorphic_cache_table()->PrintSizes(); | 1497 megamorphic_cache_table()->PrintSizes(); |
1488 Symbols::DumpStats(); | 1498 Symbols::DumpStats(); |
1489 OS::Print("[-] Stopping isolate:\n" | 1499 OS::Print("[-] Stopping isolate:\n" |
1490 "\tisolate: %s\n", name()); | 1500 "\tisolate: %s\n", name()); |
1491 } | 1501 } |
1492 | 1502 |
1493 if ((timeline_event_recorder_ != NULL) && | 1503 if ((timeline_event_recorder_ != NULL) && |
rmacnak
2015/07/17 17:23:26
Move emitting the timeline events to the first gro
koda
2015/07/17 17:45:30
Done.
| |
1494 (FLAG_timeline_trace_dir != NULL)) { | 1504 (FLAG_timeline_trace_dir != NULL)) { |
1495 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); | 1505 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); |
1496 } | 1506 } |
1497 } | 1507 } |
1498 | 1508 |
1509 #if defined(DEBUG) | |
1510 // No concurrent sweeper tasks should be running at this point. | |
1511 if (heap_ != NULL) { | |
1512 PageSpace* old_space = heap_->old_space(); | |
1513 MonitorLocker ml(old_space->tasks_lock()); | |
1514 ASSERT(old_space->tasks() == 0); | |
1515 } | |
1516 #endif | |
1517 | |
1499 // TODO(5411455): For now just make sure there are no current isolates | 1518 // TODO(5411455): For now just make sure there are no current isolates |
1500 // as we are shutting down the isolate. | 1519 // as we are shutting down the isolate. |
1501 Thread::ExitIsolate(); | 1520 Thread::ExitIsolate(); |
1502 // All threads should have exited by now. | 1521 // All threads should have exited by now. |
1503 thread_registry()->CheckNotScheduled(this); | 1522 thread_registry()->CheckNotScheduled(this); |
1504 Profiler::ShutdownProfilingForIsolate(this); | 1523 Profiler::ShutdownProfilingForIsolate(this); |
1505 } | 1524 } |
1506 | 1525 |
1507 | 1526 |
1508 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1527 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2098 serialized_message_, serialized_message_len_); | 2117 serialized_message_, serialized_message_len_); |
2099 } | 2118 } |
2100 | 2119 |
2101 | 2120 |
2102 void IsolateSpawnState::Cleanup() { | 2121 void IsolateSpawnState::Cleanup() { |
2103 SwitchIsolateScope switch_scope(I); | 2122 SwitchIsolateScope switch_scope(I); |
2104 Dart::ShutdownIsolate(); | 2123 Dart::ShutdownIsolate(); |
2105 } | 2124 } |
2106 | 2125 |
2107 } // namespace dart | 2126 } // namespace dart |
OLD | NEW |