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

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

Issue 795923003: Dart2js, move deferred global vars to the right output unit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status files 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 } 987 }
988 988
989 void emitStaticFunctions(List<Element> staticFunctions) { 989 void emitStaticFunctions(List<Element> staticFunctions) {
990 for (Element element in staticFunctions) { 990 for (Element element in staticFunctions) {
991 ClassBuilder builder = new ClassBuilder(element, namer); 991 ClassBuilder builder = new ClassBuilder(element, namer);
992 containerBuilder.addMember(element, builder); 992 containerBuilder.addMember(element, builder);
993 getElementDescriptor(element).properties.addAll(builder.properties); 993 getElementDescriptor(element).properties.addAll(builder.properties);
994 } 994 }
995 } 995 }
996 996
997 void emitStaticNonFinalFieldInitializations(CodeBuffer buffer) { 997 void emitStaticNonFinalFieldInitializations(CodeBuffer buffer,
998 OutputUnit outputUnit) {
998 JavaScriptConstantCompiler handler = backend.constants; 999 JavaScriptConstantCompiler handler = backend.constants;
999 Iterable<VariableElement> staticNonFinalFields = 1000 Iterable<VariableElement> staticNonFinalFields =
1000 handler.getStaticNonFinalFieldsForEmission(); 1001 handler.getStaticNonFinalFieldsForEmission();
1001 for (Element element in Elements.sortedByPosition(staticNonFinalFields)) { 1002 for (Element element in Elements.sortedByPosition(staticNonFinalFields)) {
1002 // [:interceptedNames:] is handled in [emitInterceptedNames]. 1003 // [:interceptedNames:] is handled in [emitInterceptedNames].
1003 if (element == backend.interceptedNames) continue; 1004 if (element == backend.interceptedNames) continue;
1004 // `mapTypeToInterceptor` is handled in [emitMapTypeToInterceptor]. 1005 // `mapTypeToInterceptor` is handled in [emitMapTypeToInterceptor].
1005 if (element == backend.mapTypeToInterceptor) continue; 1006 if (element == backend.mapTypeToInterceptor) continue;
1007 OutputUnit ou = compiler.deferredLoadTask.outputUnitForElement(element);
floitsch 2014/12/11 09:46:28 Don't use "ou".
sigurdm 2014/12/11 13:28:50 Done.
1008 if (ou != outputUnit) continue;
floitsch 2014/12/11 09:46:28 Don't always continue. If it's the main output uni
sigurdm 2014/12/11 13:28:50 Done.
1006 compiler.withCurrentElement(element, () { 1009 compiler.withCurrentElement(element, () {
1007 ConstantValue initialValue = handler.getInitialValueFor(element).value; 1010 ConstantValue initialValue = handler.getInitialValueFor(element).value;
1008 jsAst.Expression init = 1011 jsAst.Expression init =
1009 js('$isolateProperties.# = #', 1012 js('$isolateProperties.# = #',
1010 [namer.getNameOfGlobalField(element), 1013 [namer.getNameOfGlobalField(element),
1011 constantEmitter.referenceInInitializationContext(initialValue)]); 1014 constantEmitter.referenceInInitializationContext(initialValue)]);
1012 buffer.write(jsAst.prettyPrint(init, compiler, 1015 buffer.write(jsAst.prettyPrint(init, compiler,
1013 monitor: compiler.dumpInfoTask)); 1016 monitor: compiler.dumpInfoTask));
1014 buffer.write('$N'); 1017 buffer.write('$N');
1015 }); 1018 });
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 // Constants in checked mode call into RTI code to set type information 1666 // Constants in checked mode call into RTI code to set type information
1664 // which may need getInterceptor (and one-shot interceptor) methods, so 1667 // which may need getInterceptor (and one-shot interceptor) methods, so
1665 // we have to make sure that [emitGetInterceptorMethods] and 1668 // we have to make sure that [emitGetInterceptorMethods] and
1666 // [emitOneShotInterceptors] have been called. 1669 // [emitOneShotInterceptors] have been called.
1667 emitCompileTimeConstants(mainBuffer, mainOutputUnit); 1670 emitCompileTimeConstants(mainBuffer, mainOutputUnit);
1668 1671
1669 emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes); 1672 emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes);
1670 1673
1671 // Static field initializations require the classes and compile-time 1674 // Static field initializations require the classes and compile-time
1672 // constants to be set up. 1675 // constants to be set up.
1673 emitStaticNonFinalFieldInitializations(mainBuffer); 1676 emitStaticNonFinalFieldInitializations(mainBuffer, mainOutputUnit);
1674 interceptorEmitter.emitInterceptedNames(mainBuffer); 1677 interceptorEmitter.emitInterceptedNames(mainBuffer);
1675 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer); 1678 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer);
1676 emitLazilyInitializedStaticFields(mainBuffer); 1679 emitLazilyInitializedStaticFields(mainBuffer);
1677 1680
1678 mainBuffer.writeln(); 1681 mainBuffer.writeln();
1679 mainBuffer.add(nativeBuffer); 1682 mainBuffer.add(nativeBuffer);
1680 1683
1681 metadataEmitter.emitMetadata(mainBuffer); 1684 metadataEmitter.emitMetadata(mainBuffer);
1682 1685
1683 isolateProperties = isolatePropertiesName; 1686 isolateProperties = isolatePropertiesName;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 // the isolate-properties and for storing the current isolate. During 2108 // the isolate-properties and for storing the current isolate. During
2106 // the setup (the code above this lines) we must set the variable to 2109 // the setup (the code above this lines) we must set the variable to
2107 // the isolate-properties. 2110 // the isolate-properties.
2108 // After we have done the setup (finishing with `finishClasses`) it must 2111 // After we have done the setup (finishing with `finishClasses`) it must
2109 // point to the current Isolate. Otherwise all methods/functions 2112 // point to the current Isolate. Otherwise all methods/functions
2110 // accessing isolate variables will access the wrong object. 2113 // accessing isolate variables will access the wrong object.
2111 outputBuffer.write("${namer.currentIsolate}$_=${_}arguments[1]$N"); 2114 outputBuffer.write("${namer.currentIsolate}$_=${_}arguments[1]$N");
2112 typeTestEmitter.emitRuntimeTypeSupport(outputBuffer, outputUnit); 2115 typeTestEmitter.emitRuntimeTypeSupport(outputBuffer, outputUnit);
2113 2116
2114 emitCompileTimeConstants(outputBuffer, outputUnit); 2117 emitCompileTimeConstants(outputBuffer, outputUnit);
2118 emitStaticNonFinalFieldInitializations(outputBuffer, outputUnit);
2115 outputBuffer.write('}$N'); 2119 outputBuffer.write('}$N');
2116 2120
2117 if (compiler.useContentSecurityPolicy) { 2121 if (compiler.useContentSecurityPolicy) {
2118 jsAst.FunctionDeclaration precompiledFunctionAst = 2122 jsAst.FunctionDeclaration precompiledFunctionAst =
2119 buildCspPrecompiledFunctionFor(outputUnit); 2123 buildCspPrecompiledFunctionFor(outputUnit);
2120 2124
2121 outputBuffer.write( 2125 outputBuffer.write(
2122 jsAst.prettyPrint( 2126 jsAst.prettyPrint(
2123 precompiledFunctionAst, compiler, 2127 precompiledFunctionAst, compiler,
2124 monitor: compiler.dumpInfoTask, 2128 monitor: compiler.dumpInfoTask,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2201 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2198 if (element.isInstanceMember) { 2202 if (element.isInstanceMember) {
2199 cachedClassBuilders.remove(element.enclosingClass); 2203 cachedClassBuilders.remove(element.enclosingClass);
2200 2204
2201 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2205 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2202 2206
2203 } 2207 }
2204 } 2208 }
2205 } 2209 }
2206 } 2210 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698