From: Jonathan S. Shapiro <shap@er...> - 2008-01-21 23:28:17
When I last looked, TinyScheme GC did not do compaction. It's mainly an
issue for vectors and strings, and this is why the current vector and
string representations are doubly indirect.
The reason not to compact is C code, because object references on the C
stack and within C data structures can be quite hard to find.
Fergus Henderson came up with a sensible solution for the C stack many
years ago. I am about to send out a description of that.
A solution for "retained" object pointers in the C heap (e.g. I want to
store a reference to a Scheme vector or thunk into a C location) is to
allocate a "wrapper" object for this purpose. The wrapper object
consists of a single wrapped pointer, and it must live in a
non-compactable place, but at least all wrappers are the same size
(unlike vectors). You then tweak the "eval" object to indirect
transparently when a wrapper reference is encountered.
Pointers to wrappers must be handled conservatively or with explicit
I'll describe the Fergus trick in a moment.