| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 static final Uri DART_FOREIGN_HELPER = | 226 static final Uri DART_FOREIGN_HELPER = |
| 227 new Uri(scheme: 'dart', path: '_foreign_helper'); | 227 new Uri(scheme: 'dart', path: '_foreign_helper'); |
| 228 static final Uri DART_JS_MIRRORS = | 228 static final Uri DART_JS_MIRRORS = |
| 229 new Uri(scheme: 'dart', path: '_js_mirrors'); | 229 new Uri(scheme: 'dart', path: '_js_mirrors'); |
| 230 static final Uri DART_JS_NAMES = | 230 static final Uri DART_JS_NAMES = |
| 231 new Uri(scheme: 'dart', path: '_js_names'); | 231 new Uri(scheme: 'dart', path: '_js_names'); |
| 232 static final Uri DART_EMBEDDED_NAMES = | 232 static final Uri DART_EMBEDDED_NAMES = |
| 233 new Uri(scheme: 'dart', path: '_js_embedded_names'); | 233 new Uri(scheme: 'dart', path: '_js_embedded_names'); |
| 234 static final Uri DART_ISOLATE_HELPER = | 234 static final Uri DART_ISOLATE_HELPER = |
| 235 new Uri(scheme: 'dart', path: '_isolate_helper'); | 235 new Uri(scheme: 'dart', path: '_isolate_helper'); |
| 236 static final Uri PACKAGE_JS = |
| 237 new Uri(scheme: 'package', path: 'js/js.dart'); |
| 236 | 238 |
| 237 static const String INVOKE_ON = '_getCachedInvocation'; | 239 static const String INVOKE_ON = '_getCachedInvocation'; |
| 238 static const String START_ROOT_ISOLATE = 'startRootIsolate'; | 240 static const String START_ROOT_ISOLATE = 'startRootIsolate'; |
| 239 | 241 |
| 240 | 242 |
| 241 String get patchVersion => emitter.patchVersion; | 243 String get patchVersion => emitter.patchVersion; |
| 242 | 244 |
| 243 bool get supportsReflection => emitter.emitter.supportsReflection; | 245 bool get supportsReflection => emitter.emitter.supportsReflection; |
| 244 | 246 |
| 245 final Annotations annotations; | 247 final Annotations annotations; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 ClassElement jsInterceptorClass; | 284 ClassElement jsInterceptorClass; |
| 283 ClassElement jsStringClass; | 285 ClassElement jsStringClass; |
| 284 ClassElement jsArrayClass; | 286 ClassElement jsArrayClass; |
| 285 ClassElement jsNumberClass; | 287 ClassElement jsNumberClass; |
| 286 ClassElement jsIntClass; | 288 ClassElement jsIntClass; |
| 287 ClassElement jsDoubleClass; | 289 ClassElement jsDoubleClass; |
| 288 ClassElement jsNullClass; | 290 ClassElement jsNullClass; |
| 289 ClassElement jsBoolClass; | 291 ClassElement jsBoolClass; |
| 290 ClassElement jsPlainJavaScriptObjectClass; | 292 ClassElement jsPlainJavaScriptObjectClass; |
| 291 ClassElement jsUnknownJavaScriptObjectClass; | 293 ClassElement jsUnknownJavaScriptObjectClass; |
| 294 ClassElement jsJavaScriptFunctionClass; |
| 295 ClassElement jsJavaScriptObjectClass; |
| 292 | 296 |
| 293 ClassElement jsIndexableClass; | 297 ClassElement jsIndexableClass; |
| 294 ClassElement jsMutableIndexableClass; | 298 ClassElement jsMutableIndexableClass; |
| 295 | 299 |
| 296 ClassElement jsMutableArrayClass; | 300 ClassElement jsMutableArrayClass; |
| 297 ClassElement jsFixedArrayClass; | 301 ClassElement jsFixedArrayClass; |
| 298 ClassElement jsExtendableArrayClass; | 302 ClassElement jsExtendableArrayClass; |
| 299 ClassElement jsUnmodifiableArrayClass; | 303 ClassElement jsUnmodifiableArrayClass; |
| 300 ClassElement jsPositiveIntClass; | 304 ClassElement jsPositiveIntClass; |
| 301 ClassElement jsUInt32Class; | 305 ClassElement jsUInt32Class; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 319 ConstructorElement mapLiteralConstructorEmpty; | 323 ConstructorElement mapLiteralConstructorEmpty; |
| 320 Element mapLiteralUntypedMaker; | 324 Element mapLiteralUntypedMaker; |
| 321 Element mapLiteralUntypedEmptyMaker; | 325 Element mapLiteralUntypedEmptyMaker; |
| 322 | 326 |
| 323 ClassElement noSideEffectsClass; | 327 ClassElement noSideEffectsClass; |
| 324 ClassElement noThrowsClass; | 328 ClassElement noThrowsClass; |
| 325 ClassElement noInlineClass; | 329 ClassElement noInlineClass; |
| 326 ClassElement forceInlineClass; | 330 ClassElement forceInlineClass; |
| 327 ClassElement irRepresentationClass; | 331 ClassElement irRepresentationClass; |
| 328 | 332 |
| 333 ClassElement jsAnnotationClass; |
| 334 |
| 329 Element getInterceptorMethod; | 335 Element getInterceptorMethod; |
| 330 | 336 |
| 331 ClassElement jsInvocationMirrorClass; | 337 ClassElement jsInvocationMirrorClass; |
| 332 | 338 |
| 333 /// If [true], the compiler will emit code that logs whenever a method is | 339 /// If [true], the compiler will emit code that logs whenever a method is |
| 334 /// called. When TRACE_METHOD is 'console' this will be logged | 340 /// called. When TRACE_METHOD is 'console' this will be logged |
| 335 /// directly in the JavaScript console. When TRACE_METHOD is 'post' the | 341 /// directly in the JavaScript console. When TRACE_METHOD is 'post' the |
| 336 /// information will be sent to a server via a POST request. | 342 /// information will be sent to a server via a POST request. |
| 337 static const String TRACE_METHOD = const String.fromEnvironment('traceCalls'); | 343 static const String TRACE_METHOD = const String.fromEnvironment('traceCalls'); |
| 338 static const bool TRACE_CALLS = | 344 static const bool TRACE_CALLS = |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 659 |
| 654 ConstantSystem get constantSystem => constants.constantSystem; | 660 ConstantSystem get constantSystem => constants.constantSystem; |
| 655 | 661 |
| 656 /// Returns constant environment for the JavaScript interpretation of the | 662 /// Returns constant environment for the JavaScript interpretation of the |
| 657 /// constants. | 663 /// constants. |
| 658 JavaScriptConstantCompiler get constants { | 664 JavaScriptConstantCompiler get constants { |
| 659 return constantCompilerTask.jsConstantCompiler; | 665 return constantCompilerTask.jsConstantCompiler; |
| 660 } | 666 } |
| 661 | 667 |
| 662 FunctionElement resolveExternalFunction(FunctionElement element) { | 668 FunctionElement resolveExternalFunction(FunctionElement element) { |
| 663 if (isForeign(element)) return element; | 669 if (isForeign(element) || element.isJsInterop) return element; |
| 664 return patchResolverTask.measure(() { | 670 return patchResolverTask.measure(() { |
| 665 return patchResolverTask.resolveExternalFunction(element); | 671 return patchResolverTask.resolveExternalFunction(element); |
| 666 }); | 672 }); |
| 667 } | 673 } |
| 668 | 674 |
| 669 // TODO(karlklose): Split into findHelperFunction and findHelperClass and | 675 // TODO(karlklose): Split into findHelperFunction and findHelperClass and |
| 670 // add a check that the element has the expected kind. | 676 // add a check that the element has the expected kind. |
| 671 Element findHelper(String name) => find(jsHelperLibrary, name); | 677 Element findHelper(String name) => find(jsHelperLibrary, name); |
| 672 Element findAsyncHelper(String name) => find(asyncLibrary, name); | 678 Element findAsyncHelper(String name) => find(asyncLibrary, name); |
| 673 Element findInterceptor(String name) => find(interceptorsLibrary, name); | 679 Element findInterceptor(String name) => find(interceptorsLibrary, name); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 // Interceptors must override all Object methods due to calling convention | 887 // Interceptors must override all Object methods due to calling convention |
| 882 // differences. | 888 // differences. |
| 883 assert(interceptorMember.enclosingClass == interceptorClass); | 889 assert(interceptorMember.enclosingClass == interceptorClass); |
| 884 }); | 890 }); |
| 885 } | 891 } |
| 886 | 892 |
| 887 void addInterceptorsForNativeClassMembers( | 893 void addInterceptorsForNativeClassMembers( |
| 888 ClassElement cls, Enqueuer enqueuer) { | 894 ClassElement cls, Enqueuer enqueuer) { |
| 889 if (enqueuer.isResolutionQueue) { | 895 if (enqueuer.isResolutionQueue) { |
| 890 cls.ensureResolved(compiler); | 896 cls.ensureResolved(compiler); |
| 897 if (cls.isJsInterop) { |
| 898 if (!cls.implementsInterface(jsJavaScriptObjectClass)) { |
| 899 compiler.reportError( |
| 900 cls, |
| 901 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, |
| 902 {'cls': cls.name}); |
| 903 return; |
| 904 } |
| 905 |
| 906 cls.forEachMember((ClassElement classElement, Element member) { |
| 907 if (member.isSynthesized) return; |
| 908 if (cls.isJsInterop && member is FunctionElement) { |
| 909 FunctionElement fn = member; |
| 910 if (!fn.isExternal && !fn.isAbstract) { |
| 911 compiler.reportError( |
| 912 fn, |
| 913 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER, |
| 914 {'cls': cls.name, 'member': member.name}); |
| 915 } |
| 916 } |
| 917 }); |
| 918 } |
| 891 cls.forEachMember((ClassElement classElement, Element member) { | 919 cls.forEachMember((ClassElement classElement, Element member) { |
| 892 if (member.name == Identifiers.call) { | 920 if (member.name == Identifiers.call) { |
| 893 compiler.reportError( | 921 compiler.reportError( |
| 894 member, | 922 member, |
| 895 MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS); | 923 MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS); |
| 896 return; | 924 return; |
| 897 } | 925 } |
| 898 if (member.isSynthesized) return; | 926 if (member.isSynthesized) return; |
| 899 // All methods on [Object] are shadowed by [Interceptor]. | 927 // All methods on [Object] are shadowed by [Interceptor]. |
| 900 if (classElement == compiler.objectClass) return; | 928 if (classElement == compiler.objectClass) return; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 enqueueClass(enqueuer, mapLiteralClass, registry); | 1059 enqueueClass(enqueuer, mapLiteralClass, registry); |
| 1032 // For map literals, the dependency between the implementation class | 1060 // For map literals, the dependency between the implementation class |
| 1033 // and [Map] is not visible, so we have to add it manually. | 1061 // and [Map] is not visible, so we have to add it manually. |
| 1034 rti.registerRtiDependency(mapLiteralClass, cls); | 1062 rti.registerRtiDependency(mapLiteralClass, cls); |
| 1035 } else if (cls == boundClosureClass) { | 1063 } else if (cls == boundClosureClass) { |
| 1036 // TODO(johnniwinther): Is this a noop? | 1064 // TODO(johnniwinther): Is this a noop? |
| 1037 enqueueClass(enqueuer, boundClosureClass, registry); | 1065 enqueueClass(enqueuer, boundClosureClass, registry); |
| 1038 } else if (Elements.isNativeOrExtendsNative(cls)) { | 1066 } else if (Elements.isNativeOrExtendsNative(cls)) { |
| 1039 enqueue(enqueuer, getNativeInterceptorMethod, registry); | 1067 enqueue(enqueuer, getNativeInterceptorMethod, registry); |
| 1040 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); | 1068 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); |
| 1069 enqueueClass(enqueuer, jsJavaScriptObjectClass, registry); |
| 1041 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); | 1070 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); |
| 1071 enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry); |
| 1042 } else if (cls == mapLiteralClass) { | 1072 } else if (cls == mapLiteralClass) { |
| 1043 // For map literals, the dependency between the implementation class | 1073 // For map literals, the dependency between the implementation class |
| 1044 // and [Map] is not visible, so we have to add it manually. | 1074 // and [Map] is not visible, so we have to add it manually. |
| 1045 Element getFactory(String name, int arity) { | 1075 Element getFactory(String name, int arity) { |
| 1046 // The constructor is on the patch class, but dart2js unit tests don't | 1076 // The constructor is on the patch class, but dart2js unit tests don't |
| 1047 // have a patch class. | 1077 // have a patch class. |
| 1048 ClassElement implementation = cls.patch != null ? cls.patch : cls; | 1078 ClassElement implementation = cls.patch != null ? cls.patch : cls; |
| 1049 ConstructorElement ctor = implementation.lookupConstructor(name); | 1079 ConstructorElement ctor = implementation.lookupConstructor(name); |
| 1050 if (ctor == null | 1080 if (ctor == null |
| 1051 || (Name.isPrivateName(name) | 1081 || (Name.isPrivateName(name) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 addInterceptors(jsBoolClass, enqueuer, registry); | 1138 addInterceptors(jsBoolClass, enqueuer, registry); |
| 1109 } else if (cls == compiler.nullClass || cls == jsNullClass) { | 1139 } else if (cls == compiler.nullClass || cls == jsNullClass) { |
| 1110 addInterceptors(jsNullClass, enqueuer, registry); | 1140 addInterceptors(jsNullClass, enqueuer, registry); |
| 1111 } else if (cls == compiler.numClass || cls == jsNumberClass) { | 1141 } else if (cls == compiler.numClass || cls == jsNumberClass) { |
| 1112 addInterceptors(jsIntClass, enqueuer, registry); | 1142 addInterceptors(jsIntClass, enqueuer, registry); |
| 1113 addInterceptors(jsPositiveIntClass, enqueuer, registry); | 1143 addInterceptors(jsPositiveIntClass, enqueuer, registry); |
| 1114 addInterceptors(jsUInt32Class, enqueuer, registry); | 1144 addInterceptors(jsUInt32Class, enqueuer, registry); |
| 1115 addInterceptors(jsUInt31Class, enqueuer, registry); | 1145 addInterceptors(jsUInt31Class, enqueuer, registry); |
| 1116 addInterceptors(jsDoubleClass, enqueuer, registry); | 1146 addInterceptors(jsDoubleClass, enqueuer, registry); |
| 1117 addInterceptors(jsNumberClass, enqueuer, registry); | 1147 addInterceptors(jsNumberClass, enqueuer, registry); |
| 1148 } else if (cls == jsJavaScriptObjectClass) { |
| 1149 addInterceptors(jsJavaScriptObjectClass, enqueuer, registry); |
| 1118 } else if (cls == jsPlainJavaScriptObjectClass) { | 1150 } else if (cls == jsPlainJavaScriptObjectClass) { |
| 1119 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry); | 1151 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry); |
| 1120 } else if (cls == jsUnknownJavaScriptObjectClass) { | 1152 } else if (cls == jsUnknownJavaScriptObjectClass) { |
| 1121 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry); | 1153 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry); |
| 1154 } else if (cls == jsJavaScriptFunctionClass) { |
| 1155 addInterceptors(jsJavaScriptFunctionClass, enqueuer, registry); |
| 1122 } else if (Elements.isNativeOrExtendsNative(cls)) { | 1156 } else if (Elements.isNativeOrExtendsNative(cls)) { |
| 1123 addInterceptorsForNativeClassMembers(cls, enqueuer); | 1157 addInterceptorsForNativeClassMembers(cls, enqueuer); |
| 1124 } else if (cls == jsIndexingBehaviorInterface) { | 1158 } else if (cls == jsIndexingBehaviorInterface) { |
| 1125 // These two helpers are used by the emitter and the codegen. | 1159 // These two helpers are used by the emitter and the codegen. |
| 1126 // Because we cannot enqueue elements at the time of emission, | 1160 // Because we cannot enqueue elements at the time of emission, |
| 1127 // we make sure they are always generated. | 1161 // we make sure they are always generated. |
| 1128 enqueue(enqueuer, findHelper('isJsIndexable'), registry); | 1162 enqueue(enqueuer, findHelper('isJsIndexable'), registry); |
| 1129 } | 1163 } |
| 1130 | 1164 |
| 1131 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer); | 1165 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer); |
| 1132 } | 1166 } |
| 1133 | 1167 |
| 1134 void registerUseInterceptor(Enqueuer enqueuer) { | 1168 void registerUseInterceptor(Enqueuer enqueuer) { |
| 1135 assert(!enqueuer.isResolutionQueue); | 1169 assert(!enqueuer.isResolutionQueue); |
| 1136 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return; | 1170 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return; |
| 1137 Registry registry = compiler.globalDependencies; | 1171 Registry registry = compiler.globalDependencies; |
| 1138 enqueue(enqueuer, getNativeInterceptorMethod, registry); | 1172 enqueue(enqueuer, getNativeInterceptorMethod, registry); |
| 1173 enqueueClass(enqueuer, jsJavaScriptObjectClass, registry); |
| 1139 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); | 1174 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); |
| 1175 enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry); |
| 1140 needToInitializeIsolateAffinityTag = true; | 1176 needToInitializeIsolateAffinityTag = true; |
| 1141 needToInitializeDispatchProperty = true; | 1177 needToInitializeDispatchProperty = true; |
| 1142 } | 1178 } |
| 1143 | 1179 |
| 1144 JavaScriptItemCompilationContext createItemCompilationContext() { | 1180 JavaScriptItemCompilationContext createItemCompilationContext() { |
| 1145 return new JavaScriptItemCompilationContext(); | 1181 return new JavaScriptItemCompilationContext(); |
| 1146 } | 1182 } |
| 1147 | 1183 |
| 1148 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { | 1184 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { |
| 1149 assert(interceptorsLibrary != null); | 1185 assert(interceptorsLibrary != null); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 | 1496 |
| 1461 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { | 1497 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { |
| 1462 return new native.NativeResolutionEnqueuer(world, compiler); | 1498 return new native.NativeResolutionEnqueuer(world, compiler); |
| 1463 } | 1499 } |
| 1464 | 1500 |
| 1465 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { | 1501 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { |
| 1466 return new native.NativeCodegenEnqueuer(world, compiler, emitter); | 1502 return new native.NativeCodegenEnqueuer(world, compiler, emitter); |
| 1467 } | 1503 } |
| 1468 | 1504 |
| 1469 ClassElement defaultSuperclass(ClassElement element) { | 1505 ClassElement defaultSuperclass(ClassElement element) { |
| 1506 if (element.isJsInterop) return jsJavaScriptObjectClass; |
| 1470 // Native classes inherit from Interceptor. | 1507 // Native classes inherit from Interceptor. |
| 1471 return element.isNative ? jsInterceptorClass : compiler.objectClass; | 1508 return element.isNative ? jsInterceptorClass : compiler.objectClass; |
| 1472 } | 1509 } |
| 1473 | 1510 |
| 1474 /** | 1511 /** |
| 1475 * Unit test hook that returns code of an element as a String. | 1512 * Unit test hook that returns code of an element as a String. |
| 1476 * | 1513 * |
| 1477 * Invariant: [element] must be a declaration element. | 1514 * Invariant: [element] must be a declaration element. |
| 1478 */ | 1515 */ |
| 1479 String assembleCode(Element element) { | 1516 String assembleCode(Element element) { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2092 jsUInt31Class = findClass('JSUInt31'); | 2129 jsUInt31Class = findClass('JSUInt31'); |
| 2093 jsDoubleClass = findClass('JSDouble'); | 2130 jsDoubleClass = findClass('JSDouble'); |
| 2094 jsNumberClass = findClass('JSNumber'); | 2131 jsNumberClass = findClass('JSNumber'); |
| 2095 jsNullClass = findClass('JSNull'); | 2132 jsNullClass = findClass('JSNull'); |
| 2096 jsBoolClass = findClass('JSBool'); | 2133 jsBoolClass = findClass('JSBool'); |
| 2097 jsMutableArrayClass = findClass('JSMutableArray'); | 2134 jsMutableArrayClass = findClass('JSMutableArray'); |
| 2098 jsFixedArrayClass = findClass('JSFixedArray'); | 2135 jsFixedArrayClass = findClass('JSFixedArray'); |
| 2099 jsExtendableArrayClass = findClass('JSExtendableArray'); | 2136 jsExtendableArrayClass = findClass('JSExtendableArray'); |
| 2100 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); | 2137 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); |
| 2101 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); | 2138 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); |
| 2139 jsJavaScriptObjectClass = findClass('JavaScriptObject'); |
| 2140 jsJavaScriptFunctionClass = findClass('JavaScriptFunction'); |
| 2102 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); | 2141 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); |
| 2103 jsIndexableClass = findClass('JSIndexable'); | 2142 jsIndexableClass = findClass('JSIndexable'); |
| 2104 jsMutableIndexableClass = findClass('JSMutableIndexable'); | 2143 jsMutableIndexableClass = findClass('JSMutableIndexable'); |
| 2105 } else if (uri == DART_JS_HELPER) { | 2144 } else if (uri == DART_JS_HELPER) { |
| 2106 initializeHelperClasses(); | 2145 initializeHelperClasses(); |
| 2107 assertMethod = findHelper('assertHelper'); | 2146 assertMethod = findHelper('assertHelper'); |
| 2108 | 2147 |
| 2109 typeLiteralClass = findClass('TypeImpl'); | 2148 typeLiteralClass = findClass('TypeImpl'); |
| 2110 constMapLiteralClass = findClass('ConstantMap'); | 2149 constMapLiteralClass = findClass('ConstantMap'); |
| 2111 typeVariableClass = findClass('TypeVariable'); | 2150 typeVariableClass = findClass('TypeVariable'); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2126 preserveMetadataMarker = find(library, 'preserveMetadata'); | 2165 preserveMetadataMarker = find(library, 'preserveMetadata'); |
| 2127 preserveUrisMarker = find(library, 'preserveUris'); | 2166 preserveUrisMarker = find(library, 'preserveUris'); |
| 2128 preserveLibraryNamesMarker = find(library, 'preserveLibraryNames'); | 2167 preserveLibraryNamesMarker = find(library, 'preserveLibraryNames'); |
| 2129 } else if (uri == DART_JS_NAMES) { | 2168 } else if (uri == DART_JS_NAMES) { |
| 2130 preserveNamesMarker = find(library, 'preserveNames'); | 2169 preserveNamesMarker = find(library, 'preserveNames'); |
| 2131 } else if (uri == DART_EMBEDDED_NAMES) { | 2170 } else if (uri == DART_EMBEDDED_NAMES) { |
| 2132 jsGetNameEnum = find(library, 'JsGetName'); | 2171 jsGetNameEnum = find(library, 'JsGetName'); |
| 2133 jsBuiltinEnum = find(library, 'JsBuiltin'); | 2172 jsBuiltinEnum = find(library, 'JsBuiltin'); |
| 2134 } else if (uri == Uris.dart_html) { | 2173 } else if (uri == Uris.dart_html) { |
| 2135 htmlLibraryIsLoaded = true; | 2174 htmlLibraryIsLoaded = true; |
| 2175 } else if (uri == PACKAGE_JS) { |
| 2176 jsAnnotationClass = find(library, 'Js'); |
| 2136 } | 2177 } |
| 2137 annotations.onLibraryScanned(library); | 2178 annotations.onLibraryScanned(library); |
| 2138 }); | 2179 }); |
| 2139 } | 2180 } |
| 2140 | 2181 |
| 2141 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 2182 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 2142 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { | 2183 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { |
| 2143 return new Future.value(); | 2184 return new Future.value(); |
| 2144 } | 2185 } |
| 2145 | 2186 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2521 return staticFields; | 2562 return staticFields; |
| 2522 } | 2563 } |
| 2523 | 2564 |
| 2524 /// Called when [enqueuer] is empty, but before it is closed. | 2565 /// Called when [enqueuer] is empty, but before it is closed. |
| 2525 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) { | 2566 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) { |
| 2526 // Add elements referenced only via custom elements. Return early if any | 2567 // Add elements referenced only via custom elements. Return early if any |
| 2527 // elements are added to avoid counting the elements as due to mirrors. | 2568 // elements are added to avoid counting the elements as due to mirrors. |
| 2528 customElementsAnalysis.onQueueEmpty(enqueuer); | 2569 customElementsAnalysis.onQueueEmpty(enqueuer); |
| 2529 if (!enqueuer.queueIsEmpty) return false; | 2570 if (!enqueuer.queueIsEmpty) return false; |
| 2530 | 2571 |
| 2572 // XXXX this is a bad hack. |
| 2573 // We are validating way too many times. |
| 2574 compiler.libraryLoader.libraries.forEach(processJsInteropAnnotationsInLibrar
y); |
| 2575 |
| 2576 |
| 2531 noSuchMethodRegistry.onQueueEmpty(); | 2577 noSuchMethodRegistry.onQueueEmpty(); |
| 2532 if (!enabledNoSuchMethod && | 2578 if (!enabledNoSuchMethod && |
| 2533 (noSuchMethodRegistry.hasThrowingNoSuchMethod || | 2579 (noSuchMethodRegistry.hasThrowingNoSuchMethod || |
| 2534 noSuchMethodRegistry.hasComplexNoSuchMethod)) { | 2580 noSuchMethodRegistry.hasComplexNoSuchMethod)) { |
| 2535 enableNoSuchMethod(enqueuer); | 2581 enableNoSuchMethod(enqueuer); |
| 2536 enabledNoSuchMethod = true; | 2582 enabledNoSuchMethod = true; |
| 2537 } | 2583 } |
| 2538 | 2584 |
| 2539 if (compiler.hasIncrementalSupport) { | 2585 if (compiler.hasIncrementalSupport) { |
| 2540 // Always enable tear-off closures during incremental compilation. | 2586 // Always enable tear-off closures during incremental compilation. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2570 dependency.constant, | 2616 dependency.constant, |
| 2571 new CodegenRegistry(compiler, | 2617 new CodegenRegistry(compiler, |
| 2572 dependency.annotatedElement.analyzableElement.treeElements)); | 2618 dependency.annotatedElement.analyzableElement.treeElements)); |
| 2573 } | 2619 } |
| 2574 metadataConstants.clear(); | 2620 metadataConstants.clear(); |
| 2575 } | 2621 } |
| 2576 } | 2622 } |
| 2577 return true; | 2623 return true; |
| 2578 } | 2624 } |
| 2579 | 2625 |
| 2626 void processJsInteropAnnotationsInLibrary(LibraryElement library) { |
| 2627 checkJsInteropAnnotation(compiler, library); |
| 2628 library.implementation.forEachLocalMember((Element element) { |
| 2629 checkJsInteropAnnotation(compiler, element); |
| 2630 }); |
| 2631 } |
| 2632 |
| 2580 void onElementResolved(Element element, TreeElements elements) { | 2633 void onElementResolved(Element element, TreeElements elements) { |
| 2581 if ((element.isFunction || element.isGenerativeConstructor) && | 2634 if ((element.isFunction || element.isGenerativeConstructor) && |
| 2582 annotations.noInline(element)) { | 2635 annotations.noInline(element)) { |
| 2583 inlineCache.markAsNonInlinable(element); | 2636 inlineCache.markAsNonInlinable(element); |
| 2584 } | 2637 } |
| 2585 | 2638 |
| 2586 LibraryElement library = element.library; | 2639 LibraryElement library = element.library; |
| 2587 if (!library.isPlatformLibrary && !library.canUseNative) return; | 2640 if (!library.isPlatformLibrary && !library.canUseNative) return; |
| 2588 bool hasNoInline = false; | 2641 bool hasNoInline = false; |
| 2589 bool hasForceInline = false; | 2642 bool hasForceInline = false; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 } | 3151 } |
| 3099 } | 3152 } |
| 3100 | 3153 |
| 3101 /// Records that [constant] is used by the element behind [registry]. | 3154 /// Records that [constant] is used by the element behind [registry]. |
| 3102 class Dependency { | 3155 class Dependency { |
| 3103 final ConstantValue constant; | 3156 final ConstantValue constant; |
| 3104 final Element annotatedElement; | 3157 final Element annotatedElement; |
| 3105 | 3158 |
| 3106 const Dependency(this.constant, this.annotatedElement); | 3159 const Dependency(this.constant, this.annotatedElement); |
| 3107 } | 3160 } |
| OLD | NEW |