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

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart

Issue 1528953002: Tweaks to improve performance of type-inference. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/types/union_type_mask.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index a5680663b42babb1f0b732cb0e6a77ce72a21d3c..4ff72abcc81347b0ada2d56bd23603fe6c047361 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -538,11 +538,28 @@ class TypeInformationSystem extends TypeSystem<TypeInformation> {
}
TypeMask joinTypeMasks(Iterable<TypeMask> masks) {
- TypeMask newType = const TypeMask.nonNullEmpty();
+ var dynamicType = compiler.typesTask.dynamicType;
+ // Optimization: we are iterating over masks twice, but because `masks` is a
+ // mapped iterable, we save the intermediate results to avoid computing them
+ // again.
+ var list = [];
for (TypeMask mask in masks) {
- newType = newType.union(mask, classWorld);
+ // Don't do any work on computing unions if we know that after all that
+ // work the result will be `dynamic`.
+ // TODO(sigmund): change to `mask == dynamicType` so we can continue to
+ // track the non-nullable bit.
+ if (mask.containsAll(classWorld)) return dynamicType;
Siggi Cherem (dart-lang) 2015/12/17 01:02:57 note: i reverted a change I did here: instead of `
+ list.add(mask);
}
- return newType.containsAll(classWorld) ? dynamicType.type : newType;
+
+ TypeMask newType = null;
+ for (TypeMask mask in masks) {
+ newType = newType == null ? mask : newType.union(mask, classWorld);
+ // Likewise - stop early if we already reach dynamic.
+ if (newType.containsAll(classWorld)) return dynamicType;
+ }
+
+ return newType ?? const TypeMask.nonNullEmpty();
}
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/types/union_type_mask.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698