| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 static const checkedModeHelpers = CheckedModeHelper.helpers; | 275 static const checkedModeHelpers = CheckedModeHelper.helpers; |
| 276 | 276 |
| 277 // Checked mode helpers indexed by name. | 277 // Checked mode helpers indexed by name. |
| 278 Map<String, CheckedModeHelper> checkedModeHelperByName = | 278 Map<String, CheckedModeHelper> checkedModeHelperByName = |
| 279 new Map<String, CheckedModeHelper>.fromIterable( | 279 new Map<String, CheckedModeHelper>.fromIterable( |
| 280 checkedModeHelpers, | 280 checkedModeHelpers, |
| 281 key: (helper) => helper.name); | 281 key: (helper) => helper.name); |
| 282 | 282 |
| 283 TypeVariableHandler typeVariableHandler; | 283 TypeVariableHandler typeVariableHandler; |
| 284 | 284 |
| 285 static const bool DUMP_DEPENDENCIES = |
| 286 const bool.fromEnvironment('DUMP_DEPENDENCIES'); |
| 287 |
| 285 /// Number of methods compiled before considering reflection. | 288 /// Number of methods compiled before considering reflection. |
| 286 int preMirrorsMethodCount = 0; | 289 int preMirrorsMethodCount = 0; |
| 287 | 290 |
| 288 /// Resolution and codegen support for generating table of interceptors and | 291 /// Resolution and codegen support for generating table of interceptors and |
| 289 /// constructors for custom elements. | 292 /// constructors for custom elements. |
| 290 CustomElementsAnalysis customElementsAnalysis; | 293 CustomElementsAnalysis customElementsAnalysis; |
| 291 | 294 |
| 292 JavaScriptConstantTask constantCompilerTask; | 295 JavaScriptConstantTask constantCompilerTask; |
| 293 | 296 |
| 294 JavaScriptBackend(Compiler compiler, bool generateSourceMap) | 297 JavaScriptBackend(Compiler compiler, bool generateSourceMap) |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 // Unconditionally register the helper that checks if the | 860 // Unconditionally register the helper that checks if the |
| 858 // expression in an if/while/for is a boolean. | 861 // expression in an if/while/for is a boolean. |
| 859 // TODO(ngeoffray): Should we have the resolver register those instead? | 862 // TODO(ngeoffray): Should we have the resolver register those instead? |
| 860 Element e = | 863 Element e = |
| 861 compiler.findHelper('boolConversionCheck'); | 864 compiler.findHelper('boolConversionCheck'); |
| 862 if (e != null) enqueue(world, e, registry); | 865 if (e != null) enqueue(world, e, registry); |
| 863 } | 866 } |
| 864 registerCheckedModeHelpers(registry); | 867 registerCheckedModeHelpers(registry); |
| 865 } | 868 } |
| 866 | 869 |
| 867 onResolutionComplete() => rti.computeClassesNeedingRti(); | 870 onResolutionComplete() { |
| 871 super.onResolutionComplete(); |
| 872 rti.computeClassesNeedingRti(); |
| 873 } |
| 868 | 874 |
| 869 void onStringInterpolation(Registry registry) { | 875 void onStringInterpolation(Registry registry) { |
| 870 assert(registry.isForResolution); | 876 assert(registry.isForResolution); |
| 871 registerBackendStaticInvocation(getStringInterpolationHelper(), registry); | 877 registerBackendStaticInvocation(getStringInterpolationHelper(), registry); |
| 872 } | 878 } |
| 873 | 879 |
| 874 void onCatchStatement(Registry registry) { | 880 void onCatchStatement(Registry registry) { |
| 875 assert(registry.isForResolution); | 881 assert(registry.isForResolution); |
| 876 registerBackendStaticInvocation(getExceptionUnwrapper(), registry); | 882 registerBackendStaticInvocation(getExceptionUnwrapper(), registry); |
| 877 registerBackendInstantiation(jsPlainJavaScriptObjectClass, registry); | 883 registerBackendInstantiation(jsPlainJavaScriptObjectClass, registry); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 assert(registry.isForResolution); | 1090 assert(registry.isForResolution); |
| 1085 registerBackendStaticInvocation(getFallThroughError(), registry); | 1091 registerBackendStaticInvocation(getFallThroughError(), registry); |
| 1086 } | 1092 } |
| 1087 | 1093 |
| 1088 void registerCheckDeferredIsLoaded(Registry registry) { | 1094 void registerCheckDeferredIsLoaded(Registry registry) { |
| 1089 enqueueInResolution(getCheckDeferredIsLoaded(), registry); | 1095 enqueueInResolution(getCheckDeferredIsLoaded(), registry); |
| 1090 // Also register the types of the arguments passed to this method. | 1096 // Also register the types of the arguments passed to this method. |
| 1091 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); | 1097 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); |
| 1092 } | 1098 } |
| 1093 | 1099 |
| 1094 void enableNoSuchMethod(Enqueuer world) { | 1100 void enableNoSuchMethod(context, Enqueuer world) { |
| 1095 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); | 1101 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); |
| 1096 world.registerInvocation(compiler.noSuchMethodSelector); | 1102 world.registerInvocation(context, compiler.noSuchMethodSelector); |
| 1097 } | 1103 } |
| 1098 | 1104 |
| 1099 void onSuperNoSuchMethod(Registry registry) { | 1105 void onSuperNoSuchMethod(Registry registry) { |
| 1100 assert(registry.isForResolution); | 1106 assert(registry.isForResolution); |
| 1101 registerBackendStaticInvocation(getCreateInvocationMirror(), registry); | 1107 registerBackendStaticInvocation(getCreateInvocationMirror(), registry); |
| 1102 registerBackendStaticInvocation( | 1108 registerBackendStaticInvocation( |
| 1103 compiler.objectClass.lookupLocalMember(Compiler.NO_SUCH_METHOD), | 1109 compiler.objectClass.lookupLocalMember(Compiler.NO_SUCH_METHOD), |
| 1104 registry); | 1110 registry); |
| 1105 registerBackendInstantiation(compiler.listClass, registry); | 1111 registerBackendInstantiation(compiler.listClass, registry); |
| 1106 } | 1112 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 MessageKind kind = | 1299 MessageKind kind = |
| 1294 compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library) | 1300 compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library) |
| 1295 ? MessageKind.MIRROR_IMPORT | 1301 ? MessageKind.MIRROR_IMPORT |
| 1296 : MessageKind.MIRROR_IMPORT_NO_USAGE; | 1302 : MessageKind.MIRROR_IMPORT_NO_USAGE; |
| 1297 compiler.withCurrentElement(library, () { | 1303 compiler.withCurrentElement(library, () { |
| 1298 compiler.reportInfo(importTag, kind); | 1304 compiler.reportInfo(importTag, kind); |
| 1299 }); | 1305 }); |
| 1300 } | 1306 } |
| 1301 } | 1307 } |
| 1302 } | 1308 } |
| 1309 if (true && DUMP_DEPENDENCIES) { |
| 1310 String representation(object) { |
| 1311 return "'$object'"; |
| 1312 } |
| 1313 EventSink<String> output = compiler.outputProvider("", "pl"); |
| 1314 [compiler.enqueuer.resolution, compiler.enqueuer.codegen].forEach((e) { |
| 1315 Relations deps = e.dependencies; |
| 1316 for (String relation in deps.links.keys) { |
| 1317 output.add('${deps.prefix}_$relation().\n'); |
| 1318 } |
| 1319 }); |
| 1320 output.close(); |
| 1321 } |
| 1303 } | 1322 } |
| 1304 | 1323 |
| 1305 Element getDartClass(Element element) { | 1324 Element getDartClass(Element element) { |
| 1306 for (ClassElement dartClass in implementationClasses.keys) { | 1325 for (ClassElement dartClass in implementationClasses.keys) { |
| 1307 if (element == implementationClasses[dartClass]) { | 1326 if (element == implementationClasses[dartClass]) { |
| 1308 return dartClass; | 1327 return dartClass; |
| 1309 } | 1328 } |
| 1310 } | 1329 } |
| 1311 return element; | 1330 return element; |
| 1312 } | 1331 } |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 } | 1974 } |
| 1956 | 1975 |
| 1957 /// Records that [constant] is used by the element behind [registry]. | 1976 /// Records that [constant] is used by the element behind [registry]. |
| 1958 class Dependency { | 1977 class Dependency { |
| 1959 final Constant constant; | 1978 final Constant constant; |
| 1960 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. | 1979 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. |
| 1961 final Registry registry; | 1980 final Registry registry; |
| 1962 | 1981 |
| 1963 const Dependency(this.constant, this.registry); | 1982 const Dependency(this.constant, this.registry); |
| 1964 } | 1983 } |
| OLD | NEW |