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

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

Issue 10191014: Reland r6578 without changing the order of pages in the PageSpace::pages_ list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 | « runtime/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 pages_ = page->next();
125 }
126 if (page == pages_tail_) {
127 pages_tail_ = previous_page;
128 }
129 // TODO(iposva): Consider adding to a pool of empty pages.
130 page->Deallocate();
131 }
132
133
118 void PageSpace::FreeLargePage(HeapPage* page, HeapPage* previous_page) { 134 void PageSpace::FreeLargePage(HeapPage* page, HeapPage* previous_page) {
119 capacity_ -= page->memory_->size(); 135 capacity_ -= page->memory_->size();
120 // Remove the page from the list. 136 // Remove the page from the list.
121 if (previous_page != NULL) { 137 if (previous_page != NULL) {
122 previous_page->set_next(page->next()); 138 previous_page->set_next(page->next());
123 } else { 139 } else {
124 large_pages_ = page->next(); 140 large_pages_ = page->next();
125 } 141 }
126 page->Deallocate(); 142 page->Deallocate();
127 } 143 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 GCMarker marker(heap_); 293 GCMarker marker(heap_);
278 marker.MarkObjects(isolate, this, invoke_api_callbacks); 294 marker.MarkObjects(isolate, this, invoke_api_callbacks);
279 295
280 // Reset the bump allocation page to unused. 296 // Reset the bump allocation page to unused.
281 bump_page_ = NULL; 297 bump_page_ = NULL;
282 // Reset the freelists and setup sweeping. 298 // Reset the freelists and setup sweeping.
283 freelist_.Reset(); 299 freelist_.Reset();
284 GCSweeper sweeper(heap_); 300 GCSweeper sweeper(heap_);
285 intptr_t in_use = 0; 301 intptr_t in_use = 0;
286 302
303 HeapPage* prev_page = NULL;
287 HeapPage* page = pages_; 304 HeapPage* page = pages_;
288 while (page != NULL) { 305 while (page != NULL) {
289 intptr_t page_in_use = sweeper.SweepPage(page, &freelist_); 306 intptr_t page_in_use = sweeper.SweepPage(page, &freelist_);
290 in_use += page_in_use; 307 HeapPage* next_page = page->next();
291 page = page->next(); 308 if (page_in_use == 0) {
309 FreePage(page, prev_page);
310 } else {
311 in_use += page_in_use;
312 prev_page = page;
313 }
314 // Advance to the next page.
315 page = next_page;
292 } 316 }
293 317
294 HeapPage* prev_page = NULL; 318 prev_page = NULL;
295 page = large_pages_; 319 page = large_pages_;
296 while (page != NULL) { 320 while (page != NULL) {
297 intptr_t page_in_use = sweeper.SweepLargePage(page); 321 intptr_t page_in_use = sweeper.SweepLargePage(page);
298 HeapPage* next_page = page->next(); 322 HeapPage* next_page = page->next();
299 if (page_in_use == 0) { 323 if (page_in_use == 0) {
300 FreeLargePage(page, prev_page); 324 FreeLargePage(page, prev_page);
301 } else { 325 } else {
302 in_use += page_in_use; 326 in_use += page_in_use;
303 prev_page = page; 327 prev_page = page;
304 } 328 }
(...skipping 22 matching lines...) Expand all
327 OS::PrintErr(" done.\n"); 351 OS::PrintErr(" done.\n");
328 } 352 }
329 353
330 count_++; 354 count_++;
331 // Done, reset the marker. 355 // Done, reset the marker.
332 ASSERT(sweeping_); 356 ASSERT(sweeping_);
333 sweeping_ = false; 357 sweeping_ = false;
334 } 358 }
335 359
336 } // namespace dart 360 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698