[gclist] Finalization and death notices

Charles Fiterman cef@geodesic.com
Mon, 08 Oct 2001 15:09:48 -0500


At 03:39 PM 10/8/01 -0400, you wrote:
>  I've suggested in the past that, if you want to be friendly to both
>C++ idioms and gc, you need to transparently decouple these two operations.

C++ almost decouples free and destruct. You can invoke the destructor
directly by its name. And except for a silly rule against freeing new'ed
objects you'd be able to free them. Write your own allocator and you can.
Keeping track of destructors does just require doing something better with
the vtable pointer than zeroing it.

I'm going to repeat a couple of older suggestions. 

A language can isolate which classes can be reference counted and make
destruction more prompt. If you wanted that you could inherit from a
reference_counted pseudo class that gave warnings if you couldn't be
reference counted with certainty.

Examination of class definitions can tell if an internally used classes can
be expanded or should be referenced. This has been experimented with and
works well. You get the appearance of a pure object oriented language and
the efficiency of a language with expand notation.

Execution frames should be full objects. This means a constructor is just
an execution frame used in a context that leaves a pointer to the frame.
This vastly improves the symmetry and generality of a language. 

If A calls B calls C and B and C aren't used as constructors leaving their
addresses outside of A then B and C's frames can be allocated when A's
frame is. This improves speed and generality and debugging over stack
technology. You can even write programs in which all storage allocation is
done at compile time (not all programs can be done this way). This is one
of the great problems of mission critical software.

Conservative collectors can turn internal pointers into object pointers in
a small number of cycles. This means complex objects don't need base
pointers. In modern machines cache considerations swamp instruction counts
so this will be much faster.

If instantiable class descriptors inherit from heap descriptors it become
easy to turn object pointers to class descriptors. It becomes easy and
efficient to traverse all members of a class. Eliminating class pointers
from objects will make them faster as well as cheaper because of cache
considerations.