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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library deferred_load; 5 library deferred_load;
6 6
7 import 'common/backend_api.dart' show Backend; 7 import 'common/backend_api.dart' show Backend;
8 import 'common/tasks.dart' show CompilerTask; 8 import 'common/tasks.dart' show CompilerTask;
9 import 'common.dart'; 9 import 'common.dart';
10 import 'compiler.dart' show Compiler; 10 import 'compiler.dart' show Compiler;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 }), 329 }),
330 IMPACT_USE); 330 IMPACT_USE);
331 331
332 if (analyzableElement.resolvedAst.kind != ResolvedAstKind.PARSED) { 332 if (analyzableElement.resolvedAst.kind != ResolvedAstKind.PARSED) {
333 return; 333 return;
334 } 334 }
335 335
336 TreeElements treeElements = analyzableElement.resolvedAst.elements; 336 TreeElements treeElements = analyzableElement.resolvedAst.elements;
337 assert(treeElements != null); 337 assert(treeElements != null);
338 338
339 // TODO(johnniwinther): Add only expressions that are actually needed.
340 // Currently some potential expressions are visited that should never
341 // be added, and some implicit constant expression that should be
Siggi Cherem (dart-lang) 2016/05/09 20:03:04 rephrase? (I'm not sure I understood the last phra
Johnni Winther 2016/05/10 09:26:16 Done.
342 // allowed. See dartbug.com/26406 for context.
339 treeElements 343 treeElements
340 .forEachConstantNode((Node node, ConstantExpression expression) { 344 .forEachConstantNode((Node node, ConstantExpression expression) {
341 // Explicitly depend on the backend constants. 345 // Explicitly depend on the backend constants.
342 ConstantValue value; 346 if (backend.constants.hasConstantValue(expression)) {
343 value = backend.constants.getConstantValue(expression); 347 ConstantValue value =
344 // TODO(johnniwinther): ensure `value` is not null or use directly the 348 backend.constants.getConstantValue(expression);
345 // expression to calculate dependencies. See dartbug.com/26406 for 349 assert(invariant(node, value != null,
346 // context. 350 message: "Constant expression without value: "
347 if (value != null) { 351 "${expression.toStructuredText()}."));
348 constants.add(value); 352 constants.add(value);
353 } else {
354 assert(invariant(node,
355 expression.isImplicit || expression.isPotential,
356 message: "Unexpected unevaluated constant expression: "
357 "${expression.toStructuredText()}."));
349 } 358 }
350 }); 359 });
351 } 360 }
352 } 361 }
353 362
354 // TODO(sigurdm): How is metadata on a patch-class handled? 363 // TODO(sigurdm): How is metadata on a patch-class handled?
355 for (MetadataAnnotation metadata in element.metadata) { 364 for (MetadataAnnotation metadata in element.metadata) {
356 ConstantValue constant = 365 ConstantValue constant =
357 backend.constants.getConstantValueForMetadata(metadata); 366 backend.constants.getConstantValueForMetadata(metadata);
358 if (constant != null) { 367 if (constant != null) {
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 return result; 995 return result;
987 } 996 }
988 997
989 bool operator ==(other) { 998 bool operator ==(other) {
990 if (other is! _DeclaredDeferredImport) return false; 999 if (other is! _DeclaredDeferredImport) return false;
991 return declaration == other.declaration; 1000 return declaration == other.declaration;
992 } 1001 }
993 1002
994 int get hashCode => declaration.hashCode * 17; 1003 int get hashCode => declaration.hashCode * 17;
995 } 1004 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698