You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportfunctionup(a){returnmutual$up$down(0,a);}exportfunctiondown(a){returnmutual$up$down(1,a);}exportfunctionmutual$up$down(mode,up$a,down$a){if(mode==0){// This is the `up` functionif(wibble(up$a)){mode=1;down$a=up$a;}else{returnup$a;}}else{// This is the `down` functionif(wibble(down$a)){mode=1;down$a=down$a*down$a;}else{mode=0;up$a=down$a;}}}
The exact names etc we would use would need some thought, but you get the idea.
We already identify functions reference loops during analysis, so perhaps we could use that as a starting point for identifying when this optimisation can be applied.
This would be a challenging item of work.
The text was updated successfully, but these errors were encountered:
V8 (the most widely used JS engine) doesn't implement tail calls for some bad reason, so we need to implement tail call optimisation in the compiler.
Today we support self-recursion. Extend this to support mutual recursion.
My thought was that we could compile this code
To something like this
The exact names etc we would use would need some thought, but you get the idea.
We already identify functions reference loops during analysis, so perhaps we could use that as a starting point for identifying when this optimisation can be applied.
This would be a challenging item of work.
The text was updated successfully, but these errors were encountered: