xo-interpreter2 .. xo-arena. memory pool introspection
This commit is contained in:
parent
438e92d51b
commit
6ec8bd53a2
2 changed files with 7 additions and 18 deletions
|
|
@ -21,7 +21,7 @@ namespace xo {
|
|||
class StringTable {
|
||||
public:
|
||||
using DArena = xo::mm::DArena;
|
||||
using MemorySizeInfo = xo::mm::MemorySizeInfo;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
using StringMap = xo::map::DArenaHashMap<std::string_view,
|
||||
DUniqueString*>;
|
||||
using size_type = StringMap::size_type;
|
||||
|
|
@ -46,8 +46,8 @@ namespace xo {
|
|||
**/
|
||||
bool verify_ok(verify_policy p = verify_policy::throw_only()) const;
|
||||
|
||||
std::size_t _n_store() const noexcept;
|
||||
MemorySizeInfo _store_info(std::size_t i) const noexcept;
|
||||
/** visit string-table memory pools, call visitor(info) for each **/
|
||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||
|
||||
private:
|
||||
/** allocate string storage in this arena; use DString to represent each string.
|
||||
|
|
|
|||
|
|
@ -160,22 +160,11 @@ namespace xo {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
StringTable::_n_store() const noexcept
|
||||
void
|
||||
StringTable::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
return 1 + map_._n_store();
|
||||
}
|
||||
|
||||
MemorySizeInfo
|
||||
StringTable::_store_info(std::size_t i) const noexcept
|
||||
{
|
||||
if (i == 0)
|
||||
return strings_._store_info();
|
||||
|
||||
if (i+1 < map_._n_store())
|
||||
return map_._store_info(i-1);
|
||||
|
||||
return MemorySizeInfo::sentinel();
|
||||
strings_.visit_pools(visitor);
|
||||
map_.visit_pools(visitor);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue