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

Unified Diff: vm/pages.cc

Issue 8962006: - Honor max_capacity even for large page allocation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years 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 | « vm/pages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/pages.cc
===================================================================
--- vm/pages.cc (revision 2528)
+++ vm/pages.cc (working copy)
@@ -69,6 +69,13 @@
}
+intptr_t PageSpace::LargePageSizeFor(intptr_t size) {
+ intptr_t page_size = Utils::RoundUp(size + sizeof(HeapPage),
+ VirtualMemory::PageSize());
+ return page_size;
+}
+
+
void PageSpace::AllocatePage() {
HeapPage* page = HeapPage::Allocate(kPageSize, is_executable_);
if (pages_ == NULL) {
@@ -82,8 +89,7 @@
HeapPage* PageSpace::AllocateLargePage(intptr_t size) {
- intptr_t page_size = Utils::RoundUp(size + sizeof(HeapPage),
- VirtualMemory::PageSize());
+ intptr_t page_size = LargePageSizeFor(size);
HeapPage* page = HeapPage::Allocate(page_size, is_executable_);
page->set_next(large_pages_);
large_pages_ = page;
@@ -136,7 +142,7 @@
if (size < kAllocatablePageSize) {
result = TryBumpAllocate(size);
if (result == 0) {
- if (capacity_ < max_capacity_) {
+ if (CanIncreaseCapacity(kPageSize)) {
AllocatePage();
result = TryBumpAllocate(size);
ASSERT(result != 0);
@@ -144,11 +150,18 @@
}
} else {
// Large page allocation.
- HeapPage* page = AllocateLargePage(size);
- if (page != NULL) {
- result = page->top();
- page->set_top(result + size);
+ intptr_t page_size = LargePageSizeFor(size);
+ if (page_size < size) {
+ // On overflow we fail to allocate.
+ return 0;
}
+ if (CanIncreaseCapacity(page_size)) {
+ HeapPage* page = AllocateLargePage(size);
+ if (page != NULL) {
+ result = page->top();
+ page->set_top(result + size);
+ }
+ }
}
if (result != 0) {
in_use_ += size;
« 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