xo-gc: copy/move step for collection phase

This commit is contained in:
Roland Conybeare 2026-01-04 00:34:19 -05:00
commit ed0ca0a16b
3 changed files with 19 additions and 3 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include "AllocHeader.hpp"
#include "padding.hpp"
#include <utility>
namespace xo {
@ -121,6 +122,11 @@ namespace xo {
return (hdr.repr_ & size_mask());
}
/** extract padded size from alloc header @p hdr **/
std::size_t size_with_padding(repr_type hdr) const noexcept {
return padding::with_padding(this->size(hdr));
}
/** true iff sentinel tseq, flagging a forwarding pointer **/
bool is_forwarding_tseq(repr_type hdr) const noexcept {
// e.g.
@ -134,6 +140,11 @@ namespace xo {
bool is_size_enabled() const noexcept { return size_bits_ > 0; }
/** construct alloc header for a forwarding object **/
AllocHeader mark_forwarding_tseq(AllocHeader hdr) const noexcept {
return AllocHeader((hdr.repr_ & ~tseq_mask()) | tseq_mask());
}
/** if non-zero, allocate extra space between allocs, and fill
* with fixed test-pattern contents. Allows for simple
* runtime arena sanitizing checks.

View file

@ -52,8 +52,15 @@ namespace xo {
/** @defgroup mm-allocinfo-methods **/
///@{
AllocHeader header() const noexcept { return *p_header_; }
/** true for non-sentinel AllocInfo instance **/
bool is_valid() const { return (p_config_ != nullptr) && (p_header_ != nullptr); }
bool is_valid() const noexcept { return ((p_config_ != nullptr)
&& (p_header_ != nullptr)); }
/** true iff sentinel tseq, flagging a forwarding pointer **/
bool is_forwarding_tseq() const noexcept {
return p_config_->is_forwarding_tseq(*p_header_);
}
/** Guard bytes preceding allocation-header **/
span_type guard_lo() const noexcept;

View file

@ -40,8 +40,6 @@ namespace xo {
*/
std::size_t dz = (align - (z % align)) % align;
z += dz;
return dz;
}