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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 785303003: Add option for outputting a deferred loading mapping. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Whitespace Created 5 years, 11 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 | Annotate | Revision Log
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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 } 1726 }
1727 1727
1728 // Constants in checked mode call into RTI code to set type information 1728 // Constants in checked mode call into RTI code to set type information
1729 // which may need getInterceptor (and one-shot interceptor) methods, so 1729 // which may need getInterceptor (and one-shot interceptor) methods, so
1730 // we have to make sure that [emitGetInterceptorMethods] and 1730 // we have to make sure that [emitGetInterceptorMethods] and
1731 // [emitOneShotInterceptors] have been called. 1731 // [emitOneShotInterceptors] have been called.
1732 emitCompileTimeConstants(mainBuffer, mainOutputUnit); 1732 emitCompileTimeConstants(mainBuffer, mainOutputUnit);
1733 1733
1734 emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes); 1734 emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes);
1735 1735
1736 if (compiler.deferredMapUri != null) {
1737 outputDeferredMap();
1738 }
1739
1736 // Static field initializations require the classes and compile-time 1740 // Static field initializations require the classes and compile-time
1737 // constants to be set up. 1741 // constants to be set up.
1738 emitStaticNonFinalFieldInitializations(mainBuffer, mainOutputUnit); 1742 emitStaticNonFinalFieldInitializations(mainBuffer, mainOutputUnit);
1739 interceptorEmitter.emitInterceptedNames(mainBuffer); 1743 interceptorEmitter.emitInterceptedNames(mainBuffer);
1740 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer); 1744 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer);
1741 emitLazilyInitializedStaticFields(mainBuffer); 1745 emitLazilyInitializedStaticFields(mainBuffer);
1742 1746
1743 mainBuffer.writeln(); 1747 mainBuffer.writeln();
1744 mainBuffer.write(nativeBuffer); 1748 mainBuffer.write(nativeBuffer);
1745 1749
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 SourceFile compiledFile = new StringSourceFile(null, code); 2267 SourceFile compiledFile = new StringSourceFile(null, code);
2264 SourceMapBuilder sourceMapBuilder = 2268 SourceMapBuilder sourceMapBuilder =
2265 new SourceMapBuilder(sourceMapUri, fileUri, compiledFile); 2269 new SourceMapBuilder(sourceMapUri, fileUri, compiledFile);
2266 buffer.forEachSourceLocation(sourceMapBuilder.addMapping); 2270 buffer.forEachSourceLocation(sourceMapBuilder.addMapping);
2267 String sourceMap = sourceMapBuilder.build(); 2271 String sourceMap = sourceMapBuilder.build();
2268 compiler.outputProvider(name, 'js.map') 2272 compiler.outputProvider(name, 'js.map')
2269 ..add(sourceMap) 2273 ..add(sourceMap)
2270 ..close(); 2274 ..close();
2271 } 2275 }
2272 2276
2277 void outputDeferredMap() {
2278 Map mapping = new Map();
floitsch 2015/01/05 14:10:38 types.
sigurdm 2015/01/05 15:23:08 I changed it to Map<String, dynamic> If we want th
2279 // Json does not support comments, so we embed the explanation in the
2280 // data.
2281 mapping["_comment"] = "This mapping shows which compiled `.js` files are "
2282 "needed for a given deferred library import.";
2283 mapping.addAll(compiler.deferredLoadTask.deferredMap());
2284 compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map')
2285 ..add(const JsonEncoder.withIndent(" ").convert(mapping))
2286 ..close();
2287 }
2288
2273 void invalidateCaches() { 2289 void invalidateCaches() {
2274 if (!compiler.hasIncrementalSupport) return; 2290 if (!compiler.hasIncrementalSupport) return;
2275 if (cachedElements.isEmpty) return; 2291 if (cachedElements.isEmpty) return;
2276 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2292 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2277 if (element.isInstanceMember) { 2293 if (element.isInstanceMember) {
2278 cachedClassBuilders.remove(element.enclosingClass); 2294 cachedClassBuilders.remove(element.enclosingClass);
2279 2295
2280 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2296 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2281 2297
2282 } 2298 }
2283 } 2299 }
2284 } 2300 }
2285 } 2301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698