summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-10-24 01:50:14 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-10-24 01:50:14 +0300
commit753cec25f5641d904797e96998a0ec34b3bb4fed (patch)
tree5bd18e79d720745ced410c175ee0f059bbad8fdd
parent5533d1c7c7d96950b8bec9d38c4a452d4b104689 (diff)
downloadbdwgc-753cec25f5641d904797e96998a0ec34b3bb4fed.tar.gz
Add I_HOLD_LOCK assertion to expand_hp_inner and related functions
(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.
-rw-r--r--alloc.c2
-rw-r--r--obj_map.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/alloc.c b/alloc.c
index 06213ce8..86c9ac81 100644
--- 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)
diff --git a/obj_map.c b/obj_map.c
index 9fdeb0af..d332254e 100644
--- 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");
}