Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Issue 160073006: Implement handling of arrow functions in the parser (Closed)

Created:
6 years, 10 months ago by aperez
Modified:
6 years, 5 months ago
CC:
v8-dev
Visibility:
Public.

Description

Implement handling of arrow functions in the parser Arrow functions are parsed from ParseAssignmentExpression. Handling the parameter list is done by letting ParseConditionalExpression() parse a comma-separated list of identifiers, and it returns a tree of BinaryOperation nodes with VariableProxy leaves, or a single VariableProxy if there is only one parameter. When the arrow token "=>" is found, the VariableProxy nodes are passed to ParseFunctionLiteral(), which will then skip parsing the paramaeter list. This avoids having to rewind when the arrow is found and restart parsing the parameter list. Note that ParseExpression() expects parenthesized expressions to not be empty, so checking for a closing parenthesis is added in handling the empty parameter list "()" will accept a right-paren and return an empty expression, which means that the parameter list is empty. Additionally, this adds the following machinery: - A runtime flag "harmony_arrow_functions" (disabled by default). Enabling "harmony" will enable it as well. - An IsArrow bit in SharedFunctionInfo, and accessors for it. - An IsArrow bit in FunctionLiteral, accessorts for it, and a constructor parameter to set its value. - In ParserBase: allow_arrow_functions() and set_allow_arrow_functions() - A V8 native %FunctionIsArrow(), which is used to skip adding the "function " prefix when getting the source code for an arrow function. R=marja@chromium.org Committed: https://code.google.com/p/v8/source/detail?r=22265

Patch Set 1 #

Patch Set 2 : Rebased against latest changes in parser #

Patch Set 3 : Rebased #

Patch Set 4 : Implement handling of arrow functions in the parser #

Total comments: 18

Patch Set 5 : Rebased, moved to ParserBase, fixed as per comments #

Patch Set 6 : Rebased, made arrow function objects not have .prototype #

Patch Set 7 : Rebased after latest changes in runtime.{h,cc} #

Total comments: 13

Patch Set 8 : Rebased and fixed nits #

Patch Set 9 : Extra parens in parameter lists now recognized, no longer segfaults on "()" #

Total comments: 9

Patch Set 10 : Version with parsing code only, tests into test-parsing.cc #

Total comments: 8

Patch Set 11 : Made tests more comprehensive #

Total comments: 1

Patch Set 12 : Removed ParamListFinder #

Total comments: 21

Patch Set 13 : Cleanup round #

Patch Set 14 : Same, plus a rebase and conflicts resolved #

Total comments: 10

Patch Set 15 : Moar clean ups, return dummy FunctionLiteral for arrow functions #

Total comments: 4

Patch Set 16 : Fixed nits #

Patch Set 17 : Make ParameterListFromExpression() return arguments in natural order #

Patch Set 18 : Made sure build suceeds with GCC and werror=yes #

Patch Set 19 : Fixed cpplint issues #

Patch Set 20 : New upload after doing "make dependencies" #

Patch Set 21 : What "git cl format" produces #

Unified diffs Side-by-side diffs Delta from patch set Stats (+876 lines, -276 lines) Patch
M src/ast.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 chunks +7 lines, -0 lines 0 comments Download
M src/flag-definitions.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +2 lines, -0 lines 0 comments Download
M src/messages.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
M src/parser.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 6 chunks +68 lines, -0 lines 0 comments Download
M src/parser.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 3 chunks +53 lines, -0 lines 0 comments Download
M src/preparser.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 30 chunks +399 lines, -41 lines 0 comments Download
M src/scanner.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +2 lines, -0 lines 0 comments Download
M src/scanner.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +13 lines, -1 line 0 comments Download
M src/token.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +133 lines, -132 lines 0 comments Download
M test/cctest/test-parsing.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 20 chunks +198 lines, -102 lines 0 comments Download

Messages

Total messages: 84 (0 generated)
aperez
6 years, 10 months ago (2014-02-12 11:54:14 UTC) #1
aperez
I have rebased the patch after the latest changes in the parser (FunctionState et al.). ...
6 years, 10 months ago (2014-02-12 16:01:05 UTC) #2
jochen (gone - plz use gerrit)
On 2014/02/12 16:01:05, aperez wrote: > I have rebased the patch after the latest changes ...
6 years, 10 months ago (2014-02-12 16:02:52 UTC) #3
aperez
On 2014/02/12 16:02:52, jochen wrote: > On 2014/02/12 16:01:05, aperez wrote: > > I have ...
6 years, 10 months ago (2014-02-14 17:01:12 UTC) #4
aperez
CL updated
6 years, 9 months ago (2014-03-21 20:39:02 UTC) #5
marja
Here are some comments (but I didn't yet look at all the code in detail). ...
6 years, 9 months ago (2014-03-24 09:04:06 UTC) #6
marja
Hmm, one more comment... what am I missing? I thought arrow funcs are just syntactic ...
6 years, 9 months ago (2014-03-24 09:06:47 UTC) #7
rossberg
On 2014/03/24 09:06:47, marja wrote: > Hmm, one more comment... what am I missing? I ...
6 years, 9 months ago (2014-03-24 09:21:06 UTC) #8
marja
On 2014/03/24 09:21:06, rossberg wrote: > On 2014/03/24 09:06:47, marja wrote: > > Hmm, one ...
6 years, 9 months ago (2014-03-24 09:23:44 UTC) #9
rossberg
In addition to the comments below, this is lacking tests. You should be able to ...
6 years, 9 months ago (2014-03-25 12:35:34 UTC) #10
aperez
https://codereview.chromium.org/160073006/diff/380001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/160073006/diff/380001/src/parser.cc#newcode3139 src/parser.cc:3139: Vector<VariableProxy*> Parser::ParameterListFromExpression( On 2014/03/25 12:35:34, rossberg wrote: > How ...
6 years, 8 months ago (2014-04-09 08:47:15 UTC) #11
marja
Btw, I just refactored ParseFunctionLiteral. Con: you'll need to rebase. Pro: The function is less ...
6 years, 8 months ago (2014-04-15 08:32:49 UTC) #12
aperez
On 2014/04/15 08:32:49, marja wrote: > Btw, I just refactored ParseFunctionLiteral. Con: you'll need to ...
6 years, 8 months ago (2014-04-15 08:59:58 UTC) #13
aperez
On 2014/04/15 08:59:58, aperez wrote: > On 2014/04/15 08:32:49, marja wrote: > > Btw, I ...
6 years, 8 months ago (2014-04-15 19:40:53 UTC) #14
aperez
6 years, 8 months ago (2014-04-15 19:41:08 UTC) #15
marja
Thanks for working on this! Some questions which popped in my mind while reading through ...
6 years, 8 months ago (2014-04-24 08:08:05 UTC) #16
aperez
On 2014/04/24 08:08:05, marja wrote: > Thanks for working on this! > > Some questions ...
6 years, 8 months ago (2014-04-24 12:38:04 UTC) #17
aperez
https://codereview.chromium.org/160073006/diff/440001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/160073006/diff/440001/src/parser.cc#newcode3202 src/parser.cc:3202: Vector<VariableProxy*> ParserTraits::ParameterListFromExpression( On 2014/04/24 08:08:06, marja wrote: > It ...
6 years, 8 months ago (2014-04-24 12:38:36 UTC) #18
aperez
On 2014/04/24 12:38:36, aperez wrote: > https://codereview.chromium.org/160073006/diff/440001/src/preparser.h#newcode736 > src/preparser.h:736: class PreParserStatement { > On 2014/04/24 ...
6 years, 8 months ago (2014-04-24 15:27:24 UTC) #19
marja
https://codereview.chromium.org/160073006/diff/440001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/160073006/diff/440001/src/parser.cc#newcode3202 src/parser.cc:3202: Vector<VariableProxy*> ParserTraits::ParameterListFromExpression( Hmm, okay. It would be good to ...
6 years, 7 months ago (2014-04-29 09:38:43 UTC) #20
aperez
On 2014/04/29 09:38:43, marja wrote: > https://codereview.chromium.org/160073006/diff/440001/src/parser.cc > File src/parser.cc (right): > > https://codereview.chromium.org/160073006/diff/440001/src/parser.cc#newcode3202 > ...
6 years, 7 months ago (2014-05-26 12:08:34 UTC) #21
marja
Thanks for the update! Here's a (non-exhaustive) list of comments. In addition, pls add the ...
6 years, 7 months ago (2014-05-26 12:46:06 UTC) #22
marja
https://codereview.chromium.org/160073006/diff/480001/src/parser.h File src/parser.h (right): https://codereview.chromium.org/160073006/diff/480001/src/parser.h#newcode388 src/parser.h:388: typedef v8::internal::Scope* ScopePtr; On 2014/05/26 12:46:06, marja wrote: > ...
6 years, 7 months ago (2014-05-26 12:48:32 UTC) #23
aperez
On 2014/05/26 12:46:06, marja wrote: > Thanks for the update! > > Here's a (non-exhaustive) ...
6 years, 6 months ago (2014-06-04 11:02:55 UTC) #24
marja
Cool, I'll have another look when you get PreParser sorted out. On 2014/06/04 11:02:55, aperez ...
6 years, 6 months ago (2014-06-04 11:06:41 UTC) #25
aperez
On 2014/06/04 11:06:41, marja wrote: > Cool, I'll have another look when you get PreParser ...
6 years, 6 months ago (2014-06-04 15:02:52 UTC) #26
aperez
On 2014/06/04 15:02:52, aperez wrote: > On 2014/06/04 11:06:41, marja wrote: > > Cool, I'll ...
6 years, 6 months ago (2014-06-05 06:30:47 UTC) #27
aperez
On 2014/05/26 12:46:06, marja wrote: > https://codereview.chromium.org/160073006/diff/480001/src/preparser.h#newcode2314 > src/preparser.h:2314: ParserBase<Traits>::ParseArrowFunctionLiteralBody( > A lot of this ...
6 years, 6 months ago (2014-06-14 20:42:06 UTC) #28
aperez
Just posted a new update. (BTW, if this CL is getting gets too big, I ...
6 years, 6 months ago (2014-06-16 18:46:52 UTC) #29
marja
Thanks for posting a new patch! Here are some comments again. Sorry, they're a bit ...
6 years, 6 months ago (2014-06-17 11:47:38 UTC) #30
marja
Hi again, I was also thinking, why does this CL get so complicated, that is, ...
6 years, 6 months ago (2014-06-18 07:21:52 UTC) #31
arv (Not doing code reviews)
On 2014/06/18 07:21:52, marja wrote: > Though, it was sort of expected that this is ...
6 years, 6 months ago (2014-06-18 14:04:56 UTC) #32
rossberg
On 2014/06/18 14:04:56, arv wrote: > On 2014/06/18 07:21:52, marja wrote: > > Though, it ...
6 years, 6 months ago (2014-06-18 14:27:23 UTC) #33
aperez
On 2014/06/17 11:47:38, marja wrote: > Thanks for posting a new patch! Here are some ...
6 years, 6 months ago (2014-06-18 14:54:14 UTC) #34
aperez
On 2014/06/18 14:27:23, rossberg wrote: > [...] The tricky part, though, is what to do ...
6 years, 6 months ago (2014-06-18 14:56:46 UTC) #35
marja
On 2014/06/18 14:54:14, aperez wrote: > On 2014/06/17 11:47:38, marja wrote: > https://codereview.chromium.org/160073006/diff/500001/src/parser.cc#newcode3323 > > ...
6 years, 6 months ago (2014-06-18 15:05:15 UTC) #36
marja
Hmm, though, detecting "eval" and such complicates the "is comma separated parameter list" stuff a ...
6 years, 6 months ago (2014-06-18 15:08:02 UTC) #37
marja
On 2014/06/18 15:08:02, marja wrote: > Hmm, though, detecting "eval" and such complicates the "is ...
6 years, 6 months ago (2014-06-18 15:15:15 UTC) #38
marja
(Sorry for the 4th message in the row..) If you need to track stuff like ...
6 years, 6 months ago (2014-06-18 15:18:13 UTC) #39
arv (Not doing code reviews)
On 2014/06/18 15:15:15, marja wrote: > On 2014/06/18 15:08:02, marja wrote: > > Hmm, though, ...
6 years, 6 months ago (2014-06-18 15:43:03 UTC) #40
aperez
On 2014/06/18 15:43:03, arv wrote: > On 2014/06/18 15:15:15, marja wrote: > > On 2014/06/18 ...
6 years, 6 months ago (2014-06-18 15:51:08 UTC) #41
aperez
On 2014/06/18 15:18:13, marja wrote: > (Sorry for the 4th message in the row..) > ...
6 years, 6 months ago (2014-06-18 15:58:32 UTC) #42
marja
https://codereview.chromium.org/160073006/diff/520001/src/scanner.h File src/scanner.h (right): https://codereview.chromium.org/160073006/diff/520001/src/scanner.h#newcode767 src/scanner.h:767: } Btw, I don't think this state machine works ...
6 years, 6 months ago (2014-06-18 16:21:17 UTC) #43
aperez
On 2014/06/18 at 16:21:17, marja wrote: > https://codereview.chromium.org/160073006/diff/520001/src/scanner.h > File src/scanner.h (right): > > https://codereview.chromium.org/160073006/diff/520001/src/scanner.h#newcode767 ...
6 years, 6 months ago (2014-06-24 16:08:39 UTC) #44
marja
On 2014/06/24 16:08:39, aperez wrote: > On 2014/06/18 at 16:21:17, marja wrote: > > https://codereview.chromium.org/160073006/diff/520001/src/scanner.h ...
6 years, 6 months ago (2014-06-25 08:47:14 UTC) #45
aperez
On 2014/06/18 at 15:15:15, marja wrote: > On 2014/06/18 15:08:02, marja wrote: > > Hmm, ...
6 years, 6 months ago (2014-06-25 17:20:22 UTC) #46
marja
The approach of not detecting duplicate identifiers when preparsing sounds good enough for the first ...
6 years, 6 months ago (2014-06-26 07:36:54 UTC) #47
marja
Alright, the latest patch set is much better! Yay! Could you do a round of ...
6 years, 6 months ago (2014-06-26 14:38:14 UTC) #48
aperez
On 2014/06/26 at 14:38:14, marja wrote: > Alright, the latest patch set is much better! ...
6 years, 5 months ago (2014-06-28 10:41:39 UTC) #49
marja
Alright, thanks, I'll have a look at the latest patch set now.
6 years, 5 months ago (2014-07-01 06:46:17 UTC) #50
marja
aperez@, btw, have you ran all the relevant tests; can I assume they pass? I ...
6 years, 5 months ago (2014-07-01 07:01:12 UTC) #51
marja
Even better! The comments I have are pretty minor (basically just 2 non-trivial ones), so ...
6 years, 5 months ago (2014-07-01 07:23:40 UTC) #52
aperez
On 2014/07/01 at 07:01:12, marja wrote: > aperez@, btw, have you ran all the relevant ...
6 years, 5 months ago (2014-07-01 11:48:07 UTC) #53
Jakob Kummerow
On 2014/07/01 07:01:12, marja wrote: > I usually run this set: > > tools/run-tests.py -j28 ...
6 years, 5 months ago (2014-07-01 14:18:08 UTC) #54
marja
rossberg@, btw, one thing: This CL makes V8 crash if the arrow function allowing flag ...
6 years, 5 months ago (2014-07-03 07:57:14 UTC) #55
rossberg
On 2014/07/03 07:57:14, marja wrote: > This CL makes V8 crash if the arrow function ...
6 years, 5 months ago (2014-07-03 09:07:11 UTC) #56
aperez
On 2014/07/01 at 07:23:40, marja wrote: > I don't think we need to make arrow ...
6 years, 5 months ago (2014-07-03 20:01:47 UTC) #57
aperez
On 2014/07/03 at 09:07:11, rossberg wrote: > On 2014/07/03 07:57:14, marja wrote: > > This ...
6 years, 5 months ago (2014-07-03 20:12:28 UTC) #58
marja
LGTM assuming you fix these comments. Thanks for working on this! It got a lot ...
6 years, 5 months ago (2014-07-04 08:21:14 UTC) #59
aperez
On 2014/07/04 at 08:21:14, marja wrote: > LGTM assuming you fix these comments. Yay! > ...
6 years, 5 months ago (2014-07-04 09:30:57 UTC) #60
marja
Re: tail recursion, sounds a bit like premature optimization; I'm not sure. How long does ...
6 years, 5 months ago (2014-07-04 09:40:27 UTC) #61
marja
Btw, I'm okay with landing this and you can investigate the parameter list un-reversing as ...
6 years, 5 months ago (2014-07-07 07:07:49 UTC) #62
aperez
On 2014/07/07 at 07:07:49, marja wrote: > Btw, I'm okay with landing this and you ...
6 years, 5 months ago (2014-07-07 08:26:23 UTC) #63
marja
Sounds good. I think it's good to start with being less obscure, until proven that ...
6 years, 5 months ago (2014-07-07 08:27:37 UTC) #64
aperez
On 2014/07/07 at 08:27:37, marja wrote: > Sounds good. I think it's good to start ...
6 years, 5 months ago (2014-07-07 11:43:14 UTC) #65
marja
Umm, this doesn't compile for me, does it compile for you? -Werror=unused-but-set-variable
6 years, 5 months ago (2014-07-07 11:49:44 UTC) #66
aperez
On 2014/07/07 at 11:49:44, marja wrote: > Umm, this doesn't compile for me, does it ...
6 years, 5 months ago (2014-07-07 12:46:28 UTC) #67
aperez
On 2014/07/07 at 12:46:28, aperez wrote: > On 2014/07/07 at 11:49:44, marja wrote: > > ...
6 years, 5 months ago (2014-07-07 13:02:55 UTC) #68
marja
Unfortunately, "make qc" still fails :( It's a presubmit error this time. Are you uploading ...
6 years, 5 months ago (2014-07-07 13:18:45 UTC) #69
marja
On 2014/07/07 13:18:45, marja wrote: > Unfortunately, "make qc" still fails :( It's a presubmit ...
6 years, 5 months ago (2014-07-07 13:21:05 UTC) #70
aperez
On 2014/07/07 at 13:21:05, marja wrote: > On 2014/07/07 13:18:45, marja wrote: > > Unfortunately, ...
6 years, 5 months ago (2014-07-07 14:28:53 UTC) #71
marja
Okay, now this gets silly. make qc runs, but I get this error when I'm ...
6 years, 5 months ago (2014-07-07 15:01:18 UTC) #72
marja
On 2014/07/07 15:01:18, marja wrote: > Okay, now this gets silly. make qc runs, but ...
6 years, 5 months ago (2014-07-07 15:08:17 UTC) #73
aperez
On 2014/07/07 at 15:08:17, marja wrote: > On 2014/07/07 15:01:18, marja wrote: > > Okay, ...
6 years, 5 months ago (2014-07-07 15:40:22 UTC) #74
aperez
On 2014/07/07 at 15:40:22, aperez wrote: > On 2014/07/07 at 15:08:17, marja wrote: > > ...
6 years, 5 months ago (2014-07-07 20:30:05 UTC) #75
marja
On 2014/07/07 20:30:05, aperez wrote: > Ok, that worked. Now this issue shows and I ...
6 years, 5 months ago (2014-07-07 20:32:52 UTC) #76
aperez
On 2014/07/07 at 20:32:52, marja wrote: > On 2014/07/07 20:30:05, aperez wrote: > > > ...
6 years, 5 months ago (2014-07-08 04:10:47 UTC) #77
marja
On 2014/07/08 04:10:47, aperez wrote: > On 2014/07/07 at 20:32:52, marja wrote: > > On ...
6 years, 5 months ago (2014-07-08 07:07:50 UTC) #78
marja
Committed patchset #21 manually as r22265 (presubmit successful).
6 years, 5 months ago (2014-07-08 07:11:24 UTC) #79
marja
I reverted this because it fails ASAN: http://build.chromium.org/p/client.v8/builders/V8%20Linux64%20ASAN/builds/1551/steps/Check/logs/stdio Please create a fixed CL so that ...
6 years, 5 months ago (2014-07-08 07:49:59 UTC) #80
marja
On 2014/07/08 07:49:59, marja wrote: > I reverted this because it fails ASAN: > > ...
6 years, 5 months ago (2014-07-08 08:18:54 UTC) #81
aperez
On 2014/07/08 at 08:18:54, marja wrote: > On 2014/07/08 07:49:59, marja wrote: > > I ...
6 years, 5 months ago (2014-07-08 15:00:02 UTC) #82
aperez
On 2014/07/08 at 15:00:02, aperez wrote: > On 2014/07/08 at 08:18:54, marja wrote: > > ...
6 years, 5 months ago (2014-07-09 18:39:23 UTC) #83
marja
6 years, 5 months ago (2014-07-10 08:04:18 UTC) #84
Message was sent while issue was closed.
Luckily, this one is easy to fix by just looking at the log I linked to. The
problem is that Collector::ToVector returns a vector allocated with Vector::New,
and you need to call Dispose on it at some point.

Powered by Google App Engine
This is Rietveld 408576698