xo-gc: + ACollector.assign_member()
This commit is contained in:
parent
ae167d70a3
commit
f7e8fd5f65
2 changed files with 35 additions and 13 deletions
|
|
@ -31,6 +31,7 @@ namespace xo {
|
|||
using repr_type = xo::map::DArenaHashMap<key_type, Binding::slot_type>;
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
using size_type = std::uint32_t;
|
||||
|
|
@ -47,10 +48,16 @@ namespace xo {
|
|||
* Use memory from @p mm for DGlobalSymtab instance.
|
||||
* Hashmap for variables per @p var_cfg; for types per @p type_cfg.
|
||||
**/
|
||||
static dp<DGlobalSymtab> make(obj<AAllocator> mm,
|
||||
obj<AAllocator> fixed_mm,
|
||||
const ArenaHashMapConfig & var_cfg,
|
||||
const ArenaHashMapConfig & type_cfg);
|
||||
static DGlobalSymtab * _make(obj<AAllocator> mm,
|
||||
obj<AAllocator> fixed_mm,
|
||||
const ArenaHashMapConfig & var_cfg,
|
||||
const ArenaHashMapConfig & type_cfg);
|
||||
|
||||
/** like _make(..), but create fop **/
|
||||
static obj<AGCObject,DGlobalSymtab> make(obj<AAllocator> mm,
|
||||
obj<AAllocator> fixed_mm,
|
||||
const ArenaHashMapConfig & var_cfg,
|
||||
const ArenaHashMapConfig & type_cfg);
|
||||
|
||||
/** non-trivial destructor for @ref map_ **/
|
||||
~DGlobalSymtab() = default;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DGlobalSymtab.hpp"
|
||||
#include "GlobalSymtab.hpp"
|
||||
#include "Typename.hpp"
|
||||
#include "Binding.hpp"
|
||||
#include "DUniqueString.hpp"
|
||||
|
|
@ -29,11 +29,11 @@ namespace xo {
|
|||
{
|
||||
}
|
||||
|
||||
dp<DGlobalSymtab>
|
||||
DGlobalSymtab::make(obj<AAllocator> mm,
|
||||
obj<AAllocator> aux_mm,
|
||||
const ArenaHashMapConfig & var_cfg,
|
||||
const ArenaHashMapConfig & type_cfg)
|
||||
DGlobalSymtab *
|
||||
DGlobalSymtab::_make(obj<AAllocator> mm,
|
||||
obj<AAllocator> aux_mm,
|
||||
const ArenaHashMapConfig & var_cfg,
|
||||
const ArenaHashMapConfig & type_cfg)
|
||||
{
|
||||
/* note: using aux_mm for DArenaHashMap superstructure.
|
||||
* {variable, type} storage allocated from mm.
|
||||
|
|
@ -51,14 +51,26 @@ namespace xo {
|
|||
|
||||
DArray * types = DArray::empty(mm, type_map->capacity());
|
||||
|
||||
auto symtab = dp<DGlobalSymtab>::make(mm,
|
||||
std::move(var_map), vars,
|
||||
std::move(type_map), types);
|
||||
void * mem = mm.alloc_for<DGlobalSymtab>();
|
||||
|
||||
auto symtab = new (mem) DGlobalSymtab(std::move(var_map),
|
||||
vars,
|
||||
std::move(type_map),
|
||||
types);
|
||||
assert(symtab);
|
||||
|
||||
return symtab;
|
||||
}
|
||||
|
||||
obj<AGCObject,DGlobalSymtab>
|
||||
DGlobalSymtab::make(obj<AAllocator> mm,
|
||||
obj<AAllocator> aux_mm,
|
||||
const ArenaHashMapConfig & var_cfg,
|
||||
const ArenaHashMapConfig & type_cfg)
|
||||
{
|
||||
return obj<AGCObject,DGlobalSymtab>(_make(mm, aux_mm, var_cfg, type_cfg));
|
||||
}
|
||||
|
||||
void
|
||||
DGlobalSymtab::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
|
|
@ -275,6 +287,9 @@ namespace xo {
|
|||
{
|
||||
// map_ doesn't contain any gc-owned data, can skip
|
||||
|
||||
static_assert(var_map_.is_gc_eligible() == false);
|
||||
static_assert(type_map_.is_gc_eligible() == false);
|
||||
|
||||
gc.forward_inplace(&vars_);
|
||||
gc.forward_inplace(&types_);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue