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

Issue 2778223002: Add primitive to create closures and use it for closure conversion (Closed)

Created:
3 years, 8 months ago by Dmitry Stefantsov
Modified:
3 years, 8 months ago
Reviewers:
asgerf, karlklose
CC:
reviews_dartlang.org, Kevin Millikin (Google)
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add primitive to create closures and use it for closure conversion A new AST node 'ClosureCreation' is added. It takes a name of a top-level function, a context, and a closure function type and creates a closure of the given type. The effect of this closure invocation is the same as of the invocation of the given top-level function with the contexts as the first argument. In order to use 'ClosureCreation', the closure conversion pass now transforms closures into top-level functions, not closure classes. These functions receive the context as the first argument. The type of the expression represented by 'ClosureCreation' is its third parameter. It its the responsibility of closure conversion pass to create the correct types for 'ClosureCreation' nodes based on types of closures transformed into top-level functions. R=asgerf@google.com Committed: https://github.com/dart-lang/sdk/commit/42f82d1d2128161f402d5a69b20f82e7ee23f210

Patch Set 1 : Add 'ClosureCreation' AST node with necessary supplements #

Patch Set 2 : Remove type variables or substitute them with dynamic #

Patch Set 3 : Use closed top-level functions instead of closure classes #

Patch Set 4 : Edit comments #

Patch Set 5 : Rename context parameter in closed top-level functions #

Patch Set 6 : Fix bug: put parameters with no initalizers into contexts correctly #

Total comments: 6

Patch Set 7 : Use Reference in ClosureCreation instead of String with function name #

Patch Set 8 : Skip context param in closure type construction, rather than remove it #

Total comments: 6

Patch Set 9 : Follow common pattern for AST nodes with References in ClosureCreation #

Unified diffs Side-by-side diffs Delta from patch set Stats (+548 lines, -822 lines) Patch
M pkg/kernel/binary.md View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M pkg/kernel/lib/ast.dart View 1 2 3 4 5 6 7 8 1 chunk +43 lines, -0 lines 0 comments Download
M pkg/kernel/lib/binary/ast_from_binary.dart View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -0 lines 0 comments Download
M pkg/kernel/lib/binary/ast_to_binary.dart View 1 2 3 4 5 6 7 8 1 chunk +7 lines, -0 lines 0 comments Download
M pkg/kernel/lib/binary/tag.dart View 1 chunk +2 lines, -0 lines 0 comments Download
M pkg/kernel/lib/text/ast_to_text.dart View 1 2 3 4 5 6 7 8 1 chunk +12 lines, -0 lines 0 comments Download
M pkg/kernel/lib/transformations/closure/converter.dart View 1 2 3 4 5 6 7 8 20 chunks +189 lines, -143 lines 0 comments Download
M pkg/kernel/lib/type_checker.dart View 2 chunks +14 lines, -2 lines 0 comments Download
M pkg/kernel/lib/visitor.dart View 3 chunks +4 lines, -0 lines 0 comments Download
M pkg/kernel/testcases/closures/capture_closure.dart.expect View 1 2 3 4 5 6 1 chunk +8 lines, -27 lines 0 comments Download
M pkg/kernel/testcases/closures/capture_closure_parameter.dart.expect View 1 2 3 4 5 6 1 chunk +11 lines, -29 lines 0 comments Download
M pkg/kernel/testcases/closures/capture_this.dart.expect View 1 2 3 4 5 6 2 chunks +11 lines, -38 lines 0 comments Download
M pkg/kernel/testcases/closures/catch.dart.expect View 1 2 3 4 5 6 2 chunks +6 lines, -15 lines 0 comments Download
M pkg/kernel/testcases/closures/closure_in_constructor.dart.expect View 1 2 3 4 5 6 2 chunks +8 lines, -26 lines 0 comments Download
M pkg/kernel/testcases/closures/closure_in_initializer.dart.expect View 1 2 3 4 5 6 1 chunk +8 lines, -26 lines 0 comments Download
M pkg/kernel/testcases/closures/closure_in_initializer_closure.dart.expect View 1 2 3 4 5 6 1 chunk +16 lines, -43 lines 0 comments Download
M pkg/kernel/testcases/closures/closures.dart.expect View 1 2 3 4 5 6 2 chunks +4 lines, -13 lines 0 comments Download
M pkg/kernel/testcases/closures/field.dart.expect View 1 2 3 4 5 6 2 chunks +16 lines, -52 lines 0 comments Download
M pkg/kernel/testcases/closures/for_in_closure.dart.expect View 1 2 3 4 5 6 3 chunks +4 lines, -13 lines 0 comments Download
M pkg/kernel/testcases/closures/for_loop.dart.expect View 1 2 3 4 5 6 3 chunks +9 lines, -27 lines 0 comments Download
M pkg/kernel/testcases/closures/for_variable_capture_test.dart.expect View 1 2 3 4 5 6 2 chunks +4 lines, -14 lines 0 comments Download
M pkg/kernel/testcases/closures/instance_tear_off.dart.expect View 1 2 3 4 5 6 5 chunks +110 lines, -212 lines 0 comments Download
M pkg/kernel/testcases/closures/named_closure.dart.expect View 1 2 3 4 5 6 2 chunks +4 lines, -13 lines 0 comments Download
M pkg/kernel/testcases/closures/non_void_context.dart.expect View 1 2 3 4 5 6 3 chunks +10 lines, -29 lines 0 comments Download
M pkg/kernel/testcases/closures/static_tear_off.dart.expect View 1 2 3 4 5 6 2 chunks +12 lines, -32 lines 0 comments Download
M pkg/kernel/testcases/closures/type_variables.dart.expect View 1 2 3 4 5 6 2 chunks +19 lines, -55 lines 0 comments Download
M pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect View 1 2 3 4 5 6 2 chunks +4 lines, -13 lines 0 comments Download

Messages

Total messages: 9 (2 generated)
Dmitry Stefantsov
3 years, 8 months ago (2017-03-31 10:31:22 UTC) #2
asgerf
https://codereview.chromium.org/2778223002/diff/100001/pkg/kernel/binary.md File pkg/kernel/binary.md (right): https://codereview.chromium.org/2778223002/diff/100001/pkg/kernel/binary.md#newcode686 pkg/kernel/binary.md:686: String topLevelFunctionName; This should be a MemberReference https://codereview.chromium.org/2778223002/diff/100001/pkg/kernel/lib/ast.dart File ...
3 years, 8 months ago (2017-03-31 11:03:52 UTC) #3
Dmitry Stefantsov
PTAL https://codereview.chromium.org/2778223002/diff/100001/pkg/kernel/binary.md File pkg/kernel/binary.md (right): https://codereview.chromium.org/2778223002/diff/100001/pkg/kernel/binary.md#newcode686 pkg/kernel/binary.md:686: String topLevelFunctionName; On 2017/03/31 11:03:41, asgerf wrote: > ...
3 years, 8 months ago (2017-03-31 11:54:13 UTC) #4
asgerf
Just a few more things :) https://codereview.chromium.org/2778223002/diff/140001/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/2778223002/diff/140001/pkg/kernel/lib/ast.dart#newcode2862 pkg/kernel/lib/ast.dart:2862: Reference topLevelFunctionReference; Great! ...
3 years, 8 months ago (2017-03-31 12:08:43 UTC) #5
Dmitry Stefantsov
Thanks for the new comments! Hope, this time I got it right. PTAL. https://codereview.chromium.org/2778223002/diff/140001/pkg/kernel/lib/ast.dart File ...
3 years, 8 months ago (2017-03-31 12:40:18 UTC) #6
asgerf
LGTM
3 years, 8 months ago (2017-03-31 12:42:12 UTC) #7
Dmitry Stefantsov
3 years, 8 months ago (2017-03-31 12:44:13 UTC) #9
Message was sent while issue was closed.
Committed patchset #9 (id:160001) manually as
42f82d1d2128161f402d5a69b20f82e7ee23f210 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698