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

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

Issue 2012973002: Background finalization. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/heap.cc ('k') | runtime/vm/profiler.h » ('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/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/text_buffer.h" 10 #include "platform/text_buffer.h"
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 1545
1546 1546
1547 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor { 1547 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor {
1548 public: 1548 public:
1549 FinalizeWeakPersistentHandlesVisitor() : HandleVisitor(Thread::Current()) { 1549 FinalizeWeakPersistentHandlesVisitor() : HandleVisitor(Thread::Current()) {
1550 } 1550 }
1551 1551
1552 void VisitHandle(uword addr) { 1552 void VisitHandle(uword addr) {
1553 FinalizablePersistentHandle* handle = 1553 FinalizablePersistentHandle* handle =
1554 reinterpret_cast<FinalizablePersistentHandle*>(addr); 1554 reinterpret_cast<FinalizablePersistentHandle*>(addr);
1555 handle->UpdateUnreachable(thread()->isolate()); 1555 FinalizationQueue* queue = NULL; // Finalize in the foreground.
1556 handle->UpdateUnreachable(thread()->isolate(), queue);
1556 } 1557 }
1557 1558
1558 private: 1559 private:
1559 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 1560 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
1560 }; 1561 };
1561 1562
1562 1563
1563 void Isolate::LowLevelShutdown() { 1564 void Isolate::LowLevelShutdown() {
1564 // Ensure we have a zone and handle scope so that we can call VM functions, 1565 // Ensure we have a zone and handle scope so that we can call VM functions,
1565 // but we no longer allocate new heap objects. 1566 // but we no longer allocate new heap objects.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 } 1669 }
1669 } 1670 }
1670 1671
1671 // Remove this isolate from the list *before* we start tearing it down, to 1672 // Remove this isolate from the list *before* we start tearing it down, to
1672 // avoid exposing it in a state of decay. 1673 // avoid exposing it in a state of decay.
1673 RemoveIsolateFromList(this); 1674 RemoveIsolateFromList(this);
1674 1675
1675 if (heap_ != NULL) { 1676 if (heap_ != NULL) {
1676 // Wait for any concurrent GC tasks to finish before shutting down. 1677 // Wait for any concurrent GC tasks to finish before shutting down.
1677 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). 1678 // TODO(koda): Support faster sweeper shutdown (e.g., after current page).
1678 PageSpace* old_space = heap_->old_space(); 1679 {
1679 MonitorLocker ml(old_space->tasks_lock()); 1680 PageSpace* old_space = heap_->old_space();
1680 while (old_space->tasks() > 0) { 1681 MonitorLocker ml(old_space->tasks_lock());
1681 ml.Wait(); 1682 while (old_space->tasks() > 0) {
1683 ml.Wait();
1684 }
1685 }
1686
1687 // Wait for background finalization to finish before shutting down.
1688 {
1689 MonitorLocker ml(heap_->finalization_tasks_lock());
1690 while (heap_->finalization_tasks() > 0) {
1691 ml.Wait();
1692 }
1682 } 1693 }
1683 } 1694 }
1684 1695
1685 // Then, proceed with low-level teardown. 1696 // Then, proceed with low-level teardown.
1686 LowLevelShutdown(); 1697 LowLevelShutdown();
1687 1698
1688 #if defined(DEBUG) 1699 #if defined(DEBUG)
1689 // No concurrent sweeper tasks should be running at this point. 1700 // No concurrent sweeper tasks should be running at this point.
1690 if (heap_ != NULL) { 1701 if (heap_ != NULL) {
1691 PageSpace* old_space = heap_->old_space(); 1702 PageSpace* old_space = heap_->old_space();
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2792 void IsolateSpawnState::DecrementSpawnCount() { 2803 void IsolateSpawnState::DecrementSpawnCount() {
2793 ASSERT(spawn_count_monitor_ != NULL); 2804 ASSERT(spawn_count_monitor_ != NULL);
2794 ASSERT(spawn_count_ != NULL); 2805 ASSERT(spawn_count_ != NULL);
2795 MonitorLocker ml(spawn_count_monitor_); 2806 MonitorLocker ml(spawn_count_monitor_);
2796 ASSERT(*spawn_count_ > 0); 2807 ASSERT(*spawn_count_ > 0);
2797 *spawn_count_ = *spawn_count_ - 1; 2808 *spawn_count_ = *spawn_count_ - 1;
2798 ml.Notify(); 2809 ml.Notify();
2799 } 2810 }
2800 2811
2801 } // namespace dart 2812 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698