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

Issue 2942623004: Fuse top level type inference with dependency generation. (Closed)

Created:
3 years, 6 months ago by Paul Berry
Modified:
3 years, 6 months ago
CC:
reviews_dartlang.org, dart-fe-team+reviews_google.com
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Fuse top level type inference with dependency generation. This CL combines the two parts of top level type inference (determining dependencies and inferring a type) into a single operation. The technique is: instead of evaluating top level types in topologically sorted order (which requires that we figure out the dependencies first, so that we can do topological sorting), we simply iterate over the fields requiring inference and begin inferring them in whatever order they are encountered. If, while trying to infer the type of one field, we discover a reference to field that hasn't been type inferred yet, we make a recursive call to infer the second field. If this recursion leads to a loop, then we mark all of the fields in the loop as participating in a circularity (and set their types to `dynamic` for error recovery purposes). To facilitate experimentation, I've left the old code in place, but disabled it using a const bool `fusedTopLevelInference`. The old code can be re-enabled by setting this bool to `false`. Once we are sure that we want to proceed with this approach, we can remove the old code. Note that there are some minor user-visible behavioral changes: - When there is a circularity, we no longer consider the entire strongly connected component to be part of the circularity; we only consider the loop formed by following the first unresolved dependency of each field. (I did this because of ease of implementation, and because it made it easier to reassure myself that the outcome of the algorithm is independent of the order in which fields are visited). See pkg/front_end/testcases/inference_new/strongly_connected_component.dart for the user-visible consequence of this change. - We no longer need to speculatively assume that method invocations depend on the types of their parameters when not supplying generic types; now they only depend on the types of their parameters when the method being invoked is known to be generic. See pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart. - We no longer need to speculatively assume that invocations of `+`, `-`, `*`, and `%` depend on the types of their RHS; now they only depend on the types of their RHS when the type of the LHS is `int`. See pkg/front_end/testcases/inference_new/dependency_only_if_overloaded.dart. R=sigmund@google.com Committed: https://github.com/dart-lang/sdk/commit/79bf5f593139fa489eaebb288aa45213d0a6d7ae

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+366 lines, -57 lines) Patch
M pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart View 8 chunks +29 lines, -31 lines 0 comments Download
M pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart View 13 chunks +100 lines, -22 lines 2 comments Download
M pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart View 3 chunks +9 lines, -2 lines 0 comments Download
M pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart View 1 chunk +10 lines, -2 lines 0 comments Download
M pkg/front_end/test/fasta/kompile.status View 1 chunk +3 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart View 1 chunk +31 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart.direct.expect View 1 chunk +19 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart.outline.expect View 1 chunk +19 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart.strong.expect View 1 chunk +19 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_overloaded.dart View 1 chunk +32 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_overloaded.dart.direct.expect View 1 chunk +14 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_overloaded.dart.outline.expect View 1 chunk +15 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/dependency_only_if_overloaded.dart.strong.expect View 1 chunk +14 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/strongly_connected_component.dart View 1 chunk +21 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/strongly_connected_component.dart.direct.expect View 1 chunk +10 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/strongly_connected_component.dart.outline.expect View 1 chunk +11 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference_new/strongly_connected_component.dart.strong.expect View 1 chunk +10 lines, -0 lines 0 comments Download

Messages

Total messages: 10 (3 generated)
Paul Berry
3 years, 6 months ago (2017-06-15 21:10:53 UTC) #2
Siggi Cherem (dart-lang)
lgtm. I think its fine to land, but Konstantin you've reviewed more of the inference ...
3 years, 6 months ago (2017-06-15 22:12:32 UTC) #3
Paul Berry
https://codereview.chromium.org/2942623004/diff/1/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart File pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart (right): https://codereview.chromium.org/2942623004/diff/1/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart#newcode23 pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart:23: /// This means that code is currently on the ...
3 years, 6 months ago (2017-06-15 22:16:52 UTC) #4
Paul Berry
On 2017/06/15 22:12:32, Siggi Cherem (dart-lang) wrote: > lgtm. I think its fine to land, ...
3 years, 6 months ago (2017-06-15 22:22:59 UTC) #5
Paul Berry
Committed patchset #1 (id:1) manually as 79bf5f593139fa489eaebb288aa45213d0a6d7ae (presubmit successful).
3 years, 6 months ago (2017-06-16 01:13:57 UTC) #7
ahe
DBC > If, while trying to infer the > type of one field, we discover ...
3 years, 6 months ago (2017-06-16 13:15:23 UTC) #9
scheglov
3 years, 6 months ago (2017-06-16 15:39:39 UTC) #10
Message was sent while issue was closed.
LGTM

Powered by Google App Engine
This is Rietveld 408576698