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

Side by Side Diff: vm/pages.cc

Issue 10093010: - Free completely empty pages as part of sweep. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | « vm/pages.h ('k') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/gc_marker.h" 8 #include "vm/gc_marker.h"
9 #include "vm/gc_sweeper.h" 9 #include "vm/gc_sweeper.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 HeapPage* PageSpace::AllocateLargePage(intptr_t size) { 108 HeapPage* PageSpace::AllocateLargePage(intptr_t size) {
109 intptr_t page_size = LargePageSizeFor(size); 109 intptr_t page_size = LargePageSizeFor(size);
110 HeapPage* page = HeapPage::Allocate(page_size, is_executable_); 110 HeapPage* page = HeapPage::Allocate(page_size, is_executable_);
111 page->set_next(large_pages_); 111 page->set_next(large_pages_);
112 large_pages_ = page; 112 large_pages_ = page;
113 capacity_ += page_size; 113 capacity_ += page_size;
114 return page; 114 return page;
115 } 115 }
116 116
117 117
118 void PageSpace::FreePage(HeapPage* page, HeapPage* previous_page) {
119 capacity_ -= page->memory_->size();
120 // Remove the page from the list.
121 if (previous_page != NULL) {
122 previous_page->set_next(page->next());
123 } else {
124 large_pages_ = page->next();
Mads Ager (google) 2012/04/16 10:39:09 Shouldn't this be pages_ instead of large_pages_?
Ivan Posva 2012/04/16 13:51:04 pages_tail_ was not really needed. Removed.
125 }
126 // TODO(iposva): Consider adding to a pool of empty pages.
127 page->Deallocate();
128 }
129
130
118 void PageSpace::FreeLargePage(HeapPage* page, HeapPage* previous_page) { 131 void PageSpace::FreeLargePage(HeapPage* page, HeapPage* previous_page) {
119 capacity_ -= page->memory_->size(); 132 capacity_ -= page->memory_->size();
120 // Remove the page from the list. 133 // Remove the page from the list.
121 if (previous_page != NULL) { 134 if (previous_page != NULL) {
122 previous_page->set_next(page->next()); 135 previous_page->set_next(page->next());
123 } else { 136 } else {
124 large_pages_ = page->next(); 137 large_pages_ = page->next();
125 } 138 }
126 page->Deallocate(); 139 page->Deallocate();
127 } 140 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 GCMarker marker(heap_); 290 GCMarker marker(heap_);
278 marker.MarkObjects(isolate, this, invoke_api_callbacks); 291 marker.MarkObjects(isolate, this, invoke_api_callbacks);
279 292
280 // Reset the bump allocation page to unused. 293 // Reset the bump allocation page to unused.
281 bump_page_ = NULL; 294 bump_page_ = NULL;
282 // Reset the freelists and setup sweeping. 295 // Reset the freelists and setup sweeping.
283 freelist_.Reset(); 296 freelist_.Reset();
284 GCSweeper sweeper(heap_); 297 GCSweeper sweeper(heap_);
285 intptr_t in_use = 0; 298 intptr_t in_use = 0;
286 299
300 HeapPage* prev_page = NULL;
287 HeapPage* page = pages_; 301 HeapPage* page = pages_;
288 while (page != NULL) { 302 while (page != NULL) {
289 intptr_t page_in_use = sweeper.SweepPage(page, &freelist_); 303 intptr_t page_in_use = sweeper.SweepPage(page, &freelist_);
290 in_use += page_in_use; 304 HeapPage* next_page = page->next();
291 page = page->next(); 305 if (page_in_use == 0) {
306 FreePage(page, prev_page);
307 } else {
308 in_use += page_in_use;
309 prev_page = page;
310 }
311 // Advance to the next page.
312 page = next_page;
292 } 313 }
293 314
294 HeapPage* prev_page = NULL;
295 page = large_pages_; 315 page = large_pages_;
296 while (page != NULL) { 316 while (page != NULL) {
297 intptr_t page_in_use = sweeper.SweepLargePage(page); 317 intptr_t page_in_use = sweeper.SweepLargePage(page);
298 HeapPage* next_page = page->next(); 318 HeapPage* next_page = page->next();
299 if (page_in_use == 0) { 319 if (page_in_use == 0) {
300 FreeLargePage(page, prev_page); 320 FreeLargePage(page, prev_page);
301 } else { 321 } else {
302 in_use += page_in_use; 322 in_use += page_in_use;
303 prev_page = page; 323 prev_page = page;
304 } 324 }
(...skipping 22 matching lines...) Expand all
327 OS::PrintErr(" done.\n"); 347 OS::PrintErr(" done.\n");
328 } 348 }
329 349
330 count_++; 350 count_++;
331 // Done, reset the marker. 351 // Done, reset the marker.
332 ASSERT(sweeping_); 352 ASSERT(sweeping_);
333 sweeping_ = false; 353 sweeping_ = false;
334 } 354 }
335 355
336 } // namespace dart 356 } // namespace dart
OLDNEW
« no previous file with comments | « vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698