Commit 487d512e authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Use regular FreeList for MapSpace

MapSpace was using a separate FreeList implementation since all maps
have the save exact same size. Remove FreeListMap and use the regular
free list which is also used for the old space. This will allow to use
LABs in the map space.

Bug: v8:10315
Change-Id: I00cfcb260edb20f044ad74a24772f810e1f93afd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2442789Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70256}
parent abcd1835
......@@ -417,50 +417,6 @@ FreeSpace FreeListManyCachedOrigin::Allocate(size_t size_in_bytes,
}
}
// ------------------------------------------------
// FreeListMap implementation
FreeListMap::FreeListMap() {
// Initializing base (FreeList) fields
number_of_categories_ = 1;
last_category_ = kOnlyCategory;
min_block_size_ = kMinBlockSize;
categories_ = new FreeListCategory*[number_of_categories_]();
Reset();
}
size_t FreeListMap::GuaranteedAllocatable(size_t maximum_freed) {
return maximum_freed;
}
Page* FreeListMap::GetPageForSize(size_t size_in_bytes) {
return GetPageForCategoryType(kOnlyCategory);
}
FreeListMap::~FreeListMap() { delete[] categories_; }
FreeSpace FreeListMap::Allocate(size_t size_in_bytes, size_t* node_size,
AllocationOrigin origin) {
DCHECK_GE(kMaxBlockSize, size_in_bytes);
// The following DCHECK ensures that maps are allocated one by one (ie,
// without folding). This assumption currently holds. However, if it were to
// become untrue in the future, you'll get an error here. To fix it, I would
// suggest removing the DCHECK, and replacing TryFindNodeIn by
// SearchForNodeInList below.
DCHECK_EQ(size_in_bytes, Map::kSize);
FreeSpace node = TryFindNodeIn(kOnlyCategory, size_in_bytes, node_size);
if (!node.is_null()) {
Page::FromHeapObject(node)->IncreaseAllocatedBytes(*node_size);
}
DCHECK_IMPLIES(node.is_null(), IsEmpty());
return node;
}
// ------------------------------------------------
// Generic FreeList methods (non alloc/free related)
......
......@@ -488,31 +488,6 @@ class V8_EXPORT_PRIVATE FreeListManyCachedOrigin
AllocationOrigin origin) override;
};
// FreeList for maps: since maps are all the same size, uses a single freelist.
class V8_EXPORT_PRIVATE FreeListMap : public FreeList {
public:
size_t GuaranteedAllocatable(size_t maximum_freed) override;
Page* GetPageForSize(size_t size_in_bytes) override;
FreeListMap();
~FreeListMap() override;
V8_WARN_UNUSED_RESULT FreeSpace Allocate(size_t size_in_bytes,
size_t* node_size,
AllocationOrigin origin) override;
private:
static const size_t kMinBlockSize = Map::kSize;
static const size_t kMaxBlockSize = MemoryChunk::kPageSize;
static const FreeListCategoryType kOnlyCategory = 0;
FreeListCategoryType SelectFreeListCategoryType(
size_t size_in_bytes) override {
return kOnlyCategory;
}
};
} // namespace internal
} // namespace v8
......
......@@ -512,7 +512,8 @@ class MapSpace : public PagedSpace {
public:
// Creates a map space object.
explicit MapSpace(Heap* heap)
: PagedSpace(heap, MAP_SPACE, NOT_EXECUTABLE, new FreeListMap()) {}
: PagedSpace(heap, MAP_SPACE, NOT_EXECUTABLE,
FreeList::CreateFreeList()) {}
int RoundSizeDownToObjectAlignment(int size) override {
if (base::bits::IsPowerOfTwo(Map::kSize)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment