diff --git a/include/xo/gc/DX1Collector.hpp b/include/xo/gc/DX1Collector.hpp index c5b8483..bd9d5a6 100644 --- a/include/xo/gc/DX1Collector.hpp +++ b/include/xo/gc/DX1Collector.hpp @@ -155,6 +155,7 @@ namespace xo { // ----- DX1Collector ----- struct DX1Collector { + using typeseq = xo::facet::typeseq; using size_type = DArena::size_type; using value_type = DArena::value_type; using header_type = DArena::header_type; @@ -216,9 +217,14 @@ namespace xo { // ----- allocation ----- - /** simple allocation. new allocs always in gen0 to-space **/ - value_type alloc(size_type z) noexcept; - /** compound allocation. To be followed immediately by: + /** simple allocation. allocate @p z bytes of memory + * for an object of type @p t. + * New allocs always in gen0 to-space + **/ + value_type alloc(typeseq t, size_type z) noexcept; + /** compound allocation. Allocate @p z bytes of memory + * for an object of type @p t. + * To be followed immediately by: * 1. zero or more calls to sub_alloc(zi, complete=false), then * 2. exactly one call to sub_alloc(zi, complete=true) * all the allocs in a compound allocation share the same @@ -226,7 +232,7 @@ namespace xo { * allocation with size z + sum(zi). * New allocs always in gen0 to-space **/ - value_type super_alloc(size_type z) noexcept; + value_type super_alloc(typeseq t, size_type z) noexcept; /** sub-allocation with preceding compound allocation. * New allocs always in gen0 to-space **/ diff --git a/include/xo/gc/detail/IAllocator_DX1Collector.hpp b/include/xo/gc/detail/IAllocator_DX1Collector.hpp index c525dad..6ba79b5 100644 --- a/include/xo/gc/detail/IAllocator_DX1Collector.hpp +++ b/include/xo/gc/detail/IAllocator_DX1Collector.hpp @@ -29,6 +29,7 @@ namespace xo { * RAllocator RCollector.hpp */ struct IAllocator_DX1Collector { + using typeseq = xo::facet::typeseq; using size_type = std::size_t; using value_type = std::byte *; using range_type = AAllocator::range_type; @@ -58,8 +59,8 @@ namespace xo { static range_type alloc_range(const DX1Collector & d, DArena & ialloc) noexcept; /** always alloc in gen0 to-space **/ - static value_type alloc(DX1Collector & d, size_type z) noexcept; - static value_type super_alloc(DX1Collector & d, size_type z) noexcept; + static value_type alloc(DX1Collector & d, typeseq t, size_type z) noexcept; + static value_type super_alloc(DX1Collector & d, typeseq t, size_type z) noexcept; static value_type sub_alloc(DX1Collector & d, size_type z, bool complete) noexcept; /** expand gen0 spaces (both from-space and to-space) **/ static bool expand(DX1Collector & d, size_type z) noexcept; diff --git a/src/gc/DX1Collector.cpp b/src/gc/DX1Collector.cpp index de74776..26223b9 100644 --- a/src/gc/DX1Collector.cpp +++ b/src/gc/DX1Collector.cpp @@ -216,14 +216,14 @@ namespace xo { } auto - DX1Collector::alloc(size_type z) noexcept -> value_type + DX1Collector::alloc(typeseq t, size_type z) noexcept -> value_type { - return with_facet::mkobj(new_space()).alloc(z); + return with_facet::mkobj(new_space()).alloc(t, z); } auto - DX1Collector::super_alloc(size_type z) noexcept -> value_type { - return with_facet::mkobj(new_space()).super_alloc(z); + DX1Collector::super_alloc(typeseq t, size_type z) noexcept -> value_type { + return with_facet::mkobj(new_space()).super_alloc(t, z); } auto diff --git a/src/gc/IAllocator_DX1Collector.cpp b/src/gc/IAllocator_DX1Collector.cpp index d3e172f..b5b26b5 100644 --- a/src/gc/IAllocator_DX1Collector.cpp +++ b/src/gc/IAllocator_DX1Collector.cpp @@ -12,6 +12,7 @@ namespace xo { using xo::facet::with_facet; + using xo::facet::typeseq; using std::size_t; using std::byte; @@ -80,15 +81,19 @@ namespace xo { } auto - IAllocator_DX1Collector::alloc(DX1Collector & d, size_type z) noexcept -> value_type + IAllocator_DX1Collector::alloc(DX1Collector & d, + typeseq t, + size_type z) noexcept -> value_type { - return d.alloc(z); + return d.alloc(t, z); } auto - IAllocator_DX1Collector::super_alloc(DX1Collector & d, size_type z) noexcept -> value_type + IAllocator_DX1Collector::super_alloc(DX1Collector & d, + typeseq t, + size_type z) noexcept -> value_type { - return d.super_alloc(z); + return d.super_alloc(t, z); } auto diff --git a/utest/DX1CollectorIterator.test.cpp b/utest/DX1CollectorIterator.test.cpp index ba3ba09..58a498c 100644 --- a/utest/DX1CollectorIterator.test.cpp +++ b/utest/DX1CollectorIterator.test.cpp @@ -30,6 +30,7 @@ namespace xo { using xo::mm::cmpresult; using xo::mm::padding; using xo::facet::with_facet; + using xo::facet::typeseq; using std::byte; namespace ut { @@ -109,7 +110,7 @@ namespace xo { REQUIRE(a1o.allocated() == 0); size_t req_z = 13; - byte * mem = gc.alloc(req_z); + byte * mem = gc.alloc(typeseq::anon(), req_z); REQUIRE(mem != nullptr); diff --git a/utest/random_allocs.cpp b/utest/random_allocs.cpp index 4031534..654c6c9 100644 --- a/utest/random_allocs.cpp +++ b/utest/random_allocs.cpp @@ -43,6 +43,8 @@ namespace utest { xoshiro256ss * p_rgen, obj mm) { + using xo::facet::typeseq; + scope log(XO_DEBUG(catch_flag), xtag("n-alloc", n_alloc)); /* track allocs. verify: @@ -65,7 +67,7 @@ namespace utest { bool ok_flag = true; - std::byte * mem = mm.alloc(z); + std::byte * mem = mm.alloc(typeseq::anon(), z); log && log(xtag("i_alloc", i_alloc), xtag("si", si),