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

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

Issue 102833008: Revert "Dummy receiver optimization" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // use only the selector of that instruction. 179 // use only the selector of that instruction.
180 if (dominator != null) { 180 if (dominator != null) {
181 interceptedClasses = 181 interceptedClasses =
182 backend.getInterceptedClassesOn(dominator.selector.name); 182 backend.getInterceptedClassesOn(dominator.selector.name);
183 183
184 // If we found that we need number, we must still go through all 184 // If we found that we need number, we must still go through all
185 // uses to check if they require int, or double. 185 // uses to check if they require int, or double.
186 if (interceptedClasses.contains(backend.jsNumberClass) 186 if (interceptedClasses.contains(backend.jsNumberClass)
187 && !(interceptedClasses.contains(backend.jsDoubleClass) 187 && !(interceptedClasses.contains(backend.jsDoubleClass)
188 || interceptedClasses.contains(backend.jsIntClass))) { 188 || interceptedClasses.contains(backend.jsIntClass))) {
189 for (HInstruction user in node.usedBy) { 189 for (var user in node.usedBy) {
190 if (user is! HInvoke) continue; 190 if (user is! HInvoke) continue;
191 Set<ClassElement> intercepted = 191 Set<ClassElement> intercepted =
192 backend.getInterceptedClassesOn(user.selector.name); 192 backend.getInterceptedClassesOn(user.selector.name);
193 if (intercepted.contains(backend.jsIntClass)) { 193 if (intercepted.contains(backend.jsIntClass)) {
194 interceptedClasses.add(backend.jsIntClass); 194 interceptedClasses.add(backend.jsIntClass);
195 } 195 }
196 if (intercepted.contains(backend.jsDoubleClass)) { 196 if (intercepted.contains(backend.jsDoubleClass)) {
197 interceptedClasses.add(backend.jsDoubleClass); 197 interceptedClasses.add(backend.jsDoubleClass);
198 } 198 }
199 } 199 }
200 } 200 }
201 } else { 201 } else {
202 interceptedClasses = new Set<ClassElement>(); 202 interceptedClasses = new Set<ClassElement>();
203 for (HInstruction user in node.usedBy) { 203 for (var user in node.usedBy) {
204 if (user is HIs) { 204 if (user is HIs) {
205 // Is-checks can be performed on any intercepted class. 205 // Is-checks can be performed on any intercepted class.
206 interceptedClasses.addAll(backend.interceptedClasses); 206 interceptedClasses.addAll(backend.interceptedClasses);
207 break; 207 break;
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 List<HInstruction> users = node.usedBy.toList();
219 node.block.rewrite(node, receiver); 218 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 (HInstruction user in users) {
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 HConstant dummy = graph.addConstant(constant, compiler);
235 immediateReceiver.usedBy.remove(invoke);
236 invoke.inputs[1] = dummy;
237 dummy.usedBy.add(invoke);
238 }
239 }
240 }
241 return false; 219 return false;
242 } 220 }
243 221
244 // Try computing a constant interceptor. 222 // Try computing a constant interceptor.
245 HInstruction constantInterceptor = 223 HInstruction constantInterceptor =
246 tryComputeConstantInterceptor(receiver, interceptedClasses); 224 tryComputeConstantInterceptor(receiver, interceptedClasses);
247 if (constantInterceptor != null) { 225 if (constantInterceptor != null) {
248 node.block.rewrite(node, constantInterceptor); 226 node.block.rewrite(node, constantInterceptor);
249 return false; 227 return false;
250 } 228 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 instruction = new HInvokeDynamicMethod( 280 instruction = new HInvokeDynamicMethod(
303 selector, inputs, node.instructionType, true); 281 selector, inputs, node.instructionType, true);
304 } 282 }
305 283
306 HBasicBlock block = node.block; 284 HBasicBlock block = node.block;
307 block.addAfter(node, instruction); 285 block.addAfter(node, instruction);
308 block.rewrite(node, instruction); 286 block.rewrite(node, instruction);
309 return true; 287 return true;
310 } 288 }
311 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698