[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Stack space allocation
From: |
John Lenz |
Subject: |
[Chicken-users] Stack space allocation |
Date: |
Mon, 22 Mar 2004 14:31:38 -0600 |
Hi. I am in the process of redoing the swig stuff, and I have a
question about C_alloc.
Would the following code be valid?
C_word result = C_SCHEME_END_OF_LIST;
{
C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_SWIG_POINTER);
result = C_pair(&known_space,
C_swigmpointer(&known_space, arg1, arg1t),
result);
}
{
C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_SWIG_POINTER);
result = C_pair(&known_space,
C_swigmpointer(&known_space, arg2, arg2t),
result);
}
{
C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_SWIG_POINTER);
result = C_pair(&known_space,
C_swigmpointer(&known_space, arg3, arg3t),
result);
}
C_kontinue(cont, result);
What I am concerned about is alloca calls inside a C block. I am
unsure if the compiler might be optimizing stack space. That is, since
I create three blocks, it would assume that stack space can be shared
between them and then the alloca call would return the same space to
all three blocks.
Also, when wrapping say a std::list I would like to do something like
for (i = list.begin(); i != list.end(); ++i) {
C_word *space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_SWIG_POINTER);
C_pair(...);
}
would that also be acceptable? The compiler won't optimize the stack
space usage so that every iteration has new data space.
or would say
C_word *space = C_alloc((C_SIZEOF_PAIR + C_SIZEOF_SWIG_POINTER) * list.
size());
and allocate it all at once work better?
Note the list.size() is a O(n) operation.
John
- [Chicken-users] Stack space allocation,
John Lenz <=