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

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

Issue 2041373004: Revert "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 FinalizationQueue* queue = NULL; // Finalize in the foreground. 1555 handle->UpdateUnreachable(thread()->isolate());
1556 handle->UpdateUnreachable(thread()->isolate(), queue);
1557 } 1556 }
1558 1557
1559 private: 1558 private:
1560 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 1559 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
1561 }; 1560 };
1562 1561
1563 1562
1564 void Isolate::LowLevelShutdown() { 1563 void Isolate::LowLevelShutdown() {
1565 // Ensure we have a zone and handle scope so that we can call VM functions, 1564 // Ensure we have a zone and handle scope so that we can call VM functions,
1566 // but we no longer allocate new heap objects. 1565 // but we no longer allocate new heap objects.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 } 1668 }
1670 } 1669 }
1671 1670
1672 // Remove this isolate from the list *before* we start tearing it down, to 1671 // Remove this isolate from the list *before* we start tearing it down, to
1673 // avoid exposing it in a state of decay. 1672 // avoid exposing it in a state of decay.
1674 RemoveIsolateFromList(this); 1673 RemoveIsolateFromList(this);
1675 1674
1676 if (heap_ != NULL) { 1675 if (heap_ != NULL) {
1677 // Wait for any concurrent GC tasks to finish before shutting down. 1676 // Wait for any concurrent GC tasks to finish before shutting down.
1678 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). 1677 // TODO(koda): Support faster sweeper shutdown (e.g., after current page).
1679 { 1678 PageSpace* old_space = heap_->old_space();
1680 PageSpace* old_space = heap_->old_space(); 1679 MonitorLocker ml(old_space->tasks_lock());
1681 MonitorLocker ml(old_space->tasks_lock()); 1680 while (old_space->tasks() > 0) {
1682 while (old_space->tasks() > 0) { 1681 ml.Wait();
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 }
1693 } 1682 }
1694 } 1683 }
1695 1684
1696 // Then, proceed with low-level teardown. 1685 // Then, proceed with low-level teardown.
1697 LowLevelShutdown(); 1686 LowLevelShutdown();
1698 1687
1699 #if defined(DEBUG) 1688 #if defined(DEBUG)
1700 // No concurrent sweeper tasks should be running at this point. 1689 // No concurrent sweeper tasks should be running at this point.
1701 if (heap_ != NULL) { 1690 if (heap_ != NULL) {
1702 PageSpace* old_space = heap_->old_space(); 1691 PageSpace* old_space = heap_->old_space();
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2803 void IsolateSpawnState::DecrementSpawnCount() { 2792 void IsolateSpawnState::DecrementSpawnCount() {
2804 ASSERT(spawn_count_monitor_ != NULL); 2793 ASSERT(spawn_count_monitor_ != NULL);
2805 ASSERT(spawn_count_ != NULL); 2794 ASSERT(spawn_count_ != NULL);
2806 MonitorLocker ml(spawn_count_monitor_); 2795 MonitorLocker ml(spawn_count_monitor_);
2807 ASSERT(*spawn_count_ > 0); 2796 ASSERT(*spawn_count_ > 0);
2808 *spawn_count_ = *spawn_count_ - 1; 2797 *spawn_count_ = *spawn_count_ - 1;
2809 ml.Notify(); 2798 ml.Notify();
2810 } 2799 }
2811 2800
2812 } // namespace dart 2801 } // 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