Leopold Toetsch <[EMAIL PROTECTED]> writes:

> Piers Cawley <[EMAIL PROTECTED]> wrote:
>> Leopold Toetsch <[EMAIL PROTECTED]> writes:
>>> As calling conventions clearly state, that the caller has to save
>>> everything, its probably up to imcc/pcc.c to insert above
>>> statements, if another sub gets called from a sub. I'll fix that in
>>> a minute ;-)
>
>> If and only if that's not a tail call of course.
>
> Good point. But I can imagine, that's by far more simple to detect tail
> calls at the AST level then inside the flattened code parrot sees. So
> the HL can emit (a TBD) flag like "tailcall" appended to the .pcc_call
> sequence.
> Then the call can be optimized to a C<jump> opcode. The construction of
> the subroutine object (which is outside of the call sequence) will lead
> to an used once LHS, which the optimizer already can get rid of.

I'm not sure you can optimize it to a jump opcode when you're tail
calling another function can you? You could be tailcalling into a
closure so you'll need to use invoke to do the right thing with the
lexical stack etc.

Reply via email to