| ... | ... | @@ -379,8 +379,11 @@ const WasmPageAllocator = struct { |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | if (free_start < extendedOffset()) { |
| 382 | | conventional.recycle(free_start, free_end - free_start); |
| 383 | | } else { |
| 382 | const clamped_end = std.math.min(extendedOffset(), free_end); |
| 383 | conventional.recycle(free_start, clamped_end - free_start); |
| 384 | } |
| 385 | |
| 386 | if (free_end > extendedOffset()) { |
| 384 | 387 | if (extended.totalPages() == 0) { |
| 385 | 388 | // Steal the last page from the memory currently being recycled |
| 386 | 389 | // TODO: would it be better if we use the first page instead? |
| ... | ... | @@ -390,7 +393,8 @@ const WasmPageAllocator = struct { |
| 390 | 393 | // Since this is the first page being freed and we consume it, assume *nothing* is free. |
| 391 | 394 | std.mem.set(u8, extended.bytes, FreeBlock.used); |
| 392 | 395 | } |
| 393 | | extended.recycle(free_start - extendedOffset(), free_end - free_start); |
| 396 | const clamped_start = std.math.max(extendedOffset(), free_start); |
| 397 | extended.recycle(clamped_start - extendedOffset(), free_end - clamped_start); |
| 394 | 398 | } |
| 395 | 399 | } |
| 396 | 400 | |