ES6: Tail-call optimization in IonMonkey

NEW
Unassigned

Status

()

Core
JavaScript Engine
P3
normal
5 years ago
2 months ago

People

(Reporter: dmandelin, Unassigned)

Tracking

(Depends on: 1 bug, Blocks: 1 bug, {feature})

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [js:p3], URL)

(Reporter)

Description

5 years ago
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

5 years ago
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]
Duplicate of this bug: 960532
Depends on: 565374
Priority: -- → P3
(Assignee)

Updated

3 years ago
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/

Comment 6

a year ago
https://bugs.chromium.org/p/v8/issues/detail?id=4698 Chrome also is done.
More details on Webkit:
https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit/
You need to log in before you can comment on or make changes to this bug.