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

Issue 1968263002: Remove unused 'receiver' field from generators (Closed)

Created:
4 years, 7 months ago by Dan Ehrenberg
Modified:
4 years, 7 months ago
CC:
v8-mips-ports_googlegroups.com, v8-ppc-ports_googlegroups.com, v8-reviews_googlegroups.com, v8-x87-ports_googlegroups.com, Yang
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Remove unused 'receiver' field from generators V8 previously handled the receiver ('this') specially with respect to scoping, but it now handles it similarly to other local variables in most contexts. Generators had some code in them to restore the receiver on generator resume, but this support is redundant with the way that contexts already will restore the receiver. Further, async arrow functions cannot have redundant reads and writes of the receiver as it would trigger a TDZ error in some cases. This patch eliminates the unnecesary saving of the receiver. To preserve the calling convention, the hole value is restored as the receiver in ResumeGeneratorTrampoline, similarly to how arguments are restored as the hole, however it is expected that this value will never be seen by user code because of the forced context allocation, which impacts the receiver just like the arguments. This patch fixes an async/await test in the unsubmitted draft code which failed previously due to an unnecessary read of 'this' in a subclass constructor when it was in TDZ. R=neis,bmeurer BUG=v8:4483

Patch Set 1 #

Patch Set 2 : bytecode expectations #

Patch Set 3 : Fix test which checked for second parameter #

Patch Set 4 : weaken dcheck #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -90 lines) Patch
M src/arm/builtins-arm.cc View 1 chunk +2 lines, -3 lines 0 comments Download
M src/arm64/builtins-arm64.cc View 1 chunk +2 lines, -3 lines 0 comments Download
M src/debug/mirrors.js View 2 chunks +0 lines, -9 lines 0 comments Download
M src/ia32/builtins-ia32.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M src/mips/builtins-mips.cc View 1 chunk +2 lines, -3 lines 0 comments Download
M src/mips64/builtins-mips64.cc View 1 chunk +2 lines, -3 lines 0 comments Download
M src/objects.h View 2 chunks +1 line, -5 lines 0 comments Download
M src/objects-debug.cc View 1 chunk +0 lines, -1 line 0 comments Download
M src/objects-inl.h View 1 chunk +0 lines, -1 line 0 comments Download
M src/parsing/parser.cc View 1 chunk +1 line, -3 lines 0 comments Download
M src/runtime/runtime.h View 1 chunk +1 line, -2 lines 0 comments Download
M src/runtime/runtime-debug.cc View 1 2 3 2 chunks +8 lines, -5 lines 0 comments Download
M src/runtime/runtime-generator.cc View 3 chunks +1 line, -13 lines 0 comments Download
M src/x64/builtins-x64.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M test/cctest/interpreter/bytecode_expectations/Generators.golden View 1 12 chunks +16 lines, -23 lines 0 comments Download
M test/cctest/test-ast-expression-visitor.cc View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M test/mjsunit/es6/generators-mirror.js View 4 chunks +8 lines, -11 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 20 (9 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968263002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968263002/20001
4 years, 7 months ago (2016-05-11 23:32:52 UTC) #4
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_avx2_rel_ng on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel_ng/builds/1514) v8_linux64_avx2_rel_ng_triggered on ...
4 years, 7 months ago (2016-05-11 23:52:03 UTC) #6
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968263002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968263002/40001
4 years, 7 months ago (2016-05-11 23:54:52 UTC) #8
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_avx2_rel_ng on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel_ng/builds/1515) v8_linux64_avx2_rel_ng_triggered on ...
4 years, 7 months ago (2016-05-12 00:13:27 UTC) #10
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968263002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968263002/60001
4 years, 7 months ago (2016-05-12 00:29:13 UTC) #12
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_arm_rel_ng on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_arm_rel_ng/builds/1505) v8_linux_arm_rel_ng_triggered on ...
4 years, 7 months ago (2016-05-12 00:48:26 UTC) #14
Benedikt Meurer
I don't think this will work. This will break the FrameSummary for resumed generator frames, ...
4 years, 7 months ago (2016-05-12 04:04:46 UTC) #15
Dan Ehrenberg
On 2016/05/12 at 04:04:46, bmeurer wrote: > I don't think this will work. This will ...
4 years, 7 months ago (2016-05-12 04:47:12 UTC) #16
Benedikt Meurer
On 2016/05/12 04:47:12, Dan Ehrenberg wrote: > On 2016/05/12 at 04:04:46, bmeurer wrote: > > ...
4 years, 7 months ago (2016-05-12 17:50:19 UTC) #17
Benedikt Meurer
4 years, 7 months ago (2016-05-12 17:50:40 UTC) #19
Dan Ehrenberg
4 years, 7 months ago (2016-05-12 17:56:57 UTC) #20
On 2016/05/12 at 17:50:19, bmeurer wrote:
> On 2016/05/12 04:47:12, Dan Ehrenberg wrote:
> > On 2016/05/12 at 04:04:46, bmeurer wrote:
> > > I don't think this will work. This will break the FrameSummary for resumed
> > generator frames, and by that it'll probably break a lot of users of the
> > FrameSummary, because now the receiver in the FrameSummary is the_hole.
> > 
> > For async arrow functions to be able to call super (obscure, I know), the
real
> > receiver needs to be context-allocated, and we cannot have an accurate
receiver
> > copied into the generator. How should we handle this?
> 
> I doesn't matter what you copy into the generator, that's completely
orthogonal to the issue at hand. I talked briefly with Andreas and Yang today,
and we should focus on fixing the issue that makes the test fail. Optimizing the
generator suspend/resume by not saving the receiver slot is an optimization that
we can discuss afterwards (there are some additional constraints due to
FrameSummary and some debugger interaction, which are unrelated to
super/async/generators).
> 
> So, if I understand correctly, the bug is due to the multiple ThisExpression
ast nodes being emitted for yields?

The issue is the read of 'this' to be passed into CreateJSGeneratorObject, which
might be in the TDZ in case it's in a subclass constructor. I can simply replace
this with 'undefined' when it's an async arrow function, if that's how arrows
generally work with the receiver in the stack frame.

Powered by Google App Engine
This is Rietveld 408576698