Revision: 2678 Author: [email protected] Date: Thu Aug 13 05:13:50 2009 Log: Changed semi space Grow to be rounded to OS page size.
Review URL: http://codereview.chromium.org/164469 http://code.google.com/p/v8/source/detail?r=2678 Modified: /branches/bleeding_edge/src/spaces.cc ======================================= --- /branches/bleeding_edge/src/spaces.cc Wed Aug 12 06:54:43 2009 +++ /branches/bleeding_edge/src/spaces.cc Thu Aug 13 05:13:50 2009 @@ -340,6 +340,17 @@ return true; } +bool MemoryAllocator::UncommitBlock(Address start, size_t size) { + ASSERT(start != NULL); + ASSERT(size > 0); + ASSERT(initial_chunk_ != NULL); + ASSERT(InInitialChunk(start)); + ASSERT(InInitialChunk(start + size - 1)); + + if (!initial_chunk_->Uncommit(start, size)) return false; + Counters::memory_allocated.Decrement(size); + return true; +} Page* MemoryAllocator::InitializePagesInChunk(int chunk_id, int pages_in_chunk, PagedSpace* owner) { @@ -1039,6 +1050,26 @@ #endif +bool SemiSpace::Commit() { + ASSERT(!is_committed()); + if (!MemoryAllocator::CommitBlock(start_, capacity_, executable())) { + return false; + } + committed_ = true; + return true; +} + + +bool SemiSpace::Uncommit() { + ASSERT(is_committed()); + if (!MemoryAllocator::UncommitBlock(start_, capacity_)) { + return false; + } + committed_ = false; + return true; +} + + // ----------------------------------------------------------------------------- // SemiSpace implementation @@ -1053,18 +1084,15 @@ // addresses. capacity_ = initial_capacity; maximum_capacity_ = maximum_capacity; - - if (!MemoryAllocator::CommitBlock(start, capacity_, executable())) { - return false; - } + committed_ = false; start_ = start; address_mask_ = ~(maximum_capacity - 1); object_mask_ = address_mask_ | kHeapObjectTag; object_expected_ = reinterpret_cast<uintptr_t>(start) | kHeapObjectTag; - age_mark_ = start_; - return true; + + return Commit(); } @@ -1076,7 +1104,7 @@ bool SemiSpace::Grow() { // Commit 50% extra space but only up to maximum capacity. - int extra = capacity_/2; + int extra = RoundUp(capacity_ / 2, OS::AllocateAlignment()); if (capacity_ + extra > maximum_capacity_) { extra = maximum_capacity_ - capacity_; } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
