Bug 148665 - [ES6] Recognize calls in tail position
Summary: [ES6] Recognize calls in tail position
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Basile Clement
URL:
Keywords:
: 146481 (view as bug list)
Depends on:
Blocks: 148661
  Show dependency treegraph
 
Reported: 2015-08-31 18:03 PDT by Basile Clement
Modified: 2015-09-03 20:05 PDT (History)
2 users (show)

See Also:


Attachments
Patch (118.39 KB, patch)
2015-08-31 19:05 PDT, Basile Clement
no flags Details | Formatted Diff | Diff
Patch (118.98 KB, patch)
2015-08-31 19:25 PDT, Basile Clement
no flags Details | Formatted Diff | Diff
Patch (28.40 KB, patch)
2015-09-01 14:10 PDT, Basile Clement
no flags Details | Formatted Diff | Diff
Patch for landing (28.76 KB, patch)
2015-09-03 19:17 PDT, Basile Clement
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Basile Clement 2015-08-31 18:03:30 PDT
...
Comment 1 Basile Clement 2015-08-31 19:04:40 PDT
*** Bug 146481 has been marked as a duplicate of this bug. ***
Comment 2 Basile Clement 2015-08-31 19:05:20 PDT
Created attachment 260345 [details]
Patch
Comment 3 Basile Clement 2015-08-31 19:25:24 PDT
Created attachment 260346 [details]
Patch
Comment 4 Saam Barati 2015-09-01 07:39:56 PDT
Comment on attachment 260346 [details]
Patch

r=me
Comment 5 Geoffrey Garen 2015-09-01 11:29:50 PDT
Comment on attachment 260346 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=260346&action=review

> Source/JavaScriptCore/parser/Nodes.h:85
> +    enum TailCallMode {
> +        CanHaveTailCalls,
> +        NoTailCalls,
> +    };

Please use "enum class".

"CanHaveTailCalls" seems to wishy-washy. This is the value we use to indicate that we are in tail position, so all calls will be tail calls, right? If so, I would call this "enum class TailCallMode { DoTailCall, DoNotTailCall }" or "enum class TailPosition { InTailPosition, NotInTailPosition }".

It would be nice if we stored this state on the bytecode generator, rather than passing it through to each emitBytecode function. There's a lot of boilerplate for passing this value through, which we don't need.
Comment 6 Basile Clement 2015-09-01 11:51:31 PDT
(In reply to comment #5)
> Comment on attachment 260346 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=260346&action=review
> 
> > Source/JavaScriptCore/parser/Nodes.h:85
> > +    enum TailCallMode {
> > +        CanHaveTailCalls,
> > +        NoTailCalls,
> > +    };
> 
> Please use "enum class".
> 
> "CanHaveTailCalls" seems to wishy-washy. This is the value we use to
> indicate that we are in tail position, so all calls will be tail calls,
> right? If so, I would call this "enum class TailCallMode { DoTailCall,
> DoNotTailCall }" or "enum class TailPosition { InTailPosition,
> NotInTailPosition }".

When said this way, it makes sense. I couldn't find a good name because I got stuck thinking that if we don't have an actual call, then we are not doing a tail call, and I kind of got confused by this. I like the TailPosition enum class.

> 
> It would be nice if we stored this state on the bytecode generator, rather
> than passing it through to each emitBytecode function. There's a lot of
> boilerplate for passing this value through, which we don't need.

Unless I am missing something, storing this on the bytecode generator would make us explicitely clear the "in tail position" state on all constructs that prevent tail calls. The reason I used the "function argument" style was that it allowed to explicitely pass that information for constructs that supports tail calls, and make the default to not have tail calls. This makes it simpler for AST edges that don't support tail calls (which is a bunch of them), and also makes it less error-prone to add new nodes. But maybe I am missing an implementation possibility here.
Comment 7 Basile Clement 2015-09-01 14:09:56 PDT
*** Bug 146481 has been marked as a duplicate of this bug. ***
Comment 8 Basile Clement 2015-09-01 14:10:53 PDT
Created attachment 260381 [details]
Patch
Comment 9 Saam Barati 2015-09-03 17:27:55 PDT
Comment on attachment 260381 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=260381&action=review

r=me with suggestion.

> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:68
> +    class SetForScope {

I think we should give this its own file in hopes of using it in other contexts.
Comment 10 Basile Clement 2015-09-03 19:17:21 PDT
Created attachment 260552 [details]
Patch for landing
Comment 11 WebKit Commit Bot 2015-09-03 20:05:53 PDT
Comment on attachment 260552 [details]
Patch for landing

Clearing flags on attachment: 260552

Committed r189336: <http://trac.webkit.org/changeset/189336>
Comment 12 WebKit Commit Bot 2015-09-03 20:05:58 PDT
All reviewed patches have been landed.  Closing bug.