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

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: about to land 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 ClassElement jsInterceptorClass; 286 ClassElement jsInterceptorClass;
285 ClassElement jsStringClass; 287 ClassElement jsStringClass;
286 ClassElement jsArrayClass; 288 ClassElement jsArrayClass;
287 ClassElement jsNumberClass; 289 ClassElement jsNumberClass;
288 ClassElement jsIntClass; 290 ClassElement jsIntClass;
289 ClassElement jsDoubleClass; 291 ClassElement jsDoubleClass;
290 ClassElement jsNullClass; 292 ClassElement jsNullClass;
291 ClassElement jsBoolClass; 293 ClassElement jsBoolClass;
292 ClassElement jsPlainJavaScriptObjectClass; 294 ClassElement jsPlainJavaScriptObjectClass;
293 ClassElement jsUnknownJavaScriptObjectClass; 295 ClassElement jsUnknownJavaScriptObjectClass;
296 ClassElement jsJavaScriptFunctionClass;
297 ClassElement jsJavaScriptObjectClass;
294 298
295 ClassElement jsIndexableClass; 299 ClassElement jsIndexableClass;
296 ClassElement jsMutableIndexableClass; 300 ClassElement jsMutableIndexableClass;
297 301
298 ClassElement jsMutableArrayClass; 302 ClassElement jsMutableArrayClass;
299 ClassElement jsFixedArrayClass; 303 ClassElement jsFixedArrayClass;
300 ClassElement jsExtendableArrayClass; 304 ClassElement jsExtendableArrayClass;
301 ClassElement jsUnmodifiableArrayClass; 305 ClassElement jsUnmodifiableArrayClass;
302 ClassElement jsPositiveIntClass; 306 ClassElement jsPositiveIntClass;
303 ClassElement jsUInt32Class; 307 ClassElement jsUInt32Class;
(...skipping 16 matching lines...) Expand all
320 ConstructorElement mapLiteralConstructorEmpty; 324 ConstructorElement mapLiteralConstructorEmpty;
321 Element mapLiteralUntypedMaker; 325 Element mapLiteralUntypedMaker;
322 Element mapLiteralUntypedEmptyMaker; 326 Element mapLiteralUntypedEmptyMaker;
323 327
324 ClassElement noSideEffectsClass; 328 ClassElement noSideEffectsClass;
325 ClassElement noThrowsClass; 329 ClassElement noThrowsClass;
326 ClassElement noInlineClass; 330 ClassElement noInlineClass;
327 ClassElement forceInlineClass; 331 ClassElement forceInlineClass;
328 ClassElement irRepresentationClass; 332 ClassElement irRepresentationClass;
329 333
334 ClassElement jsAnnotationClass;
335
330 Element getInterceptorMethod; 336 Element getInterceptorMethod;
331 337
332 ClassElement jsInvocationMirrorClass; 338 ClassElement jsInvocationMirrorClass;
333 339
334 ClassElement typedArrayClass; 340 ClassElement typedArrayClass;
335 ClassElement typedArrayOfIntClass; 341 ClassElement typedArrayOfIntClass;
336 342
337 /// If [true], the compiler will emit code that logs whenever a method is 343 /// If [true], the compiler will emit code that logs whenever a method is
338 /// called. When TRACE_METHOD is 'console' this will be logged 344 /// called. When TRACE_METHOD is 'console' this will be logged
339 /// directly in the JavaScript console. When TRACE_METHOD is 'post' the 345 /// directly in the JavaScript console. When TRACE_METHOD is 'post' the
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 /// Number of methods compiled before considering reflection. 615 /// Number of methods compiled before considering reflection.
610 int preMirrorsMethodCount = 0; 616 int preMirrorsMethodCount = 0;
611 617
612 /// Resolution and codegen support for generating table of interceptors and 618 /// Resolution and codegen support for generating table of interceptors and
613 /// constructors for custom elements. 619 /// constructors for custom elements.
614 CustomElementsAnalysis customElementsAnalysis; 620 CustomElementsAnalysis customElementsAnalysis;
615 621
616 /// Codegen support for tree-shaking entries of `LookupMap`. 622 /// Codegen support for tree-shaking entries of `LookupMap`.
617 LookupMapAnalysis lookupMapAnalysis; 623 LookupMapAnalysis lookupMapAnalysis;
618 624
625 /// Codegen support for typed JavaScript interop.
626 JsInteropAnalysis jsInteropAnalysis;
627
619 /// Support for classifying `noSuchMethod` implementations. 628 /// Support for classifying `noSuchMethod` implementations.
620 NoSuchMethodRegistry noSuchMethodRegistry; 629 NoSuchMethodRegistry noSuchMethodRegistry;
621 630
622 JavaScriptConstantTask constantCompilerTask; 631 JavaScriptConstantTask constantCompilerTask;
623 632
624 JavaScriptResolutionCallbacks resolutionCallbacks; 633 JavaScriptResolutionCallbacks resolutionCallbacks;
625 634
626 PatchResolverTask patchResolverTask; 635 PatchResolverTask patchResolverTask;
627 636
628 bool enabledNoSuchMethod = false; 637 bool enabledNoSuchMethod = false;
(...skipping 20 matching lines...) Expand all
649 : const StartEndSourceInformationStrategy()) 658 : const StartEndSourceInformationStrategy())
650 : const JavaScriptSourceInformationStrategy(), 659 : const JavaScriptSourceInformationStrategy(),
651 helpers = new BackendHelpers(compiler), 660 helpers = new BackendHelpers(compiler),
652 impacts = new BackendImpacts(compiler), 661 impacts = new BackendImpacts(compiler),
653 super(compiler) { 662 super(compiler) {
654 emitter = new CodeEmitterTask( 663 emitter = new CodeEmitterTask(
655 compiler, namer, generateSourceMap, useStartupEmitter); 664 compiler, namer, generateSourceMap, useStartupEmitter);
656 typeVariableHandler = new TypeVariableHandler(compiler); 665 typeVariableHandler = new TypeVariableHandler(compiler);
657 customElementsAnalysis = new CustomElementsAnalysis(this); 666 customElementsAnalysis = new CustomElementsAnalysis(this);
658 lookupMapAnalysis = new LookupMapAnalysis(this, reporter); 667 lookupMapAnalysis = new LookupMapAnalysis(this, reporter);
668 jsInteropAnalysis = new JsInteropAnalysis(this);
669
659 noSuchMethodRegistry = new NoSuchMethodRegistry(this); 670 noSuchMethodRegistry = new NoSuchMethodRegistry(this);
660 constantCompilerTask = new JavaScriptConstantTask(compiler); 671 constantCompilerTask = new JavaScriptConstantTask(compiler);
661 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); 672 resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
662 patchResolverTask = new PatchResolverTask(compiler); 673 patchResolverTask = new PatchResolverTask(compiler);
663 functionCompiler = compiler.useCpsIr 674 functionCompiler = compiler.useCpsIr
664 ? new CpsFunctionCompiler( 675 ? new CpsFunctionCompiler(
665 compiler, this, sourceInformationStrategy) 676 compiler, this, sourceInformationStrategy)
666 : new SsaFunctionCompiler(this, sourceInformationStrategy); 677 : new SsaFunctionCompiler(this, sourceInformationStrategy);
667 } 678 }
668 679
669 ConstantSystem get constantSystem => constants.constantSystem; 680 ConstantSystem get constantSystem => constants.constantSystem;
670 681
671 DiagnosticReporter get reporter => compiler.reporter; 682 DiagnosticReporter get reporter => compiler.reporter;
672 683
673 Resolution get resolution => compiler.resolution; 684 Resolution get resolution => compiler.resolution;
674 685
675 /// Returns constant environment for the JavaScript interpretation of the 686 /// Returns constant environment for the JavaScript interpretation of the
676 /// constants. 687 /// constants.
677 JavaScriptConstantCompiler get constants { 688 JavaScriptConstantCompiler get constants {
678 return constantCompilerTask.jsConstantCompiler; 689 return constantCompilerTask.jsConstantCompiler;
679 } 690 }
680 691
681 FunctionElement resolveExternalFunction(FunctionElement element) { 692 FunctionElement resolveExternalFunction(FunctionElement element) {
682 if (isForeign(element)) return element; 693 if (isForeign(element) || element.isJsInterop) return element;
683 return patchResolverTask.measure(() { 694 return patchResolverTask.measure(() {
684 return patchResolverTask.resolveExternalFunction(element); 695 return patchResolverTask.resolveExternalFunction(element);
685 }); 696 });
686 } 697 }
687 698
688 // TODO(karlklose): Split into findHelperFunction and findHelperClass and 699 // TODO(karlklose): Split into findHelperFunction and findHelperClass and
689 // add a check that the element has the expected kind. 700 // add a check that the element has the expected kind.
690 Element findHelper(String name) => find(jsHelperLibrary, name); 701 Element findHelper(String name) => find(jsHelperLibrary, name);
691 Element findAsyncHelper(String name) => find(asyncLibrary, name); 702 Element findAsyncHelper(String name) => find(asyncLibrary, name);
692 Element findInterceptor(String name) => find(interceptorsLibrary, name); 703 Element findInterceptor(String name) => find(interceptorsLibrary, name);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 enqueueClass(enqueuer, mapLiteralClass, registry); 1086 enqueueClass(enqueuer, mapLiteralClass, registry);
1076 // For map literals, the dependency between the implementation class 1087 // For map literals, the dependency between the implementation class
1077 // and [Map] is not visible, so we have to add it manually. 1088 // and [Map] is not visible, so we have to add it manually.
1078 rti.registerRtiDependency(mapLiteralClass, cls); 1089 rti.registerRtiDependency(mapLiteralClass, cls);
1079 } else if (cls == boundClosureClass) { 1090 } else if (cls == boundClosureClass) {
1080 // TODO(johnniwinther): Is this a noop? 1091 // TODO(johnniwinther): Is this a noop?
1081 enqueueClass(enqueuer, boundClosureClass, registry); 1092 enqueueClass(enqueuer, boundClosureClass, registry);
1082 } else if (Elements.isNativeOrExtendsNative(cls)) { 1093 } else if (Elements.isNativeOrExtendsNative(cls)) {
1083 enqueue(enqueuer, getNativeInterceptorMethod, registry); 1094 enqueue(enqueuer, getNativeInterceptorMethod, registry);
1084 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); 1095 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies);
1096 enqueueClass(enqueuer, jsJavaScriptObjectClass, registry);
1085 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); 1097 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry);
1098 enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry);
1086 } else if (cls == mapLiteralClass) { 1099 } else if (cls == mapLiteralClass) {
1087 // For map literals, the dependency between the implementation class 1100 // For map literals, the dependency between the implementation class
1088 // and [Map] is not visible, so we have to add it manually. 1101 // and [Map] is not visible, so we have to add it manually.
1089 Element getFactory(String name, int arity) { 1102 Element getFactory(String name, int arity) {
1090 // The constructor is on the patch class, but dart2js unit tests don't 1103 // The constructor is on the patch class, but dart2js unit tests don't
1091 // have a patch class. 1104 // have a patch class.
1092 ClassElement implementation = cls.patch != null ? cls.patch : cls; 1105 ClassElement implementation = cls.patch != null ? cls.patch : cls;
1093 ConstructorElement ctor = implementation.lookupConstructor(name); 1106 ConstructorElement ctor = implementation.lookupConstructor(name);
1094 if (ctor == null 1107 if (ctor == null
1095 || (Name.isPrivateName(name) 1108 || (Name.isPrivateName(name)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 addInterceptors(jsBoolClass, enqueuer, registry); 1165 addInterceptors(jsBoolClass, enqueuer, registry);
1153 } else if (cls == compiler.nullClass || cls == jsNullClass) { 1166 } else if (cls == compiler.nullClass || cls == jsNullClass) {
1154 addInterceptors(jsNullClass, enqueuer, registry); 1167 addInterceptors(jsNullClass, enqueuer, registry);
1155 } else if (cls == compiler.numClass || cls == jsNumberClass) { 1168 } else if (cls == compiler.numClass || cls == jsNumberClass) {
1156 addInterceptors(jsIntClass, enqueuer, registry); 1169 addInterceptors(jsIntClass, enqueuer, registry);
1157 addInterceptors(jsPositiveIntClass, enqueuer, registry); 1170 addInterceptors(jsPositiveIntClass, enqueuer, registry);
1158 addInterceptors(jsUInt32Class, enqueuer, registry); 1171 addInterceptors(jsUInt32Class, enqueuer, registry);
1159 addInterceptors(jsUInt31Class, enqueuer, registry); 1172 addInterceptors(jsUInt31Class, enqueuer, registry);
1160 addInterceptors(jsDoubleClass, enqueuer, registry); 1173 addInterceptors(jsDoubleClass, enqueuer, registry);
1161 addInterceptors(jsNumberClass, enqueuer, registry); 1174 addInterceptors(jsNumberClass, enqueuer, registry);
1175 } else if (cls == jsJavaScriptObjectClass) {
1176 addInterceptors(jsJavaScriptObjectClass, enqueuer, registry);
1162 } else if (cls == jsPlainJavaScriptObjectClass) { 1177 } else if (cls == jsPlainJavaScriptObjectClass) {
1163 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry); 1178 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, registry);
1164 } else if (cls == jsUnknownJavaScriptObjectClass) { 1179 } else if (cls == jsUnknownJavaScriptObjectClass) {
1165 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry); 1180 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, registry);
1181 } else if (cls == jsJavaScriptFunctionClass) {
1182 addInterceptors(jsJavaScriptFunctionClass, enqueuer, registry);
1166 } else if (Elements.isNativeOrExtendsNative(cls)) { 1183 } else if (Elements.isNativeOrExtendsNative(cls)) {
1167 addInterceptorsForNativeClassMembers(cls, enqueuer); 1184 addInterceptorsForNativeClassMembers(cls, enqueuer);
1168 } else if (cls == jsIndexingBehaviorInterface) { 1185 } else if (cls == jsIndexingBehaviorInterface) {
1169 // These two helpers are used by the emitter and the codegen. 1186 // These two helpers are used by the emitter and the codegen.
1170 // Because we cannot enqueue elements at the time of emission, 1187 // Because we cannot enqueue elements at the time of emission,
1171 // we make sure they are always generated. 1188 // we make sure they are always generated.
1172 enqueue(enqueuer, findHelper('isJsIndexable'), registry); 1189 enqueue(enqueuer, findHelper('isJsIndexable'), registry);
1173 } 1190 }
1174 1191
1175 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer); 1192 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer);
1176 if (!enqueuer.isResolutionQueue) { 1193 if (!enqueuer.isResolutionQueue) {
1177 lookupMapAnalysis.registerInstantiatedClass(cls); 1194 lookupMapAnalysis.registerInstantiatedClass(cls);
1178 } 1195 }
1179 } 1196 }
1180 1197
1181 void registerInstantiatedType(InterfaceType type, 1198 void registerInstantiatedType(InterfaceType type,
1182 Enqueuer enqueuer, 1199 Enqueuer enqueuer,
1183 Registry registry, 1200 Registry registry,
1184 {bool mirrorUsage: false}) { 1201 {bool mirrorUsage: false}) {
1185 lookupMapAnalysis.registerInstantiatedType(type, registry); 1202 lookupMapAnalysis.registerInstantiatedType(type, registry);
1186 super.registerInstantiatedType( 1203 super.registerInstantiatedType(
1187 type, enqueuer, registry, mirrorUsage: mirrorUsage); 1204 type, enqueuer, registry, mirrorUsage: mirrorUsage);
1188 } 1205 }
1189 1206
1190 void registerUseInterceptor(Enqueuer enqueuer) { 1207 void registerUseInterceptor(Enqueuer enqueuer) {
1191 assert(!enqueuer.isResolutionQueue); 1208 assert(!enqueuer.isResolutionQueue);
1192 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return; 1209 if (!enqueuer.nativeEnqueuer.hasInstantiatedNativeClasses()) return;
1193 Registry registry = compiler.globalDependencies; 1210 Registry registry = compiler.globalDependencies;
1194 enqueue(enqueuer, getNativeInterceptorMethod, registry); 1211 enqueue(enqueuer, getNativeInterceptorMethod, registry);
1212 enqueueClass(enqueuer, jsJavaScriptObjectClass, registry);
1195 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry); 1213 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, registry);
1214 enqueueClass(enqueuer, jsJavaScriptFunctionClass, registry);
1196 needToInitializeIsolateAffinityTag = true; 1215 needToInitializeIsolateAffinityTag = true;
1197 needToInitializeDispatchProperty = true; 1216 needToInitializeDispatchProperty = true;
1198 } 1217 }
1199 1218
1200 JavaScriptItemCompilationContext createItemCompilationContext() { 1219 JavaScriptItemCompilationContext createItemCompilationContext() {
1201 return new JavaScriptItemCompilationContext(); 1220 return new JavaScriptItemCompilationContext();
1202 } 1221 }
1203 1222
1204 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) { 1223 void enqueueHelpers(ResolutionEnqueuer world, Registry registry) {
1205 assert(interceptorsLibrary != null); 1224 assert(interceptorsLibrary != null);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 1596
1578 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { 1597 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) {
1579 return new native.NativeResolutionEnqueuer(world, compiler); 1598 return new native.NativeResolutionEnqueuer(world, compiler);
1580 } 1599 }
1581 1600
1582 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { 1601 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) {
1583 return new native.NativeCodegenEnqueuer(world, compiler, emitter); 1602 return new native.NativeCodegenEnqueuer(world, compiler, emitter);
1584 } 1603 }
1585 1604
1586 ClassElement defaultSuperclass(ClassElement element) { 1605 ClassElement defaultSuperclass(ClassElement element) {
1606 if (element.isJsInterop) return jsJavaScriptObjectClass;
1587 // Native classes inherit from Interceptor. 1607 // Native classes inherit from Interceptor.
1588 return element.isNative ? jsInterceptorClass : compiler.objectClass; 1608 return element.isNative ? jsInterceptorClass : compiler.objectClass;
1589 } 1609 }
1590 1610
1591 /** 1611 /**
1592 * Unit test hook that returns code of an element as a String. 1612 * Unit test hook that returns code of an element as a String.
1593 * 1613 *
1594 * Invariant: [element] must be a declaration element. 1614 * Invariant: [element] must be a declaration element.
1595 */ 1615 */
1596 String getGeneratedCode(Element element) { 1616 String getGeneratedCode(Element element) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 jsUInt31Class = findClass('JSUInt31'); 2013 jsUInt31Class = findClass('JSUInt31');
1994 jsDoubleClass = findClass('JSDouble'); 2014 jsDoubleClass = findClass('JSDouble');
1995 jsNumberClass = findClass('JSNumber'); 2015 jsNumberClass = findClass('JSNumber');
1996 jsNullClass = findClass('JSNull'); 2016 jsNullClass = findClass('JSNull');
1997 jsBoolClass = findClass('JSBool'); 2017 jsBoolClass = findClass('JSBool');
1998 jsMutableArrayClass = findClass('JSMutableArray'); 2018 jsMutableArrayClass = findClass('JSMutableArray');
1999 jsFixedArrayClass = findClass('JSFixedArray'); 2019 jsFixedArrayClass = findClass('JSFixedArray');
2000 jsExtendableArrayClass = findClass('JSExtendableArray'); 2020 jsExtendableArrayClass = findClass('JSExtendableArray');
2001 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); 2021 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray');
2002 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); 2022 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject');
2023 jsJavaScriptObjectClass = findClass('JavaScriptObject');
2024 jsJavaScriptFunctionClass = findClass('JavaScriptFunction');
2003 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); 2025 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject');
2004 jsIndexableClass = findClass('JSIndexable'); 2026 jsIndexableClass = findClass('JSIndexable');
2005 jsMutableIndexableClass = findClass('JSMutableIndexable'); 2027 jsMutableIndexableClass = findClass('JSMutableIndexable');
2006 } else if (uri == DART_JS_HELPER) { 2028 } else if (uri == DART_JS_HELPER) {
2007 initializeHelperClasses(); 2029 initializeHelperClasses();
2008 helpers.assertTest = findHelper('assertTest'); 2030 helpers.assertTest = findHelper('assertTest');
2009 helpers.assertThrow = findHelper('assertThrow'); 2031 helpers.assertThrow = findHelper('assertThrow');
2010 helpers.assertHelper = findHelper('assertHelper'); 2032 helpers.assertHelper = findHelper('assertHelper');
2011 assertUnreachableMethod = findHelper('assertUnreachable'); 2033 assertUnreachableMethod = findHelper('assertUnreachable');
2012 2034
(...skipping 22 matching lines...) Expand all
2035 } else if (uri == DART_EMBEDDED_NAMES) { 2057 } else if (uri == DART_EMBEDDED_NAMES) {
2036 jsGetNameEnum = find(library, 'JsGetName'); 2058 jsGetNameEnum = find(library, 'JsGetName');
2037 jsBuiltinEnum = find(library, 'JsBuiltin'); 2059 jsBuiltinEnum = find(library, 'JsBuiltin');
2038 } else if (uri == Uris.dart_html) { 2060 } else if (uri == Uris.dart_html) {
2039 htmlLibraryIsLoaded = true; 2061 htmlLibraryIsLoaded = true;
2040 } else if (uri == PACKAGE_LOOKUP_MAP) { 2062 } else if (uri == PACKAGE_LOOKUP_MAP) {
2041 lookupMapAnalysis.init(library); 2063 lookupMapAnalysis.init(library);
2042 } else if (uri == Uris.dart__native_typed_data) { 2064 } else if (uri == Uris.dart__native_typed_data) {
2043 typedArrayClass = findClass('NativeTypedArray'); 2065 typedArrayClass = findClass('NativeTypedArray');
2044 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt'); 2066 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt');
2067 } else if (uri == PACKAGE_JS) {
2068 jsAnnotationClass = find(library, 'Js');
2045 } 2069 }
2046 annotations.onLibraryScanned(library); 2070 annotations.onLibraryScanned(library);
2047 }); 2071 });
2048 } 2072 }
2049 2073
2050 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { 2074 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) {
2051 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { 2075 if (!loadedLibraries.containsLibrary(Uris.dart_core)) {
2052 return new Future.value(); 2076 return new Future.value();
2053 } 2077 }
2054 2078
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 addForEmission: false); 2513 addForEmission: false);
2490 } 2514 }
2491 metadataConstants.clear(); 2515 metadataConstants.clear();
2492 } 2516 }
2493 } 2517 }
2494 return true; 2518 return true;
2495 } 2519 }
2496 2520
2497 void onQueueClosed() { 2521 void onQueueClosed() {
2498 lookupMapAnalysis.onQueueClosed(); 2522 lookupMapAnalysis.onQueueClosed();
2523 jsInteropAnalysis.onQueueClosed();
2499 } 2524 }
2500 2525
2501 void onCodegenStart() { 2526 void onCodegenStart() {
2502 lookupMapAnalysis.onCodegenStart(); 2527 lookupMapAnalysis.onCodegenStart();
2503 } 2528 }
2504 2529
2505 void onElementResolved(Element element, TreeElements elements) { 2530 void onElementResolved(Element element, TreeElements elements) {
2506 if ((element.isFunction || element.isGenerativeConstructor) && 2531 if ((element.isFunction || element.isGenerativeConstructor) &&
2507 annotations.noInline(element)) { 2532 annotations.noInline(element)) {
2508 inlineCache.markAsNonInlinable(element); 2533 inlineCache.markAsNonInlinable(element);
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 } 3042 }
3018 3043
3019 /// Records that [constant] is used by the element behind [registry]. 3044 /// Records that [constant] is used by the element behind [registry].
3020 class Dependency { 3045 class Dependency {
3021 final ConstantValue constant; 3046 final ConstantValue constant;
3022 final Element annotatedElement; 3047 final Element annotatedElement;
3023 3048
3024 const Dependency(this.constant, this.annotatedElement); 3049 const Dependency(this.constant, this.annotatedElement);
3025 } 3050 }
3026 3051
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698