xo-gc: + scaffold for gc primitives

This commit is contained in:
Roland Conybeare 2026-03-24 22:20:23 -04:00
commit 5369c82ed5
5 changed files with 88 additions and 1 deletions

View 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 */

View file

@ -6,6 +6,7 @@ set(SELF_SRCS
init_primitives.cpp
SetupProcedure2.cpp
ObjectPrimitives.cpp
GcPrimitives.cpp
PrimitiveRegistry.cpp
DPrimitive.cpp
DSimpleRcx.cpp

View 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 */

View file

@ -31,7 +31,7 @@ namespace xo {
InstallSink sink,
InstallFlags flags)
{
scope log(XO_DEBUG(true));
scope log(XO_DEBUG(false));
bool ok = true;

View file

@ -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"