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

Side by Side Diff: pkg/compiler/lib/src/enqueue.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: More tests 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
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 dart2js; 5 part of dart2js;
6 6
7 typedef ItemCompilationContext ItemCompilationContextCreator(); 7 typedef ItemCompilationContext ItemCompilationContextCreator();
8 8
9 class EnqueueTask extends CompilerTask { 9 class EnqueueTask extends CompilerTask {
10 final ResolutionEnqueuer resolution; 10 final ResolutionEnqueuer resolution;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // All field initializers must be resolved as they could 155 // All field initializers must be resolved as they could
156 // have an observable side-effect (and cannot be tree-shaken 156 // have an observable side-effect (and cannot be tree-shaken
157 // away). 157 // away).
158 addToWorkList(member); 158 addToWorkList(member);
159 return; 159 return;
160 } 160 }
161 } else if (member.kind == ElementKind.FUNCTION) { 161 } else if (member.kind == ElementKind.FUNCTION) {
162 FunctionElement function = member; 162 FunctionElement function = member;
163 function.computeSignature(compiler); 163 function.computeSignature(compiler);
164 if (function.name == Compiler.NO_SUCH_METHOD) { 164 if (function.name == Compiler.NO_SUCH_METHOD) {
165 enableNoSuchMethod(function); 165 compiler.backend.registerNoSuchMethod(function, this);
Johnni Winther 2015/03/16 14:20:43 Move this to the ResolutionEnqueuer; only resoluti
Harry Terkelsen 2015/03/17 21:43:11 I am calling Enqueuer.registerNoSuchMethod here be
166 } 166 }
167 if (function.name == Compiler.CALL_OPERATOR_NAME && 167 if (function.name == Compiler.CALL_OPERATOR_NAME &&
168 !cls.typeVariables.isEmpty) { 168 !cls.typeVariables.isEmpty) {
169 registerCallMethodWithFreeTypeVariables( 169 registerCallMethodWithFreeTypeVariables(
170 function, compiler.globalDependencies); 170 function, compiler.globalDependencies);
171 } 171 }
172 // If there is a property access with the same name as a method we 172 // If there is a property access with the same name as a method we
173 // need to emit the method. 173 // need to emit the method.
174 if (universe.hasInvokedGetter(function, compiler.world)) { 174 if (universe.hasInvokedGetter(function, compiler.world)) {
175 registerClosurizedMember(function, compiler.globalDependencies); 175 registerClosurizedMember(function, compiler.globalDependencies);
(...skipping 29 matching lines...) Expand all
205 return; 205 return;
206 } 206 }
207 } 207 }
208 208
209 // The element is not yet used. Add it to the list of instance 209 // The element is not yet used. Add it to the list of instance
210 // members to still be processed. 210 // members to still be processed.
211 instanceMembersByName.putIfAbsent(memberName, () => new Set<Element>()) 211 instanceMembersByName.putIfAbsent(memberName, () => new Set<Element>())
212 .add(member); 212 .add(member);
213 } 213 }
214 214
215 void enableNoSuchMethod(Element element) {}
216 void enableIsolateSupport() {} 215 void enableIsolateSupport() {}
217 216
218 void processInstantiatedClass(ClassElement cls) { 217 void processInstantiatedClass(ClassElement cls) {
219 task.measure(() { 218 task.measure(() {
220 if (_processedClasses.contains(cls)) return; 219 if (_processedClasses.contains(cls)) return;
221 // The class must be resolved to compute the set of all 220 // The class must be resolved to compute the set of all
222 // supertypes. 221 // supertypes.
223 cls.ensureResolved(compiler); 222 cls.ensureResolved(compiler);
224 223
225 void processClass(ClassElement cls) { 224 void processClass(ClassElement cls) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 733
735 nativeEnqueuer.registerElement(element); 734 nativeEnqueuer.registerElement(element);
736 return true; 735 return true;
737 } 736 }
738 737
739 void enableIsolateSupport() { 738 void enableIsolateSupport() {
740 compiler.hasIsolateSupport = true; 739 compiler.hasIsolateSupport = true;
741 compiler.backend.enableIsolateSupport(this); 740 compiler.backend.enableIsolateSupport(this);
742 } 741 }
743 742
744 void enableNoSuchMethod(Element element) {
745 if (compiler.enabledNoSuchMethod) return;
746 if (compiler.backend.isDefaultNoSuchMethodImplementation(element)) return;
747
748 compiler.enabledNoSuchMethod = true;
749 compiler.backend.enableNoSuchMethod(element, this);
750 }
751
752 /** 743 /**
753 * Adds an action to the deferred task queue. 744 * Adds an action to the deferred task queue.
754 * 745 *
755 * The action is performed the next time the resolution queue has been 746 * The action is performed the next time the resolution queue has been
756 * emptied. 747 * emptied.
757 * 748 *
758 * The queue is processed in FIFO order. 749 * The queue is processed in FIFO order.
759 */ 750 */
760 void addDeferredAction(Element element, DeferredAction action) { 751 void addDeferredAction(Element element, DeferredAction action) {
761 if (queueIsClosed) { 752 if (queueIsClosed) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 void processWorkItem(void f(WorkItem work), WorkItem work) { 890 void processWorkItem(void f(WorkItem work), WorkItem work) {
900 f(work); 891 f(work);
901 } 892 }
902 } 893 }
903 894
904 void removeFromSet(Map<String, Set<Element>> map, Element element) { 895 void removeFromSet(Map<String, Set<Element>> map, Element element) {
905 Set<Element> set = map[element.name]; 896 Set<Element> set = map[element.name];
906 if (set == null) return; 897 if (set == null) return;
907 set.remove(element); 898 set.remove(element);
908 } 899 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698