Chromium Code Reviews| Index: src/spaces.h |
| =================================================================== |
| --- src/spaces.h (revision 5551) |
| +++ src/spaces.h (working copy) |
| @@ -371,7 +371,7 @@ |
| // Identity used in error reporting. |
| AllocationSpace identity() { return id_; } |
| - virtual int Size() = 0; |
| + virtual intptr_t Size() = 0; |
| #ifdef ENABLE_HEAP_PROTECTION |
| // Protect/unprotect the space by marking it read-only/writable. |
| @@ -491,7 +491,7 @@ |
| public: |
| // Initializes its internal bookkeeping structures. |
| // Max capacity of the total space. |
| - static bool Setup(int max_capacity); |
| + static bool Setup(intptr_t max_capacity); |
| // Deletes valid chunks. |
| static void TearDown(); |
| @@ -582,16 +582,18 @@ |
| MemoryAllocationCallback callback); |
| // Returns the maximum available bytes of heaps. |
| - static int Available() { return capacity_ < size_ ? 0 : capacity_ - size_; } |
| + static intptr_t Available() { |
| + return capacity_ < size_ ? 0 : capacity_ - size_; |
| + } |
| // Returns allocated spaces in bytes. |
| - static int Size() { return size_; } |
| + static intptr_t Size() { return size_; } |
| // Returns allocated executable spaces in bytes. |
| - static int SizeExecutable() { return size_executable_; } |
| + static intptr_t SizeExecutable() { return size_executable_; } |
| // Returns maximum available bytes that the old space can have. |
| - static int MaxAvailable() { |
| + static intptr_t MaxAvailable() { |
| return (Available() / Page::kPageSize) * Page::kObjectAreaSize; |
| } |
| @@ -649,12 +651,12 @@ |
| private: |
| // Maximum space size in bytes. |
| - static int capacity_; |
| + static intptr_t capacity_; |
| // Allocated space size in bytes. |
| - static int size_; |
| + static intptr_t size_; |
| // Allocated executable space size in bytes. |
| - static int size_executable_; |
| + static intptr_t size_executable_; |
| struct MemoryAllocationCallbackRegistration { |
| MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, |
| @@ -927,10 +929,10 @@ |
| } |
| // Accessors for the allocation statistics. |
| - int Capacity() { return capacity_; } |
| - int Available() { return available_; } |
| - int Size() { return size_; } |
| - int Waste() { return waste_; } |
| + intptr_t Capacity() { return capacity_; } |
| + intptr_t Available() { return available_; } |
| + intptr_t Size() { return size_; } |
| + intptr_t Waste() { return waste_; } |
| // Grow the space by adding available bytes. |
| void ExpandSpace(int size_in_bytes) { |
| @@ -945,13 +947,13 @@ |
| } |
| // Allocate from available bytes (available -> size). |
| - void AllocateBytes(int size_in_bytes) { |
| + void AllocateBytes(intptr_t size_in_bytes) { |
| available_ -= size_in_bytes; |
| size_ += size_in_bytes; |
| } |
| // Free allocated bytes, making them available (size -> available). |
| - void DeallocateBytes(int size_in_bytes) { |
| + void DeallocateBytes(intptr_t size_in_bytes) { |
| size_ -= size_in_bytes; |
| available_ += size_in_bytes; |
| } |
| @@ -964,23 +966,25 @@ |
| // Consider the wasted bytes to be allocated, as they contain filler |
| // objects (waste -> size). |
| - void FillWastedBytes(int size_in_bytes) { |
| + void FillWastedBytes(intptr_t size_in_bytes) { |
| waste_ -= size_in_bytes; |
| size_ += size_in_bytes; |
| } |
| private: |
| - int capacity_; |
| - int available_; |
| - int size_; |
| - int waste_; |
| + intptr_t capacity_; |
| + intptr_t available_; |
| + intptr_t size_; |
| + intptr_t waste_; |
| }; |
| class PagedSpace : public Space { |
| public: |
| // Creates a space with a maximum capacity, and an id. |
| - PagedSpace(int max_capacity, AllocationSpace id, Executability executable); |
| + PagedSpace(intptr_t max_capacity, |
| + AllocationSpace id, |
| + Executability executable); |
| virtual ~PagedSpace() {} |
| @@ -1031,21 +1035,21 @@ |
| } |
| // Current capacity without growing (Size() + Available() + Waste()). |
| - int Capacity() { return accounting_stats_.Capacity(); } |
| + intptr_t Capacity() { return accounting_stats_.Capacity(); } |
| // Total amount of memory committed for this space. For paged |
| // spaces this equals the capacity. |
| - int CommittedMemory() { return Capacity(); } |
| + intptr_t CommittedMemory() { return Capacity(); } |
| // Available bytes without growing. |
| - int Available() { return accounting_stats_.Available(); } |
| + intptr_t Available() { return accounting_stats_.Available(); } |
| // Allocated bytes in this space. |
| - virtual int Size() { return accounting_stats_.Size(); } |
| + virtual intptr_t Size() { return accounting_stats_.Size(); } |
| // Wasted bytes due to fragmentation and not recoverable until the |
| // next GC of this space. |
| - int Waste() { return accounting_stats_.Waste(); } |
| + intptr_t Waste() { return accounting_stats_.Waste(); } |
| // Returns the address of the first object in this space. |
| Address bottom() { return first_page_->ObjectAreaStart(); } |
| @@ -1137,7 +1141,7 @@ |
| protected: |
| // Maximum capacity of this space. |
| - int max_capacity_; |
| + intptr_t max_capacity_; |
| // Accounting information for this space. |
| AllocationStats accounting_stats_; |
| @@ -1328,7 +1332,7 @@ |
| // If we don't have these here then SemiSpace will be abstract. However |
| // they should never be called. |
| - virtual int Size() { |
| + virtual intptr_t Size() { |
| UNREACHABLE(); |
| return 0; |
| } |
| @@ -1471,22 +1475,26 @@ |
| } |
| // Return the allocated bytes in the active semispace. |
| - virtual int Size() { return static_cast<int>(top() - bottom()); } |
| + virtual intptr_t Size() { return static_cast<int>(top() - bottom()); } |
| + // The same, but returning an int. We have to have the one that returns |
| + // intptr_t because it is inherited, but if we know we are dealing with the |
| + // new space, which can't get as big as the other spaces then this is useful: |
| + int IntSize() { return static_cast<int>(Size()); } |
|
Vyacheslav Egorov (Chromium)
2010/09/29 14:55:20
SizeAsInt ?
Erik Corry
2010/09/30 07:09:38
Done.
|
| // Return the current capacity of a semispace. |
| - int Capacity() { |
| + intptr_t Capacity() { |
| ASSERT(to_space_.Capacity() == from_space_.Capacity()); |
| return to_space_.Capacity(); |
| } |
| // Return the total amount of memory committed for new space. |
| - int CommittedMemory() { |
| + intptr_t CommittedMemory() { |
| if (from_space_.is_committed()) return 2 * Capacity(); |
| return Capacity(); |
| } |
| // Return the available bytes without growing in the active semispace. |
| - int Available() { return Capacity() - Size(); } |
| + intptr_t Available() { return Capacity() - Size(); } |
| // Return the maximum capacity of a semispace. |
| int MaximumCapacity() { |
| @@ -1681,7 +1689,7 @@ |
| void Reset(); |
| // Return the number of bytes available on the free list. |
| - int available() { return available_; } |
| + intptr_t available() { return available_; } |
| // Place a node on the free list. The block of size 'size_in_bytes' |
| // starting at 'start' is placed on the free list. The return value is the |
| @@ -1783,7 +1791,7 @@ |
| void Reset(); |
| // Return the number of bytes available on the free list. |
| - int available() { return available_; } |
| + intptr_t available() { return available_; } |
| // Place a node on the free list. The block starting at 'start' (assumed to |
| // have size object_size_) is placed on the free list. Bookkeeping |
| @@ -1797,7 +1805,7 @@ |
| private: |
| // Available bytes on the free list. |
| - int available_; |
| + intptr_t available_; |
| // The head of the free list. |
| Address head_; |
| @@ -1823,7 +1831,7 @@ |
| public: |
| // Creates an old space object with a given maximum capacity. |
| // The constructor does not allocate pages from OS. |
| - explicit OldSpace(int max_capacity, |
| + explicit OldSpace(intptr_t max_capacity, |
| AllocationSpace id, |
| Executability executable) |
| : PagedSpace(max_capacity, id, executable), free_list_(id) { |
| @@ -1832,7 +1840,7 @@ |
| // The bytes available on the free list (ie, not above the linear allocation |
| // pointer). |
| - int AvailableFree() { return free_list_.available(); } |
| + intptr_t AvailableFree() { return free_list_.available(); } |
| // The limit of allocation for a page in this space. |
| virtual Address PageAllocationLimit(Page* page) { |
| @@ -1893,7 +1901,7 @@ |
| class FixedSpace : public PagedSpace { |
| public: |
| - FixedSpace(int max_capacity, |
| + FixedSpace(intptr_t max_capacity, |
| AllocationSpace id, |
| int object_size_in_bytes, |
| const char* name) |
| @@ -1968,7 +1976,7 @@ |
| class MapSpace : public FixedSpace { |
| public: |
| // Creates a map space object with a maximum capacity. |
| - MapSpace(int max_capacity, int max_map_space_pages, AllocationSpace id) |
| + MapSpace(intptr_t max_capacity, int max_map_space_pages, AllocationSpace id) |
| : FixedSpace(max_capacity, id, Map::kSize, "map"), |
| max_map_space_pages_(max_map_space_pages) { |
| ASSERT(max_map_space_pages < kMaxMapPageIndex); |
| @@ -2073,7 +2081,7 @@ |
| class CellSpace : public FixedSpace { |
| public: |
| // Creates a property cell space object with a maximum capacity. |
| - CellSpace(int max_capacity, AllocationSpace id) |
| + CellSpace(intptr_t max_capacity, AllocationSpace id) |
| : FixedSpace(max_capacity, id, JSGlobalPropertyCell::kSize, "cell") {} |
| protected: |
| @@ -2129,7 +2137,7 @@ |
| // Given a chunk size, returns the object size it can accommodate. Used by |
| // LargeObjectSpace::Available. |
| - static int ObjectSizeFor(int chunk_size) { |
| + static intptr_t ObjectSizeFor(intptr_t chunk_size) { |
| if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0; |
| return chunk_size - Page::kPageSize - Page::kObjectStartOffset; |
| } |
| @@ -2165,11 +2173,11 @@ |
| Object* AllocateRawFixedArray(int size_in_bytes); |
| // Available bytes for objects in this space. |
| - int Available() { |
| + intptr_t Available() { |
| return LargeObjectChunk::ObjectSizeFor(MemoryAllocator::Available()); |
| } |
| - virtual int Size() { |
| + virtual intptr_t Size() { |
| return size_; |
| } |
| @@ -2223,7 +2231,7 @@ |
| private: |
| // The head of the linked list of large object chunks. |
| LargeObjectChunk* first_chunk_; |
| - int size_; // allocated bytes |
| + intptr_t size_; // allocated bytes |
| int page_count_; // number of chunks |