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

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.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/old_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
index d16d5c577b289c305f8aeb9d7dfced27f416d064..46bc7531a5b266abaa0bc35a9f67bdd0a8186467 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
@@ -571,26 +571,39 @@ class OldEmitter implements Emitter {
}
}
- void emitMetadata(Program program, CodeOutput output) {
-
- addMetadataGlobal(List<String> list, String global) {
- String globalAccess = generateEmbeddedGlobalAccessString(global);
- output.add('$globalAccess$_=$_[');
- for (String data in list) {
- if (data is String) {
- if (data != 'null') {
- output.add(data);
- }
- } else {
- throw 'Unexpected value in ${global}: ${Error.safeToString(data)}';
- }
- output.add(',$n');
- }
- output.add('];$n');
- }
+ void emitMetadata(Program program, CodeOutput output, OutputUnit outputUnit) {
+
+ addMetadata(List<String> list, String listAccess) {
+ output.add('$listAccess$_=$_[');
+ if (list != null) {
+ for (String data in list) {
+ if (data is String) {
+ if (data != 'null') {
+ output.add(data);
+ }
+ } else {
+ throw 'Unexpected value in ${listAccess}: '
sigurdm 2015/04/09 13:00:15 Make this an assert
zarah 2015/04/10 10:56:03 Changed the code. See below.
+ '${Error.safeToString(data)}';
+ }
+ output.add(',$n');
+ }
+ }
+ output.add('];$n');
sigurdm 2015/04/09 13:00:15 Again here you could let listaccess be a js-expres
zarah 2015/04/10 10:56:03 Done.
+ }
- addMetadataGlobal(program.metadata, embeddedNames.METADATA);
- addMetadataGlobal(program.metadataTypes, embeddedNames.TYPES);
+ List<String> types = program.metadataTypes[outputUnit];
+ List<String> metadata = program.metadata;
+
+ if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) {
+ addMetadata(metadata,
+ generateEmbeddedGlobalAccessString(embeddedNames.METADATA));
+ addMetadata(types,
+ generateEmbeddedGlobalAccessString(embeddedNames.TYPES));
+ } else {
+ if (types != null) {
+ addMetadata(types, 'var ${namer.deferredTypesName}');
+ }
+ }
}
void emitCompileTimeConstants(CodeOutput output,
@@ -1259,7 +1272,7 @@ class OldEmitter implements Emitter {
mainOutput.add(N);
}
- mainOutput.add('$setupProgramName(dart)$N');
+ mainOutput.add('$setupProgramName(dart, 0)$N');
interceptorEmitter.emitGetInterceptorMethods(mainOutput);
interceptorEmitter.emitOneShotInterceptors(mainOutput);
@@ -1289,7 +1302,7 @@ class OldEmitter implements Emitter {
mainOutput.add('\n');
- emitMetadata(program, mainOutput);
+ emitMetadata(program, mainOutput, mainOutputUnit);
isolateProperties = isolatePropertiesName;
// The following code should not use the short-hand for the
@@ -1695,6 +1708,8 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) {
'$globalsHolder.$setupProgramName$N')
..add('var ${namer.isolateName}$_=$_'
'${globalsHolder}.${namer.isolateName}$N');
+ String typesAccess =
+ generateEmbeddedGlobalAccessString(embeddedNames.TYPES);
if (libraryDescriptorBuffer != null) {
// TODO(ahe): This defines a lot of properties on the
// Isolate.prototype object. We know this will turn it into a
@@ -1720,7 +1735,13 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) {
allowVariableMinification: false));
output.add(N);
}
- output.add('$setupProgramName(dart)$N');
+ output.add('$setupProgramName(dart, ${typesAccess}.length)$N');
+ }
+
+ if (task.metadataCollector.types[outputUnit] != null) {
+ emitMetadata(program, output, outputUnit);
+ output.add('${typesAccess}.'
+ 'push.apply(${typesAccess},$_${namer.deferredTypesName})$N');
}
// Set the currentIsolate variable to the current isolate (which is

Powered by Google App Engine
This is Rietveld 408576698