xo-gc: + scaffold for gc primitives
This commit is contained in:
parent
61baf9c2b5
commit
0f8494427e
11 changed files with 267 additions and 1 deletions
20
xo-gc/include/xo/gc/SetupGc.hpp
Normal file
20
xo-gc/include/xo/gc/SetupGc.hpp
Normal 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
xo-gc/include/xo/gc/init_gc.hpp
Normal file
21
xo-gc/include/xo/gc/init_gc.hpp
Normal 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 */
|
||||
22
xo-gc/src/gc/MutationLogEntry.cpp
Normal file
22
xo-gc/src/gc/MutationLogEntry.cpp
Normal 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
xo-gc/src/gc/SetupGc.cpp
Normal file
36
xo-gc/src/gc/SetupGc.cpp
Normal 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 */
|
||||
46
xo-gc/src/gc/X1CollectorConfig.cpp
Normal file
46
xo-gc/src/gc/X1CollectorConfig.cpp
Normal 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
xo-gc/src/gc/init_gc.cpp
Normal file
34
xo-gc/src/gc/init_gc.cpp
Normal 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 */
|
||||
30
xo-procedure2/include/xo/procedure2/GcPrimitives.hpp
Normal file
30
xo-procedure2/include/xo/procedure2/GcPrimitives.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/** @file GcPrimitives.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Primitive_gco_1_gco.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** @rbief primitives centered on gc/ data structures.
|
||||
* (i.e. X1Collector)
|
||||
**/
|
||||
class GcPrimitives {
|
||||
public:
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
|
||||
public:
|
||||
/** create primitive: request collection **/
|
||||
static DPrimitive_gco_1_gco * make_request_gc_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
/* end GcPrimitives.hpp */
|
||||
|
|
@ -6,6 +6,7 @@ set(SELF_SRCS
|
|||
init_primitives.cpp
|
||||
SetupProcedure2.cpp
|
||||
ObjectPrimitives.cpp
|
||||
GcPrimitives.cpp
|
||||
PrimitiveRegistry.cpp
|
||||
DPrimitive.cpp
|
||||
DSimpleRcx.cpp
|
||||
|
|
|
|||
55
xo-procedure2/src/procedure2/GcPrimitives.cpp
Normal file
55
xo-procedure2/src/procedure2/GcPrimitives.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/** @file GcPrimitives.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#include "GcPrimitives.hpp"
|
||||
#include <xo/object2/Integer.hpp>
|
||||
#include <xo/object2/Boolean.hpp>
|
||||
#include <xo/type/FunctionType.hpp>
|
||||
#include <xo/type/AtomicType.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/generation.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::generation;
|
||||
|
||||
namespace scm {
|
||||
|
||||
// ----- request-gc -----
|
||||
|
||||
obj<AGCObject>
|
||||
xfer_request_gc(obj<ARuntimeContext> rcx,
|
||||
obj<AGCObject> upto_gco)
|
||||
{
|
||||
bool have_gc = false;
|
||||
|
||||
if (rcx.collector()) {
|
||||
generation upto(obj<AGCObject,DInteger>::from(upto_gco));
|
||||
|
||||
rcx.collector().request_gc(upto);
|
||||
|
||||
have_gc = true;
|
||||
}
|
||||
|
||||
return DBoolean::box(rcx.allocator(), have_gc);
|
||||
}
|
||||
|
||||
DPrimitive_gco_1_gco *
|
||||
GcPrimitives::make_request_gc_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
(void)stbl;
|
||||
|
||||
auto int_ty = DAtomicType::make(mm, Metatype::t_integer());
|
||||
auto bool_ty = DAtomicType::make(mm, Metatype::t_bool());
|
||||
auto pm_ty = obj<AType,DFunctionType>(DFunctionType::_make(mm,
|
||||
bool_ty,
|
||||
int_ty));
|
||||
|
||||
return DPrimitive_gco_1_gco::_make(mm, "request_gc", pm_ty, &xfer_request_gc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* end GcPrimitives.cpp */
|
||||
|
|
@ -31,7 +31,7 @@ namespace xo {
|
|||
InstallSink sink,
|
||||
InstallFlags flags)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "SetupProcedure2.hpp"
|
||||
#include "Procedure.hpp"
|
||||
#include "ObjectPrimitives.hpp"
|
||||
#include "GcPrimitives.hpp"
|
||||
#include "SimpleRcx.hpp"
|
||||
#include "Primitive_gco_0.hpp"
|
||||
#include "Primitive_gco_1_gco.hpp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue