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

Unified Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 2430683003: Property extraction getters (tear-offs) are effect-free (Closed)
Patch Set: Created 4 years, 2 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
« pkg/compiler/lib/src/ssa/nodes.dart ('K') | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index fb5f1963b454a5b6bf56af83c6b5c41e84af449a..befe41f0872e61fad98944f4d68d18ebcbae3f42 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -901,8 +901,22 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
HInstruction receiver = node.getDartReceiver(compiler);
Element field = findConcreteFieldForDynamicAccess(receiver, node.selector);
- if (field == null) return node;
- return directFieldGet(receiver, field);
+ if (field != null) return directFieldGet(receiver, field);
+
+ if (node.element == null) {
+ Element element = compiler.closedWorld
+ .locateSingleElement(node.selector, receiver.instructionType);
+ if (element != null && element.name == node.selector.name) {
+ node.element = element;
+ if (element.isFunction) {
+ // A property extraction getter, aka a tear-off.
+ node.sideEffects.clearAllDependencies();
+ node.sideEffects.clearAllSideEffects();
+ // TODO(sra): Also setUseGvn() to allow tear-offs to be shared.
Siggi Cherem (dart-lang) 2016/10/18 23:26:02 anything blocking this now? or is this just to kee
sra1 2016/10/19 02:16:57 I'll do it
+ }
+ }
+ }
+ return node;
}
HInstruction directFieldGet(HInstruction receiver, Element field) {
@@ -1065,10 +1079,11 @@ class SsaInstructionSimplifier extends HBaseVisitor
// be a class extending `Interceptor` then it can be called directly.
if (new TypeMask.nonNullSubclass(helpers.jsInterceptorClass, closedWorld)
.isDisjoint(input.instructionType, closedWorld)) {
+ var inputs = <HInstruction>[input, input]; // [interceptor, receiver].
HInstruction result = new HInvokeDynamicMethod(
selector,
input.instructionType, // receiver mask.
- <HInstruction>[input, input], // [interceptor, receiver].
+ inputs,
sra1 2016/10/18 23:18:22 This is to avoid the formatter bug https://github.
toStringType)..sourceInformation = node.sourceInformation;
return result;
}
« pkg/compiler/lib/src/ssa/nodes.dart ('K') | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698