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

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

Issue 2258523002: Dummy receiver optimization for super calls (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Use receiver type - synthesized type was invalid for abstract superclass Created 4 years, 4 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 | « no previous file | 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/codegen_helpers.dart
diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
index 5a0f55803394c8bc279e2ea8f3fea59c293a7c39..dca34c5016f91460465e5e1c30a635756294c06f 100644
--- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart
+++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
@@ -96,49 +96,61 @@ class SsaInstructionSelection extends HBaseVisitor {
HInstruction visitInvokeDynamic(HInvokeDynamic node) {
if (node.isInterceptedCall) {
- // Calls of the form
- //
- // a.foo$1(a, x)
- //
- // where the interceptor calling convention is used come from recognizing
- // that 'a' is a 'self-interceptor'. If the selector matches only methods
- // that ignore the explicit receiver parameter, replace occurences of the
- // receiver argument with a dummy receiver '0':
- //
- // a.foo$1(a, x) ---> a.foo$1(0, x)
- //
- // This often reduces the number of references to 'a' to one, allowing 'a'
- // to be generated at use to avoid a temporary, e.g.
- //
- // t1 = b.get$thing();
- // t1.foo$1(t1, x)
- // --->
- // b.get$thing().foo$1(0, x)
- //
- Selector selector = node.selector;
- TypeMask mask = node.mask;
+ tryReplaceInterceptorWithDummy(node, node.selector, node.mask);
+ }
+ return node;
+ }
+
+ HInstruction visitInvokeSuper(HInvokeSuper node) {
+ if (node.isInterceptedCall) {
+ TypeMask mask = node.getDartReceiver(compiler).instructionType;
+ tryReplaceInterceptorWithDummy(node, node.selector, mask);
+ }
+ return node;
+ }
+
+ void tryReplaceInterceptorWithDummy(
+ HInvoke node, Selector selector, TypeMask mask) {
+ // Calls of the form
+ //
+ // a.foo$1(a, x)
+ //
+ // where the interceptor calling convention is used come from recognizing
+ // that 'a' is a 'self-interceptor'. If the selector matches only methods
+ // that ignore the explicit receiver parameter, replace occurences of the
+ // receiver argument with a dummy receiver '0':
+ //
+ // a.foo$1(a, x) ---> a.foo$1(0, x)
+ //
+ // This often reduces the number of references to 'a' to one, allowing 'a'
+ // to be generated at use to avoid a temporary, e.g.
+ //
+ // t1 = b.get$thing();
+ // t1.foo$1(t1, x)
+ // --->
+ // b.get$thing().foo$1(0, x)
+ //
+
+ // TODO(15933): Make automatically generated property extraction closures
+ // work with the dummy receiver optimization.
+ if (selector.isGetter) return;
+
+ // This assignment of inputs is uniform for HInvokeDynamic and HInvokeSuper.
+ HInstruction interceptor = node.inputs[0];
+ HInstruction receiverArgument = node.inputs[1];
+
+ if (interceptor.nonCheck() == receiverArgument.nonCheck()) {
if (backend.isInterceptedSelector(selector) &&
!backend.isInterceptedMixinSelector(selector, mask)) {
- HInstruction interceptor = node.inputs[0];
- HInstruction receiverArgument = node.inputs[1];
-
- if (interceptor.nonCheck() == receiverArgument.nonCheck()) {
- // TODO(15933): Make automatically generated property extraction
- // closures work with the dummy receiver optimization.
- if (!selector.isGetter) {
- ConstantValue constant = new SyntheticConstantValue(
- SyntheticConstantKind.DUMMY_INTERCEPTOR,
- receiverArgument.instructionType);
- HConstant dummy = graph.addConstant(constant, compiler);
- receiverArgument.usedBy.remove(node);
- node.inputs[1] = dummy;
- dummy.usedBy.add(node);
- }
- }
+ ConstantValue constant = new SyntheticConstantValue(
+ SyntheticConstantKind.DUMMY_INTERCEPTOR,
+ receiverArgument.instructionType);
+ HConstant dummy = graph.addConstant(constant, compiler);
+ receiverArgument.usedBy.remove(node);
+ node.inputs[1] = dummy;
+ dummy.usedBy.add(node);
}
}
-
- return node;
}
HInstruction visitFieldSet(HFieldSet setter) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698