Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-21 19:24:41


scleary_at_[hidden] wrote:

> What I meant is that current Allocators can be copy-constructed across
> underlying types; that is:

I have got this completely wrong. When reading the allocator specs,
I missed the requirement for a 'generalised copy constructor'.

There is also a good reason for default ctor: to make an instance
which is later assigned to.

Can Felix GC use/be a standard allocator?
-----------------------------------------

When Felix GC wants to allocate memory for a T,
it needs at least

        sizeof(T) + sizeof(frame_t)

storage, and in addition the address returned must be
aligned suitably for a frame_t, and, it must be possible
to calculate the address of the T memory. The frame_t
is a prefix to the T storage. It must be aligned
suitably for a pointer. The only way I can think
of to allocate an arbitrary T is then to allocate

        struct raw_memory_t {
                frame_t frame;
                T data;
        };

instead (where T is the type the client wants to allocate).

To _use_ Felix GC as an allocator, we have to solve
the problem: where does the shape information come from?

The allocator knows the T, so it could use a 'traits'
style thingo to get the shape object. It is also possible
to build a (global) map typeid(T) -> shape for T.
This prevents more than one shape per type.

Unfortunately, I cannot see a way for the Felix operator new
to work. That function is type independent (it gets sizeof(T),
and forgets the T). So "new" functions cannot call allocators
to get hold of memory.

This problem can be solved by using a templated function
that calls the Felix allocator. Unfortunately, that technique
prevents initialisation of the object!

Catch 22. It seems like the existing solution -- a custom
concept of an allocator -- is still the only viable one.

I'd be interested if anyone can see how to make the Felix GC
either USE a standard allocator to allocate memory, AND/OR
be modelled AS such an allocator. I can't see how to do it.

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk