44#define ALIGNED_GC_MALLOC (sz ) MAYBE_MONITOR_ALLOC(GC_MALLOC(sz), sz)
55#define ALIGNED_GC_MALLOC_ATOMIC (sz ) MAYBE_MONITOR_ALLOC(GC_MALLOC_ATOMIC(sz), sz)
66#define ALIGNED_GC_MALLOC_UNCOLLECTABLE (sz ) MAYBE_MONITOR_ALLOC(GC_MALLOC_UNCOLLECTABLE(sz), sz)
7- #define ALIGNED_GC_MALLOC_KIND (stmp, sz, knd, kndaddr ) MAYBE_MONITOR_ALLOC(GC_malloc_kind_global(sz, knd), sz)
7+ #define ALIGNED_GC_MALLOC_KIND (sz, knd ) MAYBE_MONITOR_ALLOC(GC_malloc_kind_global(sz, knd), sz)
88#define ALIGNED_GC_MALLOC_STRONG_WEAK_KIND (sz, knd ) MAYBE_MONITOR_ALLOC(GC_malloc_kind_global(sz, knd), sz)
99#define ALIGNED_GC_MALLOC_ATOMIC_KIND (stmp, sz, knd, kndaddr ) \
1010 MAYBE_MONITOR_ALLOC ( \
1111 (knd == GC_I_PTRFREE) ? GC_malloc_kind_global(sz, knd) : malloc_kind_error(GC_I_PTRFREE, knd, sz, stmp, kndaddr), sz)
12- #define ALIGNED_GC_MALLOC_UNCOLLECTABLE_KIND (stmp, sz, knd, kndaddr ) \
12+ #define ALIGNED_GC_MALLOC_UNCOLLECTABLE_KIND (sz, knd ) \
1313 MAYBE_MONITOR_ALLOC (GC_generic_malloc_uncollectable(sz, knd), sz)
1414#else
1515#error "There is more work to do to support more than 3 tag bits"
@@ -24,7 +24,7 @@ template <typename Stage, typename Cons, typename... ARGS> inline Cons* do_cons_
2424 RAIIAllocationStage<Stage> stage (my_thread_low_level);
2525#ifdef USE_PRECISE_GC
2626 ConsHeader_s* header = reinterpret_cast <ConsHeader_s*>(
27- ALIGNED_GC_MALLOC_KIND (STAMP_UNSHIFT_WTAG (STAMPWTAG_CONS), size, global_cons_kind, & global_cons_kind)); // wasMTAG
27+ ALIGNED_GC_MALLOC_KIND (size, global_cons_kind)); // wasMTAG
2828#ifdef DEBUG_BOEHMPRECISE_ALLOC
2929 printf (" %s:%d:%s cons = %p\n " , __FILE__, __LINE__, __FUNCTION__, cons);
3030#endif
@@ -62,14 +62,14 @@ inline Header_s* do_atomic_allocation(const Header_s::StampWtagMtag& the_header,
6262 return header;
6363};
6464
65+ template <bool weakp>
6566inline Header_s* do_weak_allocation (const Header_s::StampWtagMtag& the_header, size_t size) {
6667 size_t true_size = size;
67- #ifdef USE_PRECISE_GC
68- Header_s* header = reinterpret_cast <Header_s*>(ALIGNED_GC_MALLOC_ATOMIC (true_size));
69- // Header_s* header = reinterpret_cast<Header_s*>(ALIGNED_GC_MALLOC_STRONG_WEAK_KIND_ATOMIC(true_size,global_strong_weak_kind));
70- #else
71- Header_s* header = reinterpret_cast <Header_s*>(ALIGNED_GC_MALLOC_ATOMIC (true_size));
72- #endif
68+ Header_s* header;
69+ if constexpr (weakp)
70+ header = reinterpret_cast <Header_s*>(ALIGNED_GC_MALLOC_ATOMIC (true_size));
71+ else
72+ header = reinterpret_cast <Header_s*>(ALIGNED_GC_MALLOC_KIND (true_size, GC_I_NORMAL));
7373 my_thread_low_level->_Allocations .registerWeakAllocation (the_header._value , true_size);
7474#ifdef DEBUG_GUARD
7575 memset (header, 0x00 , true_size);
@@ -92,7 +92,7 @@ inline Header_s* do_general_allocation(const Header_s::StampWtagMtag& the_header
9292 auto stamp = the_header.stamp ();
9393 auto & kind = global_stamp_layout[stamp].boehm ._kind ;
9494 GCTOOLS_ASSERT (kind != KIND_UNDEFINED);
95- Header_s* header = reinterpret_cast <Header_s*>(ALIGNED_GC_MALLOC_KIND (stamp, true_size, kind, & kind));
95+ Header_s* header = reinterpret_cast <Header_s*>(ALIGNED_GC_MALLOC_KIND (true_size, kind));
9696#ifdef DEBUG_BOEHMPRECISE_ALLOC
9797 printf (" %s:%d:%s header = %p\n " , __FILE__, __LINE__, __FUNCTION__, header);
9898#endif
@@ -117,8 +117,7 @@ inline Header_s* do_uncollectable_allocation(const Header_s::StampWtagMtag& the_
117117#endif
118118#ifdef USE_PRECISE_GC
119119 Header_s* header = reinterpret_cast <Header_s*>(
120- ALIGNED_GC_MALLOC_UNCOLLECTABLE_KIND (the_header.stamp (), true_size, global_stamp_layout[the_header.stamp ()].boehm ._kind ,
121- &global_stamp_layout[the_header.stamp ()].boehm ._kind ));
120+ ALIGNED_GC_MALLOC_UNCOLLECTABLE_KIND (true_size, global_stamp_layout[the_header.stamp ()].boehm ._kind ));
122121#ifdef DEBUG_BOEHMPRECISE_ALLOC
123122 printf (" %s:%d:%s header = %p\n " , __FILE__, __LINE__, __FUNCTION__, header);
124123#endif
0 commit comments