xo-gc: + scaffold for gc primitives

This commit is contained in:
Roland Conybeare 2026-03-24 22:20:23 -04:00
commit 57d895a41c
6 changed files with 179 additions and 0 deletions

20
include/xo/gc/SetupGc.hpp Normal file
View file

@ -0,0 +1,20 @@
/** @file SetupGc.hpp
*
* @author Roland Conybeare, Mar 2026
**/
#pragma once
namespace xo {
namespace mm {
class SetupGc {
public:
/** Register gc (facet,impl) combinations with FacetRegistry **/
static bool register_facets();
};
} /*namespace mm*/
} /*namespace xo*/
/* end SetupGc.hpp */

21
include/xo/gc/init_gc.hpp Normal file
View file

@ -0,0 +1,21 @@
/** @file init_gc.hpp
*
* @author Roland Conybeare, Mar 2026
**/
#pragma once
#include <xo/subsys/Subsystem.hpp>
namespace xo {
/* tag to represent the xo-gc/ subsystem within ordered initialization */
enum S_gc_tag {};
template <>
struct InitSubsys<S_gc_tag> {
static void init();
static InitEvidence require();
};
} /*namespace xo*/
/* end init_gc.hpp */

View file

@ -0,0 +1,22 @@
/** @file MutationLogEntry.cpp
*
* @author Roland Conybeare, Mar 2026
**/
#include "MutationLogEntry.hpp"
namespace xo {
namespace mm {
MutationLogEntry::MutationLogEntry(void * parent,
void ** p_data,
obj<AGCObject> snap)
: parent_{parent},
p_data_{p_data},
snap_{snap}
{}
} /*namespace mm*/
} /*namespace xo*/
/* end MutationLogEntry.cpp */

36
src/gc/SetupGc.cpp Normal file
View file

@ -0,0 +1,36 @@
/** @file SetupGc.cpp
*
* @author Roland Conybeare, Mar 2026
**/
#include "SetupGc.hpp"
#include "X1Collector.hpp"
#include <xo/facet/FacetRegistry.hpp>
#include <xo/indentlog/scope.hpp>
namespace xo {
using xo::mm::AAllocator;
using xo::mm::ACollector;
using xo::mm::DX1Collector;
using xo::facet::FacetRegistry;
using xo::reflect::typeseq;
namespace mm {
bool
SetupGc::register_facets()
{
scope log(XO_DEBUG(true));
FacetRegistry::register_impl<AAllocator, DX1Collector>();
FacetRegistry::register_impl<ACollector, DX1Collector>();
log && log(xtag("DX1Collector.tseq", typeseq::id<DX1Collector>()));
log && log(xtag("ACollector.tseq", typeseq::id<ACollector>()));
return true;
}
}
} /*namespace xo*/
/* end SetupGc.cpp */

View file

@ -0,0 +1,46 @@
/** @file X1CollectorConfig.cpp
*
* @author Roland Conybeare, Mar 2026
**/
#include "X1CollectorConfig.hpp"
namespace xo {
namespace mm {
X1CollectorConfig
X1CollectorConfig::with_name(std::string name)
{
X1CollectorConfig copy = *this;
copy.name_ = std::move(name);
return copy;
}
X1CollectorConfig
X1CollectorConfig::with_size(std::size_t gen_z)
{
X1CollectorConfig copy = *this;
copy.arena_config_ = arena_config_.with_size(gen_z);
return copy;
}
X1CollectorConfig
X1CollectorConfig::with_debug_flag(bool x)
{
X1CollectorConfig copy = *this;
copy.debug_flag_ = x;
return copy;
}
X1CollectorConfig
X1CollectorConfig::with_sanitize_flag(bool x)
{
X1CollectorConfig copy = *this;
copy.sanitize_flag_ = x;
return copy;
}
} /*namespace mm*/
} /*namespace xo*/
/* end X1CollectorConfig.cpp */

34
src/gc/init_gc.cpp Normal file
View file

@ -0,0 +1,34 @@
/** @file init_gc.cpp
*
* @author Roland Conybeare, Mar 2026
**/
#include "init_gc.hpp"
#include "SetupGc.hpp"
#include <xo/alloc2/init_alloc2.hpp>
namespace xo {
using xo::mm::SetupGc;
void
InitSubsys<S_gc_tag>::init()
{
SetupGc::register_facets();
}
InitEvidence
InitSubsys<S_gc_tag>::require() {
InitEvidence retval;
/* recursive subsystem deps for xo-gc/ */
retval ^= InitSubsys<S_alloc2_tag>::require();
/* xo-gc/'s own initialization code */
retval ^= Subsystem::provide<S_gc_tag>("gc", &init);
return retval;
}
} /*namespace xo*/
/* end init_gc.cpp */