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

Issue 1097283003: Resolve references to "this" the same way as normal variables (Closed)

Created:
5 years, 8 months ago by wingo
Modified:
5 years, 7 months ago
CC:
v8-dev, Yang, Michael Starzinger, aperez, adamk
Base URL:
https://chromium.googlesource.com/v8/v8@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Resolve references to "this" the same way as normal variables Make the parser handle references to "this" as unresolved variables, so the same logic as for the rest of function parameters is used for the receiver. Minor additions to the code generation handle copying the receiver to the context, along with the rest of the function parameters. Based on work by Adrian Perez de Castro <aperez@igalia.com>;. BUG= LOG=N Committed: https://crrev.com/18619d355192e2699203d12d9ebb9caea107b693 Cr-Commit-Position: refs/heads/master@{#28236}

Patch Set 1 : #

Total comments: 8

Patch Set 2 : All TF tests passing #

Total comments: 6

Patch Set 3 : Patch receiver in only one place #

Total comments: 1

Patch Set 4 : Add tests for "this" scoping in arrow functions #

Total comments: 7

Patch Set 5 : Rebase on master; fix nits #

Patch Set 6 : Add ia32, arm, arm64 support #

Patch Set 7 : Script contexts have empty function as their closure #

Patch Set 8 : Rebase to apply cleanly #

Patch Set 9 : Statically resolve "this" even inside "with" #

Total comments: 6

Patch Set 10 : Add TODO to fix fat-fingered "this" scoping in script context #

Total comments: 7

Patch Set 11 : Rebase and fix nits #

Unified diffs Side-by-side diffs Delta from patch set Stats (+288 lines, -101 lines) Patch
M src/arm/full-codegen-arm.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +7 lines, -5 lines 0 comments Download
M src/arm/lithium-codegen-arm.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -3 lines 0 comments Download
M src/arm64/full-codegen-arm64.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +7 lines, -5 lines 0 comments Download
M src/arm64/lithium-codegen-arm64.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -3 lines 0 comments Download
M src/compiler/ast-graph-builder.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M src/compiler/ast-graph-builder.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +44 lines, -11 lines 0 comments Download
M src/contexts.cc View 1 chunk +7 lines, -2 lines 0 comments Download
M src/heap/heap.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +6 lines, -3 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +5 lines, -4 lines 0 comments Download
M src/parser.cc View 1 2 3 4 5 6 7 8 9 10 6 chunks +14 lines, -9 lines 0 comments Download
M src/runtime/runtime-debug.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +13 lines, -8 lines 0 comments Download
M src/runtime/runtime-scopes.cc View 1 2 3 4 5 6 3 chunks +17 lines, -3 lines 0 comments Download
M src/scopeinfo.cc View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M src/scopes.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +20 lines, -3 lines 0 comments Download
M src/scopes.cc View 1 2 3 4 5 6 7 8 5 chunks +37 lines, -29 lines 0 comments Download
M src/variables.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +7 lines, -5 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +5 lines, -4 lines 0 comments Download
M test/mjsunit/debug-scopes.js View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/arrow-functions-this.js View 1 2 3 4 5 6 7 8 9 10 1 chunk +81 lines, -0 lines 0 comments Download

Messages

Total messages: 56 (13 generated)
wingo
This is a WIP to resolve "this" using the normal variable resolution mechanism. It passes ...
5 years, 8 months ago (2015-04-21 16:09:49 UTC) #2
wingo
5 years, 8 months ago (2015-04-21 16:10:37 UTC) #4
wingo
Another note -- a side effect of this patch will be that "this" can end ...
5 years, 8 months ago (2015-04-21 16:12:09 UTC) #5
wingo
Another note: this depends on https://codereview.chromium.org/1085263003/
5 years, 8 months ago (2015-04-21 16:15:01 UTC) #6
Michael Starzinger
https://codereview.chromium.org/1097283003/diff/20001/src/compiler/ast-graph-builder.cc File src/compiler/ast-graph-builder.cc (right): https://codereview.chromium.org/1097283003/diff/20001/src/compiler/ast-graph-builder.cc#newcode646 src/compiler/ast-graph-builder.cc:646: if (variable->is_this()) { AFAICT, this is only needed for ...
5 years, 8 months ago (2015-04-21 18:13:44 UTC) #8
wingo
Sheepish confessions follow. Thanks for the feedback Michael :) https://codereview.chromium.org/1097283003/diff/20001/src/compiler/ast-graph-builder.cc File src/compiler/ast-graph-builder.cc (right): https://codereview.chromium.org/1097283003/diff/20001/src/compiler/ast-graph-builder.cc#newcode646 src/compiler/ast-graph-builder.cc:646: ...
5 years, 8 months ago (2015-04-22 08:04:00 UTC) #9
wingo
New patch passes all tests, thanks to the Michael's expert administration of the cluestick :)
5 years, 8 months ago (2015-04-22 08:55:50 UTC) #11
Michael Starzinger
Looking good, I like this a lot more now. Just one more suggestion. :) https://codereview.chromium.org/1097283003/diff/20001/src/compiler/ast-graph-builder.cc ...
5 years, 8 months ago (2015-04-22 10:59:22 UTC) #12
Michael Starzinger
https://codereview.chromium.org/1097283003/diff/60001/src/compiler/ast-graph-builder.cc File src/compiler/ast-graph-builder.cc (right): https://codereview.chromium.org/1097283003/diff/60001/src/compiler/ast-graph-builder.cc#newcode475 src/compiler/ast-graph-builder.cc:475: Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); On 2015/04/22 10:59:21, Michael Starzinger ...
5 years, 8 months ago (2015-04-22 11:17:53 UTC) #13
wingo
Fixed TF nits. I realized that this patch actually excludes arrow functions from has_this_declaration, so ...
5 years, 8 months ago (2015-04-22 13:05:23 UTC) #14
Michael Starzinger
The TF part looks good. Didn't look at the rest, I'll leave that to Andreas. ...
5 years, 8 months ago (2015-04-22 13:26:19 UTC) #16
wingo
Updated CL adds tests for "this" scoping in arrow functions.
5 years, 8 months ago (2015-04-22 14:57:04 UTC) #18
rossberg
LGTM, but Dmitry should perhaps also have a second eyeball on the scoping matters. https://codereview.chromium.org/1097283003/diff/80001/src/contexts.cc ...
5 years, 8 months ago (2015-04-22 15:39:32 UTC) #19
adamk
Just a few drive-by s/CHECK/DCHECK/ nits. Overall looks good. https://codereview.chromium.org/1097283003/diff/100001/src/scopes.h File src/scopes.h (right): https://codereview.chromium.org/1097283003/diff/100001/src/scopes.h#newcode350 src/scopes.h:350: ...
5 years, 8 months ago (2015-04-22 15:50:54 UTC) #21
wingo
On 2015/04/22 15:39:32, rossberg wrote: > LGTM, but Dmitry should perhaps also have a second ...
5 years, 8 months ago (2015-04-23 13:24:44 UTC) #22
rossberg
On 2015/04/23 13:24:44, wingo wrote: > On 2015/04/22 15:39:32, rossberg wrote: > https://codereview.chromium.org/1097283003/diff/80001/src/contexts.cc#newcode261 > > ...
5 years, 8 months ago (2015-04-23 13:30:53 UTC) #23
rossberg
https://codereview.chromium.org/1097283003/diff/100001/test/mjsunit/harmony/arrow-functions-this.js File test/mjsunit/harmony/arrow-functions-this.js (right): https://codereview.chromium.org/1097283003/diff/100001/test/mjsunit/harmony/arrow-functions-this.js#newcode26 test/mjsunit/harmony/arrow-functions-this.js:26: var withObject = { ['this']: object } Nit: you ...
5 years, 8 months ago (2015-04-23 13:31:45 UTC) #24
wingo
Updated patch fixes nits. It also enabled parts of the test that were commented out ...
5 years, 8 months ago (2015-04-23 14:16:02 UTC) #25
wingo
Updated patch adds ia32, arm, arm64 implementations. I believe we are good to go; PTAL ...
5 years, 8 months ago (2015-04-23 14:57:12 UTC) #26
wingo
Regarding the failing try-builds -- could it be that try builds and rebased patches somehow ...
5 years, 8 months ago (2015-04-23 15:23:02 UTC) #27
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1097283003/140001
5 years, 8 months ago (2015-04-23 15:49:51 UTC) #30
wingo
On 2015/04/23 15:23:02, wingo wrote: > Regarding the failing try-builds -- could it be that ...
5 years, 8 months ago (2015-04-23 15:50:27 UTC) #31
wingo
On 2015/04/23 15:50:27, wingo wrote: > On 2015/04/23 15:23:02, wingo wrote: > > Regarding the ...
5 years, 8 months ago (2015-04-23 16:08:07 UTC) #32
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_rel/builds/5190)
5 years, 8 months ago (2015-04-23 16:10:09 UTC) #34
wingo
Updated patchset fixes the context->closure() == context->declaration_context()->closure() consistency check for script contexts. I wonder how ...
5 years, 8 months ago (2015-04-24 08:13:50 UTC) #35
wingo
Updated patchset to apply to master. Unfortunately we are now failing this test, which oddly ...
5 years, 8 months ago (2015-04-27 16:01:39 UTC) #36
arv (Not doing code reviews)
On 2015/04/27 16:01:39, wingo wrote: > Updated patchset to apply to master. Unfortunately we are ...
5 years, 8 months ago (2015-04-27 16:13:34 UTC) #37
wingo
On 2015/04/27 16:13:34, arv wrote: > What happens with your cl in this case? > ...
5 years, 8 months ago (2015-04-27 16:24:33 UTC) #38
wingo
On 2015/04/27 16:01:39, wingo wrote: > A useful short-term step would be to resolve "this" ...
5 years, 8 months ago (2015-04-27 16:26:29 UTC) #39
wingo
On 2015/04/27 16:26:29, wingo wrote: > On 2015/04/27 16:01:39, wingo wrote: > > A useful ...
5 years, 8 months ago (2015-04-27 16:36:58 UTC) #40
wingo
Yesterday Andreas asked me to figure out what was happening with "this" and "with" in ...
5 years, 7 months ago (2015-04-28 08:02:17 UTC) #41
arv (Not doing code reviews)
Amazing work. https://codereview.chromium.org/1097283003/diff/200001/src/scopeinfo.cc File src/scopeinfo.cc (right): https://codereview.chromium.org/1097283003/diff/200001/src/scopeinfo.cc#newcode321 src/scopeinfo.cc:321: name->Equals(*GetIsolate()->factory()->this_string()); Another option would be to use ...
5 years, 7 months ago (2015-04-28 14:26:18 UTC) #42
wingo
https://codereview.chromium.org/1097283003/diff/200001/src/scopeinfo.cc File src/scopeinfo.cc (right): https://codereview.chromium.org/1097283003/diff/200001/src/scopeinfo.cc#newcode321 src/scopeinfo.cc:321: name->Equals(*GetIsolate()->factory()->this_string()); On 2015/04/28 14:26:18, arv wrote: > Another option ...
5 years, 7 months ago (2015-04-28 15:07:42 UTC) #43
rossberg
On 2015/04/28 08:02:17, wingo wrote: > Yesterday Andreas asked me to figure out what was ...
5 years, 7 months ago (2015-04-28 16:27:04 UTC) #44
wingo
On 2015/04/28 16:27:04, rossberg wrote: > I wonder if the natural solution wouldn't be to ...
5 years, 7 months ago (2015-04-28 19:02:13 UTC) #45
wingo
Updated CL adds TODO for sorting out "this" scope in script context.
5 years, 7 months ago (2015-05-05 14:39:42 UTC) #46
arv (Not doing code reviews)
LGTM Some JS style nits https://codereview.chromium.org/1097283003/diff/220001/src/parser.cc File src/parser.cc (right): https://codereview.chromium.org/1097283003/diff/220001/src/parser.cc#newcode745 src/parser.cc:745: pos + 4, Variable::THIS); ...
5 years, 7 months ago (2015-05-05 14:59:10 UTC) #48
wingo
Updated patch rebases to apply cleanly and fixes nits from Erik. https://codereview.chromium.org/1097283003/diff/220001/src/parser.cc File src/parser.cc (right): ...
5 years, 7 months ago (2015-05-05 15:49:29 UTC) #49
wingo
Going to CQ+ as Andreas indicated offline that we should land this then follow up ...
5 years, 7 months ago (2015-05-05 15:52:04 UTC) #50
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1097283003/240001
5 years, 7 months ago (2015-05-05 15:54:50 UTC) #53
commit-bot: I haz the power
Committed patchset #11 (id:240001)
5 years, 7 months ago (2015-05-05 16:38:25 UTC) #54
commit-bot: I haz the power
Patchset 11 (id:??) landed as https://crrev.com/18619d355192e2699203d12d9ebb9caea107b693 Cr-Commit-Position: refs/heads/master@{#28236}
5 years, 7 months ago (2015-05-05 16:38:33 UTC) #55
wingo
5 years, 7 months ago (2015-05-05 17:23:32 UTC) #56
Message was sent while issue was closed.
A revert of this CL (patchset #11 id:240001) has been created in
https://codereview.chromium.org/1113133006/ by wingo@igalia.com.

The reason for reverting is: nosnap failures.

Powered by Google App Engine
This is Rietveld 408576698