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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ptal Created 5 years, 2 months 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
OLDNEW
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
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 static final Uri PACKAGE_LOOKUP_MAP = 238 static final Uri PACKAGE_LOOKUP_MAP =
237 new Uri(scheme: 'package', path: 'lookup_map/lookup_map.dart'); 239 new Uri(scheme: 'package', path: 'lookup_map/lookup_map.dart');
238 240
239 static const String INVOKE_ON = '_getCachedInvocation'; 241 static const String INVOKE_ON = '_getCachedInvocation';
240 static const String START_ROOT_ISOLATE = 'startRootIsolate'; 242 static const String START_ROOT_ISOLATE = 'startRootIsolate';
241 243
242 244
243 String get patchVersion => emitter.patchVersion; 245 String get patchVersion => emitter.patchVersion;
244 246
245 bool get supportsReflection => emitter.emitter.supportsReflection; 247 bool get supportsReflection => emitter.emitter.supportsReflection;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ClassElement jsInterceptorClass; 289 ClassElement jsInterceptorClass;
288 ClassElement jsStringClass; 290 ClassElement jsStringClass;
289 ClassElement jsArrayClass; 291 ClassElement jsArrayClass;
290 ClassElement jsNumberClass; 292 ClassElement jsNumberClass;
291 ClassElement jsIntClass; 293 ClassElement jsIntClass;
292 ClassElement jsDoubleClass; 294 ClassElement jsDoubleClass;
293 ClassElement jsNullClass; 295 ClassElement jsNullClass;
294 ClassElement jsBoolClass; 296 ClassElement jsBoolClass;
295 ClassElement jsPlainJavaScriptObjectClass; 297 ClassElement jsPlainJavaScriptObjectClass;
296 ClassElement jsUnknownJavaScriptObjectClass; 298 ClassElement jsUnknownJavaScriptObjectClass;
299 ClassElement jsJavaScriptFunctionClass;
300 ClassElement jsJavaScriptObjectClass;
297 301
298 ClassElement jsIndexableClass; 302 ClassElement jsIndexableClass;
299 ClassElement jsMutableIndexableClass; 303 ClassElement jsMutableIndexableClass;
300 304
301 ClassElement jsMutableArrayClass; 305 ClassElement jsMutableArrayClass;
302 ClassElement jsFixedArrayClass; 306 ClassElement jsFixedArrayClass;
303 ClassElement jsExtendableArrayClass; 307 ClassElement jsExtendableArrayClass;
304 ClassElement jsUnmodifiableArrayClass; 308 ClassElement jsUnmodifiableArrayClass;
305 ClassElement jsPositiveIntClass; 309 ClassElement jsPositiveIntClass;
306 ClassElement jsUInt32Class; 310 ClassElement jsUInt32Class;
(...skipping 17 matching lines...) Expand all
324 ConstructorElement mapLiteralConstructorEmpty; 328 ConstructorElement mapLiteralConstructorEmpty;
325 Element mapLiteralUntypedMaker; 329 Element mapLiteralUntypedMaker;
326 Element mapLiteralUntypedEmptyMaker; 330 Element mapLiteralUntypedEmptyMaker;
327 331
328 ClassElement noSideEffectsClass; 332 ClassElement noSideEffectsClass;
329 ClassElement noThrowsClass; 333 ClassElement noThrowsClass;
330 ClassElement noInlineClass; 334 ClassElement noInlineClass;
331 ClassElement forceInlineClass; 335 ClassElement forceInlineClass;
332 ClassElement irRepresentationClass; 336 ClassElement irRepresentationClass;
333 337
338 ClassElement jsAnnotationClass;
339
334 Element getInterceptorMethod; 340 Element getInterceptorMethod;
335 341
336 ClassElement jsInvocationMirrorClass; 342 ClassElement jsInvocationMirrorClass;
337 343
338 ClassElement typedArrayClass; 344 ClassElement typedArrayClass;
339 ClassElement typedArrayOfIntClass; 345 ClassElement typedArrayOfIntClass;
340 346
341 /// If [true], the compiler will emit code that logs whenever a method is 347 /// If [true], the compiler will emit code that logs whenever a method is
342 /// called. When TRACE_METHOD is 'console' this will be logged 348 /// called. When TRACE_METHOD is 'console' this will be logged
343 /// directly in the JavaScript console. When TRACE_METHOD is 'post' the 349 /// directly in the JavaScript console. When TRACE_METHOD is 'post' the
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 /// Number of methods compiled before considering reflection. 618 /// Number of methods compiled before considering reflection.
613 int preMirrorsMethodCount = 0; 619 int preMirrorsMethodCount = 0;
614 620
615 /// Resolution and codegen support for generating table of interceptors and 621 /// Resolution and codegen support for generating table of interceptors and
616 /// constructors for custom elements. 622 /// constructors for custom elements.
617 CustomElementsAnalysis customElementsAnalysis; 623 CustomElementsAnalysis customElementsAnalysis;
618 624
619 /// Codegen support for tree-shaking entries of `LookupMap`. 625 /// Codegen support for tree-shaking entries of `LookupMap`.
620 LookupMapAnalysis lookupMapAnalysis; 626 LookupMapAnalysis lookupMapAnalysis;
621 627
628 /// Codegen support for typed JavaScript interop.
629 JsInteropAnalysis jsInteropAnalysis;
630
622 /// Support for classifying `noSuchMethod` implementations. 631 /// Support for classifying `noSuchMethod` implementations.
623 NoSuchMethodRegistry noSuchMethodRegistry; 632 NoSuchMethodRegistry noSuchMethodRegistry;
624 633
625 JavaScriptConstantTask constantCompilerTask; 634 JavaScriptConstantTask constantCompilerTask;
626 635
627 JavaScriptResolutionCallbacks resolutionCallbacks; 636 JavaScriptResolutionCallbacks resolutionCallbacks;
628 637
629 PatchResolverTask patchResolverTask; 638 PatchResolverTask patchResolverTask;
630 639
631 bool enabledNoSuchMethod = false; 640 bool enabledNoSuchMethod = false;
(...skipping 14 matching lines...) Expand all
646 ? (useNewSourceInfo 655 ? (useNewSourceInfo
647 ? const PositionSourceInformationStrategy() 656 ? const PositionSourceInformationStrategy()
648 : const StartEndSourceInformationStrategy()) 657 : const StartEndSourceInformationStrategy())
649 : const JavaScriptSourceInformationStrategy(), 658 : const JavaScriptSourceInformationStrategy(),
650 super(compiler) { 659 super(compiler) {
651 emitter = new CodeEmitterTask( 660 emitter = new CodeEmitterTask(
652 compiler, namer, generateSourceMap, useStartupEmitter); 661 compiler, namer, generateSourceMap, useStartupEmitter);
653 typeVariableHandler = new TypeVariableHandler(compiler); 662 typeVariableHandler = new TypeVariableHandler(compiler);
654 customElementsAnalysis = new CustomElementsAnalysis(this); 663 customElementsAnalysis = new CustomElementsAnalysis(this);
655 lookupMapAnalysis = new LookupMapAnalysis(this); 664 lookupMapAnalysis = new LookupMapAnalysis(this);
665 jsInteropAnalysis = new JsInteropAnalysis(this);
666
656 noSuchMethodRegistry = new NoSuchMethodRegistry(this); 667 noSuchMethodRegistry = new NoSuchMethodRegistry(this);
657 constantCompilerTask = new JavaScriptConstantTask(compiler); 668 constantCompilerTask = new JavaScriptConstantTask(compiler);
658 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); 669 resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
659 patchResolverTask = new PatchResolverTask(compiler); 670 patchResolverTask = new PatchResolverTask(compiler);
660 functionCompiler = compiler.useCpsIr 671 functionCompiler = compiler.useCpsIr
661 ? new CpsFunctionCompiler( 672 ? new CpsFunctionCompiler(
662 compiler, this, sourceInformationStrategy) 673 compiler, this, sourceInformationStrategy)
663 : new SsaFunctionCompiler(this, sourceInformationStrategy); 674 : new SsaFunctionCompiler(this, sourceInformationStrategy);
664 } 675 }
665 676
666 ConstantSystem get constantSystem => constants.constantSystem; 677 ConstantSystem get constantSystem => constants.constantSystem;
667 678
668 Resolution get resolution => compiler.resolution; 679 Resolution get resolution => compiler.resolution;
669 680
670 /// Returns constant environment for the JavaScript interpretation of the 681 /// Returns constant environment for the JavaScript interpretation of the
671 /// constants. 682 /// constants.
672 JavaScriptConstantCompiler get constants { 683 JavaScriptConstantCompiler get constants {
673 return constantCompilerTask.jsConstantCompiler; 684 return constantCompilerTask.jsConstantCompiler;
674 } 685 }
675 686
676 FunctionElement resolveExternalFunction(FunctionElement element) { 687 FunctionElement resolveExternalFunction(FunctionElement element) {
677 if (isForeign(element)) return element; 688 if (isForeign(element) || element.isJsInterop) return element;
678 return patchResolverTask.measure(() { 689 return patchResolverTask.measure(() {
679 return patchResolverTask.resolveExternalFunction(element); 690 return patchResolverTask.resolveExternalFunction(element);
680 }); 691 });
681 } 692 }
682 693
683 // TODO(karlklose): Split into findHelperFunction and findHelperClass and 694 // TODO(karlklose): Split into findHelperFunction and findHelperClass and
684 // add a check that the element has the expected kind. 695 // add a check that the element has the expected kind.
685 Element findHelper(String name) => find(jsHelperLibrary, name); 696 Element findHelper(String name) => find(jsHelperLibrary, name);
686 Element findAsyncHelper(String name) => find(asyncLibrary, name); 697 Element findAsyncHelper(String name) => find(asyncLibrary, name);
687 Element findInterceptor(String name) => find(interceptorsLibrary, name); 698 Element findInterceptor(String name) => find(interceptorsLibrary, name);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 // Interceptors must override all Object methods due to calling convention 906 // Interceptors must override all Object methods due to calling convention
896 // differences. 907 // differences.
897 assert(interceptorMember.enclosingClass == interceptorClass); 908 assert(interceptorMember.enclosingClass == interceptorClass);
898 }); 909 });
899 } 910 }
900 911
901 void addInterceptorsForNativeClassMembers( 912 void addInterceptorsForNativeClassMembers(
902 ClassElement cls, Enqueuer enqueuer) { 913 ClassElement cls, Enqueuer enqueuer) {
903 if (enqueuer.isResolutionQueue) { 914 if (enqueuer.isResolutionQueue) {
904 cls.ensureResolved(resolution); 915 cls.ensureResolved(resolution);
916 if (cls.isJsInterop) {
sra1 2015/10/06 21:42:17 Ideally this should be done earlier. Add a TODO to
Jacob 2015/10/13 01:19:23 done.
917 if (!cls.implementsInterface(jsJavaScriptObjectClass)) {
918 compiler.reportErrorMessage(
919 cls,
920 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS,
921 {'cls': cls.name});
922 return;
923 }
924
925 cls.forEachMember((ClassElement classElement, Element member) {
926 if (member.isSynthesized) return;
927 if (cls.isJsInterop && member is FunctionElement) {
928 FunctionElement fn = member;
929 if (!fn.isExternal && !fn.isAbstract) {
930 compiler.reportErrorMessage(
931 fn,
932 MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER,
933 {'cls': cls.name, 'member': member.name});
934 }
935 }
936 });
937 }
905 cls.forEachMember((ClassElement classElement, Element member) { 938 cls.forEachMember((ClassElement classElement, Element member) {
906 if (member.name == Identifiers.call) { 939 if (member.name == Identifiers.call) {
907 compiler.reportErrorMessage( 940 compiler.reportErrorMessage(
908 member, 941 member,
909 MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS); 942 MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS);
910 return; 943 return;
911 } 944 }
912 if (member.isSynthesized) return; 945 if (member.isSynthesized) return;
913 // All methods on [Object] are shadowed by [Interceptor]. 946 // All methods on [Object] are shadowed by [Interceptor].
914 if (classElement == compiler.objectClass) return; 947 if (classElement == compiler.objectClass) return;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 enqueueClass(enqueuer, mapLiteralClass, registry); 1103 enqueueClass(enqueuer, mapLiteralClass, registry);
1071 // For map literals, the dependency between the implementation class 1104 // For map literals, the dependency between the implementation class
1072 // and [Map] is not visible, so we have to add it manually. 1105 // and [Map] is not visible, so we have to add it manually.
1073 rti.registerRtiDependency(mapLiteralClass, cls); 1106 rti.registerRtiDependency(mapLiteralClass, cls);
1074 } else if (cls == boundClosureClass) { 1107 } else if (cls == boundClosureClass) {
1075 // TODO(johnniwinther): Is this a noop? 1108 // TODO(johnniwinther): Is this a noop?
1076 enqueueClass(enqueuer, boundClosureClass, registry); 1109 enqueueClass(enqueuer, boundClosureClass, registry);
1077 } else if (Elements.isNativeOrExtendsNative(cls)) { 1110 } else if (Elements.isNativeOrExtendsNative(cls)) {
1078 enqueue(enqueuer, getNativeInterceptorMethod, registry); 1111 enqueue(enqueuer, getNativeInterceptorMethod, registry);
1079 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); 1112 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies);
1113 enqueueClass(enqueuer, jsJavaScriptObjectClass, registry);
1080 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); 1114 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry);
1115 enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry);
1081 } else if (cls == mapLiteralClass) { 1116 } else if (cls == mapLiteralClass) {
1082 // For map literals, the dependency between the implementation class 1117 // For map literals, the dependency between the implementation class
1083 // and [Map] is not visible, so we have to add it manually. 1118 // and [Map] is not visible, so we have to add it manually.
1084 Element getFactory(String name, int arity) { 1119 Element getFactory(String name, int arity) {
1085 // The constructor is on the patch class, but dart2js unit tests don't 1120 // The constructor is on the patch class, but dart2js unit tests don't
1086 // have a patch class. 1121 // have a patch class.
1087 ClassElement implementation = cls.patch != null ? cls.patch : cls; 1122 ClassElement implementation = cls.patch != null ? cls.patch : cls;
1088 ConstructorElement ctor = implementation.lookupConstructor(name); 1123 ConstructorElement ctor = implementation.lookupConstructor(name);
1089 if (ctor == null 1124 if (ctor == null
1090 || (Name.isPrivateName(name) 1125 || (Name.isPrivateName(name)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 addInterceptors(jsBoolClass, enqueuer, registry); 1182 addInterceptors(jsBoolClass, enqueuer, registry);
1148 } else if (cls == compiler.nullClass || cls == jsNullClass) { 1183 } else if (cls == compiler.nullClass || cls == jsNullClass) {
1149 addInterceptors(jsNullClass, enqueuer, registry); 1184 addInterceptors(jsNullClass, enqueuer, registry);
1150 } else if (cls == compiler.numClass || cls == jsNumberClass) { 1185 } else if (cls == compiler.numClass || cls == jsNumberClass) {
1151 addInterceptors(jsIntClass, enqueuer, registry); 1186 addInterceptors(jsIntClass, enqueuer, registry);
1152 addInterceptors(jsPositiveIntClass, enqueuer, registry); 1187 addInterceptors(jsPositiveIntClass, enqueuer, registry);
1153 addInterceptors(jsUInt32Class, enqueuer, registry); 1188 addInterceptors(jsUInt32Class, enqueuer, registry);
1154 addInterceptors(jsUInt31Class, enqueuer, registry); 1189 addInterceptors(jsUInt31Class, enqueuer, registry);
1155 addInterceptors(jsDoubleClass, enqueuer, registry); 1190 addInterceptors(jsDoubleClass, enqueuer, registry);
1156 addInterceptors(jsNumberClass, enqueuer, registry); 1191 addInterceptors(jsNumberClass, enqueuer, registry);
1192 } else if (cls == jsJavaScriptObjectClass) {
1193 addInterceptors(jsJavaScriptObjectClass, enqueuer, registry);
1157 } else if (cls == jsPlainJavaScriptObjectClass) { 1194 } else if (cls == jsPlainJavaScriptObjectClass) {
1158 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry); 1195 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry);
1159 } else if (cls == jsUnknownJavaScriptObjectClass) { 1196 } else if (cls == jsUnknownJavaScriptObjectClass) {
1160 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry); 1197 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry);
1198 } else if (cls == jsJavaScriptFunctionClass) {
1199 addInterceptors(jsJavaScriptFunctionClass, enqueuer, registry);
1161 } else if (Elements.isNativeOrExtendsNative(cls)) { 1200 } else if (Elements.isNativeOrExtendsNative(cls)) {
1162 addInterceptorsForNativeClassMembers(cls, enqueuer); 1201 addInterceptorsForNativeClassMembers(cls, enqueuer);
1163 } else if (cls == jsIndexingBehaviorInterface) { 1202 } else if (cls == jsIndexingBehaviorInterface) {
1164 // These two helpers are used by the emitter and the codegen. 1203 // These two helpers are used by the emitter and the codegen.
1165 // Because we cannot enqueue elements at the time of emission, 1204 // Because we cannot enqueue elements at the time of emission,
1166 // we make sure they are always generated. 1205 // we make sure they are always generated.
1167 enqueue(enqueuer, findHelper('isJsIndexable'), registry); 1206 enqueue(enqueuer, findHelper('isJsIndexable'), registry);
1168 } 1207 }
1169 1208
1170 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer); 1209 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer);
1171 if (!enqueuer.isResolutionQueue) { 1210 if (!enqueuer.isResolutionQueue) {
1172 lookupMapAnalysis.registerInstantiatedClass(cls); 1211 lookupMapAnalysis.registerInstantiatedClass(cls);
1173 } 1212 }
1174 } 1213 }
1175 1214
1176 void registerInstantiatedType(InterfaceType type, 1215 void registerInstantiatedType(InterfaceType type,
1177 Enqueuer enqueuer, 1216 Enqueuer enqueuer,
1178 Registry registry, 1217 Registry registry,
1179 {bool mirrorUsage: false}) { 1218 {bool mirrorUsage: false}) {
1180 lookupMapAnalysis.registerInstantiatedType(type, registry); 1219 lookupMapAnalysis.registerInstantiatedType(type, registry);
1181 super.registerInstantiatedType( 1220 super.registerInstantiatedType(
1182 type, enqueuer, registry, mirrorUsage: mirrorUsage); 1221 type, enqueuer, registry, mirrorUsage: mirrorUsage);
1183 } 1222 }
1184 1223
1185 void registerUseInterceptor(Enqueuer enqueuer) { 1224 void registerUseInterceptor(Enqueuer enqueuer) {
1186 assert(!enqueuer.isResolutionQueue); 1225 assert(!enqueuer.isResolutionQueue);
1187 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return; 1226 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return;
1188 Registry registry = compiler.globalDependencies; 1227 Registry registry = compiler.globalDependencies;
1189 enqueue(enqueuer, getNativeInterceptorMethod, registry); 1228 enqueue(enqueuer, getNativeInterceptorMethod, registry);
1229 enqueueClass(enqueuer, jsJavaScriptObjectClass, registry);
1190 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); 1230 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry);
1231 enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry);
1191 needToInitializeIsolateAffinityTag = true; 1232 needToInitializeIsolateAffinityTag = true;
1192 needToInitializeDispatchProperty = true; 1233 needToInitializeDispatchProperty = true;
1193 } 1234 }
1194 1235
1195 JavaScriptItemCompilationContext createItemCompilationContext() { 1236 JavaScriptItemCompilationContext createItemCompilationContext() {
1196 return new JavaScriptItemCompilationContext(); 1237 return new JavaScriptItemCompilationContext();
1197 } 1238 }
1198 1239
1199 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { 1240 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) {
1200 assert(interceptorsLibrary != null); 1241 assert(interceptorsLibrary != null);
(...skipping 15 matching lines...) Expand all
1216 TRACE_METHOD == 'console' ? 'consoleTraceHelper' : 'postTraceHelper'); 1257 TRACE_METHOD == 'console' ? 'consoleTraceHelper' : 'postTraceHelper');
1217 assert(traceHelper != null); 1258 assert(traceHelper != null);
1218 enqueueInResolution(traceHelper, registry); 1259 enqueueInResolution(traceHelper, registry);
1219 } 1260 }
1220 enqueueInResolution(assertUnreachableMethod, registry); 1261 enqueueInResolution(assertUnreachableMethod, registry);
1221 registerCheckedModeHelpers(registry); 1262 registerCheckedModeHelpers(registry);
1222 } 1263 }
1223 1264
1224 onResolutionComplete() { 1265 onResolutionComplete() {
1225 super.onResolutionComplete(); 1266 super.onResolutionComplete();
1267
sra1 2015/10/06 21:42:17 remove extra line
Jacob 2015/10/13 01:19:23 Done.
1226 computeMembersNeededForReflection(); 1268 computeMembersNeededForReflection();
1227 rti.computeClassesNeedingRti(); 1269 rti.computeClassesNeedingRti();
1228 } 1270 }
1229 1271
1230 onTypeInferenceComplete() { 1272 onTypeInferenceComplete() {
1231 super.onTypeInferenceComplete(); 1273 super.onTypeInferenceComplete();
1232 noSuchMethodRegistry.onTypeInferenceComplete(); 1274 noSuchMethodRegistry.onTypeInferenceComplete();
1233 } 1275 }
1234 1276
1235 void registerGetRuntimeTypeArgument(Registry registry) { 1277 void registerGetRuntimeTypeArgument(Registry registry) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 1585
1544 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { 1586 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) {
1545 return new native.NativeResolutionEnqueuer(world, compiler); 1587 return new native.NativeResolutionEnqueuer(world, compiler);
1546 } 1588 }
1547 1589
1548 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { 1590 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) {
1549 return new native.NativeCodegenEnqueuer(world, compiler, emitter); 1591 return new native.NativeCodegenEnqueuer(world, compiler, emitter);
1550 } 1592 }
1551 1593
1552 ClassElement defaultSuperclass(ClassElement element) { 1594 ClassElement defaultSuperclass(ClassElement element) {
1595 if (element.isJsInterop) return jsJavaScriptObjectClass;
1553 // Native classes inherit from Interceptor. 1596 // Native classes inherit from Interceptor.
1554 return element.isNative ? jsInterceptorClass : compiler.objectClass; 1597 return element.isNative ? jsInterceptorClass : compiler.objectClass;
1555 } 1598 }
1556 1599
1557 /** 1600 /**
1558 * Unit test hook that returns code of an element as a String. 1601 * Unit test hook that returns code of an element as a String.
1559 * 1602 *
1560 * Invariant: [element] must be a declaration element. 1603 * Invariant: [element] must be a declaration element.
1561 */ 1604 */
1562 String getGeneratedCode(Element element) { 1605 String getGeneratedCode(Element element) {
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 jsUInt31Class = findClass('JSUInt31'); 2214 jsUInt31Class = findClass('JSUInt31');
2172 jsDoubleClass = findClass('JSDouble'); 2215 jsDoubleClass = findClass('JSDouble');
2173 jsNumberClass = findClass('JSNumber'); 2216 jsNumberClass = findClass('JSNumber');
2174 jsNullClass = findClass('JSNull'); 2217 jsNullClass = findClass('JSNull');
2175 jsBoolClass = findClass('JSBool'); 2218 jsBoolClass = findClass('JSBool');
2176 jsMutableArrayClass = findClass('JSMutableArray'); 2219 jsMutableArrayClass = findClass('JSMutableArray');
2177 jsFixedArrayClass = findClass('JSFixedArray'); 2220 jsFixedArrayClass = findClass('JSFixedArray');
2178 jsExtendableArrayClass = findClass('JSExtendableArray'); 2221 jsExtendableArrayClass = findClass('JSExtendableArray');
2179 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); 2222 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray');
2180 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); 2223 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject');
2224 jsJavaScriptObjectClass = findClass('JavaScriptObject');
2225 jsJavaScriptFunctionClass = findClass('JavaScriptFunction');
2181 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); 2226 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject');
2182 jsIndexableClass = findClass('JSIndexable'); 2227 jsIndexableClass = findClass('JSIndexable');
2183 jsMutableIndexableClass = findClass('JSMutableIndexable'); 2228 jsMutableIndexableClass = findClass('JSMutableIndexable');
2184 } else if (uri == DART_JS_HELPER) { 2229 } else if (uri == DART_JS_HELPER) {
2185 initializeHelperClasses(); 2230 initializeHelperClasses();
2186 assertTestMethod = findHelper('assertTest'); 2231 assertTestMethod = findHelper('assertTest');
2187 assertThrowMethod = findHelper('assertThrow'); 2232 assertThrowMethod = findHelper('assertThrow');
2188 assertHelperMethod = findHelper('assertHelper'); 2233 assertHelperMethod = findHelper('assertHelper');
2189 assertUnreachableMethod = findHelper('assertUnreachable'); 2234 assertUnreachableMethod = findHelper('assertUnreachable');
2190 2235
(...skipping 22 matching lines...) Expand all
2213 } else if (uri == DART_EMBEDDED_NAMES) { 2258 } else if (uri == DART_EMBEDDED_NAMES) {
2214 jsGetNameEnum = find(library, 'JsGetName'); 2259 jsGetNameEnum = find(library, 'JsGetName');
2215 jsBuiltinEnum = find(library, 'JsBuiltin'); 2260 jsBuiltinEnum = find(library, 'JsBuiltin');
2216 } else if (uri == Uris.dart_html) { 2261 } else if (uri == Uris.dart_html) {
2217 htmlLibraryIsLoaded = true; 2262 htmlLibraryIsLoaded = true;
2218 } else if (uri == PACKAGE_LOOKUP_MAP) { 2263 } else if (uri == PACKAGE_LOOKUP_MAP) {
2219 lookupMapAnalysis.init(library); 2264 lookupMapAnalysis.init(library);
2220 } else if (uri == Uris.dart__native_typed_data) { 2265 } else if (uri == Uris.dart__native_typed_data) {
2221 typedArrayClass = findClass('NativeTypedArray'); 2266 typedArrayClass = findClass('NativeTypedArray');
2222 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt'); 2267 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt');
2268 } else if (uri == PACKAGE_JS) {
2269 jsAnnotationClass = find(library, 'Js');
2223 } 2270 }
2224 annotations.onLibraryScanned(library); 2271 annotations.onLibraryScanned(library);
2225 }); 2272 });
2226 } 2273 }
2227 2274
2228 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { 2275 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) {
2229 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { 2276 if (!loadedLibraries.containsLibrary(Uris.dart_core)) {
2230 return new Future.value(); 2277 return new Future.value();
2231 } 2278 }
2232 2279
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 } 2709 }
2663 } 2710 }
2664 return true; 2711 return true;
2665 } 2712 }
2666 2713
2667 void onQueueClosed() { 2714 void onQueueClosed() {
2668 lookupMapAnalysis.onQueueClosed(); 2715 lookupMapAnalysis.onQueueClosed();
2669 } 2716 }
2670 2717
2671 void onCodegenStart() { 2718 void onCodegenStart() {
2719 jsInteropAnalysis.onCodegenStart();
2672 lookupMapAnalysis.onCodegenStart(); 2720 lookupMapAnalysis.onCodegenStart();
2673 } 2721 }
2674 2722
2675 void onElementResolved(Element element, TreeElements elements) { 2723 void onElementResolved(Element element, TreeElements elements) {
2676 if ((element.isFunction || element.isGenerativeConstructor) && 2724 if ((element.isFunction || element.isGenerativeConstructor) &&
2677 annotations.noInline(element)) { 2725 annotations.noInline(element)) {
2678 inlineCache.markAsNonInlinable(element); 2726 inlineCache.markAsNonInlinable(element);
2679 } 2727 }
2680 2728
2681 LibraryElement library = element.library; 2729 LibraryElement library = element.library;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 } 3285 }
3238 } 3286 }
3239 3287
3240 /// Records that [constant] is used by the element behind [registry]. 3288 /// Records that [constant] is used by the element behind [registry].
3241 class Dependency { 3289 class Dependency {
3242 final ConstantValue constant; 3290 final ConstantValue constant;
3243 final Element annotatedElement; 3291 final Element annotatedElement;
3244 3292
3245 const Dependency(this.constant, this.annotatedElement); 3293 const Dependency(this.constant, this.annotatedElement);
3246 } 3294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698