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

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 2729613004: Cleanup registration of closures (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/enqueue.dart » ('j') | pkg/compiler/lib/src/enqueue.dart » ('J')
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 library closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import 'common/names.dart' show Identifiers; 7 import 'common/names.dart' show Identifiers;
8 import 'common/resolution.dart' show ParsingContext, Resolution; 8 import 'common/resolution.dart' show ParsingContext, Resolution;
9 import 'common/tasks.dart' show CompilerTask; 9 import 'common/tasks.dart' show CompilerTask;
10 import 'common.dart'; 10 import 'common.dart';
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 1097
1098 void visitInvokable( 1098 void visitInvokable(
1099 ExecutableElement element, Node node, void visitChildren()) { 1099 ExecutableElement element, Node node, void visitChildren()) {
1100 bool oldInsideClosure = insideClosure; 1100 bool oldInsideClosure = insideClosure;
1101 Element oldFunctionElement = executableContext; 1101 Element oldFunctionElement = executableContext;
1102 ClosureClassMap oldClosureData = closureData; 1102 ClosureClassMap oldClosureData = closureData;
1103 1103
1104 insideClosure = outermostElement != null; 1104 insideClosure = outermostElement != null;
1105 LocalFunctionElement closure; 1105 LocalFunctionElement closure;
1106 executableContext = element; 1106 executableContext = element;
1107 bool needsRti = false;
1107 if (insideClosure) { 1108 if (insideClosure) {
1108 closure = element; 1109 closure = element;
1109 closures.add(closure); 1110 closures.add(closure);
1110 closureData = globalizeClosure(node, closure); 1111 closureData = globalizeClosure(node, closure);
1112 needsRti = compiler.options.enableTypeAssertions ||
1113 compiler.backend.rtiNeed.localFunctionNeedsRti(closure);
1111 } else { 1114 } else {
1112 outermostElement = element; 1115 outermostElement = element;
1113 ThisLocal thisElement = null; 1116 ThisLocal thisElement = null;
1114 if (element.isInstanceMember || element.isGenerativeConstructor) { 1117 if (element.isInstanceMember || element.isGenerativeConstructor) {
1115 thisElement = new ThisLocal(element); 1118 thisElement = new ThisLocal(element);
1116 } 1119 }
1117 closureData = new ClosureClassMap(null, null, null, thisElement); 1120 closureData = new ClosureClassMap(null, null, null, thisElement);
1121 if (element is MethodElement) {
1122 needsRti = compiler.options.enableTypeAssertions ||
1123 compiler.backend.rtiNeed.methodNeedsRti(element);
1124 }
1118 } 1125 }
1119 closureMappingCache[element.declaration] = closureData; 1126 closureMappingCache[element.declaration] = closureData;
1120 if (closureData.callElement != null) { 1127 if (closureData.callElement != null) {
1121 closureMappingCache[closureData.callElement] = closureData; 1128 closureMappingCache[closureData.callElement] = closureData;
1122 } 1129 }
1123 1130
1124 inNewScope(node, () { 1131 inNewScope(node, () {
1125 ResolutionDartType type = element.type;
1126 // If the method needs RTI, or checked mode is set, we need to 1132 // If the method needs RTI, or checked mode is set, we need to
1127 // escape the potential type variables used in that closure. 1133 // escape the potential type variables used in that closure.
1128 if (element is FunctionElement && 1134 if (needsRti) {
1129 (compiler.backend.rtiNeed.methodNeedsRti(element) || 1135 analyzeTypeVariables(element.type);
1130 compiler.options.enableTypeAssertions)) {
1131 analyzeTypeVariables(type);
1132 } 1136 }
1133 1137
1134 visitChildren(); 1138 visitChildren();
1135 }); 1139 });
1136 1140
1137 ClosureClassMap savedClosureData = closureData; 1141 ClosureClassMap savedClosureData = closureData;
1138 bool savedInsideClosure = insideClosure; 1142 bool savedInsideClosure = insideClosure;
1139 1143
1140 // Restore old values. 1144 // Restore old values.
1141 insideClosure = oldInsideClosure; 1145 insideClosure = oldInsideClosure;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 /// 1225 ///
1222 /// Move the below classes to a JS model eventually. 1226 /// Move the below classes to a JS model eventually.
1223 /// 1227 ///
1224 abstract class JSEntity implements Entity { 1228 abstract class JSEntity implements Entity {
1225 Entity get declaredEntity; 1229 Entity get declaredEntity;
1226 } 1230 }
1227 1231
1228 abstract class PrivatelyNamedJSEntity implements JSEntity { 1232 abstract class PrivatelyNamedJSEntity implements JSEntity {
1229 Entity get rootOfScope; 1233 Entity get rootOfScope;
1230 } 1234 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/enqueue.dart » ('j') | pkg/compiler/lib/src/enqueue.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698