New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 2160 link

Starred by 115 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2015
Cc:
Components:
HW: All
NextAction: ----
OS: All
Priority: 2
Type: FeatureRequest

Blocked on:
issue 4395
issue 4400

Blocking:
issue 811



Sign in to add a comment

Add support for default parameters

Project Member Reported by arv@chromium.org, May 30 2012

Issue description

SpiderMonkey just added support for default paramaters

http://wiki.ecmascript.org/doku.php?id=harmony:parameter_default_values
 
Labels: Type-FeatureRequest Priority-Low Harmony
Status: Accepted
When does the Chromium team get deep into Harmony implementations? I am interested in seeing your implementations vs Mozilla's. Let me know. 

Comment 3 Deleted

a friendly bump
Owner: caitpott...@gmail.com
Status: Started
Project Member

Comment 6 by bugdroid1@chromium.org, Jun 1 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/892c85485881f8be2f17bd83238980f858126576

commit 892c85485881f8be2f17bd83238980f858126576
Author: caitpotter88 <caitpotter88@gmail.com>
Date: Mon Jun 01 17:10:39 2015

[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

Review URL: https://codereview.chromium.org/1127063003

Cr-Commit-Position: refs/heads/master@{#28739}

[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/bootstrapper.cc
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/flag-definitions.h
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/messages.h
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/parser.cc
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/parser.h
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/preparser.cc
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/preparser.h
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/scopes.cc
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/scopes.h
[modify] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/src/variables.h
[add] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/test/mjsunit/harmony/default-parameters-debug.js
[add] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/test/mjsunit/harmony/default-parameters-lazy.js
[add] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/test/mjsunit/harmony/default-parameters.js

Project Member

Comment 7 by bugdroid1@chromium.org, Jun 1 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/904fbc303a759de5d1d83667a1203f44a8ef9760

commit 904fbc303a759de5d1d83667a1203f44a8ef9760
Author: caitpotter88 <caitpotter88@gmail.com>
Date: Mon Jun 01 18:34:55 2015

Revert of [es6] implement default parameters via desugaring (patchset #19 id:380001 of https://codereview.chromium.org/1127063003/)

Reason for revert:
Broken on arm64

Original issue's 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}

TBR=rossberg@chromium.org,wingo@igalia.com,arv@chromium.org,dslomov@chromium.org,adamk@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= v8:2160 

Review URL: https://codereview.chromium.org/1163853002

Cr-Commit-Position: refs/heads/master@{#28740}

[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/bootstrapper.cc
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/flag-definitions.h
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/messages.h
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/parser.cc
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/parser.h
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/preparser.cc
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/preparser.h
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/scopes.cc
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/scopes.h
[modify] http://crrev.com/904fbc303a759de5d1d83667a1203f44a8ef9760/src/variables.h
[delete] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/test/mjsunit/harmony/default-parameters-debug.js
[delete] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/test/mjsunit/harmony/default-parameters-lazy.js
[delete] http://crrev.com/892c85485881f8be2f17bd83238980f858126576/test/mjsunit/harmony/default-parameters.js

Blockedon: v8:4159
Blockedon: -v8:4159

Comment 10 by arv@chromium.org, Jun 30 2015

Cc: arv@chromium.org rossberg@chromium.org
Labels: -Priority-Low Priority-Medium HW-All OS-All Area-Language
Bump
Project Member

Comment 13 by bugdroid1@chromium.org, Aug 21 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/365fd7bc351705e4fb181741829f89e580549daf

commit 365fd7bc351705e4fb181741829f89e580549daf
Author: rossberg <rossberg@chromium.org>
Date: Fri Aug 21 10:58:35 2015

[es6] Parameter scopes for sloppy eval

This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,

  let x = 1;
  function f(g = () => x) {
    var y
    eval("var x = 2")
    return g() + x  // f() = 3
  }

we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:

- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.

- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).

- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.

- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.

- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.

- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.

- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.

- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.

- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.

- While at it, refactor and unify some respective code in the debugger.

Sorry, this CL is large. I could try to split it up, but everything is rather entangled.

@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.

R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG= v8:811 , v8:2160 
LOG=N

Review URL: https://codereview.chromium.org/1292753007

Cr-Commit-Position: refs/heads/master@{#30295}

[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/include/v8.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/bootstrapper.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/compiler/ast-graph-builder.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/contexts.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/contexts.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/debug/debug-scopes.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/debug/debug-scopes.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/factory.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/factory.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/full-codegen/full-codegen.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/hydrogen.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/objects-debug.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/objects-inl.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/objects-printer.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/objects.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/objects.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/parser.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/parser.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/pattern-rewriter.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/runtime/runtime-object.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/runtime/runtime-scopes.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/scopeinfo.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/scopes.cc
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/src/scopes.h
[modify] http://crrev.com/365fd7bc351705e4fb181741829f89e580549daf/test/mjsunit/harmony/default-parameters.js

Comment 15 by adamk@chromium.org, Aug 31 2015

Blocking: v8:811

Comment 16 by adamk@chromium.org, Aug 31 2015

Blockedon: v8:4395 v8:4400
Project Member

Comment 17 by bugdroid1@chromium.org, Sep 2 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/510baeacbab311798d5e8795800ff773d00d062c

commit 510baeacbab311798d5e8795800ff773d00d062c
Author: caitpotter88 <caitpotter88@gmail.com>
Date: Wed Sep 02 21:10:51 2015

[es6] Re-implement rest parameters via desugaring.

Kills the kRestParameter bailout/disabled optimization, and fixes
lazily parsed arrow functions with rest parameters.

Supercedes https://crrev.com/1235153006/

BUG= chromium:508074 ,  v8:2160 ,  v8:2700 
LOG=N
R=rossberg@chromium.org, adamk@chromium.org, wingo@igalia.com

Review URL: https://codereview.chromium.org/1272673003

Cr-Commit-Position: refs/heads/master@{#30550}

[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/arm/code-stubs-arm.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/arm64/code-stubs-arm64.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/ast-literal-reindexer.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/ast-value-factory.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/bailout-reason.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/code-stubs.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/code-stubs.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/compiler/ast-graph-builder.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/compiler/ast-graph-builder.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/compiler/linkage.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/full-codegen/arm/full-codegen-arm.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/full-codegen/arm64/full-codegen-arm64.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/full-codegen/ia32/full-codegen-ia32.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/full-codegen/mips/full-codegen-mips.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/full-codegen/mips64/full-codegen-mips64.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/full-codegen/x64/full-codegen-x64.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/hydrogen.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/ia32/code-stubs-ia32.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/mips/code-stubs-mips.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/mips64/code-stubs-mips64.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/parser.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/parser.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/preparser.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/runtime/runtime-scopes.cc
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/runtime/runtime.h
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/src/x64/code-stubs-x64.cc
[add] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/test/mjsunit/harmony/arrow-rest-params-lazy-parsing.js
[add] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/test/mjsunit/harmony/regress/regress-508074.js
[modify] http://crrev.com/510baeacbab311798d5e8795800ff773d00d062c/test/mjsunit/harmony/rest-params.js

Project Member

Comment 18 by bugdroid1@chromium.org, Sep 3 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/9628d86085ddee83067c45046ed89e0e6f635d3f

commit 9628d86085ddee83067c45046ed89e0e6f635d3f
Author: mbrandy <mbrandy@us.ibm.com>
Date: Thu Sep 03 18:40:09 2015

PPC: [es6] Re-implement rest parameters via desugaring.

Port 510baeacbab311798d5e8795800ff773d00d062c

Original commit message:
    Kills the kRestParameter bailout/disabled optimization, and fixes
    lazily parsed arrow functions with rest parameters.

    Supercedes https://crrev.com/1235153006/

R=caitpotter88@gmail.com, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com
BUG= chromium:508074 ,  v8:2160 ,  v8:2700 
LOG=N

Review URL: https://codereview.chromium.org/1318523006

Cr-Commit-Position: refs/heads/master@{#30574}

[modify] http://crrev.com/9628d86085ddee83067c45046ed89e0e6f635d3f/src/full-codegen/ppc/full-codegen-ppc.cc
[modify] http://crrev.com/9628d86085ddee83067c45046ed89e0e6f635d3f/src/ppc/code-stubs-ppc.cc

Project Member

Comment 20 by bugdroid1@chromium.org, Sep 10 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/0cc8eaa4c628543b520ab48667176967a225f7db

commit 0cc8eaa4c628543b520ab48667176967a225f7db
Author: caitpotter88 <caitpotter88@gmail.com>
Date: Thu Sep 10 13:44:58 2015

[es6] fixup for rest parameters perf test

BUG= v8:2160 
LOG=N
NOTRY=true
R=adamk, machenbach@chromium.org, rossberg

Review URL: https://codereview.chromium.org/1331803003

Cr-Commit-Position: refs/heads/master@{#30682}

[modify] http://crrev.com/0cc8eaa4c628543b520ab48667176967a225f7db/test/js-perf-test/JSTests.json
[modify] http://crrev.com/0cc8eaa4c628543b520ab48667176967a225f7db/test/js-perf-test/RestParameters/rest.js

I keep using the wrong bug number for these perf test patches. Oops!
Project Member

Comment 22 by bugdroid1@chromium.org, Nov 5 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/2a866bc4dd6318692aee0ea45b20da3f1c0a5420

commit 2a866bc4dd6318692aee0ea45b20da3f1c0a5420
Author: adamk <adamk@chromium.org>
Date: Thu Nov 05 21:40:01 2015

Stage --harmony-destructuring and --harmony-default-parameters

Since enabling destructuring already implies enabling default parameters,
there's not a good way to separate these two. Luckily, they're both
feature-complete (save for destructuring assignment).

This causes us to pass an additional 24 test262 tests.

BUG= v8:811 ,  v8:2160 
LOG=y

Review URL: https://codereview.chromium.org/1407393009

Cr-Commit-Position: refs/heads/master@{#31844}

[modify] http://crrev.com/2a866bc4dd6318692aee0ea45b20da3f1c0a5420/src/flag-definitions.h
[modify] http://crrev.com/2a866bc4dd6318692aee0ea45b20da3f1c0a5420/test/test262/test262.status

Cc: caitpott...@gmail.com
Owner: adamk@chromium.org
Project Member

Comment 24 by bugdroid1@chromium.org, Nov 6 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/7b556cd24f13ffe0d4c42f0ab0951d72bccc9135

commit 7b556cd24f13ffe0d4c42f0ab0951d72bccc9135
Author: adamk <adamk@chromium.org>
Date: Fri Nov 06 15:48:43 2015

Split default parameters that require destructuring into their own file

This allows testing the configuration where --harmony-default-parameters
is passed without --harmony-destructuring.

R=rossberg@chromium.org
BUG= v8:2160 
LOG=n

Review URL: https://codereview.chromium.org/1410023015

Cr-Commit-Position: refs/heads/master@{#31863}

[add] http://crrev.com/7b556cd24f13ffe0d4c42f0ab0951d72bccc9135/test/mjsunit/harmony/default-parameters-destructuring.js
[modify] http://crrev.com/7b556cd24f13ffe0d4c42f0ab0951d72bccc9135/test/mjsunit/harmony/default-parameters.js

Project Member

Comment 25 by bugdroid1@chromium.org, Nov 12 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/e752f964b645fc7aafd99fd684914a10831619e8

commit e752f964b645fc7aafd99fd684914a10831619e8
Author: adamk <adamk@chromium.org>
Date: Thu Nov 12 15:59:02 2015

Ship --harmony-default-parameters

BUG= v8:2160 
LOG=y

Review URL: https://codereview.chromium.org/1438753002

Cr-Commit-Position: refs/heads/master@{#31965}

[modify] http://crrev.com/e752f964b645fc7aafd99fd684914a10831619e8/src/flag-definitions.h

Status: Fixed
Labels: Priority-2

Sign in to add a comment