xo-gc: + arena for object roots
This commit is contained in:
parent
e35a6ae587
commit
2e7f574655
3 changed files with 35 additions and 5 deletions
|
|
@ -91,6 +91,9 @@ namespace xo {
|
|||
/** storage for N object types requires 8*N bytes **/
|
||||
std::size_t object_types_z_ = 2*1024*1024;
|
||||
|
||||
/** storage for N object roots requires 8*N bytes **/
|
||||
std::size_t object_roots_z_ = 16*1024;
|
||||
|
||||
/** number of bits to represent generation **/
|
||||
std::uint64_t gen_bits_ = 8;
|
||||
|
||||
|
|
@ -169,6 +172,7 @@ namespace xo {
|
|||
std::string_view name() const { return config_.name_; }
|
||||
|
||||
const DArena * get_object_types() const noexcept { return &object_types_; }
|
||||
const DArena * get_roots() const noexcept { return &roots_; }
|
||||
const DArena * get_space(role r, generation g) const noexcept { return space_[r][g]; }
|
||||
DArena * get_space(role r, generation g) noexcept { return space_[r][g]; }
|
||||
DArena * from_space(generation g) noexcept { return get_space(role::from_space(), g); }
|
||||
|
|
@ -308,6 +312,11 @@ namespace xo {
|
|||
/** if > 0: need gc for all generations < gc_pending_upto_ **/
|
||||
generation gc_pending_upto_;
|
||||
|
||||
/** (ab)using arena to get extensible list of root objects.
|
||||
* For each root store one address (type obj<AGCObject>*)
|
||||
**/
|
||||
DArena roots_;
|
||||
|
||||
/** collector-managed memory here.
|
||||
* - space_[1] is from-space
|
||||
* - space_[0] is to-space
|
||||
|
|
|
|||
|
|
@ -30,10 +30,16 @@ namespace xo {
|
|||
bool is_type_installed(typeseq tseq) const noexcept { return O::iface()->is_type_installed(O::data(), tseq); }
|
||||
|
||||
bool install_type(const AGCObject & iface) { return O::iface()->install_type(O::data(), iface); }
|
||||
void add_gc_root_poly(obj<AGCObject> * p_root) { O::iface()->add_gc_root(O::data(), p_root); }
|
||||
void add_gc_root_poly(obj<AGCObject> * p_root) { O::iface()->add_gc_root_poly(O::data(), p_root); }
|
||||
void request_gc(generation g) { O::iface()->request_gc(O::data(), g); }
|
||||
void forward_inplace(AGCObject * lhs_iface, void ** lhs_data) { O::iface()->forward_inplace(O::data(), lhs_iface, lhs_data); }
|
||||
|
||||
/** add root @p p_root **/
|
||||
template<typename DRepr>
|
||||
void add_gc_root(obj<AGCObject, DRepr> * p_root) {
|
||||
O::iface()->add_gc_root_poly(O::data(), (obj<AGCObject> *)p_root);
|
||||
}
|
||||
|
||||
static bool _valid;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue