Open Bug 723959 Opened 12 years ago Updated 4 months ago

ES6: Tail-call optimization in IonMonkey

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: dmandelin, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [js:p3])

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
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
I have seen often extracts that look like the following:

   foo();
   return;

Do these count as "proper tail position"?
(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`.
Keywords: feature
OS: Windows 7 → All
Hardware: x86_64 → All
Whiteboard: [js:p3]
Depends on: 565374
Priority: -- → P3
Assignee: general → nobody
Summary: Harmony: Tail-call optimization in IonMonkey → ES6: Tail-call optimization in IonMonkey
WebKit is apparently the first widely used ES engine that supports proper tail call elimination:

https://www.webkit.org/blog/4054/es6-in-webkit/
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.