|What's wrong with alloca() ? email@example.com (1991-12-19)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1991-12-15)|
|Re: What's wrong with alloca() ? email@example.com (1991-12-21)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1991-12-22)|
|Re: What's wrong with alloca() ? email@example.com (1991-12-23)|
|Re: What's wrong with alloca() ? David.Chase@Eng.Sun.COM (1991-12-23)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1991-12-26)|
|Re: What's wrong with alloca() ? email@example.com (1991-12-30)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1991-12-30)|
|Re: What's wrong with alloca() ? email@example.com (1991-12-31)|
|[4 later articles]|
|From:||firstname.lastname@example.org (Preston Briggs)|
|Organization:||Rice University, Houston|
|Date:||Sun, 22 Dec 1991 18:08:57 GMT|
email@example.com (David Keppel) writes:
>By the time you've added these calls you're just
>about all the way to having ``object stack'' allocation, called
>``obstacks'' in GNU terminology. An obstack is an allocation region that
>can be used for incremental allocation and then freed all at once.
I hadn't read of obstacks, but they sound like the "arenas" described in
Fast Allocation and Deallocation of
Memory Based on Object Lifetimes
David R. Hanson
Software - Practice and Experience
January 1990, 20(1)
His implementation is very small and simple. Though allocation costs more
than a single add, it's still very fast (about 8 instructions on a VAX).
Freeing looks like about 4 instructions. It's very handy and I use it a
However, alloca is still useful. In one example, I use it in a deeply
recursive tree walk, allocating structures of different sizes. We don't
want an arena or obstack, since different pieces become free at different
times (and since it's a tree walk, we'll want to reuse freed chunks from
one branch while walking later branches).
So, we seem to want several sorts of memory allocation, with special case
allocators tuned to the special cases that arise in code. When I said
this to a friend (Scott Warren), he pointed out that we actually want
optimizers that recognize our patterns of usage, and handle the special
Of course, people have worked on this problem.
David Chase is a good example. Are there others?
Return to the
Search the comp.compilers archives again.