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

Issue 3000333002: Fix several bugs in closure conversion. (Closed)

Created:
3 years, 4 months ago by sjindel
Modified:
3 years, 4 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Fix several bugs in closure conversion. Summary: 1. Previously, in 'BuildGraphOfConvertedClosureFunction', the VM was unable to correctly forward parameters to converted closure functions when they were captured in the converted function's body. This could happen when, for example, a closure was introduced into it by async conversion. Now, this is fixed by an approach that mirrors the technique in 'BuildGraphOfFunction'. 2. Previously, local variables declared inside loop bodies were being saved in the loop's enclosing context, so closures within the loop would see new values initialized to the variable in subsequent iterations. Now, this is fixed by creating nested contexts for all loops, regardless of whether the loop variables are captured. 3. Previously, arity checks were not being performed on converted closures, so they could be called with too few or too many arguments. In the former case, the missing arguments would be filled in with garbage on the stack. Now, the assembly generation in 'CompileGraph' inserts argument count checks for converted closures as well as regular closures. Test Plan: Introduced new tests in the closure conversion suite to test each bug: 1. syncstart.dart 2. loop2.dart, blocks.dart, updated for_in_closure.dart 3. arity.dart With these changes, closure conversion passes all co19 tests in non-checked mode, except those that are not passed without it: python tools/test.py -m release -c dartk --vm-options "--reify --reify_generic_functions" co19 BUG= R=dmitryas@google.com Committed: https://github.com/dart-lang/sdk/commit/7b53e209c584ee6ce7ff4c7bbc1afc4f013889b9

Patch Set 1 #

Total comments: 14

Patch Set 2 : Fix bugs. #

Total comments: 12

Patch Set 3 : fix another condition #

Patch Set 4 : Fix another async bug. #

Total comments: 1

Patch Set 5 : Review comments #

Total comments: 1

Patch Set 6 : Comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+368 lines, -41 lines) Patch
M pkg/kernel/lib/transformations/closure/converter.dart View 1 2 3 4 6 chunks +19 lines, -0 lines 0 comments Download
M pkg/kernel/lib/transformations/closure/invalidate_closures.dart View 1 chunk +1 line, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/arity.dart View 1 2 3 4 1 chunk +28 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/arity.dart.expect View 1 2 3 4 1 chunk +27 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/blocks.dart View 1 1 chunk +52 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/blocks.dart.expect View 1 chunk +52 lines, -0 lines 0 comments Download
M pkg/kernel/testcases/closures/for_in_closure.dart View 1 chunk +2 lines, -1 line 0 comments Download
M pkg/kernel/testcases/closures/for_in_closure.dart.expect View 2 chunks +4 lines, -1 line 0 comments Download
A pkg/kernel/testcases/closures/loop2.dart View 1 2 3 4 1 chunk +30 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/loop2.dart.expect View 1 chunk +30 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/syncstar.dart View 1 2 3 4 5 1 chunk +24 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/syncstar.dart.expect View 1 chunk +35 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph_compiler_arm.cc View 1 2 3 chunks +6 lines, -4 lines 0 comments Download
M runtime/vm/flow_graph_compiler_arm64.cc View 1 2 3 chunks +6 lines, -4 lines 0 comments Download
M runtime/vm/flow_graph_compiler_ia32.cc View 1 2 3 chunks +6 lines, -4 lines 0 comments Download
M runtime/vm/flow_graph_compiler_x64.cc View 1 2 3 chunks +6 lines, -4 lines 0 comments Download
M runtime/vm/kernel_binary_flowgraph.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/kernel_binary_flowgraph.cc View 1 2 3 9 chunks +38 lines, -23 lines 0 comments Download

Messages

Total messages: 15 (5 generated)
sjindel
3 years, 4 months ago (2017-08-22 18:47:53 UTC) #2
Dmitry Stefantsov
Nice to see closure conversion becoming more stable! I have some questions and comments. Please, ...
3 years, 4 months ago (2017-08-24 09:41:13 UTC) #3
sjindel
https://codereview.chromium.org/3000333002/diff/1/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/3000333002/diff/1/pkg/kernel/lib/ast.dart#newcode3181 pkg/kernel/lib/ast.dart:3181: bool get isLoop => false; On 2017/08/24 09:41:13, Dmitry ...
3 years, 4 months ago (2017-08-24 11:11:43 UTC) #4
Dmitry Stefantsov
Thanks for the update! I have some more comments :) https://codereview.chromium.org/3000333002/diff/1/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/3000333002/diff/1/pkg/kernel/lib/ast.dart#newcode3181 ...
3 years, 4 months ago (2017-08-24 11:49:57 UTC) #5
sjindel
https://codereview.chromium.org/3000333002/diff/1/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/3000333002/diff/1/pkg/kernel/lib/ast.dart#newcode3181 pkg/kernel/lib/ast.dart:3181: bool get isLoop => false; On 2017/08/24 11:49:57, Dmitry ...
3 years, 4 months ago (2017-08-24 14:50:14 UTC) #7
Dmitry Stefantsov
LGTM if you respond to the comments. https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/loop2.dart File pkg/kernel/testcases/closures/loop2.dart (right): https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/loop2.dart#newcode1 pkg/kernel/testcases/closures/loop2.dart:1: /* On ...
3 years, 4 months ago (2017-08-24 15:07:29 UTC) #9
sjindel
https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/syncstar.dart File pkg/kernel/testcases/closures/syncstar.dart (right): https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/syncstar.dart#newcode1 pkg/kernel/testcases/closures/syncstar.dart:1: /* On 2017/08/24 15:07:29, Dmitry Stefantsov wrote: > On ...
3 years, 4 months ago (2017-08-24 15:13:42 UTC) #10
sjindel
https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/loop2.dart File pkg/kernel/testcases/closures/loop2.dart (right): https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/loop2.dart#newcode1 pkg/kernel/testcases/closures/loop2.dart:1: /* On 2017/08/24 15:07:28, Dmitry Stefantsov wrote: > On ...
3 years, 4 months ago (2017-08-24 15:14:11 UTC) #11
Dmitry Stefantsov
https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/loop2.dart File pkg/kernel/testcases/closures/loop2.dart (right): https://codereview.chromium.org/3000333002/diff/20001/pkg/kernel/testcases/closures/loop2.dart#newcode1 pkg/kernel/testcases/closures/loop2.dart:1: /* On 2017/08/24 15:14:11, sjindel wrote: > On 2017/08/24 ...
3 years, 4 months ago (2017-08-24 15:17:29 UTC) #12
sjindel
3 years, 4 months ago (2017-08-24 18:21:35 UTC) #15
Message was sent while issue was closed.
Committed patchset #6 (id:100001) manually as
7b53e209c584ee6ce7ff4c7bbc1afc4f013889b9 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698