OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
8 | 8 |
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 */ | 1186 */ |
1187 String assembleCode(Element element) { | 1187 String assembleCode(Element element) { |
1188 assert(invariant(element, element.isDeclaration)); | 1188 assert(invariant(element, element.isDeclaration)); |
1189 return jsAst.prettyPrint(generatedCode[element], compiler).getText(); | 1189 return jsAst.prettyPrint(generatedCode[element], compiler).getText(); |
1190 } | 1190 } |
1191 | 1191 |
1192 void assembleProgram() { | 1192 void assembleProgram() { |
1193 emitter.assembleProgram(); | 1193 emitter.assembleProgram(); |
1194 int totalMethodCount = generatedCode.length; | 1194 int totalMethodCount = generatedCode.length; |
1195 if (totalMethodCount != preMirrorsMethodCount) { | 1195 if (totalMethodCount != preMirrorsMethodCount) { |
1196 int mirrorCount = totalMethodCount - preMirrorsMethodCount; | 1196 bool reportedHint = false; |
1197 double percentage = (mirrorCount / totalMethodCount) * 100; | |
1198 compiler.reportHint( | |
1199 compiler.mainApp, MessageKind.MIRROR_BLOAT, | |
1200 {'count': mirrorCount, | |
1201 'total': totalMethodCount, | |
1202 'percentage': percentage.round()}); | |
1203 for (LibraryElement library in compiler.libraries.values) { | 1197 for (LibraryElement library in compiler.libraries.values) { |
1204 if (library.isInternalLibrary) continue; | 1198 if (library.isInternalLibrary) continue; |
1205 for (LibraryTag tag in library.tags) { | 1199 for (LibraryTag tag in library.tags) { |
1206 Import importTag = tag.asImport(); | 1200 Import importTag = tag.asImport(); |
1207 if (importTag == null) continue; | 1201 if (importTag == null) continue; |
1208 LibraryElement importedLibrary = library.getLibraryFromTag(tag); | 1202 LibraryElement importedLibrary = library.getLibraryFromTag(tag); |
1209 if (importedLibrary != compiler.mirrorsLibrary) continue; | 1203 if (importedLibrary != compiler.mirrorsLibrary) continue; |
| 1204 if (!reportedHint) { |
| 1205 reportedHint = true; |
| 1206 int mirrorCount = totalMethodCount - preMirrorsMethodCount; |
| 1207 double percentage = (mirrorCount / totalMethodCount) * 100; |
| 1208 compiler.reportHint( |
| 1209 compiler.mainApp, MessageKind.MIRROR_BLOAT, |
| 1210 {'count': mirrorCount, |
| 1211 'total': totalMethodCount, |
| 1212 'percentage': percentage.round()}); |
| 1213 } |
1210 MessageKind kind = | 1214 MessageKind kind = |
1211 compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library) | 1215 compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library) |
1212 ? MessageKind.MIRROR_IMPORT | 1216 ? MessageKind.MIRROR_IMPORT |
1213 : MessageKind.MIRROR_IMPORT_NO_USAGE; | 1217 : MessageKind.MIRROR_IMPORT_NO_USAGE; |
1214 compiler.withCurrentElement(library, () { | 1218 compiler.withCurrentElement(library, () { |
1215 compiler.reportInfo(importTag, kind); | 1219 compiler.reportInfo(importTag, kind); |
1216 }); | 1220 }); |
1217 } | 1221 } |
1218 } | 1222 } |
1219 } | 1223 } |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 copy(constant.values); | 1921 copy(constant.values); |
1918 copy(constant.protoValue); | 1922 copy(constant.protoValue); |
1919 copy(constant); | 1923 copy(constant); |
1920 } | 1924 } |
1921 | 1925 |
1922 void visitConstructed(ConstructedConstant constant) { | 1926 void visitConstructed(ConstructedConstant constant) { |
1923 copy(constant.fields); | 1927 copy(constant.fields); |
1924 copy(constant); | 1928 copy(constant); |
1925 } | 1929 } |
1926 } | 1930 } |
OLD | NEW |