Naive fix for mremap, without virtual space reservation

This commit is contained in:
Egor Sheremetov 2024-03-24 21:10:21 +03:00 committed by Roman Venediktov
parent 8df129b518
commit 7cf72986e8

View file

@ -277,9 +277,10 @@ void compact_phase (size_t additional_size) {
size_t next_heap_pseudo_size = MAX(next_heap_size, heap.size);
memory_chunk old_heap = heap;
heap.begin = mremap(heap.begin, WORDS_TO_BYTES(heap.size), WORDS_TO_BYTES(next_heap_pseudo_size), MREMAP_MAYMOVE);
heap.begin = mmap(NULL, WORDS_TO_BYTES(next_heap_pseudo_size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
memcpy(heap.begin, old_heap.begin, WORDS_TO_BYTES(old_heap.size));
if (heap.begin == MAP_FAILED) {
perror("ERROR: compact_phase: mremap failed\n");
perror("ERROR: compact_phase: mmap failed\n");
exit(1);
}
heap.end = heap.begin + next_heap_pseudo_size;
@ -290,6 +291,10 @@ void compact_phase (size_t additional_size) {
physically_relocate(&old_heap);
heap.current = heap.begin + live_size;
// if (munmap(old_heap.begin, old_heap.size) < 0) {
// perror("ERROR: compact_phase: munmap failed\n");
// exit(1);
// }
}
size_t compute_locations () {