Skip to content

Commit 52b6713

Browse files
committed
Revert "fix: add BLOCK_OVERHEAD before round size"
This reverts commit 7b7bf0f.
1 parent ed1ea91 commit 52b6713

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

std/assembly/rt/tlsf.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,16 +427,16 @@ function growMemory(root: Root, size: usize): void {
427427
unreachable();
428428
return;
429429
}
430-
// and additional BLOCK_OVERHEAD must be taken into account. If we are going
431-
// to merge with the tail block, that's one time, otherwise it's two times.
432-
let pagesBefore = memory.size();
433-
size += BLOCK_OVERHEAD << usize((<usize>pagesBefore << 16) - BLOCK_OVERHEAD != changetype<usize>(GETTAIL(root)));
434430
// Here, both rounding performed in searchBlock ...
435431
const halfMaxSize = BLOCK_MAXSIZE >> 1;
436432
if (size < halfMaxSize) { // don't round last fl
437433
const invRound = (sizeof<usize>() * 8 - 1) - SL_BITS;
438-
size += (1 << (invRound - clz<usize>(size))) - 1; // size should be larger than 15
434+
size += (1 << (invRound - clz<usize>(size))) - 1;
439435
}
436+
// and additional BLOCK_OVERHEAD must be taken into account. If we are going
437+
// to merge with the tail block, that's one time, otherwise it's two times.
438+
let pagesBefore = memory.size();
439+
size += BLOCK_OVERHEAD << usize((<usize>pagesBefore << 16) - BLOCK_OVERHEAD != changetype<usize>(GETTAIL(root)));
440440
let pagesNeeded = <i32>(((size + 0xffff) & ~0xffff) >>> 16);
441441
let pagesWanted = max(pagesBefore, pagesNeeded); // double memory
442442
if (memory.grow(pagesWanted) < 0) {

0 commit comments

Comments
 (0)