From e5fb574cf6c12593666cefeb5c005b1a1752af74 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 19 May 2018 12:02:00 +0300 Subject: [PATCH] Fix FAST_MALLOC_GRANS and malloc_many for MANUAL_VDB (fix of commit 73d30d2) This commit actually disables multiple objects allocation in GC_generic_malloc_many (if MANUAL_VDB and the incremental mode is on); the proper implementation would require GC_dirty call for each of the allocated object (except for the last one). * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call GC_end_stubborn_change(my_fl) after GC_generic_malloc_many(). * mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): Always fall back to GC_generic_malloc (unless !GC_incremental). --- include/gc_inline.h | 1 + mallocx.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/gc_inline.h b/include/gc_inline.h index dca8fa3a..4335a4ea 100644 --- a/include/gc_inline.h +++ b/include/gc_inline.h @@ -149,6 +149,7 @@ GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL GC_generic_malloc_many(((granules) == 0? GC_GRANULE_BYTES : \ GC_RAW_BYTES_FROM_INDEX(granules)), \ kind, my_fl); \ + GC_end_stubborn_change(my_fl); \ my_entry = *my_fl; \ if (my_entry == 0) { \ result = (*GC_get_oom_fn())((granules)*GC_GRANULE_BYTES); \ diff --git a/mallocx.c b/mallocx.c index 7b5cd5c3..8774a3e1 100644 --- a/mallocx.c +++ b/mallocx.c @@ -311,7 +311,14 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result) DCL_LOCK_STATE; GC_ASSERT(lb != 0 && (lb & (GRANULE_BYTES-1)) == 0); - if (!SMALL_OBJ(lb)) { + if (!SMALL_OBJ(lb) +# ifdef MANUAL_VDB + /* Currently a single object is allocated. */ + /* TODO: GC_dirty should be called for each linked object (but */ + /* the last one) to support multiple objects allocation. */ + || GC_incremental +# endif + ) { op = GC_generic_malloc(lb, k); if (EXPECT(0 != op, TRUE)) obj_link(op) = 0; -- 2.50.1