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

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

Issue 760383003: Incremental compilation of constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42279 and CL 760383003. Created 6 years 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 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 if (constants == null) return; 1103 if (constants == null) return;
1104 bool isMainBuffer = buffer == mainBuffer; 1104 bool isMainBuffer = buffer == mainBuffer;
1105 if (compiler.hasIncrementalSupport && isMainBuffer) { 1105 if (compiler.hasIncrementalSupport && isMainBuffer) {
1106 buffer = cachedEmittedConstantsBuffer; 1106 buffer = cachedEmittedConstantsBuffer;
1107 } 1107 }
1108 for (ConstantValue constant in constants) { 1108 for (ConstantValue constant in constants) {
1109 if (compiler.hasIncrementalSupport && isMainBuffer) { 1109 if (compiler.hasIncrementalSupport && isMainBuffer) {
1110 if (cachedEmittedConstants.contains(constant)) continue; 1110 if (cachedEmittedConstants.contains(constant)) continue;
1111 cachedEmittedConstants.add(constant); 1111 cachedEmittedConstants.add(constant);
1112 } 1112 }
1113 String name = namer.constantName(constant); 1113 jsAst.Expression init = buildConstantInitializer(constant);
1114 jsAst.Expression init = js('#.# = #',
1115 [namer.globalObjectForConstant(constant), name,
1116 constantInitializerExpression(constant)]);
1117 buffer.write(jsAst.prettyPrint(init, compiler, 1114 buffer.write(jsAst.prettyPrint(init, compiler,
1118 monitor: compiler.dumpInfoTask)); 1115 monitor: compiler.dumpInfoTask));
1119 buffer.write('$N'); 1116 buffer.write('$N');
1120 } 1117 }
1121 if (compiler.hasIncrementalSupport && isMainBuffer) { 1118 if (compiler.hasIncrementalSupport && isMainBuffer) {
1122 mainBuffer.add(cachedEmittedConstantsBuffer); 1119 mainBuffer.add(cachedEmittedConstantsBuffer);
1123 } 1120 }
1124 } 1121 }
1125 1122
1123 jsAst.Expression buildConstantInitializer(ConstantValue constant) {
1124 String name = namer.constantName(constant);
1125 return js('#.# = #',
1126 [namer.globalObjectForConstant(constant), name,
1127 constantInitializerExpression(constant)]);
1128 }
1129
1126 jsAst.Template get makeConstantListTemplate { 1130 jsAst.Template get makeConstantListTemplate {
1127 // TODO(floitsch): there is no harm in caching the template. 1131 // TODO(floitsch): there is no harm in caching the template.
1128 return jsAst.js.uncachedExpressionTemplate( 1132 return jsAst.js.uncachedExpressionTemplate(
1129 '${namer.isolateName}.$makeConstListProperty(#)'); 1133 '${namer.isolateName}.$makeConstListProperty(#)');
1130 } 1134 }
1131 1135
1132 void emitMakeConstantList(CodeBuffer buffer) { 1136 void emitMakeConstantList(CodeBuffer buffer) {
1133 buffer.write( 1137 buffer.write(
1134 jsAst.prettyPrint( 1138 jsAst.prettyPrint(
1135 // Functions are stored in the hidden class and not as properties in 1139 // Functions are stored in the hidden class and not as properties in
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2220 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2217 if (element.isInstanceMember) { 2221 if (element.isInstanceMember) {
2218 cachedClassBuilders.remove(element.enclosingClass); 2222 cachedClassBuilders.remove(element.enclosingClass);
2219 2223
2220 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2224 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2221 2225
2222 } 2226 }
2223 } 2227 }
2224 } 2228 }
2225 } 2229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698