xo-interpreter2: virtual root for VSM itself

This commit is contained in:
Roland Conybeare 2026-03-25 20:06:40 -04:00
commit 95863d512f
2 changed files with 19 additions and 11 deletions

View file

@ -1,20 +1,20 @@
# reader2
## globalsymtab for essential primitives
rework essential primitives (*,/,+,-,==,!=,..)
so parser doesn't rely on magic globalsymtab lookup strings.
## support missing primitives
tokenizer support + utest for !=,<,>,<=,>=
## boolean operators
^ (xor), | (or), & (and), ~ (not)
# gc
## add_virtual_root
Explicit alternative to `add_gc_root_poly()` for virtual roots.
Since gc doesn't touch data pointer for virtual roots, we can pass
`obj<AGCObject>` instead of `obj<AGCObject>*`.
Will evolve some awkwardness in VSM: having to construct a purposeless
`obj<AGCObject,DVirtualSchematikaMachine>` just to appease the `add_gc_root_poly` signature.
## remove_root
Remove root doesn't work.

View file

@ -47,6 +47,7 @@ namespace xo {
using xo::mm::AGCObject;
using xo::mm::MemorySizeInfo;
using xo::mm::AAllocator;
using xo::mm::ACollector;
using xo::mm::DX1Collector;
using xo::mm::DArena;
using xo::facet::FacetRegistry;
@ -73,6 +74,7 @@ namespace xo {
DVirtualSchematikaMachine::DVirtualSchematikaMachine(const VsmConfig & config,
obj<AAllocator> aux_mm)
: config_{config},
self_vroot_{obj<AGCObject,DVirtualSchematikaMachine>(this)},
aux_mm_{aux_mm},
mm_(abox<AAllocator,DX1Collector>::make(aux_mm_, config.x1_config_)),
rcx_(abox<ARuntimeContext,DVsmRcx>::make(aux_mm_, this)),
@ -88,7 +90,13 @@ namespace xo {
this->global_env_
= obj<AGCObject,DGlobalEnv>(reader_.global_env());
//this->_add_gc_roots();
// TODO:
// annoying to have to create self_vroot_ to appease
// add_gc_root_poly() signature.
// In practice gc won't modify the pointer
// (instead traverses it to find +update children)
//
mm_.to_op().to_facet<ACollector>().add_gc_root_poly(&self_vroot_);
}
DVirtualSchematikaMachine *