Skip to content

Commit

Permalink
Allocator: Calculate flex size with the correct number of elements
Browse files Browse the repository at this point in the history
This was scaling the flexbitset that was used incorrectly.
  • Loading branch information
Sonicadvance1 committed Jan 24, 2025
1 parent fab8506 commit 668a702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FEXCore/Source/Utils/Allocator/64BitAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class OSAllocator_64Bit final : public Alloc::HostAllocator {
// 0x100'0000 Pages
// 1 bit per page for tracking means 0x20'0000 (Pages / 8) bytes of flex space
// Which is 2MB of tracking
uint64_t NumElements = (Size >> FEXCore::Utils::FEX_PAGE_SHIFT) * sizeof(FlexBitElementType);
uint64_t NumElements = (Size >> FEXCore::Utils::FEX_PAGE_SHIFT);
return sizeof(LiveVMARegion) + FEXCore::FlexBitSet<FlexBitElementType>::Size(NumElements);
}

Expand Down
5 changes: 4 additions & 1 deletion FEXCore/Source/Utils/Allocator/FlexBitSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ struct FlexBitSet final {
return Get(Element);
}

static size_t Size(uint64_t Elements) {
static size_t SizeBits(uint64_t Elements) {
return std::max(FEXCore::AlignUp(Elements / MinimumSizeBits, MinimumSizeBits), MinimumSizeBits);
}
static size_t Size(uint64_t Elements) {
return SizeBits(Elements) / MinimumSizeBits;
}
};

static_assert(sizeof(FlexBitSet<uint64_t>) == 0, "This needs to be a flex member");
Expand Down

0 comments on commit 668a702

Please sign in to comment.