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

Unified Diff: src/heap/spaces.cc

Issue 577223002: Capacity returns allocatable memory and TotalCapacity returns allocatable plus non-allocatable memo… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index a66080fa57b5e01ce61409d7bc41f19594fdcd8b..f8d340f18278b3d5ded9deecfe24fe329634bdbe 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1259,14 +1259,15 @@ void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); }
void NewSpace::Grow() {
// Double the semispace size but only up to maximum capacity.
- DCHECK(Capacity() < MaximumCapacity());
- int new_capacity = Min(MaximumCapacity(), 2 * static_cast<int>(Capacity()));
+ DCHECK(TotalCapacity() < MaximumCapacity());
+ int new_capacity =
+ Min(MaximumCapacity(), 2 * static_cast<int>(TotalCapacity()));
if (to_space_.GrowTo(new_capacity)) {
// Only grow from space if we managed to grow to-space.
if (!from_space_.GrowTo(new_capacity)) {
// If we managed to grow to-space but couldn't grow from-space,
// attempt to shrink to-space.
- if (!to_space_.ShrinkTo(from_space_.Capacity())) {
+ if (!to_space_.ShrinkTo(from_space_.TotalCapacity())) {
// We are in an inconsistent state because we could not
// commit/uncommit memory from new space.
V8::FatalProcessOutOfMemory("Failed to grow new space.");
@@ -1278,16 +1279,16 @@ void NewSpace::Grow() {
void NewSpace::Shrink() {
- int new_capacity = Max(InitialCapacity(), 2 * SizeAsInt());
+ int new_capacity = Max(InitialTotalCapacity(), 2 * SizeAsInt());
int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize);
- if (rounded_new_capacity < Capacity() &&
+ if (rounded_new_capacity < TotalCapacity() &&
to_space_.ShrinkTo(rounded_new_capacity)) {
// Only shrink from-space if we managed to shrink to-space.
from_space_.Reset();
if (!from_space_.ShrinkTo(rounded_new_capacity)) {
// If we managed to shrink to-space but couldn't shrink from
// space, attempt to grow to-space again.
- if (!to_space_.GrowTo(from_space_.Capacity())) {
+ if (!to_space_.GrowTo(from_space_.TotalCapacity())) {
// We are in an inconsistent state because we could not
// commit/uncommit memory from new space.
V8::FatalProcessOutOfMemory("Failed to shrink new space.");
@@ -1465,9 +1466,9 @@ void SemiSpace::SetUp(Address start, int initial_capacity,
// space is used as the marking stack. It requires contiguous memory
// addresses.
DCHECK(maximum_capacity >= Page::kPageSize);
- initial_capacity_ = RoundDown(initial_capacity, Page::kPageSize);
- capacity_ = initial_capacity;
- maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize);
+ initial_total_capacity_ = RoundDown(initial_capacity, Page::kPageSize);
+ total_capacity_ = initial_capacity;
+ maximum_total_capacity_ = RoundDown(maximum_capacity, Page::kPageSize);
maximum_committed_ = 0;
committed_ = false;
start_ = start;
@@ -1480,15 +1481,15 @@ void SemiSpace::SetUp(Address start, int initial_capacity,
void SemiSpace::TearDown() {
start_ = NULL;
- capacity_ = 0;
+ total_capacity_ = 0;
}
bool SemiSpace::Commit() {
DCHECK(!is_committed());
- int pages = capacity_ / Page::kPageSize;
- if (!heap()->isolate()->memory_allocator()->CommitBlock(start_, capacity_,
- executable())) {
+ int pages = total_capacity_ / Page::kPageSize;
+ if (!heap()->isolate()->memory_allocator()->CommitBlock(
+ start_, total_capacity_, executable())) {
return false;
}
@@ -1500,7 +1501,7 @@ bool SemiSpace::Commit() {
current = new_page;
}
- SetCapacity(capacity_);
+ SetCapacity(total_capacity_);
committed_ = true;
Reset();
return true;
@@ -1509,8 +1510,9 @@ bool SemiSpace::Commit() {
bool SemiSpace::Uncommit() {
DCHECK(is_committed());
- Address start = start_ + maximum_capacity_ - capacity_;
- if (!heap()->isolate()->memory_allocator()->UncommitBlock(start, capacity_)) {
+ Address start = start_ + maximum_total_capacity_ - total_capacity_;
+ if (!heap()->isolate()->memory_allocator()->UncommitBlock(start,
+ total_capacity_)) {
return false;
}
anchor()->set_next_page(anchor());
@@ -1537,16 +1539,16 @@ bool SemiSpace::GrowTo(int new_capacity) {
if (!Commit()) return false;
}
DCHECK((new_capacity & Page::kPageAlignmentMask) == 0);
- DCHECK(new_capacity <= maximum_capacity_);
- DCHECK(new_capacity > capacity_);
- int pages_before = capacity_ / Page::kPageSize;
+ DCHECK(new_capacity <= maximum_total_capacity_);
+ DCHECK(new_capacity > total_capacity_);
+ int pages_before = total_capacity_ / Page::kPageSize;
int pages_after = new_capacity / Page::kPageSize;
- size_t delta = new_capacity - capacity_;
+ size_t delta = new_capacity - total_capacity_;
DCHECK(IsAligned(delta, base::OS::AllocateAlignment()));
if (!heap()->isolate()->memory_allocator()->CommitBlock(
- start_ + capacity_, delta, executable())) {
+ start_ + total_capacity_, delta, executable())) {
return false;
}
SetCapacity(new_capacity);
@@ -1569,10 +1571,10 @@ bool SemiSpace::GrowTo(int new_capacity) {
bool SemiSpace::ShrinkTo(int new_capacity) {
DCHECK((new_capacity & Page::kPageAlignmentMask) == 0);
- DCHECK(new_capacity >= initial_capacity_);
- DCHECK(new_capacity < capacity_);
+ DCHECK(new_capacity >= initial_total_capacity_);
+ DCHECK(new_capacity < total_capacity_);
if (is_committed()) {
- size_t delta = capacity_ - new_capacity;
+ size_t delta = total_capacity_ - new_capacity;
DCHECK(IsAligned(delta, base::OS::AllocateAlignment()));
MemoryAllocator* allocator = heap()->isolate()->memory_allocator();
@@ -1652,9 +1654,9 @@ void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) {
void SemiSpace::SetCapacity(int new_capacity) {
- capacity_ = new_capacity;
- if (capacity_ > maximum_committed_) {
- maximum_committed_ = capacity_;
+ total_capacity_ = new_capacity;
+ if (total_capacity_ > maximum_committed_) {
+ maximum_committed_ = total_capacity_;
}
}
@@ -1895,11 +1897,11 @@ static void DoReportStatistics(Isolate* isolate, HistogramInfo* info,
void NewSpace::ReportStatistics() {
#ifdef DEBUG
if (FLAG_heap_stats) {
- float pct = static_cast<float>(Available()) / Capacity();
+ float pct = static_cast<float>(Available()) / TotalCapacity();
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", available: %" V8_PTR_PREFIX "d, %%%d\n",
- Capacity(), Available(), static_cast<int>(pct * 100));
+ TotalCapacity(), Available(), static_cast<int>(pct * 100));
PrintF("\n Object Histogram:\n");
for (int i = 0; i <= LAST_TYPE; i++) {
if (allocated_histogram_[i].number() > 0) {
« no previous file with comments | « src/heap/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698