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

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

Issue 355123002: If a large object is truncated, also truncate the page. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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
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/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/gc_marker.h" 9 #include "vm/gc_marker.h"
10 #include "vm/gc_sweeper.h" 10 #include "vm/gc_sweeper.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 page->set_next(large_pages_); 175 page->set_next(large_pages_);
176 large_pages_ = page; 176 large_pages_ = page;
177 usage_.capacity_in_words += page_size_in_words; 177 usage_.capacity_in_words += page_size_in_words;
178 // Only one object in this page (at least until String::MakeExternal or 178 // Only one object in this page (at least until String::MakeExternal or
179 // Array::MakeArray is called). 179 // Array::MakeArray is called).
180 page->set_object_end(page->object_start() + size); 180 page->set_object_end(page->object_start() + size);
181 return page; 181 return page;
182 } 182 }
183 183
184 184
185 void PageSpace::TruncateLargePage(HeapPage* page,
186 intptr_t new_object_size_in_bytes) {
187 const intptr_t old_object_size_in_bytes =
188 page->object_end() - page->object_start();
189 ASSERT(new_object_size_in_bytes < old_object_size_in_bytes);
190 const intptr_t new_page_size_in_words =
191 LargePageSizeInWordsFor(new_object_size_in_bytes);
192 VirtualMemory* memory = page->memory_;
193 const intptr_t old_page_size_in_words = (memory->size() >> kWordSizeLog2);
194 memory->Truncate(memory->start(), (new_page_size_in_words << kWordSizeLog2));
195 usage_.capacity_in_words -= old_page_size_in_words;
196 usage_.capacity_in_words += new_page_size_in_words;
197 page->set_object_end(page->object_start() + new_object_size_in_bytes);
198 }
199
200
185 void PageSpace::FreePage(HeapPage* page, HeapPage* previous_page) { 201 void PageSpace::FreePage(HeapPage* page, HeapPage* previous_page) {
186 usage_.capacity_in_words -= (page->memory_->size() >> kWordSizeLog2); 202 usage_.capacity_in_words -= (page->memory_->size() >> kWordSizeLog2);
187 // Remove the page from the list. 203 // Remove the page from the list.
188 if (previous_page != NULL) { 204 if (previous_page != NULL) {
189 previous_page->set_next(page->next()); 205 previous_page->set_next(page->next());
190 } else { 206 } else {
191 pages_ = page->next(); 207 pages_ = page->next();
192 } 208 }
193 if (page == pages_tail_) { 209 if (page == pages_tail_) {
194 pages_tail_ = previous_page; 210 pages_tail_ = previous_page;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Advance to the next page. 547 // Advance to the next page.
532 page = next_page; 548 page = next_page;
533 } 549 }
534 550
535 int64_t mid3 = OS::GetCurrentTimeMicros(); 551 int64_t mid3 = OS::GetCurrentTimeMicros();
536 552
537 prev_page = NULL; 553 prev_page = NULL;
538 page = large_pages_; 554 page = large_pages_;
539 while (page != NULL) { 555 while (page != NULL) {
540 HeapPage* next_page = page->next(); 556 HeapPage* next_page = page->next();
541 bool page_in_use = sweeper.SweepLargePage(page); 557 const intptr_t bytes_to_end = sweeper.SweepLargePage(page);
542 if (page_in_use) { 558 if (bytes_to_end == 0) {
559 FreeLargePage(page, prev_page);
560 } else {
561 if (bytes_to_end < (page->object_end() - page->object_start())) {
Ivan Posva 2014/06/30 05:51:05 I am wondering whether we want to move the logic h
koda 2014/06/30 22:57:49 Done.
562 TruncateLargePage(page, bytes_to_end);
563 }
543 prev_page = page; 564 prev_page = page;
544 } else {
545 FreeLargePage(page, prev_page);
546 } 565 }
547 // Advance to the next page. 566 // Advance to the next page.
548 page = next_page; 567 page = next_page;
549 } 568 }
550 569
551 // Make code pages read-only. 570 // Make code pages read-only.
552 WriteProtectCode(true); 571 WriteProtectCode(true);
553 572
554 int64_t end = OS::GetCurrentTimeMicros(); 573 int64_t end = OS::GetCurrentTimeMicros();
555 574
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 return 0; 714 return 0;
696 } else { 715 } else {
697 ASSERT(total_time >= gc_time); 716 ASSERT(total_time >= gc_time);
698 int result= static_cast<int>((static_cast<double>(gc_time) / 717 int result= static_cast<int>((static_cast<double>(gc_time) /
699 static_cast<double>(total_time)) * 100); 718 static_cast<double>(total_time)) * 100);
700 return result; 719 return result;
701 } 720 }
702 } 721 }
703 722
704 } // namespace dart 723 } // namespace dart
OLDNEW
« runtime/vm/gc_sweeper.cc ('K') | « runtime/vm/pages.h ('k') | runtime/vm/virtual_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698