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

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

Issue 1136143003: Remove fake isolate from concurrent sweeper and extend lifetime of VM threads. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/isolate.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/gc_sweeper.h" 5 #include "vm/gc_sweeper.h"
6 6
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ASSERT(first_ != NULL); 106 ASSERT(first_ != NULL);
107 ASSERT(old_space_ != NULL); 107 ASSERT(old_space_ != NULL);
108 ASSERT(last_ != NULL); 108 ASSERT(last_ != NULL);
109 ASSERT(freelist_ != NULL); 109 ASSERT(freelist_ != NULL);
110 MonitorLocker ml(old_space_->tasks_lock()); 110 MonitorLocker ml(old_space_->tasks_lock());
111 old_space_->set_tasks(old_space_->tasks() + 1); 111 old_space_->set_tasks(old_space_->tasks() + 1);
112 ml.Notify(); 112 ml.Notify();
113 } 113 }
114 114
115 virtual void Run() { 115 virtual void Run() {
116 Thread::EnterIsolate(task_isolate_); 116 Thread::EnterIsolateAsHelper(task_isolate_);
117 GCSweeper sweeper; 117 GCSweeper sweeper;
118 118
119 HeapPage* page = first_; 119 HeapPage* page = first_;
120 HeapPage* prev_page = NULL; 120 HeapPage* prev_page = NULL;
121 121
122 while (page != NULL) { 122 while (page != NULL) {
123 HeapPage* next_page = page->next(); 123 HeapPage* next_page = page->next();
124 ASSERT(page->type() == HeapPage::kData); 124 ASSERT(page->type() == HeapPage::kData);
125 bool page_in_use = sweeper.SweepPage(page, freelist_, false); 125 bool page_in_use = sweeper.SweepPage(page, freelist_, false);
126 if (page_in_use) { 126 if (page_in_use) {
127 prev_page = page; 127 prev_page = page;
128 } else { 128 } else {
129 old_space_->FreePage(page, prev_page); 129 old_space_->FreePage(page, prev_page);
130 } 130 }
131 { 131 {
132 // Notify the mutator thread that we have added elements to the free 132 // Notify the mutator thread that we have added elements to the free
133 // list or that more capacity is available. 133 // list or that more capacity is available.
134 MonitorLocker ml(old_space_->tasks_lock()); 134 MonitorLocker ml(old_space_->tasks_lock());
135 ml.Notify(); 135 ml.Notify();
136 } 136 }
137 if (page == last_) break; 137 if (page == last_) break;
138 page = next_page; 138 page = next_page;
139 } 139 }
140 // This sweeper task is done. Notify the original isolate. 140 // This sweeper task is done. Notify the original isolate.
141 { 141 {
142 MonitorLocker ml(old_space_->tasks_lock()); 142 MonitorLocker ml(old_space_->tasks_lock());
143 old_space_->set_tasks(old_space_->tasks() - 1); 143 old_space_->set_tasks(old_space_->tasks() - 1);
144 ml.Notify(); 144 ml.Notify();
145 } 145 }
146 Thread::ExitIsolate(); 146 Thread::ExitIsolateAsHelper();
147 delete task_isolate_;
148 } 147 }
149 148
150 private: 149 private:
151 Isolate* task_isolate_; 150 Isolate* task_isolate_;
152 PageSpace* old_space_; 151 PageSpace* old_space_;
153 HeapPage* first_; 152 HeapPage* first_;
154 HeapPage* last_; 153 HeapPage* last_;
155 FreeList* freelist_; 154 FreeList* freelist_;
156 }; 155 };
157 156
158 157
159 void GCSweeper::SweepConcurrent(Isolate* isolate, 158 void GCSweeper::SweepConcurrent(Isolate* isolate,
160 HeapPage* first, 159 HeapPage* first,
161 HeapPage* last, 160 HeapPage* last,
162 FreeList* freelist) { 161 FreeList* freelist) {
163 SweeperTask* task = 162 SweeperTask* task =
164 new SweeperTask(isolate->ShallowCopy(), 163 new SweeperTask(isolate,
165 isolate->heap()->old_space(), 164 isolate->heap()->old_space(),
166 first, last, 165 first, last,
167 freelist); 166 freelist);
168 ThreadPool* pool = Dart::thread_pool(); 167 ThreadPool* pool = Dart::thread_pool();
169 pool->Run(task); 168 pool->Run(task);
170 } 169 }
171 170
172 } // namespace dart 171 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698