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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/interceptor_simplifier.dart

Issue 108553006: Dummy receiver optimization (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add DummyReceiverConstant Created 7 years 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * This phase simplifies interceptors in multiple ways: 8 * This phase simplifies interceptors in multiple ways:
9 * 9 *
10 * 1) If the interceptor is for an object whose type is known, it 10 * 1) If the interceptor is for an object whose type is known, it
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 208 }
209 if (user is! HInvoke) continue; 209 if (user is! HInvoke) continue;
210 // We don't handle escaping interceptors yet. 210 // We don't handle escaping interceptors yet.
211 interceptedClasses.addAll( 211 interceptedClasses.addAll(
212 backend.getInterceptedClassesOn(user.selector.name)); 212 backend.getInterceptedClassesOn(user.selector.name));
213 } 213 }
214 } 214 }
215 215
216 HInstruction receiver = node.receiver; 216 HInstruction receiver = node.receiver;
217 if (canUseSelfForInterceptor(receiver, interceptedClasses)) { 217 if (canUseSelfForInterceptor(receiver, interceptedClasses)) {
218 var users = node.usedBy.toList();
floitsch 2013/12/18 19:20:12 We use types.
sra1 2013/12/19 03:28:15 Done.
218 node.block.rewrite(node, receiver); 219 node.block.rewrite(node, receiver);
220
221 // Replace occurences of the receiver in invocations with a dummy receiver
222 // if the selector matches only methods that ignore the receiver.
223 JavaScriptBackend backend = compiler.backend;
224 for (var user in users) {
floitsch 2013/12/18 19:20:12 ditto.
sra1 2013/12/19 03:28:15 Done.
225 if (user is HInvokeDynamic) {
226 HInvokeDynamic invoke = user;
227 if (invoke.getDartReceiver(compiler) == receiver
228 && !backend.isInterceptedMixinSelector(invoke.selector)) {
229 // [receiver] might not be the direct input since `node.receiver`
230 // looks through type conversion nodes like [TypeKnown].
231 HInstruction immediateReceiver = invoke.inputs[1];
232 Constant constant = new DummyReceiverConstant(
233 immediateReceiver.instructionType);
234 var dummy = graph.addConstant(constant, compiler);
floitsch 2013/12/18 19:20:12 ditto.
sra1 2013/12/19 03:28:15 Done.
235 immediateReceiver.usedBy.remove(invoke);
236 invoke.inputs[1] = dummy;
237 dummy.usedBy.add(invoke);
238 }
239 }
240 }
219 return false; 241 return false;
220 } 242 }
221 243
222 // Try computing a constant interceptor. 244 // Try computing a constant interceptor.
223 HInstruction constantInterceptor = 245 HInstruction constantInterceptor =
224 tryComputeConstantInterceptor(receiver, interceptedClasses); 246 tryComputeConstantInterceptor(receiver, interceptedClasses);
225 if (constantInterceptor != null) { 247 if (constantInterceptor != null) {
226 node.block.rewrite(node, constantInterceptor); 248 node.block.rewrite(node, constantInterceptor);
227 return false; 249 return false;
228 } 250 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 instruction = new HInvokeDynamicMethod( 302 instruction = new HInvokeDynamicMethod(
281 selector, inputs, node.instructionType, true); 303 selector, inputs, node.instructionType, true);
282 } 304 }
283 305
284 HBasicBlock block = node.block; 306 HBasicBlock block = node.block;
285 block.addAfter(node, instruction); 307 block.addAfter(node, instruction);
286 block.rewrite(node, instruction); 308 block.rewrite(node, instruction);
287 return true; 309 return true;
288 } 310 }
289 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698