xo-object2: obj<ACollector> argument to DArray::push_back()
This commit is contained in:
parent
e9a5bea66e
commit
f79e44a2b9
20 changed files with 388 additions and 105 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
namespace xo {
|
||||
using xo::map::DArenaHashMap;
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -51,13 +52,13 @@ namespace xo {
|
|||
assert(var_map);
|
||||
|
||||
/* choosing same capacity for hash, vars */
|
||||
DArray * vars = DArray::empty(mm, var_map->capacity());
|
||||
DArray * vars = DArray::_empty(mm, var_map->capacity());
|
||||
assert(vars);
|
||||
|
||||
auto type_map = dp<repr_type>::make(aux_mm, type_cfg);
|
||||
assert(type_map);
|
||||
|
||||
DArray * types = DArray::empty(mm, type_map->capacity());
|
||||
DArray * types = DArray::_empty(mm, type_map->capacity());
|
||||
|
||||
void * mem = mm.alloc_for<DGlobalSymtab>();
|
||||
|
||||
|
|
@ -110,6 +111,8 @@ namespace xo {
|
|||
{
|
||||
scope log(XO_DEBUG(false), std::string_view(*var->name()));
|
||||
|
||||
auto gc = mm.try_to_facet<ACollector>();
|
||||
|
||||
// It's possible there's already a global variable
|
||||
// with the same name.
|
||||
//
|
||||
|
|
@ -165,7 +168,7 @@ namespace xo {
|
|||
// need slot# in .map_ for this unique symbol
|
||||
(*var_map_)[var->name()] = binding.j_slot();
|
||||
|
||||
vars_->push_back(obj<AGCObject,DVariable>(var));
|
||||
vars_->push_back(gc, obj<AGCObject,DVariable>(var));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -191,6 +194,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG(true),
|
||||
std::string_view(*tname->name()));
|
||||
|
||||
auto gc = mm.try_to_facet<ACollector>();
|
||||
|
||||
auto ix = type_map_->find(tname->name());
|
||||
|
||||
if (ix == type_map_->end()) {
|
||||
|
|
@ -218,12 +223,13 @@ namespace xo {
|
|||
(*type_map_)[tname->name()] = n;
|
||||
|
||||
log && log("STUB: need write barrier");
|
||||
types_->push_back(obj<AGCObject,DTypename>(tname));
|
||||
types_->push_back(gc, obj<AGCObject,DTypename>(tname));
|
||||
} else {
|
||||
Binding::slot_type i_slot = ix->second;
|
||||
|
||||
log && log("STUB: need write barrier");
|
||||
(*types_)[i_slot] = obj<AGCObject,DTypename>(tname);
|
||||
types_->assign_at(gc, i_slot,
|
||||
obj<AGCObject,DTypename>(tname));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::print::APrintable;
|
||||
//using xo::facet::typeseq;
|
||||
using xo::print::ppstate;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -34,8 +34,8 @@ namespace xo {
|
|||
{
|
||||
void * mem = mm.alloc_for<DLocalSymtab>();
|
||||
|
||||
DArray * vars = DArray::empty(mm, nv);
|
||||
DArray * types = DArray::empty(mm, nt);
|
||||
DArray * vars = DArray::_empty(mm, nv);
|
||||
DArray * types = DArray::_empty(mm, nt);
|
||||
|
||||
return new (mem) DLocalSymtab(p, vars, types);
|
||||
}
|
||||
|
|
@ -69,7 +69,9 @@ namespace xo {
|
|||
Binding binding = Binding::local(vars_->size());
|
||||
|
||||
DVariable * var = DVariable::make(mm, name, typeref, binding);
|
||||
vars_->push_back(obj<AGCObject,DVariable>(var));
|
||||
|
||||
auto gc = mm.try_to_facet<ACollector>();
|
||||
vars_->push_back(gc, obj<AGCObject,DVariable>(var));
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
|
@ -87,7 +89,8 @@ namespace xo {
|
|||
} else {
|
||||
obj<AGCObject> tname = DTypename::make(mm, name, type);
|
||||
|
||||
types_->push_back(tname);
|
||||
auto gc = mm.try_to_facet<ACollector>();
|
||||
types_->push_back(gc, tname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <xo/reflectutil/typeseq.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::print::APrintable;
|
||||
using xo::facet::FacetRegistry;
|
||||
|
|
@ -47,8 +48,8 @@ namespace xo {
|
|||
/** allocate 2nd, so it comes after DSequenceExpr in
|
||||
* memory. This may later allow realloc
|
||||
**/
|
||||
DArray * expr_v = DArray::empty(mm,
|
||||
c_hint_capacity);
|
||||
DArray * expr_v = DArray::_empty(mm,
|
||||
c_hint_capacity);
|
||||
|
||||
expr->expr_v_ = expr_v;
|
||||
|
||||
|
|
@ -73,23 +74,25 @@ namespace xo {
|
|||
DSequenceExpr::push_back(obj<AAllocator> mm,
|
||||
obj<AExpression> expr)
|
||||
{
|
||||
// null gc -> no write barrier
|
||||
obj<ACollector> gc = mm.try_to_facet<ACollector>();
|
||||
|
||||
if (expr_v_->size() == expr_v_->capacity()) {
|
||||
/* reallocate+expand */
|
||||
|
||||
DArray * expr_2x_v
|
||||
= DArray::empty(mm, 2 * expr_v_->capacity());
|
||||
= DArray::_empty(mm, 2 * expr_v_->capacity());
|
||||
|
||||
for (size_type i = 0, z = expr_v_->size(); i < z; ++i) {
|
||||
expr_2x_v->push_back((*expr_2x_v)[i]);
|
||||
expr_2x_v->push_back(gc, (*expr_2x_v)[i]);
|
||||
}
|
||||
|
||||
this->expr_v_ = expr_2x_v;
|
||||
}
|
||||
|
||||
obj<AGCObject> expr_gco
|
||||
= FacetRegistry::instance().variant<AGCObject,AExpression>(expr);
|
||||
obj<AGCObject> expr_gco = expr.to_facet<AGCObject>();
|
||||
|
||||
this->expr_v_->push_back(expr_gco);
|
||||
this->expr_v_->push_back(gc, expr_gco);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue