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

Issue 1127063003: [es6] implement default parameters via desugaring (Closed)

Created:
5 years, 7 months ago by caitp (gmail)
Modified:
5 years, 3 months ago
CC:
v8-dev, adamk
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[es6] implement default parameters via desugaring Stage 1 implementation: - Parameters can't be referenced before initialized (from left-to-right) - SingleNameBindings only, no support for BindingPatterns Known issues: - Incorrect scoping (parameter expressions may reference variables declared in function body) - Function arity is untouched - Hole-checking needs work - Rest parameters are broken when mixed with optional arguments BUG=v8:2160 LOG=N R=arv@chromium.org, rossberg@chromium.org Committed: https://crrev.com/892c85485881f8be2f17bd83238980f858126576 Cr-Commit-Position: refs/heads/master@{#28739}

Patch Set 1 #

Total comments: 13

Patch Set 2 : Put it behind a flag #

Patch Set 3 : Rebase it #

Patch Set 4 : arv's comments #

Total comments: 15

Patch Set 5 : Add a TODO #

Patch Set 6 : some nits #

Total comments: 19

Patch Set 7 : Put function body in a Block statement #

Patch Set 8 : Rename "optional arguments" to "default parameters" #

Patch Set 9 : Add new test cases #

Patch Set 10 : Rebase and fix tests #

Patch Set 11 : Rebase + add lazy parsing test + WIP review comments #

Total comments: 1

Patch Set 12 : Fix default-parameters-lazy.js #

Patch Set 13 : It works! ish #

Patch Set 14 : Rebase #

Total comments: 6

Patch Set 15 : Add more context-allocation tests #

Total comments: 19

Patch Set 16 : Simplify lazy-parsing test #

Patch Set 17 : Adam's comments addressed #

Patch Set 18 : Don't AllocateParameter() if hasParameterExpressions is true #

Total comments: 7

Patch Set 19 : Rebase + rossberg nits #

Unified diffs Side-by-side diffs Delta from patch set Stats (+501 lines, -29 lines) Patch
M src/bootstrapper.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +3 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 15 16 17 18 1 chunk +2 lines, -1 line 0 comments Download
M src/messages.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +2 lines, -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 3 chunks +7 lines, -3 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 7 chunks +152 lines, -6 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 11 chunks +49 lines, -6 lines 0 comments Download
M src/preparser.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +5 lines, -2 lines 0 comments Download
M src/scopes.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 5 chunks +15 lines, -1 line 0 comments Download
M src/scopes.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 8 chunks +32 lines, -10 lines 0 comments Download
M src/variables.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/default-parameters.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +143 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/default-parameters-debug.js View 1 2 3 4 5 6 7 1 chunk +65 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/default-parameters-lazy.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +22 lines, -0 lines 0 comments Download

Messages

Total messages: 58 (9 generated)
caitp (gmail)
PTAL --- third prototype, after #1104223002 This one is limited in order to be incrementally ...
5 years, 7 months ago (2015-05-06 19:55:02 UTC) #1
caitp (gmail)
This actually breaks rest parameters when used in conjunction with default arguments, due to the ...
5 years, 7 months ago (2015-05-06 20:01:43 UTC) #3
arv (Not doing code reviews)
Great incremental first step https://codereview.chromium.org/1127063003/diff/1/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/1/src/parser.cc#newcode3538 src/parser.cc:3538: How about adding a comment ...
5 years, 7 months ago (2015-05-06 20:32:39 UTC) #4
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/1/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/1/src/parser.cc#newcode3561 src/parser.cc:3561: Runtime::FunctionForId(Runtime::kInlineArguments); On 2015/05/06 20:32:38, arv wrote: > I think ...
5 years, 7 months ago (2015-05-06 20:42:55 UTC) #5
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h File src/preparser.h (right): https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h#newcode3541 src/preparser.h:3541: DCHECK(scope_->is_function_scope()); Apparently this is a problem for lazy-parsed arrow ...
5 years, 7 months ago (2015-05-09 20:57:22 UTC) #6
arv (Not doing code reviews)
https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h File src/preparser.h (right): https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h#newcode3492 src/preparser.h:3492: if (initializer && allow_harmony_optional_params() && Check(Token::ASSIGN)) { This looks ...
5 years, 7 months ago (2015-05-11 14:10:55 UTC) #7
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h File src/preparser.h (right): https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h#newcode3492 src/preparser.h:3492: if (initializer && allow_harmony_optional_params() && Check(Token::ASSIGN)) { On 2015/05/11 ...
5 years, 7 months ago (2015-05-11 14:34:57 UTC) #8
arv (Not doing code reviews)
https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h File src/preparser.h (right): https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h#newcode3492 src/preparser.h:3492: if (initializer && allow_harmony_optional_params() && Check(Token::ASSIGN)) { On 2015/05/11 ...
5 years, 7 months ago (2015-05-11 14:38:02 UTC) #9
wingo
https://codereview.chromium.org/1127063003/diff/60001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/60001/src/parser.cc#newcode1153 src/parser.cc:1153: ParseFormalParameter(scope, &error_locs, nullptr, nullptr, has_rest, nit: would be easier ...
5 years, 7 months ago (2015-05-11 15:00:48 UTC) #10
wingo
One other little thought https://codereview.chromium.org/1127063003/diff/60001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/60001/src/scopes.cc#newcode468 src/scopes.cc:468: param_positions_.Add(pos, zone()); Don't we require ...
5 years, 7 months ago (2015-05-11 15:02:51 UTC) #11
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/60001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/60001/src/parser.cc#newcode1153 src/parser.cc:1153: ParseFormalParameter(scope, &error_locs, nullptr, nullptr, has_rest, On 2015/05/11 15:00:48, wingo ...
5 years, 7 months ago (2015-05-11 15:34:25 UTC) #12
wingo
On 2015/05/11 15:34:25, caitp wrote: > https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h > File src/preparser.h (right): > > https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h#newcode3541 > ...
5 years, 7 months ago (2015-05-11 16:53:21 UTC) #13
caitp (gmail)
On 2015/05/11 16:53:21, wingo wrote: > On 2015/05/11 15:34:25, caitp wrote: > > https://codereview.chromium.org/1127063003/diff/60001/src/preparser.h > ...
5 years, 7 months ago (2015-05-11 16:58:19 UTC) #14
wingo
On 2015/05/11 16:58:19, caitp wrote: > The preparser logs locations to be lazily parsed, we ...
5 years, 7 months ago (2015-05-12 07:32:11 UTC) #15
wingo
On 2015/05/12 07:32:11, wingo wrote: > On 2015/05/11 16:58:19, caitp wrote: > > The preparser ...
5 years, 7 months ago (2015-05-12 07:50:21 UTC) #16
rossberg
https://codereview.chromium.org/1127063003/diff/100001/src/bootstrapper.cc File src/bootstrapper.cc (right): https://codereview.chromium.org/1127063003/diff/100001/src/bootstrapper.cc#newcode1730 src/bootstrapper.cc:1730: EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_optional_params) Nit: harmony_default_parameters https://codereview.chromium.org/1127063003/diff/100001/src/flag-definitions.h File src/flag-definitions.h (right): https://codereview.chromium.org/1127063003/diff/100001/src/flag-definitions.h#newcode197 src/flag-definitions.h:197: ...
5 years, 7 months ago (2015-05-12 14:04:53 UTC) #17
caitp (gmail)
Thanks https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc#newcode4301 src/parser.cc:4301: body->AddAll(*inner_body, zone()); On 2015/05/12 14:04:53, rossberg wrote: > ...
5 years, 7 months ago (2015-05-12 14:34:17 UTC) #18
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/100001/test/mjsunit/harmony/optional-arguments.js File test/mjsunit/harmony/optional-arguments.js (right): https://codereview.chromium.org/1127063003/diff/100001/test/mjsunit/harmony/optional-arguments.js#newcode55 test/mjsunit/harmony/optional-arguments.js:55: On 2015/05/12 14:04:53, rossberg wrote: > More tests, e.g.: ...
5 years, 7 months ago (2015-05-12 18:35:35 UTC) #19
rossberg
https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc#newcode3575 src/parser.cc:3575: proxy->var()->set_maybe_assigned(); On 2015/05/12 14:04:53, rossberg wrote: > Why is ...
5 years, 7 months ago (2015-05-20 07:41:47 UTC) #20
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc#newcode3575 src/parser.cc:3575: proxy->var()->set_maybe_assigned(); On 2015/05/20 07:41:47, rossberg wrote: > On 2015/05/12 ...
5 years, 7 months ago (2015-05-20 11:29:38 UTC) #21
rossberg
https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/100001/src/parser.cc#newcode3575 src/parser.cc:3575: proxy->var()->set_maybe_assigned(); On 2015/05/20 11:29:38, caitp wrote: > On 2015/05/20 ...
5 years, 7 months ago (2015-05-20 12:33:55 UTC) #22
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/100001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/100001/src/scopes.cc#newcode513 src/scopes.cc:513: void Scope::ShadowParametersForExpressions() { On 2015/05/20 11:29:38, caitp wrote: > ...
5 years, 7 months ago (2015-05-20 14:55:34 UTC) #23
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/200001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/200001/src/scopes.cc#newcode1433 src/scopes.cc:1433: if (IsLexicalVariableMode(var->mode())) { So this approach doesn't work --- ...
5 years, 7 months ago (2015-05-20 17:05:16 UTC) #24
caitp (gmail)
On 2015/05/20 17:05:16, caitp wrote: > https://codereview.chromium.org/1127063003/diff/200001/src/scopes.cc > File src/scopes.cc (right): > > https://codereview.chromium.org/1127063003/diff/200001/src/scopes.cc#newcode1433 > ...
5 years, 7 months ago (2015-05-26 16:06:28 UTC) #25
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc#newcode1442 src/scopes.cc:1442: var = variables_.Lookup(var->raw_name()); This is a hack to make ...
5 years, 7 months ago (2015-05-26 17:14:07 UTC) #27
arv (Not doing code reviews)
LGTM This has some issues but lets revisit those in follow up CLs. https://codereview.chromium.org/1127063003/diff/280001/test/mjsunit/harmony/default-parameters-lazy.js File ...
5 years, 7 months ago (2015-05-26 19:13:26 UTC) #28
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/280001/test/mjsunit/harmony/default-parameters-lazy.js File test/mjsunit/harmony/default-parameters-lazy.js (right): https://codereview.chromium.org/1127063003/diff/280001/test/mjsunit/harmony/default-parameters-lazy.js#newcode9 test/mjsunit/harmony/default-parameters-lazy.js:9: /* ............................................................................ On 2015/05/26 19:13:26, arv wrote: > I ...
5 years, 7 months ago (2015-05-26 19:36:29 UTC) #29
adamk
Various style nits follow. I think I'm about as uneasy as rossberg is about undeclaring ...
5 years, 7 months ago (2015-05-26 19:58:10 UTC) #31
adamk
https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc#newcode1442 src/scopes.cc:1442: var = variables_.Lookup(var->raw_name()); On 2015/05/26 17:14:07, caitp wrote: > ...
5 years, 7 months ago (2015-05-26 20:03:20 UTC) #32
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc#newcode1442 src/scopes.cc:1442: var = variables_.Lookup(var->raw_name()); On 2015/05/26 20:03:20, adamk wrote: > ...
5 years, 7 months ago (2015-05-26 20:24:45 UTC) #33
caitp (gmail)
5 years, 7 months ago (2015-05-26 20:24:46 UTC) #34
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc File src/scopes.cc (right): https://codereview.chromium.org/1127063003/diff/280001/src/scopes.cc#newcode1442 src/scopes.cc:1442: var = variables_.Lookup(var->raw_name()); On 2015/05/26 20:24:44, caitp wrote: > ...
5 years, 7 months ago (2015-05-26 20:28:41 UTC) #35
adamk
https://codereview.chromium.org/1127063003/diff/360001/src/scopes.h File src/scopes.h (right): https://codereview.chromium.org/1127063003/diff/360001/src/scopes.h#newcode375 src/scopes.h:375: Variable* parameter(int index) const { Is this called anywhere ...
5 years, 7 months ago (2015-05-26 20:34:02 UTC) #36
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/360001/src/scopes.h File src/scopes.h (right): https://codereview.chromium.org/1127063003/diff/360001/src/scopes.h#newcode375 src/scopes.h:375: Variable* parameter(int index) const { On 2015/05/26 20:34:02, adamk ...
5 years, 7 months ago (2015-05-26 20:59:12 UTC) #37
adamk
https://codereview.chromium.org/1127063003/diff/360001/src/scopes.h File src/scopes.h (right): https://codereview.chromium.org/1127063003/diff/360001/src/scopes.h#newcode375 src/scopes.h:375: Variable* parameter(int index) const { On 2015/05/26 20:59:11, caitp ...
5 years, 7 months ago (2015-05-26 21:38:07 UTC) #38
caitp (gmail)
So, just to recap discussions from IRC: This patch is the (as far as I ...
5 years, 6 months ago (2015-06-01 12:32:50 UTC) #39
rossberg
lgtm https://codereview.chromium.org/1127063003/diff/360001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/360001/src/parser.cc#newcode3440 src/parser.cc:3440: static const VariableMode kMode = LET; Nit: drop ...
5 years, 6 months ago (2015-06-01 15:46:39 UTC) #40
caitp (gmail)
https://codereview.chromium.org/1127063003/diff/360001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1127063003/diff/360001/src/parser.cc#newcode3440 src/parser.cc:3440: static const VariableMode kMode = LET; On 2015/06/01 15:46:39, ...
5 years, 6 months ago (2015-06-01 15:56:30 UTC) #41
caitp (gmail)
5 years, 6 months ago (2015-06-01 15:56:34 UTC) #42
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1127063003/380001
5 years, 6 months ago (2015-06-01 16:42:49 UTC) #46
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1127063003/380001
5 years, 6 months ago (2015-06-01 16:43:51 UTC) #49
commit-bot: I haz the power
Committed patchset #19 (id:380001)
5 years, 6 months ago (2015-06-01 17:10:45 UTC) #50
commit-bot: I haz the power
Patchset 19 (id:??) landed as https://crrev.com/892c85485881f8be2f17bd83238980f858126576 Cr-Commit-Position: refs/heads/master@{#28739}
5 years, 6 months ago (2015-06-01 17:10:59 UTC) #51
caitp (gmail)
A revert of this CL (patchset #19 id:380001) has been created in https://codereview.chromium.org/1163853002/ by caitpotter88@gmail.com. ...
5 years, 6 months ago (2015-06-01 18:30:10 UTC) #52
caitp (gmail)
The output from --trace-turbo-graph looks generally okay (at least the portions that I understand). So ...
5 years, 6 months ago (2015-06-02 12:47:23 UTC) #53
caitp (gmail)
On 2015/06/02 12:47:23, caitp wrote: > The output from --trace-turbo-graph looks generally okay (at least ...
5 years, 6 months ago (2015-06-02 14:55:18 UTC) #55
caitp (gmail)
On 2015/06/02 14:55:18, caitp wrote: > On 2015/06/02 12:47:23, caitp wrote: > > The output ...
5 years, 6 months ago (2015-06-02 16:05:00 UTC) #56
caitp (gmail)
On 2015/06/02 16:05:00, caitp wrote: > On 2015/06/02 14:55:18, caitp wrote: > > On 2015/06/02 ...
5 years, 6 months ago (2015-06-03 03:53:48 UTC) #57
caitp (gmail)
5 years, 6 months ago (2015-06-03 16:02:25 UTC) #58
On 2015/06/03 03:53:48, caitp wrote:
> On 2015/06/02 16:05:00, caitp wrote:
> > On 2015/06/02 14:55:18, caitp wrote:
> > > On 2015/06/02 12:47:23, caitp wrote:
> > > > The output from --trace-turbo-graph looks generally okay (at least the
> > > portions
> > > > that I understand). So I'm not sure what's causing the arm64 sim test to
> > fail.
> > > > https://gist.githubusercontent.com/caitp/20f4ba77fc0d03033552/raw/log
for
> a
> > > > (big) log with --trace-turbo and --trace-turbo-graph.
> > > 
> > > mstarzinger@ I was wondering if you (or someone else familiar with TF)
might
> > be
> > > able to shed some light on where this is going wrong on ARM64, or how I
> could
> > > determine it. The --trace-turbo-graph output for the function looks
correct,
> > but
> > > we still end up with a kLetBindingReInitialization bailout, only on ARM64,
> and
> > > only with turbofan.
> > 
> > From IRC:
> > 
> > [12:03]  <caitp> you know what
> > [12:04]  <caitp> replacing `if (FLAG_debug_code && op == Token::INIT_LET) {`
> > with `if (generate_debug_code_ && op == Token::INIT_LET) {` in
> > full-codegen-arm64.cc fixes it
> > [12:04]  <caitp> and matches the other arches better
> > [12:04]  <caitp> derp
> > 
> > so... I assume that's just a bug in full-codegen-arm64 unless this was
written
> > this way on purpose?
> 
> Anyways, looking into this more, I don't think it's strictly a TF issue but
> maybe more related to deoptimization, and probably the desugaring itself is
> slightly suspect since it's doing this bad of a job of it.
> 
> For whatever reason, after de-opt, let bindings are re-assigned and
> re-initialized. Maybe during deoptimization or OSR, these variable
> initializations should be skipped somehow? I'm not sure the approach to take
> with this, but I guess this is still not ready to land


My thinking today is that this is a bug with the "re-declaration" of parameters,
so I guess that's not going to fly. I've started working on removing that, but
it breaks a lot of stuff right now.

Powered by Google App Engine
This is Rietveld 408576698