[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memory allocation primitives?



Is there one or a small number of routines through which
everyone who wants to cons a cell must pass?  That is, in order to
profile consing, I'd like to advise CONS to do some stuff, but
that may not get all the consing done by, e.g. the list functions
such as append, remove, sublis, etc., because there is no guarantee
that they call CONS to get their cells.  What I'd like is an advisable
function like "CCL::%cons" or something that really does it for everybody.
(An alternative is to advise every language primitive that could
possibly allocate memory, but that is extremely ugly and may not even
get everything (you can't advise special forms and macros, can you? also,
macros may expand into mcl-specific internal function calls, such as
backquote).)
If there are a small number of such internal functions, that would be okay,
too.  (e.g. In the C world, the functions malloc, realloc, etc. cover 99+% of
all dynamic space allocation in programs.)

Obviously, I would like also analogous routines for other structures like
instances, defstructs, etc.

Does anybody know?

Thanks,

-- Bob

P.S.  I'm trying to implement sampled space profiling in MCL.  That is, I'd
like to generate a (conceptual) interrupt to myself every kth (user sets k)
byte allocated so I can take a sample of the run-time stack trace.
This is entirely analogous to being interrupted every kth millisecond
to take a sample for time profiling.  If there's a direct way to generate
such an interrupt for space (without advising the space allocation functions),
I'd be happy to hear about it.  Note that it doesn't work to generate time
interrupts and simply attribute all the space since the last interrupt
to the currently executing function, since the currently executing guy
might not allocate space at all.

P.P.S. I'm using MCL 2.0p2.