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

Issue 883823002: Implement proper scoping for "this" in arrow functions

Created:
5 years, 11 months ago by aperez
Modified:
5 years, 10 months ago
Reviewers:
wingo
CC:
v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Implement proper scoping for "this" in arrow functions BUG=v8:2700 LOG=Y

Patch Set 1 #

Patch Set 2 : Make sure an unresolved VariableProxy for "this" is not considered a valid LHS #

Total comments: 12

Patch Set 3 : Remove unneeded Variable::IsValidReference(), cleanup tests #

Patch Set 4 : Remove codegen changes for ppc/mips/mips64/x87 #

Total comments: 2

Patch Set 5 : Re-added an is_this flag (as en enum) in VariableProxy constructor #

Patch Set 6 : Use Variable::Kind instead of a custom enum #

Patch Set 7 : mjsunit/debug-scopes: Skip "this" the same as "arguments" #

Total comments: 7

Patch Set 8 : Avoid comparing variable proxy name #

Patch Set 9 : Rebased against master, plus fixes. Only 4 tests failing (+2 in TurboFan) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+178 lines, -97 lines) Patch
M src/ast.h View 1 2 3 4 5 6 7 8 4 chunks +8 lines, -5 lines 0 comments Download
M src/ast.cc View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -4 lines 0 comments Download
M src/compiler/ast-graph-builder.h View 1 2 3 4 5 6 7 8 1 chunk +18 lines, -10 lines 0 comments Download
M src/compiler/ast-graph-builder.cc View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -5 lines 0 comments Download
M src/parser.cc View 1 2 3 4 5 6 7 8 10 chunks +19 lines, -13 lines 0 comments Download
M src/scopeinfo.cc View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -1 line 0 comments Download
M src/scopes.h View 1 2 3 4 5 6 7 8 4 chunks +15 lines, -4 lines 0 comments Download
M src/scopes.cc View 1 2 3 4 5 6 7 8 16 chunks +48 lines, -39 lines 0 comments Download
M src/variables.h View 1 2 3 4 5 6 7 8 2 chunks +2 lines, -7 lines 0 comments Download
M src/variables.cc View 1 2 3 4 5 6 7 8 2 chunks +1 line, -3 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 2 3 4 5 6 7 8 2 chunks +5 lines, -3 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 1 2 3 4 5 6 7 8 2 chunks +4 lines, -3 lines 0 comments Download
M test/mjsunit/debug-scopes.js View 1 2 3 4 5 6 1 chunk +4 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/arrow-functions-scoping.js View 1 2 3 4 5 6 7 8 1 chunk +36 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (1 generated)
wingo
Sorry for the delay. So I would first note that only ia32, x64, arm, and ...
5 years, 10 months ago (2015-02-04 09:18:58 UTC) #2
wingo
A first review. https://codereview.chromium.org/883823002/diff/20001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/883823002/diff/20001/src/ast.h#newcode1633 src/ast.h:1633: return !is_this() && (!is_resolved() || var()->IsValidReference()); ...
5 years, 10 months ago (2015-02-04 10:02:13 UTC) #3
aperez
https://codereview.chromium.org/883823002/diff/20001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/883823002/diff/20001/src/ast.h#newcode1633 src/ast.h:1633: return !is_this() && (!is_resolved() || var()->IsValidReference()); On 2015/02/04 10:02:13, ...
5 years, 10 months ago (2015-02-04 21:00:42 UTC) #4
wingo
Looking much better! A nit to fix. I haven't reviewed the codegen/compiler tests yet. https://codereview.chromium.org/883823002/diff/60001/src/ast.h ...
5 years, 10 months ago (2015-02-05 11:08:30 UTC) #5
aperez
https://codereview.chromium.org/883823002/diff/60001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/883823002/diff/60001/src/ast.h#newcode1696 src/ast.h:1696: VariableProxy(AstValueFactory *ast_value_factory, On 2015/02/05 11:08:30, wingo wrote: > Humm, ...
5 years, 10 months ago (2015-02-06 16:05:08 UTC) #6
aperez
On 2015/02/06 16:05:08, aperez wrote: > https://codereview.chromium.org/883823002/diff/60001/src/ast.h > File src/ast.h (right): > > https://codereview.chromium.org/883823002/diff/60001/src/ast.h#newcode1696 > ...
5 years, 10 months ago (2015-02-06 16:08:43 UTC) #7
wingo
https://codereview.chromium.org/883823002/diff/120001/src/ast.h File src/ast.h (right): https://codereview.chromium.org/883823002/diff/120001/src/ast.h#newcode3424 src/ast.h:3424: (name == ast_value_factory_->this_string()) Can we instead change from "bool ...
5 years, 10 months ago (2015-02-06 17:31:19 UTC) #8
aperez
5 years, 10 months ago (2015-02-09 16:08:14 UTC) #9
https://codereview.chromium.org/883823002/diff/120001/src/ast.h
File src/ast.h (right):

https://codereview.chromium.org/883823002/diff/120001/src/ast.h#newcode3424
src/ast.h:3424: (name == ast_value_factory_->this_string())
On 2015/02/06 17:31:19, wingo wrote:
> Can we instead change from "bool is_this," to "Variable::Kind variable_kind" ?
> 
> That way we avoid the load and comparison of this_string on what is a
relatively
> hot path of the parser -- perhaps a silly concern -- and we preserve
readability
> of callers.

Acknowledged.

https://codereview.chromium.org/883823002/diff/120001/src/parser.cc
File src/parser.cc (right):

https://codereview.chromium.org/883823002/diff/120001/src/parser.cc#newcode679
src/parser.cc:679: ast_value_factory()->this_string(),
On 2015/02/06 17:31:19, wingo wrote:
> here probably we will have to pass in Variable::THIS

Acknowledged.

https://codereview.chromium.org/883823002/diff/120001/src/parser.cc#newcode735
src/parser.cc:735: ? factory->NewVariableProxy(name, interface, pos)
On 2015/02/06 17:31:19, wingo wrote:
> instead of removing false, replace with Variable::NORMAL

Acknowledged.

Powered by Google App Engine
This is Rietveld 408576698