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

Unified Diff: sdk/lib/_internal/compiler/implementation/universe/universe.dart

Issue 14416014: After a dynamic call, refine the receiver type by looking at the potential targets of that call. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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
Index: sdk/lib/_internal/compiler/implementation/universe/universe.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/universe/universe.dart (revision 22031)
+++ sdk/lib/_internal/compiler/implementation/universe/universe.dart (working copy)
@@ -91,6 +91,29 @@
bool hasFieldSetter(Element member, Compiler compiler) {
return fieldSetters.contains(member);
}
+
+ bool onlyReachesFinalFields(Selector getterSelector, Compiler compiler) {
+ assert(getterSelector.isGetter());
+ Selector setterSelector = new Selector.setterFrom(getterSelector);
+ if (getterSelector.mask != null) {
+ setterSelector = new TypedSelector(getterSelector.mask, setterSelector);
+ }
+
+ bool hasInvokedSetter = invokedSetters[setterSelector.name] != null
+ && !invokedSetters[setterSelector.name].isEmpty;
+
+ Iterable<Element> targets =
+ compiler.world.allFunctions.filter(setterSelector);
+ for (Element target in targets) {
+ assert(!target.isAbstractField());
+ // Final fields have been filtered out.
+ assert(!target.modifiers.isFinal());
+ if (target.isNative()) return false;
+ if (!target.isField()) return false;
+ if (hasInvokedSetter) return false;
+ }
+ return true;
+ }
}
class SelectorKind {
@@ -140,6 +163,9 @@
Selector.setter(SourceString name, LibraryElement library)
: this(SelectorKind.SETTER, name, library, 1);
+ Selector.setterFrom(Selector selector)
+ : this(SelectorKind.SETTER, selector.name, selector.library, 1);
+
Selector.unaryOperator(SourceString name)
: this(SelectorKind.OPERATOR,
Elements.constructOperatorName(name, true),
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/universe/function_set.dart ('k') | tests/compiler/dart2js/code_motion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698