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

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

Issue 996263002: Don't generate forwarding hooks if all noSuchMethod implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix typo 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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 570
571 TypeVariableHandler typeVariableHandler; 571 TypeVariableHandler typeVariableHandler;
572 572
573 /// Number of methods compiled before considering reflection. 573 /// Number of methods compiled before considering reflection.
574 int preMirrorsMethodCount = 0; 574 int preMirrorsMethodCount = 0;
575 575
576 /// Resolution and codegen support for generating table of interceptors and 576 /// Resolution and codegen support for generating table of interceptors and
577 /// constructors for custom elements. 577 /// constructors for custom elements.
578 CustomElementsAnalysis customElementsAnalysis; 578 CustomElementsAnalysis customElementsAnalysis;
579 579
580 /// Support for classifying `noSuchMethod` implementations.
581 NoSuchMethodRegistry noSuchMethodRegistry;
582
580 JavaScriptConstantTask constantCompilerTask; 583 JavaScriptConstantTask constantCompilerTask;
581 584
582 JavaScriptResolutionCallbacks resolutionCallbacks; 585 JavaScriptResolutionCallbacks resolutionCallbacks;
583 586
584 PatchResolverTask patchResolverTask; 587 PatchResolverTask patchResolverTask;
585 588
586 bool get canHandleCompilationFailed => true; 589 bool get canHandleCompilationFailed => true;
587 590
591 bool enabledNoSuchMethod = false;
592
588 JavaScriptBackend(Compiler compiler, bool generateSourceMap) 593 JavaScriptBackend(Compiler compiler, bool generateSourceMap)
589 : namer = determineNamer(compiler), 594 : namer = determineNamer(compiler),
590 oneShotInterceptors = new Map<String, Selector>(), 595 oneShotInterceptors = new Map<String, Selector>(),
591 interceptedElements = new Map<String, Set<Element>>(), 596 interceptedElements = new Map<String, Set<Element>>(),
592 rti = new RuntimeTypes(compiler), 597 rti = new RuntimeTypes(compiler),
593 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), 598 specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
594 super(compiler) { 599 super(compiler) {
595 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); 600 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap);
596 typeVariableHandler = new TypeVariableHandler(this); 601 typeVariableHandler = new TypeVariableHandler(this);
597 customElementsAnalysis = new CustomElementsAnalysis(this); 602 customElementsAnalysis = new CustomElementsAnalysis(this);
603 noSuchMethodRegistry = new NoSuchMethodRegistry(this);
598 constantCompilerTask = new JavaScriptConstantTask(compiler); 604 constantCompilerTask = new JavaScriptConstantTask(compiler);
599 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); 605 resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
600 patchResolverTask = new PatchResolverTask(compiler); 606 patchResolverTask = new PatchResolverTask(compiler);
601 functionCompiler = USE_CPS_IR 607 functionCompiler = USE_CPS_IR
602 ? new CpsFunctionCompiler( 608 ? new CpsFunctionCompiler(
603 compiler, this, generateSourceMap: generateSourceMap) 609 compiler, this, generateSourceMap: generateSourceMap)
604 : new SsaFunctionCompiler(this, generateSourceMap); 610 : new SsaFunctionCompiler(this, generateSourceMap);
605 } 611 }
606 612
607 ConstantSystem get constantSystem => constants.constantSystem; 613 ConstantSystem get constantSystem => constants.constantSystem;
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 DartType bound) { 1197 DartType bound) {
1192 rti.registerTypeVariableBoundsSubtypeCheck(typeArgument, bound); 1198 rti.registerTypeVariableBoundsSubtypeCheck(typeArgument, bound);
1193 } 1199 }
1194 1200
1195 void registerCheckDeferredIsLoaded(Registry registry) { 1201 void registerCheckDeferredIsLoaded(Registry registry) {
1196 enqueueInResolution(getCheckDeferredIsLoaded(), registry); 1202 enqueueInResolution(getCheckDeferredIsLoaded(), registry);
1197 // Also register the types of the arguments passed to this method. 1203 // Also register the types of the arguments passed to this method.
1198 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); 1204 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry);
1199 } 1205 }
1200 1206
1201 void enableNoSuchMethod(Element context, Enqueuer world) { 1207 void registerNoSuchMethod(Element noSuchMethod) {
1208 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
1209 }
1210
1211 void enableNoSuchMethod(Enqueuer world) {
1202 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); 1212 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies);
1203 world.registerInvocation(compiler.noSuchMethodSelector); 1213 world.registerInvocation(compiler.noSuchMethodSelector);
1204 // TODO(tyoverby): Send the context element to DumpInfoTask to be
1205 // blamed.
1206 } 1214 }
1207 1215
1208 void enableIsolateSupport(Enqueuer enqueuer) { 1216 void enableIsolateSupport(Enqueuer enqueuer) {
1209 // TODO(floitsch): We should also ensure that the class IsolateMessage is 1217 // TODO(floitsch): We should also ensure that the class IsolateMessage is
1210 // instantiated. Currently, just enabling isolate support works. 1218 // instantiated. Currently, just enabling isolate support works.
1211 if (compiler.mainFunction != null) { 1219 if (compiler.mainFunction != null) {
1212 // The JavaScript backend implements [Isolate.spawn] by looking up 1220 // The JavaScript backend implements [Isolate.spawn] by looking up
1213 // top-level functions by name. So all top-level function tear-off 1221 // top-level functions by name. So all top-level function tear-off
1214 // closures have a private name field. 1222 // closures have a private name field.
1215 // 1223 //
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 return staticFields; 2392 return staticFields;
2385 } 2393 }
2386 2394
2387 /// Called when [enqueuer] is empty, but before it is closed. 2395 /// Called when [enqueuer] is empty, but before it is closed.
2388 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) { 2396 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) {
2389 // Add elements referenced only via custom elements. Return early if any 2397 // Add elements referenced only via custom elements. Return early if any
2390 // elements are added to avoid counting the elements as due to mirrors. 2398 // elements are added to avoid counting the elements as due to mirrors.
2391 customElementsAnalysis.onQueueEmpty(enqueuer); 2399 customElementsAnalysis.onQueueEmpty(enqueuer);
2392 if (!enqueuer.queueIsEmpty) return false; 2400 if (!enqueuer.queueIsEmpty) return false;
2393 2401
2402 noSuchMethodRegistry.onQueueEmpty();
2403 if (!enabledNoSuchMethod &&
2404 (noSuchMethodRegistry.hasThrowingNoSuchMethod ||
2405 noSuchMethodRegistry.hasComplexNoSuchMethod)) {
2406 enableNoSuchMethod(enqueuer);
2407 enabledNoSuchMethod = true;
2408 }
2409
2394 if (compiler.hasIncrementalSupport) { 2410 if (compiler.hasIncrementalSupport) {
2395 // Always enable tear-off closures during incremental compilation. 2411 // Always enable tear-off closures during incremental compilation.
2396 Element e = findHelper('closureFromTearOff'); 2412 Element e = findHelper('closureFromTearOff');
2397 if (e != null && !enqueuer.isProcessed(e)) { 2413 if (e != null && !enqueuer.isProcessed(e)) {
2398 registerBackendUse(e); 2414 registerBackendUse(e);
2399 enqueuer.addToWorkList(e); 2415 enqueuer.addToWorkList(e);
2400 } 2416 }
2401 } 2417 }
2402 2418
2403 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { 2419 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 } 2850 }
2835 } 2851 }
2836 2852
2837 /// Records that [constant] is used by the element behind [registry]. 2853 /// Records that [constant] is used by the element behind [registry].
2838 class Dependency { 2854 class Dependency {
2839 final ConstantValue constant; 2855 final ConstantValue constant;
2840 final Element annotatedElement; 2856 final Element annotatedElement;
2841 2857
2842 const Dependency(this.constant, this.annotatedElement); 2858 const Dependency(this.constant, this.annotatedElement);
2843 } 2859 }
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