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

Issue 3007623002: Fix many bugs with closure conversion in checked mode. (Closed)

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

Description

Fix many bugs with closure conversion in checked mode. Summary: Previously, we use the "Vector" type in the kernel tree for the result of the "VectorCreation" operation as as the parameter type for converted closure functions. In the VM, we use the "Context" type instead, which the VM treats a little differently than normal Dart-visible types, and it doesn't not handle type checks against it correctly, breaking all closure converted code running in checked mode. Now, Since we are forced to use dynamic to represent the types of elements of the context, we may as well just use dynamic for the context type itself. Previously, we did not correct handle converted closure type checks for closures that capture type parameters. The way we handled these type checks also had several latent bugs that prevented type parameters being handled properly. Now, we handle type parameters for converted closures similarly to normal closures, and the places we treat them specially are fewer and more integrated with the rest of the closure type checking code. There is still a problem where assignments to captured variables are not checked, because they are transformed to assignments into the context, whose elements are necessarily untyped. This breaks many co19 tests, which expect type errors on these assignments. The example below should error in checked mode, but after closure conversion is runs with no errors. int b; bool c; (() { b = c; })() Test Plan: - All test cases in "pkg/kernel/testcases/closures" now run in checked mode. - Added a test "closures_types.dart" to check that captured type parameters are handled correctly in the converted closures' signature types. R=dmitryas@google.com Committed: https://github.com/dart-lang/sdk/commit/7bf835b9d5cfc6849e97758b1dcb2cfdd2be589b

Patch Set 1 #

Total comments: 13

Patch Set 2 : Review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+239 lines, -125 lines) Patch
M pkg/kernel/lib/transformations/closure/converter.dart View 3 chunks +2 lines, -2 lines 0 comments Download
M pkg/kernel/lib/transformations/closure/rewriter.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/kernel/test/closures/suite.dart View 1 chunk +1 line, -0 lines 0 comments Download
M pkg/kernel/testcases/closures/arity.dart.expect View 1 chunk +6 lines, -6 lines 0 comments Download
M pkg/kernel/testcases/closures/blocks.dart.expect View 2 chunks +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/capture_closure.dart.expect View 1 chunk +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect View 1 chunk +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/capture_this.dart.expect View 2 chunks +5 lines, -5 lines 0 comments Download
M pkg/kernel/testcases/closures/captured_class_type_vars.dart.expect View 1 chunk +1 line, -1 line 0 comments Download
M pkg/kernel/testcases/closures/catch.dart.expect View 2 chunks +2 lines, -2 lines 0 comments Download
M pkg/kernel/testcases/closures/closure_in_constructor.dart.expect View 2 chunks +4 lines, -4 lines 0 comments Download
M pkg/kernel/testcases/closures/closure_in_initializer.dart.expect View 2 chunks +4 lines, -4 lines 0 comments Download
M pkg/kernel/testcases/closures/closure_in_initializer_closure.dart.expect View 2 chunks +5 lines, -5 lines 0 comments Download
A pkg/kernel/testcases/closures/closure_types.dart View 1 1 chunk +55 lines, -0 lines 0 comments Download
A pkg/kernel/testcases/closures/closure_types.dart.expect View 1 chunk +49 lines, -0 lines 0 comments Download
M pkg/kernel/testcases/closures/closures.dart.expect View 1 chunk +2 lines, -2 lines 0 comments Download
M pkg/kernel/testcases/closures/contexts_in_field_initializers.dart.expect View 2 chunks +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/field.dart.expect View 1 chunk +4 lines, -4 lines 0 comments Download
M pkg/kernel/testcases/closures/for_in_closure.dart.expect View 2 chunks +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/for_loop.dart.expect View 2 chunks +4 lines, -4 lines 0 comments Download
M pkg/kernel/testcases/closures/for_variable_capture_test.dart.expect View 2 chunks +2 lines, -2 lines 0 comments Download
M pkg/kernel/testcases/closures/instance_tear_off.dart.expect View 1 chunk +6 lines, -6 lines 0 comments Download
M pkg/kernel/testcases/closures/loop2.dart.expect View 2 chunks +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/named_closure.dart.expect View 1 chunk +2 lines, -2 lines 0 comments Download
M pkg/kernel/testcases/closures/non_void_context.dart.expect View 2 chunks +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/syncstar.dart.expect View 2 chunks +3 lines, -3 lines 0 comments Download
M pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect View 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/vm/kernel_binary_flowgraph.cc View 1 2 chunks +11 lines, -4 lines 0 comments Download
M runtime/vm/object.cc View 1 5 chunks +47 lines, -45 lines 0 comments Download

Messages

Total messages: 14 (5 generated)
sjindel
3 years, 3 months ago (2017-08-26 17:49:46 UTC) #2
sjindel
3 years, 3 months ago (2017-08-26 17:50:22 UTC) #4
Dmitry Stefantsov
LGTM with a few suggestions. https://codereview.chromium.org/3007623002/diff/1/pkg/kernel/testcases/closures/closure_types.dart File pkg/kernel/testcases/closures/closure_types.dart (right): https://codereview.chromium.org/3007623002/diff/1/pkg/kernel/testcases/closures/closure_types.dart#newcode1 pkg/kernel/testcases/closures/closure_types.dart:1: class C<T> { Please ...
3 years, 3 months ago (2017-08-28 11:38:15 UTC) #5
Vyacheslav Egorov (Google)
drive by comments (VM code style nits - not a semantics review) https://codereview.chromium.org/3007623002/diff/1/runtime/vm/object.cc File runtime/vm/object.cc ...
3 years, 3 months ago (2017-08-28 11:55:48 UTC) #7
sjindel
https://codereview.chromium.org/3007623002/diff/1/pkg/kernel/testcases/closures/closure_types.dart File pkg/kernel/testcases/closures/closure_types.dart (right): https://codereview.chromium.org/3007623002/diff/1/pkg/kernel/testcases/closures/closure_types.dart#newcode1 pkg/kernel/testcases/closures/closure_types.dart:1: class C<T> { On 2017/08/28 11:38:15, Dmitry Stefantsov wrote: ...
3 years, 3 months ago (2017-08-28 15:05:59 UTC) #8
sjindel
Committed patchset #2 (id:20001) manually as 7bf835b9d5cfc6849e97758b1dcb2cfdd2be589b (presubmit successful).
3 years, 3 months ago (2017-08-28 15:39:41 UTC) #10
Vyacheslav Egorov (Google)
https://codereview.chromium.org/3007623002/diff/1/runtime/vm/object.cc File runtime/vm/object.cc (right): https://codereview.chromium.org/3007623002/diff/1/runtime/vm/object.cc#newcode6341 runtime/vm/object.cc:6341: // TODO(sjindel): Kernel generic methods undone. Handle type parameters ...
3 years, 3 months ago (2017-08-28 15:59:12 UTC) #11
regis
Samir, This cl broke reification of generic functions in the VM. I cannot blame you, ...
3 years, 3 months ago (2017-08-28 23:47:52 UTC) #13
sjindel
3 years, 3 months ago (2017-08-29 13:11:42 UTC) #14
Message was sent while issue was closed.
On 2017/08/28 23:47:52, regis wrote:
> Samir,
> 
> This cl broke reification of generic functions in the VM. I cannot blame you,
> because it is not enabled yet, so it is difficult for you to notice. And since
> the async zone cl by Florian is not submitted, you cannot test it yourself
> either.
> 
> I have not looked into what exactly got broken, but it has to do with generic
> closures declaring local generic closures. The parent fails to allocate a
local
> variable holding the passed in type arguments. I'll look at it tomorrow.
> 
> In the future, please cc me on such changes until reification of generic
> functions is enabled and better tested in the VM.
> 
> Thanks,
> Regis

Will do.

Powered by Google App Engine
This is Rietveld 408576698