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

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

Issue 1019903002: Revert "Don't generate forwarding hooks if all noSuchMethod implementations" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR"); 9 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR");
10 10
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 578
579 TypeVariableHandler typeVariableHandler; 579 TypeVariableHandler typeVariableHandler;
580 580
581 /// Number of methods compiled before considering reflection. 581 /// Number of methods compiled before considering reflection.
582 int preMirrorsMethodCount = 0; 582 int preMirrorsMethodCount = 0;
583 583
584 /// Resolution and codegen support for generating table of interceptors and 584 /// Resolution and codegen support for generating table of interceptors and
585 /// constructors for custom elements. 585 /// constructors for custom elements.
586 CustomElementsAnalysis customElementsAnalysis; 586 CustomElementsAnalysis customElementsAnalysis;
587 587
588 /// Support for classifying `noSuchMethod` implementations.
589 NoSuchMethodRegistry noSuchMethodRegistry;
590
591 JavaScriptConstantTask constantCompilerTask; 588 JavaScriptConstantTask constantCompilerTask;
592 589
593 JavaScriptResolutionCallbacks resolutionCallbacks; 590 JavaScriptResolutionCallbacks resolutionCallbacks;
594 591
595 PatchResolverTask patchResolverTask; 592 PatchResolverTask patchResolverTask;
596 593
597 bool get canHandleCompilationFailed => true; 594 bool get canHandleCompilationFailed => true;
598 595
599 bool enabledNoSuchMethod = false;
600
601 JavaScriptBackend(Compiler compiler, bool generateSourceMap) 596 JavaScriptBackend(Compiler compiler, bool generateSourceMap)
602 : namer = determineNamer(compiler), 597 : namer = determineNamer(compiler),
603 oneShotInterceptors = new Map<String, Selector>(), 598 oneShotInterceptors = new Map<String, Selector>(),
604 interceptedElements = new Map<String, Set<Element>>(), 599 interceptedElements = new Map<String, Set<Element>>(),
605 rti = new RuntimeTypes(compiler), 600 rti = new RuntimeTypes(compiler),
606 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), 601 specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
607 super(compiler) { 602 super(compiler) {
608 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); 603 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap);
609 typeVariableHandler = new TypeVariableHandler(this); 604 typeVariableHandler = new TypeVariableHandler(this);
610 customElementsAnalysis = new CustomElementsAnalysis(this); 605 customElementsAnalysis = new CustomElementsAnalysis(this);
611 noSuchMethodRegistry = new NoSuchMethodRegistry(this);
612 constantCompilerTask = new JavaScriptConstantTask(compiler); 606 constantCompilerTask = new JavaScriptConstantTask(compiler);
613 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); 607 resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
614 patchResolverTask = new PatchResolverTask(compiler); 608 patchResolverTask = new PatchResolverTask(compiler);
615 functionCompiler = USE_CPS_IR 609 functionCompiler = USE_CPS_IR
616 ? new CpsFunctionCompiler( 610 ? new CpsFunctionCompiler(
617 compiler, this, generateSourceMap: generateSourceMap) 611 compiler, this, generateSourceMap: generateSourceMap)
618 : new SsaFunctionCompiler(this, generateSourceMap); 612 : new SsaFunctionCompiler(this, generateSourceMap);
619 } 613 }
620 614
621 ConstantSystem get constantSystem => constants.constantSystem; 615 ConstantSystem get constantSystem => constants.constantSystem;
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 DartType bound) { 1203 DartType bound) {
1210 rti.registerTypeVariableBoundsSubtypeCheck(typeArgument, bound); 1204 rti.registerTypeVariableBoundsSubtypeCheck(typeArgument, bound);
1211 } 1205 }
1212 1206
1213 void registerCheckDeferredIsLoaded(Registry registry) { 1207 void registerCheckDeferredIsLoaded(Registry registry) {
1214 enqueueInResolution(getCheckDeferredIsLoaded(), registry); 1208 enqueueInResolution(getCheckDeferredIsLoaded(), registry);
1215 // Also register the types of the arguments passed to this method. 1209 // Also register the types of the arguments passed to this method.
1216 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); 1210 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry);
1217 } 1211 }
1218 1212
1219 void registerNoSuchMethod(Element noSuchMethod) { 1213 void enableNoSuchMethod(Element context, Enqueuer world) {
1220 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
1221 }
1222
1223 void enableNoSuchMethod(Enqueuer world) {
1224 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); 1214 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies);
1225 world.registerInvocation(compiler.noSuchMethodSelector); 1215 world.registerInvocation(compiler.noSuchMethodSelector);
1216 // TODO(tyoverby): Send the context element to DumpInfoTask to be
1217 // blamed.
1226 } 1218 }
1227 1219
1228 void enableIsolateSupport(Enqueuer enqueuer) { 1220 void enableIsolateSupport(Enqueuer enqueuer) {
1229 // TODO(floitsch): We should also ensure that the class IsolateMessage is 1221 // TODO(floitsch): We should also ensure that the class IsolateMessage is
1230 // instantiated. Currently, just enabling isolate support works. 1222 // instantiated. Currently, just enabling isolate support works.
1231 if (compiler.mainFunction != null) { 1223 if (compiler.mainFunction != null) {
1232 // The JavaScript backend implements [Isolate.spawn] by looking up 1224 // The JavaScript backend implements [Isolate.spawn] by looking up
1233 // top-level functions by name. So all top-level function tear-off 1225 // top-level functions by name. So all top-level function tear-off
1234 // closures have a private name field. 1226 // closures have a private name field.
1235 // 1227 //
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 return staticFields; 2396 return staticFields;
2405 } 2397 }
2406 2398
2407 /// Called when [enqueuer] is empty, but before it is closed. 2399 /// Called when [enqueuer] is empty, but before it is closed.
2408 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) { 2400 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) {
2409 // Add elements referenced only via custom elements. Return early if any 2401 // Add elements referenced only via custom elements. Return early if any
2410 // elements are added to avoid counting the elements as due to mirrors. 2402 // elements are added to avoid counting the elements as due to mirrors.
2411 customElementsAnalysis.onQueueEmpty(enqueuer); 2403 customElementsAnalysis.onQueueEmpty(enqueuer);
2412 if (!enqueuer.queueIsEmpty) return false; 2404 if (!enqueuer.queueIsEmpty) return false;
2413 2405
2414 noSuchMethodRegistry.onQueueEmpty();
2415 if (!enabledNoSuchMethod &&
2416 (noSuchMethodRegistry.hasThrowingNoSuchMethod ||
2417 noSuchMethodRegistry.hasComplexNoSuchMethod)) {
2418 enableNoSuchMethod(enqueuer);
2419 enabledNoSuchMethod = true;
2420 }
2421
2422 if (compiler.hasIncrementalSupport) { 2406 if (compiler.hasIncrementalSupport) {
2423 // Always enable tear-off closures during incremental compilation. 2407 // Always enable tear-off closures during incremental compilation.
2424 Element e = findHelper('closureFromTearOff'); 2408 Element e = findHelper('closureFromTearOff');
2425 if (e != null && !enqueuer.isProcessed(e)) { 2409 if (e != null && !enqueuer.isProcessed(e)) {
2426 registerBackendUse(e); 2410 registerBackendUse(e);
2427 enqueuer.addToWorkList(e); 2411 enqueuer.addToWorkList(e);
2428 } 2412 }
2429 } 2413 }
2430 2414
2431 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { 2415 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) {
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 } 2847 }
2864 } 2848 }
2865 2849
2866 /// Records that [constant] is used by the element behind [registry]. 2850 /// Records that [constant] is used by the element behind [registry].
2867 class Dependency { 2851 class Dependency {
2868 final ConstantValue constant; 2852 final ConstantValue constant;
2869 final Element annotatedElement; 2853 final Element annotatedElement;
2870 2854
2871 const Dependency(this.constant, this.annotatedElement); 2855 const Dependency(this.constant, this.annotatedElement);
2872 } 2856 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698