| Index: src/spaces.h
|
| ===================================================================
|
| --- src/spaces.h (revision 2321)
|
| +++ src/spaces.h (working copy)
|
| @@ -1380,9 +1380,9 @@
|
|
|
|
|
| // The free list for the map space.
|
| -class MapSpaceFreeList BASE_EMBEDDED {
|
| +class FixedSizeFreeList BASE_EMBEDDED {
|
| public:
|
| - explicit MapSpaceFreeList(AllocationSpace owner);
|
| + FixedSizeFreeList(AllocationSpace owner, int object_size);
|
|
|
| // Clear the free list.
|
| void Reset();
|
| @@ -1391,12 +1391,12 @@
|
| int available() { return available_; }
|
|
|
| // Place a node on the free list. The block starting at 'start' (assumed to
|
| - // have size Map::kSize) is placed on the free list. Bookkeeping
|
| + // have size object_size_) is placed on the free list. Bookkeeping
|
| // information will be written to the block, ie, its contents will be
|
| // destroyed. The start address should be word aligned.
|
| void Free(Address start);
|
|
|
| - // Allocate a map-sized block from the free list. The block is unitialized.
|
| + // Allocate a fixed sized block from the free list. The block is unitialized.
|
| // A failure is returned if no block is available.
|
| Object* Allocate();
|
|
|
| @@ -1411,7 +1411,10 @@
|
| // objects.
|
| AllocationSpace owner_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(MapSpaceFreeList);
|
| + // The size of the objects in this space.
|
| + int object_size_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(FixedSizeFreeList);
|
| };
|
|
|
|
|
| @@ -1491,29 +1494,30 @@
|
|
|
|
|
| // -----------------------------------------------------------------------------
|
| -// Old space for all map objects
|
| +// Old space for objects of a fixed size
|
|
|
| -class MapSpace : public PagedSpace {
|
| +class PagedSpaceForFixedSizedObjects : public PagedSpace {
|
| public:
|
| - // Creates a map space object with a maximum capacity.
|
| - explicit MapSpace(int max_capacity, AllocationSpace id)
|
| - : PagedSpace(max_capacity, id, NOT_EXECUTABLE), free_list_(id) { }
|
| + PagedSpaceForFixedSizedObjects(int max_capacity, AllocationSpace id,
|
| + int object_size, const char* name)
|
| + : PagedSpace(max_capacity, id, NOT_EXECUTABLE),
|
| + object_size_(object_size),
|
| + name_(name),
|
| + free_list_(id, object_size),
|
| + page_extra_(Page::kObjectAreaSize % object_size) { }
|
|
|
| // The top of allocation in a page in this space. Undefined if page is unused.
|
| virtual Address PageAllocationTop(Page* page) {
|
| return page == TopPageOf(allocation_info_) ? top()
|
| - : page->ObjectAreaEnd() - kPageExtra;
|
| + : page->ObjectAreaEnd() - page_extra_;
|
| }
|
|
|
| - // Give a map-sized block of memory to the space's free list.
|
| + // Give a fixed sized block of memory to the space's free list.
|
| void Free(Address start) {
|
| free_list_.Free(start);
|
| accounting_stats_.DeallocateBytes(Map::kSize);
|
| }
|
|
|
| - // Given an index, returns the page address.
|
| - Address PageAddress(int page_index) { return page_addresses_[page_index]; }
|
| -
|
| // Prepares for a mark-compact GC.
|
| virtual void PrepareForMarkCompact(bool will_compact);
|
|
|
| @@ -1525,18 +1529,16 @@
|
| // Verify integrity of this space.
|
| virtual void Verify();
|
|
|
| + // Implement by subclasses to verify an actual object in the space.
|
| + virtual void VerifyObject(HeapObject* obj) = 0;
|
| +
|
| // Reports statistic info of the space
|
| void ReportStatistics();
|
| +
|
| // Dump the remembered sets in the space to stdout.
|
| void PrintRSet();
|
| #endif
|
|
|
| - // Constants.
|
| - static const int kMapPageIndexBits = 10;
|
| - static const int kMaxMapPageIndex = (1 << kMapPageIndexBits) - 1;
|
| -
|
| - static const int kPageExtra = Page::kObjectAreaSize % Map::kSize;
|
| -
|
| protected:
|
| // Virtual function in the superclass. Slow path of AllocateRaw.
|
| HeapObject* SlowAllocateRaw(int size_in_bytes);
|
| @@ -1546,9 +1548,44 @@
|
| HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes);
|
|
|
| private:
|
| + // The size of objects in this space.
|
| + int object_size_;
|
| +
|
| + // The name of this space.
|
| + const char* name_;
|
| +
|
| // The space's free list.
|
| - MapSpaceFreeList free_list_;
|
| + FixedSizeFreeList free_list_;
|
|
|
| + // Bytes of each page that cannot be allocated.
|
| + int page_extra_;
|
| +};
|
| +
|
| +
|
| +// -----------------------------------------------------------------------------
|
| +// Old space for all map objects
|
| +
|
| +class MapSpace : public PagedSpaceForFixedSizedObjects {
|
| + public:
|
| + // Creates a map space object with a maximum capacity.
|
| + MapSpace(int max_capacity, AllocationSpace id)
|
| + : PagedSpaceForFixedSizedObjects(max_capacity, id, Map::kSize, "map") { }
|
| +
|
| + // Prepares for a mark-compact GC.
|
| + virtual void PrepareForMarkCompact(bool will_compact);
|
| +
|
| + // Given an index, returns the page address.
|
| + Address PageAddress(int page_index) { return page_addresses_[page_index]; }
|
| +
|
| + // Constants.
|
| + static const int kMaxMapPageIndex = (1 << MapWord::kMapPageIndexBits) - 1;
|
| +
|
| + protected:
|
| +#ifdef DEBUG
|
| + virtual void VerifyObject(HeapObject* obj);
|
| +#endif
|
| +
|
| + private:
|
| // An array of page start address in a map space.
|
| Address page_addresses_[kMaxMapPageIndex + 1];
|
|
|
| @@ -1558,6 +1595,26 @@
|
|
|
|
|
| // -----------------------------------------------------------------------------
|
| +// Old space for all global object property cell objects
|
| +
|
| +class GlobalPropertyCellSpace : public PagedSpaceForFixedSizedObjects {
|
| + public:
|
| + // Creates a property cell space object with a maximum capacity.
|
| + GlobalPropertyCellSpace(int max_capacity, AllocationSpace id)
|
| + : PagedSpaceForFixedSizedObjects(max_capacity, id,
|
| + JSGlobalPropertyCell::kSize, "cell") { }
|
| +
|
| + protected:
|
| +#ifdef DEBUG
|
| + virtual void VerifyObject(HeapObject* obj);
|
| +#endif
|
| +
|
| + public:
|
| + TRACK_MEMORY("MapSpace")
|
| +};
|
| +
|
| +
|
| +// -----------------------------------------------------------------------------
|
| // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by
|
| // the large object space. A large object is allocated from OS heap with
|
| // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset).
|
|
|