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

Unified Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1220043005: dart2js send stats, includes: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months 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 | « pkg/compiler/lib/src/stats/trusted_types_analysis_result.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/typechecker.dart
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index a0289a997c5fd4bd9726b7819bbb93f055bce1ea..9161102df06aa1d65ca41afbce730446967dd936 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -454,7 +454,7 @@ class TypeCheckerVisitor extends Visitor<DartType> {
if (result == null) {
compiler.internalError(node, 'Type is null.');
}
- return result;
+ return _record(node, result);
}
void checkTypePromotion(Node node, TypePromotion typePromotion,
@@ -1162,6 +1162,23 @@ class TypeCheckerVisitor extends Visitor<DartType> {
}
+ static bool _fyiShown = false;
+ DartType _record(Node node, DartType type) {
+ if (node is! Expression) return type;
+ if (const bool.fromEnvironment('send_stats') &&
+ executableContext != null &&
+ // TODO(sigmund): enable also in core libs.
+ !executableContext.library.isPlatformLibrary && !type.isDynamic) {
+ if (!_fyiShown) {
+ print('FYI experiment to collect send stats is on: '
+ 'caching types of expressions');
+ _fyiShown = true;
+ }
+ elements.typesCache[node] = type;
+ }
+ return type;
+ }
+
DartType visitSend(Send node) {
Element element = elements[node];
@@ -1735,6 +1752,17 @@ class TypeCheckerVisitor extends Visitor<DartType> {
SendSet initialization = definition;
DartType initializer = analyzeNonVoid(initialization.arguments.head);
checkAssignable(initialization.assignmentOperator, initializer, type);
+ // TODO(sigmund): explore inferring a type for `var` using the RHS (like
+ // DDC does), for example:
+ // if (node.type == null && node.modifiers.isVar &&
+ // !initializer.isDynamic) {
+ // var variable = elements[definition];
+ // if (variable != null) {
+ // var typePromotion = new TypePromotion(
+ // node, variable, initializer);
+ // registerKnownTypePromotion(typePromotion);
+ // }
+ // }
}
}
return const StatementType();
« no previous file with comments | « pkg/compiler/lib/src/stats/trusted_types_analysis_result.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698