As a security precaution, we have turned on the setting "Require API key authentication for API requests" for everyone. If this has broken something, please contact
Last Comment Bug 723959 - ES6: Tail-call optimization in IonMonkey
: ES6: Tail-call optimization in IonMonkey
Status: NEW
: feature
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: P3 normal with 22 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Jason Orendorff [:jorendorff]
: 960532 (view as bug list)
Depends on: 565374
Blocks: es6
  Show dependency treegraph
Reported: 2012-02-03 08:41 PST by David Mandelin [:dmandelin]
Modified: 2016-12-15 23:11 PST (History)
36 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image David Mandelin [:dmandelin] 2012-02-03 08:41:35 PST
TCO is one of the ES6 proposals, and the proposal requires calls in "proper tail position" to get TCO'd.

There is a benchmark here:
Comment 1 User image Bruno George Moraes 2012-06-26 13:22:52 PDT
Hi, in here is a discussion about how TCO makes possible to use constant stack space, so is important in the view of memory consumption.
Comment 2 User image David Teller [:Yoric] (please use "needinfo") 2013-02-09 06:25:41 PST
I have seen often extracts that look like the following:


Do these count as "proper tail position"?
Comment 3 User image Sam Tobin-Hochstadt [:samth] 2013-02-09 06:50:55 PST
(In reply to David Rajchenbach Teller [:Yoric] from comment #2)
> I have seen often extracts that look like the following:
>    foo();
>    return;
> Do these count as "proper tail position"?

No, that's not a proper tail position, because it wouldn't be ok to just return whatever `foo()` returns.  That extract must always return `undefined`.
Comment 4 User image Chris Peterson [:cpeterson] 2014-04-16 09:49:00 PDT
*** Bug 960532 has been marked as a duplicate of this bug. ***
Comment 5 User image Marc Nieper-Wißkirchen 2015-10-13 08:37:45 PDT
WebKit is apparently the first widely used ES engine that supports proper tail call elimination:
Comment 6 User image ebrahim 2016-03-23 00:41:19 PDT Chrome also is done.
Comment 7 User image Alexandre Folle de Menezes 2016-06-22 08:35:57 PDT
More details on Webkit:

Note You need to log in before you can comment on or make changes to this bug.