Question on materializing Scheme objects outside the Scheme heap
Let say I have some block of memory suitably aligned (8 bytes on my x86_64 machine), of say 16 bytes, with the first 8 bytes being (8 << 3) | 1 (in a uint64_t in native endianness), then create a properly tagged pointer to it with ($address->object (- ptr 1) 0), ptr being the pointer to said block of memory, then I just have successfully created a bytevector of size 8; all bytevector procedures work on this Scheme object that was materialized outside the Scheme heap.
My question is, (let's suppose the block of memory is never freed and reused for the sake of simplicity), is this bytevector can confuse and/or harm the garbage collector? If not, is materializing string objects in a similar fashion the same result? And what about other non-immediate values (pairs, vectors, records etc.)?
Yes, unfortunately allocating scheme objects outside the scheme heap can lead to problems with the garbage collector, which checks to see that pointers it can reach as live are within the heap. For foreign memory the ftype system, can be use for structured access. To share objects in the scheme heap with foreign functions, it is possible to lock them.