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

Unified Diff: dart/tests/compiler/dart2js/mirrors_used_test.dart

Issue 22896003: Only retain needed metadata constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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: dart/tests/compiler/dart2js/mirrors_used_test.dart
diff --git a/dart/tests/compiler/dart2js/mirrors_used_test.dart b/dart/tests/compiler/dart2js/mirrors_used_test.dart
index fc77fdff9de9983d61ffeab47ae7e109becd8eb4..04797d5a024c2ab03f680bab7df615288dbe9e83 100644
--- a/dart/tests/compiler/dart2js/mirrors_used_test.dart
+++ b/dart/tests/compiler/dart2js/mirrors_used_test.dart
@@ -15,7 +15,9 @@ import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show
Compiler;
import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show
- SourceString;
+ Constant,
+ SourceString,
+ TypeConstant;
import
'../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart'
@@ -84,6 +86,36 @@ void main() {
}
});
}
+
+ // There should at least be three metadata constants:
+ // 1. The type literal 'Foo'.
+ // 2. The list 'const [Foo]'.
+ // 3. The constructed constant for 'MirrorsUsed'.
+ Expect.isTrue(compiler.metadataHandler.compiledConstants.length >= 3);
+
+ // Make sure that most of the metadata constants aren't included in the
+ // generated code.
+ for (Constant constant in compiler.metadataHandler.compiledConstants) {
+ if (constant is TypeConstant && '${constant.representedType}' == 'Foo') {
+ // The type literal 'Foo' is retained as a constant because it is being
+ // passed to reflectClass.
+ continue;
+ }
+ Expect.isFalse(
+ compiler.constantHandler.compiledConstants.contains(constant),
+ '$constant');
+ }
+
+ // The type literal 'Foo' is both used as metadata, and as a plain value in
+ // the program. Make sure that it isn't duplicated.
+ int fooConstantCount = 0;
+ for (Constant constant in compiler.metadataHandler.compiledConstants) {
+ if (constant is TypeConstant && '${constant.representedType}' == 'Foo') {
+ fooConstantCount++;
+ }
+ }
+ Expect.equals(
+ 1, fooConstantCount, "The type literal 'Foo' is duplicated or missing.");
}
const MEMORY_SOURCE_FILES = const <String, String> {

Powered by Google App Engine
This is Rietveld 408576698