xo-interpreter/xo-alloc: GlobalEnv + mm -> shallow_copy()

This commit is contained in:
Roland Conybeare 2025-11-23 22:57:52 -05:00
commit 760bb556b2
4 changed files with 7 additions and 4 deletions

View file

@ -30,7 +30,7 @@ namespace xo {
/** required by Object i/face, but never called on Forwarding1 **/
virtual std::size_t _shallow_size() const final override;
/** required by Object i/face, but never called on Forwarding1 **/
virtual Object * _shallow_copy() const final override;
virtual Object * _shallow_copy(gc::IAlloc * mm) const final override;
/** required by Object i/face, but never called on Forwarding1 **/
virtual std::size_t _forward_children() final override;

View file

@ -57,6 +57,9 @@ namespace xo {
return (u2 <= u1 + sizeof(std::uintptr_t));
}
/** (for consistency's sake) **/
T * get() const { return ptr_; }
T * ptr() const { return ptr_; }
T ** ptr_address() { return &ptr_; }
@ -204,7 +207,7 @@ namespace xo {
*
* Require: @ref mm is an instance of @ref gc::GC
**/
virtual Object * _shallow_copy() const = 0;
virtual Object * _shallow_copy(gc::IAlloc * mm) const = 0;
/** update child pointers that refer to forwarding pointers,
* replacing them with the correct destination.

View file

@ -52,7 +52,7 @@ namespace xo {
// LCOV_EXCL_START
Object *
Forwarding1::_shallow_copy() const {
Forwarding1::_shallow_copy(gc::IAlloc *) const {
assert(false);
return nullptr;
}

View file

@ -170,7 +170,7 @@ namespace xo {
*/
if (gc->fromspace_contains(src))
{
Object * dest = src->_shallow_copy();
Object * dest = src->_shallow_copy(gc);
if (dest != src)
src->_forward_to(dest);