From 760bb556b24fa86124d1c61c882a94d927f839f7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 23 Nov 2025 22:57:52 -0500 Subject: [PATCH] xo-interpreter/xo-alloc: GlobalEnv + mm -> shallow_copy() --- include/xo/alloc/Forwarding1.hpp | 2 +- include/xo/alloc/Object.hpp | 5 ++++- src/alloc/Forwarding1.cpp | 2 +- src/alloc/Object.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/xo/alloc/Forwarding1.hpp b/include/xo/alloc/Forwarding1.hpp index 6276c1ad..77e081f9 100644 --- a/include/xo/alloc/Forwarding1.hpp +++ b/include/xo/alloc/Forwarding1.hpp @@ -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; diff --git a/include/xo/alloc/Object.hpp b/include/xo/alloc/Object.hpp index 5727331e..849cf9bb 100644 --- a/include/xo/alloc/Object.hpp +++ b/include/xo/alloc/Object.hpp @@ -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. diff --git a/src/alloc/Forwarding1.cpp b/src/alloc/Forwarding1.cpp index 4b47e4f2..b4a44ff6 100644 --- a/src/alloc/Forwarding1.cpp +++ b/src/alloc/Forwarding1.cpp @@ -52,7 +52,7 @@ namespace xo { // LCOV_EXCL_START Object * - Forwarding1::_shallow_copy() const { + Forwarding1::_shallow_copy(gc::IAlloc *) const { assert(false); return nullptr; } diff --git a/src/alloc/Object.cpp b/src/alloc/Object.cpp index 475d84ad..309e0886 100644 --- a/src/alloc/Object.cpp +++ b/src/alloc/Object.cpp @@ -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);