Skip to content

Commit

Permalink
Have realloc ensure proper "pointerness" of allcoations.
Browse files Browse the repository at this point in the history
  • Loading branch information
deadalnix committed Sep 2, 2023
1 parent 7f8900a commit 4616830
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sdlib/d/gc/tcache.d
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ public:

auto copySize = size;
auto pd = getPageDescriptor(ptr);
auto samePointerness = containsPointers == pd.containsPointers;

if (pd.isSlab()) {
auto newSizeClass = getSizeClass(size);
auto oldSizeClass = pd.sizeClass;
if (newSizeClass == oldSizeClass) {
if (samePointerness && newSizeClass == oldSizeClass) {
return ptr;
}

Expand All @@ -100,15 +101,14 @@ public:
copySize = min(size, pd.extent.usedCapacity);

auto esize = pd.extent.size;
if (alignUp(size, PageSize) == esize) {
if (samePointerness && alignUp(size, PageSize) == esize) {
pd.extent.setUsedCapacity(copySize);
return ptr;
}

// TODO: Try to extend/shrink in place.
}

containsPointers = (containsPointers | pd.containsPointers) != 0;
auto newPtr = alloc(size, containsPointers);
if (newPtr is null) {
return null;
Expand Down

0 comments on commit 4616830

Please sign in to comment.