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