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

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

Issue 1236913006: Fix crash in code coverage generation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Move timeline to first group. Created 5 years, 5 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 | « no previous file | no next file » | 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/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
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 if ((timeline_event_recorder_ != NULL) &&
1446 (FLAG_timeline_trace_dir != NULL)) {
1447 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir);
1448 }
1449 }
1450
1436 // Remove this isolate from the list *before* we start tearing it down, to 1451 // Remove this isolate from the list *before* we start tearing it down, to
1437 // avoid exposing it in a state of decay. 1452 // avoid exposing it in a state of decay.
1438 RemoveIsolateFromList(this); 1453 RemoveIsolateFromList(this);
1439 1454
1440 if (heap_ != NULL) { 1455 if (heap_ != NULL) {
1441 // Wait for any concurrent GC tasks to finish before shutting down. 1456 // Wait for any concurrent GC tasks to finish before shutting down.
1457 // TODO(koda): Support faster sweeper shutdown (e.g., after current page).
1442 PageSpace* old_space = heap_->old_space(); 1458 PageSpace* old_space = heap_->old_space();
1443 MonitorLocker ml(old_space->tasks_lock()); 1459 MonitorLocker ml(old_space->tasks_lock());
1444 while (old_space->tasks() > 0) { 1460 while (old_space->tasks() > 0) {
1445 ml.Wait(); 1461 ml.Wait();
1446 } 1462 }
1447 } 1463 }
1448 1464
1449 // Create an area where we do have a zone and a handle scope so that we can 1465 // Then, proceed with low-level teardown.
1450 // call VM functions while tearing this isolate down.
1451 { 1466 {
1467 // Ensure we have a zone and handle scope so that we can call VM functions,
1468 // but we no longer allocate new heap objects.
1452 StackZone stack_zone(this); 1469 StackZone stack_zone(this);
1453 HandleScope handle_scope(this); 1470 HandleScope handle_scope(this);
1471 NoSafepointScope no_safepoint_scope;
1454 1472
1455 if (compiler_stats_ != NULL) { 1473 if (compiler_stats_ != NULL) {
1456 compiler_stats()->Print(); 1474 compiler_stats()->Print();
1457 } 1475 }
1458 1476
1459 // Notify exit listeners that this isolate is shutting down. 1477 // Notify exit listeners that this isolate is shutting down.
1460 if (object_store() != NULL) { 1478 if (object_store() != NULL) {
1461 NotifyExitListeners(); 1479 NotifyExitListeners();
1462 } 1480 }
1463 1481
1464 // Clean up debugger resources. 1482 // Clean up debugger resources.
1465 debugger()->Shutdown(); 1483 debugger()->Shutdown();
1466 1484
1467 // Close all the ports owned by this isolate. 1485 // Close all the ports owned by this isolate.
1468 PortMap::ClosePorts(message_handler()); 1486 PortMap::ClosePorts(message_handler());
1469 1487
1470 // Fail fast if anybody tries to post any more messsages to this isolate. 1488 // Fail fast if anybody tries to post any more messsages to this isolate.
1471 delete message_handler(); 1489 delete message_handler();
1472 set_message_handler(NULL); 1490 set_message_handler(NULL);
1473 1491
1474 // Dump all accumulated timer data for the isolate. 1492 // Dump all accumulated timer data for the isolate.
1475 timer_list_.ReportTimers(); 1493 timer_list_.ReportTimers();
1476 1494
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. 1495 // Finalize any weak persistent handles with a non-null referent.
1481 FinalizeWeakPersistentHandlesVisitor visitor; 1496 FinalizeWeakPersistentHandlesVisitor visitor;
1482 api_state()->weak_persistent_handles().VisitHandles(&visitor); 1497 api_state()->weak_persistent_handles().VisitHandles(&visitor);
1483 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor); 1498 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor);
1484 1499
1485 if (FLAG_trace_isolates) { 1500 if (FLAG_trace_isolates) {
1486 heap()->PrintSizes(); 1501 heap()->PrintSizes();
1487 megamorphic_cache_table()->PrintSizes(); 1502 megamorphic_cache_table()->PrintSizes();
1488 Symbols::DumpStats(); 1503 Symbols::DumpStats();
1489 OS::Print("[-] Stopping isolate:\n" 1504 OS::Print("[-] Stopping isolate:\n"
1490 "\tisolate: %s\n", name()); 1505 "\tisolate: %s\n", name());
1491 } 1506 }
1507 }
1492 1508
1493 if ((timeline_event_recorder_ != NULL) && 1509 #if defined(DEBUG)
1494 (FLAG_timeline_trace_dir != NULL)) { 1510 // No concurrent sweeper tasks should be running at this point.
1495 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); 1511 if (heap_ != NULL) {
1496 } 1512 PageSpace* old_space = heap_->old_space();
1513 MonitorLocker ml(old_space->tasks_lock());
1514 ASSERT(old_space->tasks() == 0);
1497 } 1515 }
1516 #endif
1498 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
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698