Bug 148665

Summary: [ES6] Recognize calls in tail position
Product: WebKit Reporter: Basile Clement <basile_clement>
Component: JavaScriptCoreAssignee: Basile Clement <basile_clement>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, msaboff
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 148661    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch for landing none

Basile Clement
Reported 2015-08-31 18:03:30 PDT
...
Attachments
Patch (118.39 KB, patch)
2015-08-31 19:05 PDT, Basile Clement
no flags
Patch (118.98 KB, patch)
2015-08-31 19:25 PDT, Basile Clement
no flags
Patch (28.40 KB, patch)
2015-09-01 14:10 PDT, Basile Clement
no flags
Patch for landing (28.76 KB, patch)
2015-09-03 19:17 PDT, Basile Clement
no flags
Basile Clement
Comment 1 2015-08-31 19:04:40 PDT
*** Bug 146481 has been marked as a duplicate of this bug. ***
Basile Clement
Comment 2 2015-08-31 19:05:20 PDT
Basile Clement
Comment 3 2015-08-31 19:25:24 PDT
Saam Barati
Comment 4 2015-09-01 07:39:56 PDT
Comment on attachment 260346 [details] Patch r=me
Geoffrey Garen
Comment 5 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.
Basile Clement
Comment 6 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.
Basile Clement
Comment 7 2015-09-01 14:09:56 PDT
*** Bug 146481 has been marked as a duplicate of this bug. ***
Basile Clement
Comment 8 2015-09-01 14:10:53 PDT
Saam Barati
Comment 9 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.
Basile Clement
Comment 10 2015-09-03 19:17:21 PDT
Created attachment 260552 [details] Patch for landing
WebKit Commit Bot
Comment 11 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>
WebKit Commit Bot
Comment 12 2015-09-03 20:05:58 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.