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

Issue 1053773006: [es6] implement default/optional parameters (WIP / comments) (Closed)

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

Description

[es6] implement default/optional parameters (WIP / comments) Partial refactor of older bitrotten optional params patch More work on this over the next few weeks TODO: - new scope for parameter expressions - proper parameter list TDZ - make sure AST numbering is done before initializing values - TF support - Function.length calculation needs an update EXTRAS (might be good to land in separate intermediate patches): - ParameterKind unifies ways of denoting "special" parameter types --- hmm, it's less nice to use because of the clang-format restrictions on non-explicit single-parameter constructors :| - handy AstValueFactory::IsUndefined() helper (nope, it's awful, and Expression::IsUndefinedLiteral() is good --- canning that :>) BUG=v8:2160 R= LOG=N

Patch Set 1 #

Total comments: 14

Patch Set 2 : No explicit constructors :'( #

Patch Set 3 : partially fix scoping issue (still needs tdz on parameter refs), support variable proxies/functions #

Patch Set 4 : Fix typo + support ObjectLiteral / ArrayLiteral defaults #

Patch Set 5 : Experimental not-quite-TDZ support #

Unified diffs Side-by-side diffs Delta from patch set Stats (+229 lines, -26 lines) Patch
M src/ast.h View 1 2 7 chunks +15 lines, -12 lines 0 comments Download
M src/ast-numbering.cc View 1 2 2 chunks +6 lines, -0 lines 0 comments Download
M src/ast-value-factory.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M src/full-codegen.h View 1 chunk +2 lines, -0 lines 0 comments Download
M src/parser.cc View 1 2 3 4 7 chunks +53 lines, -9 lines 0 comments Download
M src/preparser.h View 1 2 2 chunks +4 lines, -1 line 0 comments Download
M src/preparser.cc View 1 2 2 chunks +32 lines, -0 lines 0 comments Download
M src/scopes.h View 1 2 3 4 3 chunks +10 lines, -1 line 0 comments Download
M src/scopes.cc View 1 2 3 4 3 chunks +20 lines, -2 lines 0 comments Download
M src/variables.h View 1 3 chunks +26 lines, -0 lines 0 comments Download
M src/variables.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M src/x64/full-codegen-x64.cc View 1 2 3 4 3 chunks +57 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (3 generated)
caitp (gmail)
Open for comments and suggestions, but still very much a work in progress. In particular, ...
5 years, 8 months ago (2015-04-10 03:19:51 UTC) #1
arv (Not doing code reviews)
Keep an eye on https://codereview.chromium.org/1078093002/ which cleans up the FormalParameter parsing.
5 years, 8 months ago (2015-04-10 14:39:09 UTC) #3
arv (Not doing code reviews)
I don't see how you set up the new scope that the parameters need? There ...
5 years, 8 months ago (2015-04-10 15:08:48 UTC) #4
caitp (gmail)
thx for the comments, the more the better =) especially figuring out the little bailout ...
5 years, 8 months ago (2015-04-10 15:28:01 UTC) #5
caitp (gmail)
https://codereview.chromium.org/1053773006/diff/1/src/variables.h File src/variables.h (right): https://codereview.chromium.org/1053773006/diff/1/src/variables.h#newcode14 src/variables.h:14: class ParameterKind { On 2015/04/10 15:28:00, caitp wrote: > ...
5 years, 8 months ago (2015-04-10 15:56:49 UTC) #6
arv (Not doing code reviews)
https://codereview.chromium.org/1053773006/diff/1/src/x64/full-codegen-x64.cc File src/x64/full-codegen-x64.cc (right): https://codereview.chromium.org/1053773006/diff/1/src/x64/full-codegen-x64.cc#newcode340 src/x64/full-codegen-x64.cc:340: EmitInitializeOptionalParameters(info->scope(), info->function()); This looks wrong > d8> function f(a ...
5 years, 8 months ago (2015-04-10 15:58:16 UTC) #7
arv (Not doing code reviews)
On 2015/04/10 15:58:16, arv wrote: > https://codereview.chromium.org/1053773006/diff/1/src/x64/full-codegen-x64.cc > File src/x64/full-codegen-x64.cc (right): > > https://codereview.chromium.org/1053773006/diff/1/src/x64/full-codegen-x64.cc#newcode340 > ...
5 years, 8 months ago (2015-04-10 16:04:22 UTC) #8
caitp (gmail)
On 2015/04/10 16:04:22, arv wrote: > On 2015/04/10 15:58:16, arv wrote: > > https://codereview.chromium.org/1053773006/diff/1/src/x64/full-codegen-x64.cc > ...
5 years, 8 months ago (2015-04-10 16:08:57 UTC) #9
caitp (gmail)
Part of this is fixed: ``` d8> function f(cb = function() { return "needs a ...
5 years, 8 months ago (2015-04-12 06:08:17 UTC) #10
caitp (gmail)
On 2015/04/12 06:08:17, caitp wrote: > Part of this is fixed: > > ``` > ...
5 years, 8 months ago (2015-04-12 07:17:56 UTC) #12
caitp (gmail)
Experimental parameter TDZ (it's not "really" achieving TDZ behaviour, but it was very simple): parameter_expressions_scope_ ...
5 years, 8 months ago (2015-04-12 14:04:51 UTC) #13
caitp (gmail)
5 years, 8 months ago (2015-04-12 18:03:51 UTC) #14
Trying to figure a way to do this:

If hasParameterExpressions is false:
  1. keep doing things the way they're already working, I guess?

else:
   1. for each bound name of parameters, allocate space (on heap or stack)
initialized to the hole
   2. for each parameter:
     a. if it's a "normal" parameter (no expressions), set the allocated
variable to the one passed on the stack
     b. else if it's an optional parameter, set the allocated variable to the
evaluation of the initializing expression
     c. else if it's a binding pattern parameter, perform step 2 for each
binding property/element of the binding pattern

   Constraints:
     - All references to the bound names of parameters need to refer to thees
variables initialized to the hole.
     - Within the function body, no hole-check is needed to reference one of
these names
     - Redeclaring one of these names using "var" should be legal
     - These allocated variables need to be reference-able from step 2 in the
algorithm above, but also from the
       function and its child scopes. However, the expressions in step 2 may not
reference any variables declared
       within the function or its nested scopes

Just thinking out loud, not totally sure how else the TDZ semantics would work

Powered by Google App Engine
This is Rietveld 408576698