disable current in-place growth code path for now

pull/87/head
Daniel Micay 2019-04-09 19:15:43 -04:00
parent d5c1bca915
commit d5c00b4d0d
1 changed files with 19 additions and 16 deletions

View File

@ -1386,23 +1386,26 @@ EXPORT void *h_realloc(void *old, size_t size) {
return old; return old;
} }
// in-place growth static const bool vma_merging_reliable = false;
void *guard_end = (char *)old + old_size + old_guard_size; if (vma_merging_reliable) {
size_t extra = size - old_size; // in-place growth
if (!memory_remap((char *)old + old_size, old_guard_size, old_guard_size + extra)) { void *guard_end = (char *)old + old_size + old_guard_size;
if (memory_protect_rw((char *)old + old_size, extra)) { size_t extra = size - old_size;
memory_unmap(guard_end, extra); if (!memory_remap((char *)old + old_size, old_guard_size, old_guard_size + extra)) {
} else { if (memory_protect_rw((char *)old + old_size, extra)) {
mutex_lock(&ra->lock); memory_unmap(guard_end, extra);
struct region_metadata *region = regions_find(old); } else {
if (region == NULL) { mutex_lock(&ra->lock);
fatal_error("invalid realloc"); struct region_metadata *region = regions_find(old);
} if (region == NULL) {
region->size = size; fatal_error("invalid realloc");
mutex_unlock(&ra->lock); }
region->size = size;
mutex_unlock(&ra->lock);
thread_seal_metadata(); thread_seal_metadata();
return old; return old;
}
} }
} }