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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1020853004: Don't generate invocation mirror code if all noSuchMethods forward to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add test 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 61701c3e9f2cc2f6c9499f4d36fa7ef1c0bb801c..e5285d384610dc4e54dbf1f952c28dd3dcee84f8 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -585,6 +585,9 @@ class JavaScriptBackend extends Backend {
/// constructors for custom elements.
CustomElementsAnalysis customElementsAnalysis;
+ /// Support for classifying `noSuchMethod` implementations.
+ NoSuchMethodRegistry noSuchMethodRegistry;
+
JavaScriptConstantTask constantCompilerTask;
JavaScriptResolutionCallbacks resolutionCallbacks;
@@ -593,6 +596,8 @@ class JavaScriptBackend extends Backend {
bool get canHandleCompilationFailed => true;
+ bool enabledNoSuchMethod = false;
+
JavaScriptBackend(Compiler compiler, bool generateSourceMap)
: namer = determineNamer(compiler),
oneShotInterceptors = new Map<String, Selector>(),
@@ -603,6 +608,7 @@ class JavaScriptBackend extends Backend {
emitter = new CodeEmitterTask(compiler, namer, generateSourceMap);
typeVariableHandler = new TypeVariableHandler(this);
customElementsAnalysis = new CustomElementsAnalysis(this);
+ noSuchMethodRegistry = new NoSuchMethodRegistry(this);
constantCompilerTask = new JavaScriptConstantTask(compiler);
resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
patchResolverTask = new PatchResolverTask(compiler);
@@ -1210,11 +1216,13 @@ class JavaScriptBackend extends Backend {
enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry);
}
- void enableNoSuchMethod(Element context, Enqueuer world) {
+ void registerNoSuchMethod(Element noSuchMethod) {
+ noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
+ }
+
+ void enableNoSuchMethod(Enqueuer world) {
enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies);
world.registerInvocation(compiler.noSuchMethodSelector);
- // TODO(tyoverby): Send the context element to DumpInfoTask to be
- // blamed.
}
void enableIsolateSupport(Enqueuer enqueuer) {
@@ -2403,6 +2411,14 @@ class JavaScriptBackend extends Backend {
customElementsAnalysis.onQueueEmpty(enqueuer);
if (!enqueuer.queueIsEmpty) return false;
+ noSuchMethodRegistry.onQueueEmpty();
+ if (!enabledNoSuchMethod &&
+ (noSuchMethodRegistry.hasThrowingNoSuchMethod ||
+ noSuchMethodRegistry.hasComplexNoSuchMethod)) {
+ enableNoSuchMethod(enqueuer);
+ enabledNoSuchMethod = true;
+ }
+
if (compiler.hasIncrementalSupport) {
// Always enable tear-off closures during incremental compilation.
Element e = findHelper('closureFromTearOff');
« 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