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

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

Issue 1955403002: Skip spurious constants in deferred computation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 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
Index: pkg/compiler/lib/src/deferred_load.dart
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index 6141447892f5802c8efe4f4af2bbd0affa5ab5a7..bbd91aef1d444f74a372b1eb27c0c2bb922ef55b 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -336,16 +336,28 @@ class DeferredLoadTask extends CompilerTask {
TreeElements treeElements = analyzableElement.resolvedAst.elements;
assert(treeElements != null);
+ // TODO(johnniwinther): Add only expressions that are actually needed.
+ // Currently we have some noise here: Some potential expressions are
+ // seen that should never be added (for instance field initializers
+ // in constant constructors, like `this.field = parameter`). And some
+ // implicit constant expression are seen that we should be able to add
+ // (like primitive constant literals like `true`, `"foo"` and `0`).
+ // See dartbug.com/26406 for context.
treeElements
.forEachConstantNode((Node node, ConstantExpression expression) {
// Explicitly depend on the backend constants.
- ConstantValue value;
- value = backend.constants.getConstantValue(expression);
- // TODO(johnniwinther): ensure `value` is not null or use directly the
- // expression to calculate dependencies. See dartbug.com/26406 for
- // context.
- if (value != null) {
+ if (backend.constants.hasConstantValue(expression)) {
+ ConstantValue value =
+ backend.constants.getConstantValue(expression);
+ assert(invariant(node, value != null,
+ message: "Constant expression without value: "
+ "${expression.toStructuredText()}."));
constants.add(value);
+ } else {
+ assert(invariant(node,
+ expression.isImplicit || expression.isPotential,
+ message: "Unexpected unevaluated constant expression: "
+ "${expression.toStructuredText()}."));
}
});
}
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698