diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-03-02 09:16:44 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-03-02 19:35:48 +0300 |
commit | 53997addf27a6f983ba55cf4c370d7685f8ad198 (patch) | |
tree | d7ca9718338c95701c830cbec59e723fa493f59d /alloc.c | |
parent | 60e4b3f8ffeada7635e42788ec6b4e38136fa320 (diff) | |
download | bdwgc-53997addf27a6f983ba55cf4c370d7685f8ad198.tar.gz |
Remove GC_min/max() and simplify heap bounds update in expand_hp_inner
(refactoring)
* alloc.c (GC_max, GC_min): Remove inline function.
* alloc.c (GC_expand_hp_inner): Expand GC_max() and GC_min(); use
new_limit variable.
Diffstat (limited to 'alloc.c')
-rw-r--r-- | alloc.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -1476,16 +1476,6 @@ STATIC void GC_add_to_heap(struct hblk *p, size_t bytes) void * GC_least_plausible_heap_addr = (void *)GC_WORD_MAX; void * GC_greatest_plausible_heap_addr = 0; -GC_INLINE word GC_max(word x, word y) -{ - return(x > y? x : y); -} - -GC_INLINE word GC_min(word x, word y) -{ - return(x < y? x : y); -} - STATIC word GC_max_heapsize = 0; GC_API void GC_CALL GC_set_max_heap_size(GC_word n) @@ -1559,19 +1549,15 @@ GC_INNER GC_bool GC_expand_hp_inner(word n) && (word)GC_last_heap_addr < (word)space)) { /* Assume the heap is growing up. */ word new_limit = (word)space + (word)bytes + expansion_slop; - if (new_limit > (word)space) { - GC_greatest_plausible_heap_addr = - (void *)GC_max((word)GC_greatest_plausible_heap_addr, - (word)new_limit); - } + if (new_limit > (word)space + && (word)GC_greatest_plausible_heap_addr < new_limit) + GC_greatest_plausible_heap_addr = (void *)new_limit; } else { /* Heap is growing down. */ word new_limit = (word)space - expansion_slop; - if (new_limit < (word)space) { - GC_least_plausible_heap_addr = - (void *)GC_min((word)GC_least_plausible_heap_addr, - (word)space - expansion_slop); - } + if (new_limit < (word)space + && (word)GC_least_plausible_heap_addr > new_limit) + GC_least_plausible_heap_addr = (void *)new_limit; } GC_last_heap_addr = (ptr_t)space; |