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

Side by Side Diff: src/heap/spaces.h

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_SPACES_H_ 5 #ifndef V8_HEAP_SPACES_H_
6 #define V8_HEAP_SPACES_H_ 6 #define V8_HEAP_SPACES_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomicops.h" 9 #include "src/base/atomicops.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 virtual void Print(); 2154 virtual void Print();
2155 // Validate a range of of addresses in a SemiSpace. 2155 // Validate a range of of addresses in a SemiSpace.
2156 // The "from" address must be on a page prior to the "to" address, 2156 // The "from" address must be on a page prior to the "to" address,
2157 // in the linked page order, or it must be earlier on the same page. 2157 // in the linked page order, or it must be earlier on the same page.
2158 static void AssertValidRange(Address from, Address to); 2158 static void AssertValidRange(Address from, Address to);
2159 #else 2159 #else
2160 // Do nothing. 2160 // Do nothing.
2161 inline static void AssertValidRange(Address from, Address to) {} 2161 inline static void AssertValidRange(Address from, Address to) {}
2162 #endif 2162 #endif
2163 2163
2164 // Returns the current capacity of the semi space. 2164 // Returns the current total capacity of the semispace.
2165 int Capacity() { return capacity_; } 2165 int TotalCapacity() { return total_capacity_; }
2166 2166
2167 // Returns the maximum capacity of the semi space. 2167 // Returns the maximum total capacity of the semispace.
2168 int MaximumCapacity() { return maximum_capacity_; } 2168 int MaximumTotalCapacity() { return maximum_total_capacity_; }
2169 2169
2170 // Returns the initial capacity of the semi space. 2170 // Returns the initial capacity of the semispace.
2171 int InitialCapacity() { return initial_capacity_; } 2171 int InitialTotalCapacity() { return initial_total_capacity_; }
2172 2172
2173 SemiSpaceId id() { return id_; } 2173 SemiSpaceId id() { return id_; }
2174 2174
2175 static void Swap(SemiSpace* from, SemiSpace* to); 2175 static void Swap(SemiSpace* from, SemiSpace* to);
2176 2176
2177 // Returns the maximum amount of memory ever committed by the semi space. 2177 // Returns the maximum amount of memory ever committed by the semi space.
2178 size_t MaximumCommittedMemory() { return maximum_committed_; } 2178 size_t MaximumCommittedMemory() { return maximum_committed_; }
2179 2179
2180 // Approximate amount of physical memory committed for this space. 2180 // Approximate amount of physical memory committed for this space.
2181 size_t CommittedPhysicalMemory(); 2181 size_t CommittedPhysicalMemory();
2182 2182
2183 private: 2183 private:
2184 // Flips the semispace between being from-space and to-space. 2184 // Flips the semispace between being from-space and to-space.
2185 // Copies the flags into the masked positions on all pages in the space. 2185 // Copies the flags into the masked positions on all pages in the space.
2186 void FlipPages(intptr_t flags, intptr_t flag_mask); 2186 void FlipPages(intptr_t flags, intptr_t flag_mask);
2187 2187
2188 // Updates Capacity and MaximumCommitted based on new capacity. 2188 // Updates Capacity and MaximumCommitted based on new capacity.
2189 void SetCapacity(int new_capacity); 2189 void SetCapacity(int new_capacity);
2190 2190
2191 NewSpacePage* anchor() { return &anchor_; } 2191 NewSpacePage* anchor() { return &anchor_; }
2192 2192
2193 // The current and maximum capacity of the space. 2193 // The current and maximum total capacity of the space.
2194 int capacity_; 2194 int total_capacity_;
2195 int maximum_capacity_; 2195 int maximum_total_capacity_;
2196 int initial_capacity_; 2196 int initial_total_capacity_;
2197 2197
2198 intptr_t maximum_committed_; 2198 intptr_t maximum_committed_;
2199 2199
2200 // The start address of the space. 2200 // The start address of the space.
2201 Address start_; 2201 Address start_;
2202 // Used to govern object promotion during mark-compact collection. 2202 // Used to govern object promotion during mark-compact collection.
2203 Address age_mark_; 2203 Address age_mark_;
2204 2204
2205 // Masks and comparison values to test for containment in this semispace. 2205 // Masks and comparison values to test for containment in this semispace.
2206 uintptr_t address_mask_; 2206 uintptr_t address_mask_;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 virtual intptr_t Size() { 2356 virtual intptr_t Size() {
2357 return pages_used_ * NewSpacePage::kAreaSize + 2357 return pages_used_ * NewSpacePage::kAreaSize +
2358 static_cast<int>(top() - to_space_.page_low()); 2358 static_cast<int>(top() - to_space_.page_low());
2359 } 2359 }
2360 2360
2361 // The same, but returning an int. We have to have the one that returns 2361 // The same, but returning an int. We have to have the one that returns
2362 // intptr_t because it is inherited, but if we know we are dealing with the 2362 // intptr_t because it is inherited, but if we know we are dealing with the
2363 // new space, which can't get as big as the other spaces then this is useful: 2363 // new space, which can't get as big as the other spaces then this is useful:
2364 int SizeAsInt() { return static_cast<int>(Size()); } 2364 int SizeAsInt() { return static_cast<int>(Size()); }
2365 2365
2366 // Return the current capacity of a semispace. 2366 // Return the allocatable capacity of a semispace.
2367 intptr_t EffectiveCapacity() { 2367 intptr_t Capacity() {
2368 SLOW_DCHECK(to_space_.Capacity() == from_space_.Capacity()); 2368 SLOW_DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity());
2369 return (to_space_.Capacity() / Page::kPageSize) * NewSpacePage::kAreaSize; 2369 return (to_space_.TotalCapacity() / Page::kPageSize) *
2370 NewSpacePage::kAreaSize;
2370 } 2371 }
2371 2372
2372 // Return the current capacity of a semispace. 2373 // Return the current size of a semispace, allocatable and non-allocatable
2373 intptr_t Capacity() { 2374 // memory.
2374 DCHECK(to_space_.Capacity() == from_space_.Capacity()); 2375 intptr_t TotalCapacity() {
2375 return to_space_.Capacity(); 2376 DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity());
2377 return to_space_.TotalCapacity();
2376 } 2378 }
2377 2379
2378 // Return the total amount of memory committed for new space. 2380 // Return the total amount of memory committed for new space.
2379 intptr_t CommittedMemory() { 2381 intptr_t CommittedMemory() {
2380 if (from_space_.is_committed()) return 2 * Capacity(); 2382 if (from_space_.is_committed()) return 2 * Capacity();
2381 return Capacity(); 2383 return TotalCapacity();
2382 } 2384 }
2383 2385
2384 // Return the total amount of memory committed for new space. 2386 // Return the total amount of memory committed for new space.
2385 intptr_t MaximumCommittedMemory() { 2387 intptr_t MaximumCommittedMemory() {
2386 return to_space_.MaximumCommittedMemory() + 2388 return to_space_.MaximumCommittedMemory() +
2387 from_space_.MaximumCommittedMemory(); 2389 from_space_.MaximumCommittedMemory();
2388 } 2390 }
2389 2391
2390 // Approximate amount of physical memory committed for this space. 2392 // Approximate amount of physical memory committed for this space.
2391 size_t CommittedPhysicalMemory(); 2393 size_t CommittedPhysicalMemory();
2392 2394
2393 // Return the available bytes without growing. 2395 // Return the available bytes without growing.
2394 intptr_t Available() { return Capacity() - Size(); } 2396 intptr_t Available() { return Capacity() - Size(); }
2395 2397
2396 // Return the maximum capacity of a semispace. 2398 // Return the maximum capacity of a semispace.
2397 int MaximumCapacity() { 2399 int MaximumCapacity() {
2398 DCHECK(to_space_.MaximumCapacity() == from_space_.MaximumCapacity()); 2400 DCHECK(to_space_.MaximumTotalCapacity() ==
2399 return to_space_.MaximumCapacity(); 2401 from_space_.MaximumTotalCapacity());
2402 return to_space_.MaximumTotalCapacity();
2400 } 2403 }
2401 2404
2402 bool IsAtMaximumCapacity() { return Capacity() == MaximumCapacity(); } 2405 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); }
2403 2406
2404 // Returns the initial capacity of a semispace. 2407 // Returns the initial capacity of a semispace.
2405 int InitialCapacity() { 2408 int InitialTotalCapacity() {
2406 DCHECK(to_space_.InitialCapacity() == from_space_.InitialCapacity()); 2409 DCHECK(to_space_.InitialTotalCapacity() ==
2407 return to_space_.InitialCapacity(); 2410 from_space_.InitialTotalCapacity());
2411 return to_space_.InitialTotalCapacity();
2408 } 2412 }
2409 2413
2410 // Return the address of the allocation pointer in the active semispace. 2414 // Return the address of the allocation pointer in the active semispace.
2411 Address top() { 2415 Address top() {
2412 DCHECK(to_space_.current_page()->ContainsLimit(allocation_info_.top())); 2416 DCHECK(to_space_.current_page()->ContainsLimit(allocation_info_.top()));
2413 return allocation_info_.top(); 2417 return allocation_info_.top();
2414 } 2418 }
2415 2419
2416 void set_top(Address top) { 2420 void set_top(Address top) {
2417 DCHECK(to_space_.current_page()->ContainsLimit(top)); 2421 DCHECK(to_space_.current_page()->ContainsLimit(top));
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 count = 0; 2877 count = 0;
2874 } 2878 }
2875 // Must be small, since an iteration is used for lookup. 2879 // Must be small, since an iteration is used for lookup.
2876 static const int kMaxComments = 64; 2880 static const int kMaxComments = 64;
2877 }; 2881 };
2878 #endif 2882 #endif
2879 } 2883 }
2880 } // namespace v8::internal 2884 } // namespace v8::internal
2881 2885
2882 #endif // V8_HEAP_SPACES_H_ 2886 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698