This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Handling the Perl VM's "list" op with Kawa IR
"Bradley M. Kuhn" <bkuhn@ebb.org> writes:
> I don't think there is real savings here on object allocation. The
> temporary array is always cleared at the end of each statement.
It is *cleared* - but you can re-use it. For example in any Perl
subroutine that uses the temporarty array, at the start of the subroutine do:
Stack tempArray = new Stack();
Then you can use the same tempArray for *all* list context operation
- just zero its length after each use.
If the CallContext contains the temp array, you can use a single
(per-thread) tenp array, passing it from caller to callee by
using a calling convention that passes a CsllContext.
The other reason you might want to use a temporary array is when
the length of the list is not a priori clear - for example when
lists are interpolated.
That is not to say you *should* use a temp array - it does complicate
things a bit, and the tradeoffs pro and con may be complex. So if
you can compile it away without too much difficulty, it probably makes
to do so, at least initially.
> I followed most of your example, but it seemed your idea was centered around
> trying to preserve the temporary array.
In any case, I suggest you make sure you understand the how Target and
its sub-classes are used. I would also suggest making sure you understand
how Consumer and ConsumeProc and ConsumerTarget work - except Kawa
doesn't do much with them yet.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/