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

Unified Diff: runtime/vm/pages.cc

Issue 70993002: - Convert heap sizes to words from bytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/pages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
===================================================================
--- runtime/vm/pages.cc (revision 30540)
+++ runtime/vm/pages.cc (working copy)
@@ -43,8 +43,9 @@
}
-HeapPage* HeapPage::Allocate(intptr_t size, PageType type) {
- VirtualMemory* memory = VirtualMemory::Reserve(size);
+HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) {
+ VirtualMemory* memory =
+ VirtualMemory::Reserve(size_in_words << kWordSizeLog2);
return Initialize(memory, type);
}
@@ -134,33 +135,33 @@
}
-intptr_t PageSpace::LargePageSizeFor(intptr_t size) {
+intptr_t PageSpace::LargePageSizeInWordsFor(intptr_t size) {
intptr_t page_size = Utils::RoundUp(size + HeapPage::ObjectStartOffset(),
VirtualMemory::PageSize());
- return page_size;
+ return page_size >> kWordSizeLog2;
}
HeapPage* PageSpace::AllocatePage(HeapPage::PageType type) {
- HeapPage* page = HeapPage::Allocate(kPageSize, type);
+ HeapPage* page = HeapPage::Allocate(kPageSizeInWords, type);
if (pages_ == NULL) {
pages_ = page;
} else {
pages_tail_->set_next(page);
}
pages_tail_ = page;
- capacity_in_words_ += (kPageSize >> kWordSizeLog2);
+ capacity_in_words_ += kPageSizeInWords;
page->set_object_end(page->memory_->end());
return page;
}
HeapPage* PageSpace::AllocateLargePage(intptr_t size, HeapPage::PageType type) {
- intptr_t page_size = LargePageSizeFor(size);
- HeapPage* page = HeapPage::Allocate(page_size, type);
+ intptr_t page_size_in_words = LargePageSizeInWordsFor(size);
+ HeapPage* page = HeapPage::Allocate(page_size_in_words, type);
page->set_next(large_pages_);
large_pages_ = page;
- capacity_in_words_ += (page_size >> kWordSizeLog2);
+ capacity_in_words_ += page_size_in_words;
// Only one object in this page.
page->set_object_end(page->object_start() + size);
return page;
@@ -216,7 +217,7 @@
if ((result == 0) &&
(page_space_controller_.CanGrowPageSpace(size) ||
growth_policy == kForceGrowth) &&
- CanIncreaseCapacityInWords(kPageSize >> kWordSizeLog2)) {
+ CanIncreaseCapacityInWords(kPageSizeInWords)) {
HeapPage* page = AllocatePage(type);
ASSERT(page != NULL);
// Start of the newly allocated page is the allocated object.
@@ -230,14 +231,14 @@
}
} else {
// Large page allocation.
- intptr_t page_size = LargePageSizeFor(size);
- if (page_size < size) {
+ intptr_t page_size_in_words = LargePageSizeInWordsFor(size);
+ if ((page_size_in_words << kWordSizeLog2) < size) {
// On overflow we fail to allocate.
return 0;
}
if ((page_space_controller_.CanGrowPageSpace(size) ||
growth_policy == kForceGrowth) &&
- CanIncreaseCapacityInWords(page_size >> kWordSizeLog2)) {
+ CanIncreaseCapacityInWords(page_size_in_words)) {
HeapPage* page = AllocateLargePage(size, type);
if (page != NULL) {
result = page->object_start();
@@ -568,8 +569,9 @@
bool PageSpaceController::CanGrowPageSpace(intptr_t size_in_bytes) {
- size_in_bytes = Utils::RoundUp(size_in_bytes, PageSpace::kPageSize);
- intptr_t size_in_pages = size_in_bytes / PageSpace::kPageSize;
+ intptr_t size_in_words = size_in_bytes >> kWordSizeLog2;
+ size_in_words = Utils::RoundUp(size_in_words, PageSpace::kPageSizeInWords);
+ intptr_t size_in_pages = size_in_words / PageSpace::kPageSizeInWords;
if (!is_enabled_) {
return true;
}
@@ -610,9 +612,9 @@
used_after_in_words / desired_utilization_);
intptr_t growth_in_words = Utils::RoundUp(
growth_target - used_after_in_words,
- PageSpace::kPageSize >> kWordSizeLog2);
+ PageSpace::kPageSizeInWords);
int growth_in_pages =
- growth_in_words / (PageSpace::kPageSize >> kWordSizeLog2);
+ growth_in_words / PageSpace::kPageSizeInWords;
grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_);
heap->RecordData(PageSpace::kPageGrowth, growth_in_pages);
}
« 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