xo-interpreter2 stack: plumbing for aux_mm and use opportunistically

This commit is contained in:
Roland Conybeare 2026-02-15 14:13:38 -05:00
commit 78f1b8a0b6
8 changed files with 110 additions and 42 deletions

View file

@ -41,9 +41,21 @@ namespace xo {
using size_type = std::size_t;
public:
/**
* @p config arena configuration for parser state
* @p max_stringtable_capacity
* hard max size for unique stringtable
* @p expr_alloc allocator for schematika expressions.
* Probably shared with execution.
* @p aux_alloc auxiliary allocator for non-copyable memory
* (e.g. DArenaHashMap for global symtable).
* If not using X1Collector, this can be the
* same as @p expr_alloc.
**/
ParserStateMachine(const ArenaConfig & config,
size_type max_stringtable_capacity,
obj<AAllocator> expr_alloc);
obj<AAllocator> expr_alloc,
obj<AAllocator> aux_alloc);
/** @defgroup scm-parserstatemachine-accessors accessor methods **/
///@{
@ -280,6 +292,19 @@ namespace xo {
**/
obj<AAllocator> expr_alloc_;
/** Allocator for data with lifetime bounded by this ParserStateMachine
*
* Cannot be DX1Collector; for example DArenaHashMap will
* for global symtab will be allocated from here,
* and does not support gc.
*
* If @ref expr_alloc_ is an ordinary arena (e.g. DArenaAlloc)
* can have aux_alloc_ = expr_alloc_.
* When expr_alloc_ is a garbage collector (e.g. DX1Collector)
* this needs to be distinct.
**/
obj<AAllocator> aux_alloc_;
/** symbol table with local bindings.
* non-null during parsing of lambda expressions.
* Always allocated from @p expr_alloc_.

View file

@ -164,14 +164,18 @@ namespace xo {
/** create parser in initial state;
* parser is ready to receive tokens via @ref include_token
*
* @p config arena configuration for parser stack
* @p expr_alloc allocator for schematika expressions.
* Probably shared with execution.
* @p config arena configuration for parser stack
* @p expr_alloc allocator for schematika expressions.
* Probably shared with execution.
* @p aux_alloc aux allocator for non-copyable memory
* with lifetime bounded by this
* SchematikeParser itself
* @p debug_flag true to enable debug logging
**/
SchematikaParser(const ArenaConfig & config,
size_t max_stringtable_capacity,
obj<AAllocator> expr_alloc,
obj<AAllocator> aux_alloc,
bool debug_flag);
/** scm-schematikaparser-access-methods **/

View file

@ -41,8 +41,15 @@ namespace xo {
using size_type = std::size_t;
public:
/**
* @p expr_alloc. allocator for Schematika expressions
* @p aux_alloc. allocator for miscellaneous objects
* (e.g. DArenaHashMap for global symtab)
* that have lifetime bounded by Schematika reader itself.
**/
SchematikaReader(const ReaderConfig & config,
obj<AAllocator> expr_alloc);
obj<AAllocator> expr_alloc,
obj<AAllocator> fixed_alloc);
/** visit reader-owned memory pools; call visitor(info) for each.
* Specifically exclude expr_alloc, since we don't consider