Last Comment Bug 723959 - ES6: Tail-call optimization in IonMonkey
: ES6: Tail-call optimization in IonMonkey
Status: NEW
[js:p3]
: feature
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: P3 normal with 19 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
http://wiki.ecmascript.org/doku.php?i...
: 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-05-17 02:06 PDT (History)
32 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description 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:

  http://jsperf.com/tco#chart=bar
Comment 1 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. 

http://www.mega-nerd.com/erikd/Blog/CodeHacking/fp-tail-js.html
Comment 2 David Rajchenbach-Teller [:Yoric] (please use "needinfo") 2013-02-09 06:25:41 PST
I have seen often extracts that look like the following:

   foo();
   return;

Do these count as "proper tail position"?
Comment 3 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 Chris Peterson [:cpeterson] 2014-04-16 09:49:00 PDT
*** Bug 960532 has been marked as a duplicate of this bug. ***
Comment 5 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:

https://www.webkit.org/blog/4054/es6-in-webkit/
Comment 6 ebrahim 2016-03-23 00:41:19 PDT
https://bugs.chromium.org/p/v8/issues/detail?id=4698 Chrome also is done.

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