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

Unified Diff: pkg/compiler/lib/src/js_emitter/metadata_collector.dart

Issue 1071133002: dart2js: create a 'types' table for each deferred unit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/js_emitter/metadata_collector.dart
diff --git a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
index 9876dacd6ace666e315f5468244f61204c14c3fb..48df1396d7382af53e862e07d1ea95a544a56915 100644
--- a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
+++ b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
@@ -15,12 +15,13 @@ class MetadataCollector {
/// A map used to canonicalize the entries of globalMetadata.
final Map<String, int> _globalMetadataMap = <String, int>{};
- /// A list of JS expression representing types including function types and
- /// typedefs.
- final List<String> types = <String>[];
+ /// A map with lists of JS expressions, one list for each output unit. The
+ /// entries represent types including function types and typedefs.
+ final Map<OutputUnit, List<String>> types = <OutputUnit, List<String>>{};
/// A map used to canonicalize the entries of types.
- final Map<String, int> _typesMap = <String, int>{};
+ final Map<OutputUnit, Map<String, int>> _typesMap =
+ <OutputUnit, Map<String, int>>{};
MetadataCollector(this._compiler, this._emitter);
@@ -91,6 +92,11 @@ class MetadataCollector {
}
int reifyType(DartType type) {
+ return reifyTypeForOutputUnit(type,
+ _compiler.deferredLoadTask.mainOutputUnit);
+ }
+
+ int reifyTypeForOutputUnit(DartType type, OutputUnit outputUnit) {
jsAst.Expression representation =
_backend.rti.getTypeRepresentation(
type,
@@ -103,8 +109,8 @@ class MetadataCollector {
return _backend.isAccessibleByReflection(typedef.element);
});
- return addType(
- jsAst.prettyPrint(representation, _compiler).getText());
+ return addTypeInOutputUnit(
+ jsAst.prettyPrint(representation, _compiler).getText(), outputUnit);
}
int reifyName(String name) {
@@ -118,10 +124,17 @@ class MetadataCollector {
});
}
- int addType(String compiledType) {
- return _typesMap.putIfAbsent(compiledType, () {
- types.add(compiledType);
- return types.length - 1;
+ int addTypeInOutputUnit(String compiledType, OutputUnit outputUnit) {
+ if (_typesMap[outputUnit] == null) {
+ _typesMap[outputUnit] = <String, int>{};
+ }
+ return _typesMap[outputUnit].putIfAbsent(compiledType, () {
+
+ if (types[outputUnit] == null)
+ types[outputUnit] = <String>[];
+
+ types[outputUnit].add(compiledType);
+ return types[outputUnit].length - 1;
});
}

Powered by Google App Engine
This is Rietveld 408576698