diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2021-09-11 11:47:13 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2021-09-11 11:47:13 +0300 |
commit | 3e30dd469a6da0962b359390bb426b20af422d6a (patch) | |
tree | a31c5157796111a4c2e5cc600e8a55e04fea084a | |
parent | 7aadbb5292977562cd63afadcb08e2b436b05e00 (diff) | |
download | bdwgc-3e30dd469a6da0962b359390bb426b20af422d6a.tar.gz |
Do not update scratch_last_end_ptr unless used by reg dynamic libraries
(refactoring)
* headers.c (GC_scratch_alloc): Do not update GC_scratch_last_end_ptr
unless USE_SCRATCH_LAST_END_PTR; add TODO item.
* include/private/gc_priv.h [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(USE_SCRATCH_LAST_END_PTR): Define macro.
* include/private/gc_priv.h (_GC_arrays._scratch_last_end_ptr,
GC_scratch_last_end_ptr): Do define unless USE_SCRATCH_LAST_END_PTR;
refine comment.
-rw-r--r-- | headers.c | 15 | ||||
-rw-r--r-- | include/private/gc_priv.h | 10 |
2 files changed, 17 insertions, 8 deletions
@@ -122,11 +122,13 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes) GC_add_to_our_memory(result, bytes_to_get); /* Undo scratch free area pointer update; get memory directly. */ GC_scratch_free_ptr -= bytes; - if (result != NULL) { +# ifdef USE_SCRATCH_LAST_END_PTR + if (result != NULL) { /* Update end point of last obtained area (needed only */ /* by GC_register_dynamic_libraries for some targets). */ GC_scratch_last_end_ptr = result + bytes; - } + } +# endif return result; } @@ -141,14 +143,19 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes) bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes); result = (ptr_t)GET_MEM(bytes_to_get); GC_add_to_our_memory(result, bytes_to_get); - if (result != NULL) +# ifdef USE_SCRATCH_LAST_END_PTR + if (result != NULL) GC_scratch_last_end_ptr = result + bytes; +# endif return result; } + /* TODO: some amount of unallocated space may remain unused forever */ /* Update scratch area pointers and retry. */ GC_scratch_free_ptr = result; GC_scratch_end_ptr = GC_scratch_free_ptr + bytes_to_get; - GC_scratch_last_end_ptr = GC_scratch_end_ptr; +# ifdef USE_SCRATCH_LAST_END_PTR + GC_scratch_last_end_ptr = GC_scratch_end_ptr; +# endif } } diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 1c35c98b..fac4a7ce 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1399,11 +1399,14 @@ struct _GC_arrays { hdr *_hdr_free_list; ptr_t _scratch_end_ptr; /* GC_scratch_end_ptr is end point of the current scratch area. */ - ptr_t _scratch_last_end_ptr; +# if defined(IRIX5) || (defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX)) +# define USE_SCRATCH_LAST_END_PTR +# define GC_scratch_last_end_ptr GC_arrays._scratch_last_end_ptr + ptr_t _scratch_last_end_ptr; /* GC_scratch_last_end_ptr is the end point of the last */ /* obtained scratch area. */ - /* Used by headers.c, and can easily appear to point to */ - /* heap. Also used by GC_register_dynamic_libraries(). */ + /* Used by GC_register_dynamic_libraries(). */ +# endif mse *_mark_stack; /* Limits of stack for GC_mark routine. All ranges */ /* between GC_mark_stack (incl.) and GC_mark_stack_top */ @@ -1652,7 +1655,6 @@ GC_API_PRIV GC_FAR struct _GC_arrays GC_arrays; #define GC_scratch_free_ptr GC_arrays._scratch_free_ptr #define GC_hdr_free_list GC_arrays._hdr_free_list #define GC_scratch_end_ptr GC_arrays._scratch_end_ptr -#define GC_scratch_last_end_ptr GC_arrays._scratch_last_end_ptr #define GC_size_map GC_arrays._size_map #define GC_static_roots GC_arrays._static_roots #define GC_top_index GC_arrays._top_index |