xo-interpreter2 .. xo-arena. memory pool introspection
This commit is contained in:
parent
eec85cc217
commit
d243124ea8
6 changed files with 23 additions and 59 deletions
|
|
@ -36,7 +36,7 @@ namespace xo {
|
|||
using AAllocator = xo::mm::AAllocator;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using DArena = xo::mm::DArena;
|
||||
using MemorySizeInfo = xo::mm::MemorySizeInfo;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
using size_type = std::size_t;
|
||||
|
||||
public:
|
||||
|
|
@ -62,10 +62,8 @@ namespace xo {
|
|||
/** top of parser stack **/
|
||||
obj<ASyntaxStateMachine> top_ssm() const;
|
||||
|
||||
/** number of distinct memory pools owned by PS **/
|
||||
std::size_t _n_store() const noexcept;
|
||||
/** memory consumption for i'th memory pool **/
|
||||
MemorySizeInfo _store_info(std::size_t i) const noexcept;
|
||||
/** visit psm-owned memory pools; call visitor(info) for each **/
|
||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ namespace xo {
|
|||
using token_type = Token;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using MemorySizeInfo = xo::mm::MemorySizeInfo;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
using size_type = std::size_t;
|
||||
|
||||
|
|
@ -193,10 +193,8 @@ namespace xo {
|
|||
/** top of parser stack **/
|
||||
obj<ASyntaxStateMachine> top_ssm() const;
|
||||
|
||||
/** number of distinct memory pools owned by PS **/
|
||||
std::size_t _n_store() const noexcept;
|
||||
/** memory consumption for i'th memory pool **/
|
||||
MemorySizeInfo _store_info(std::size_t i) const noexcept;
|
||||
/** visit parser-owned memory pools; invoke visitor(info) for each **/
|
||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||
|
||||
///@}
|
||||
/** scm-schematikaparser-general-methods **/
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace xo {
|
|||
class SchematikaReader {
|
||||
public:
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using MemorySizeInfo = xo::mm::MemorySizeInfo;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
using span_type = xo::mm::span<const char>;
|
||||
using size_type = std::size_t;
|
||||
|
||||
|
|
@ -44,8 +44,11 @@ namespace xo {
|
|||
SchematikaReader(const ReaderConfig & config,
|
||||
obj<AAllocator> expr_alloc);
|
||||
|
||||
std::size_t _n_store() const noexcept;
|
||||
MemorySizeInfo _store_info(std::size_t i) const noexcept;
|
||||
/** visit reader-owned memory pools; call visitor(info) for each.
|
||||
* Specifically exclude expr_alloc, since we don't consider
|
||||
* that reader-owned
|
||||
**/
|
||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||
|
||||
/** true iff parser is at top-level.
|
||||
* false iff parser is working on incomplete expression
|
||||
|
|
|
|||
|
|
@ -54,27 +54,14 @@ namespace xo {
|
|||
return this->stack_->top();
|
||||
}
|
||||
|
||||
std::size_t
|
||||
ParserStateMachine::_n_store() const noexcept
|
||||
void
|
||||
ParserStateMachine::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
return stringtable_._n_store() + 1;
|
||||
}
|
||||
|
||||
MemorySizeInfo
|
||||
ParserStateMachine::_store_info(std::size_t i) const noexcept
|
||||
{
|
||||
size_t n0 = stringtable_._n_store();
|
||||
|
||||
if (i < n0)
|
||||
return stringtable_._store_info(i);
|
||||
|
||||
if (i == n0)
|
||||
return parser_alloc_._store_info();
|
||||
stringtable_.visit_pools(visitor);
|
||||
parser_alloc_.visit_pools(visitor);
|
||||
|
||||
// not counting expr_alloc_. We don't consider
|
||||
// that to be owned by ParserStateMachine
|
||||
|
||||
return MemorySizeInfo::sentinel();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -47,16 +47,10 @@ namespace xo {
|
|||
return psm_.top_ssm();
|
||||
}
|
||||
|
||||
std::size_t
|
||||
SchematikaParser::_n_store() const noexcept
|
||||
void
|
||||
SchematikaParser::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
return psm_._n_store();
|
||||
}
|
||||
|
||||
MemorySizeInfo
|
||||
SchematikaParser::_store_info(std::size_t i) const noexcept
|
||||
{
|
||||
return psm_._store_info(i);
|
||||
return psm_.visit_pools(visitor);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -21,27 +21,11 @@ namespace xo {
|
|||
{
|
||||
}
|
||||
|
||||
std::size_t
|
||||
SchematikaReader::_n_store() const noexcept
|
||||
void
|
||||
SchematikaReader::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
return tokenizer_._n_store() + parser_._n_store();
|
||||
}
|
||||
|
||||
MemorySizeInfo
|
||||
SchematikaReader::_store_info(std::size_t i) const noexcept
|
||||
{
|
||||
size_t n_tk = tokenizer_._n_store();
|
||||
|
||||
if (i < n_tk) {
|
||||
return tokenizer_._store_info(i);
|
||||
}
|
||||
|
||||
size_t n_pr = parser_._n_store();
|
||||
|
||||
if (i < n_tk + n_pr)
|
||||
return parser_._store_info(i - n_tk);
|
||||
|
||||
return MemorySizeInfo::sentinel();
|
||||
tokenizer_.visit_pools(visitor);
|
||||
parser_.visit_pools(visitor);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue