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

Issue 1757543003: Restrict FunctionDeclarations in Statement position (Closed)

Created:
4 years, 9 months ago by Dan Ehrenberg
Modified:
4 years, 9 months ago
Reviewers:
adamk
CC:
Michael Hablich, Paweł Hajdan Jr., v8-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Restrict FunctionDeclarations in Statement position ES2015 generally bans FunctionDeclarations in positions which expect a Statement, as opposed to a StatementListItem, such as a FunctionDeclaration which constitutes the body of a for loop. However, Annex B 3.2 and 3.4 make exceptions for labeled function declarations and function declarations as the body of an if statement in sloppy mode, in the latter case specifying that the semantics are as if the function declaration occurred in a block. Chrome has historically permitted further extensions, for the body of any flow control construct. This patch addresses both the syntactic and semantic mismatches between V8 and the spec. For the semantic mismatch, function declarations as the body of if statements change from unconditionally hoisting in certain cases to acquiring the sloppy mode function in block semantics (based on Annex B 3.3). For the extra syntax permitted, this patch adds a flag, --harmony-restrictive-declarations, which excludes disallowed function declaration cases. A new UseCounter, LegacyFunctionDeclaration, is added to count how often function declarations occur as the body of other constructs in sloppy mode. With this patch, the code generally follows the form of the specification with respect to parsing FunctionDeclarations, rather than allowing them in arbitrary Statement positions, and makes it more clear where our extensions occur. BUG=v8:4647 R=adamk LOG=Y Committed: https://crrev.com/0e7f095c6dd4363d66f8b14a428f9c1f07f7dba3 Cr-Commit-Position: refs/heads/master@{#34470}

Patch Set 1 #

Patch Set 2 : Finish and make it build; fails the tests #

Patch Set 3 : Fix various typos #

Patch Set 4 : Allow labeled function declarations #

Patch Set 5 : Mozilla test is fixed #

Patch Set 6 : ignition failure expectation #

Total comments: 8

Patch Set 7 : More tests #

Patch Set 8 : fix ignition status #

Patch Set 9 : #

Patch Set 10 : Preparser support #

Patch Set 11 : Better tests #

Patch Set 12 : git cl format #

Unified diffs Side-by-side diffs Delta from patch set Stats (+339 lines, -97 lines) Patch
M include/v8.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/bootstrapper.cc View 1 2 chunks +2 lines, -0 lines 0 comments Download
M src/flag-definitions.h View 1 2 3 4 5 6 7 8 1 chunk +11 lines, -9 lines 0 comments Download
M src/messages.h View 1 chunk +3 lines, -0 lines 0 comments Download
M src/parsing/parser.h View 1 1 chunk +8 lines, -0 lines 0 comments Download
M src/parsing/parser.cc View 1 2 3 4 5 6 7 8 9 11 chunks +53 lines, -62 lines 0 comments Download
M src/parsing/parser-base.h View 1 3 chunks +3 lines, -0 lines 0 comments Download
M src/parsing/preparser.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M src/parsing/preparser.cc View 1 2 3 4 5 6 7 8 9 10 11 10 chunks +32 lines, -22 lines 0 comments Download
M test/cctest/test-parsing.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +73 lines, -1 line 0 comments Download
A test/mjsunit/harmony/sloppy-implicit-block-function.js View 1 2 3 4 5 6 7 8 9 10 1 chunk +97 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/sloppy-restrictive-block-function.js View 1 2 3 4 5 6 7 8 9 10 1 chunk +52 lines, -0 lines 0 comments Download
M test/mjsunit/mjsunit.status View 1 2 3 4 5 6 7 1 chunk +3 lines, -0 lines 0 comments Download
M test/mozilla/mozilla.status View 1 2 3 4 1 chunk +0 lines, -3 lines 0 comments Download

Messages

Total messages: 37 (17 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1757543003/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1757543003/40001
4 years, 9 months ago (2016-03-01 23:18:10 UTC) #3
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_arm_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_arm_rel/builds/14583)
4 years, 9 months ago (2016-03-01 23:33:54 UTC) #5
Dan Ehrenberg
4 years, 9 months ago (2016-03-01 23:34:40 UTC) #7
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1757543003/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1757543003/60001
4 years, 9 months ago (2016-03-01 23:34:43 UTC) #8
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_rel_ng on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng/builds/2193) v8_linux_rel_ng_triggered on ...
4 years, 9 months ago (2016-03-01 23:51:16 UTC) #10
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1757543003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1757543003/80001
4 years, 9 months ago (2016-03-01 23:56:05 UTC) #12
Dan Ehrenberg
4 years, 9 months ago (2016-03-02 00:03:55 UTC) #15
commit-bot: I haz the power
Dry run: Exceeded global retry quota
4 years, 9 months ago (2016-03-02 00:09:57 UTC) #17
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1757543003/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1757543003/100001
4 years, 9 months ago (2016-03-02 00:18:28 UTC) #19
adamk
High-level question, as I start the review: why is the addition-of-a-block-in-if-statements part not behind a ...
4 years, 9 months ago (2016-03-02 00:33:45 UTC) #20
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_dbg_ng on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng/builds/2198) v8_linux_dbg_ng_triggered on ...
4 years, 9 months ago (2016-03-02 00:35:03 UTC) #22
Dan Ehrenberg
High-level answer: Yes, the idea is that we already did the main function-in-block semantics change, ...
4 years, 9 months ago (2016-03-02 00:49:54 UTC) #23
adamk
https://codereview.chromium.org/1757543003/diff/100001/src/parsing/parser.cc File src/parsing/parser.cc (right): https://codereview.chromium.org/1757543003/diff/100001/src/parsing/parser.cc#newcode2579 src/parsing/parser.cc:2579: // ES#sec-labelled-function-declarations Labelled Function Declarations Can you add tests ...
4 years, 9 months ago (2016-03-02 00:51:10 UTC) #25
Dan Ehrenberg
https://codereview.chromium.org/1757543003/diff/100001/src/parsing/parser.cc File src/parsing/parser.cc (right): https://codereview.chromium.org/1757543003/diff/100001/src/parsing/parser.cc#newcode2579 src/parsing/parser.cc:2579: // ES#sec-labelled-function-declarations Labelled Function Declarations On 2016/03/02 at 00:51:10, ...
4 years, 9 months ago (2016-03-03 02:32:58 UTC) #26
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1757543003/170001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1757543003/170001
4 years, 9 months ago (2016-03-03 02:33:10 UTC) #28
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_presubmit on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/11815)
4 years, 9 months ago (2016-03-03 02:37:49 UTC) #30
adamk
lgtm once you've added the discussed-offline tests (for labelled function in an if statement). looks ...
4 years, 9 months ago (2016-03-03 19:51:37 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1757543003/210001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1757543003/210001
4 years, 9 months ago (2016-03-03 21:10:41 UTC) #34
commit-bot: I haz the power
Committed patchset #12 (id:210001)
4 years, 9 months ago (2016-03-03 21:34:01 UTC) #35
commit-bot: I haz the power
4 years, 9 months ago (2016-03-03 21:34:36 UTC) #37
Message was sent while issue was closed.
Patchset 12 (id:??) landed as
https://crrev.com/0e7f095c6dd4363d66f8b14a428f9c1f07f7dba3
Cr-Commit-Position: refs/heads/master@{#34470}

Powered by Google App Engine
This is Rietveld 408576698