Add I_HOLD_LOCK assertion to expand_hp_inner and related functions
authorIvan Maidanski <ivmai@mail.ru>
Tue, 23 Oct 2018 22:50:14 +0000 (01:50 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 23 Oct 2018 22:50:14 +0000 (01:50 +0300)
(code refactoring)

* alloc.c (GC_expand_hp_inner, GC_collect_or_expand): Add
GC_ASSERT(I_HOLD_LOCK()) at the beginning of the function.
* obj_map.c (GC_register_displacement_inner): Likewise.

alloc.c
obj_map.c

diff --git a/alloc.c b/alloc.c
index 06213ce..86c9ac8 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -1340,6 +1340,7 @@ GC_INNER GC_bool GC_expand_hp_inner(word n)
     word expansion_slop;        /* Number of bytes by which we expect the */
                                 /* heap to expand soon.                   */
 
+    GC_ASSERT(I_HOLD_LOCK());
     if (n < MINHINCR) n = MINHINCR;
     bytes = ROUNDUP_PAGESIZE((size_t)n * HBLKSIZE);
     if (GC_max_heapsize != 0
@@ -1433,6 +1434,7 @@ GC_INNER GC_bool GC_collect_or_expand(word needed_blocks,
     word blocks_to_get;
     IF_CANCEL(int cancel_state;)
 
+    GC_ASSERT(I_HOLD_LOCK());
     DISABLE_CANCEL(cancel_state);
     if (!GC_incremental && !GC_dont_gc &&
         ((GC_dont_expand && GC_bytes_allocd > 0)
index 9fdeb0a..d332254 100644 (file)
--- a/obj_map.c
+++ b/obj_map.c
@@ -35,6 +35,7 @@ GC_API void GC_CALL GC_register_displacement(size_t offset)
 
 GC_INNER void GC_register_displacement_inner(size_t offset)
 {
+    GC_ASSERT(I_HOLD_LOCK());
     if (offset >= VALID_OFFSET_SZ) {
         ABORT("Bad argument to GC_register_displacement");
     }