cairo-vm
                                
                                 cairo-vm copied to clipboard
                                
                                    cairo-vm copied to clipboard
                            
                            
                            
                        Evaluate implementing tail-call optimization
Cairo programs tend to rely heavily on recursion. A common optimization in languages with similar behavior is converting tail calls into jumps. It's not certain that it makes sense or that it is possible with Cairo (for a start, its memory is read only, so we can't simply reuse the slots in the stack to store the arguments for the new "call", and it may alter traces as well), but if it's possible it could save memory and instructions to implement it.
I think the original VM already does this. I will ping Lior to make sure we are not missing something, I think he told me the return() supports tail-call recusion.
It does support tail-call recursion, but not necessarily tail-call optimization. I should check the source code.