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

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

Issue 23003031: Extract interceptor calls from raw is-checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix optimization of interceptors for HIs. Created 7 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 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 interceptedClasses.add(backend.jsIntClass); 184 interceptedClasses.add(backend.jsIntClass);
185 } 185 }
186 if (intercepted.contains(backend.jsDoubleClass)) { 186 if (intercepted.contains(backend.jsDoubleClass)) {
187 interceptedClasses.add(backend.jsDoubleClass); 187 interceptedClasses.add(backend.jsDoubleClass);
188 } 188 }
189 } 189 }
190 } 190 }
191 } else { 191 } else {
192 interceptedClasses = new Set<ClassElement>(); 192 interceptedClasses = new Set<ClassElement>();
193 for (var user in node.usedBy) { 193 for (var user in node.usedBy) {
194 if (user is HIs) {
ngeoffray 2013/08/26 09:10:23 Add a comment.
Johnni Winther 2013/08/27 08:45:44 Done.
195 // TODO(johnniwinther): Optimize for is-checks that actually need the
196 // interceptor.
ngeoffray 2013/08/26 09:10:23 I think you should move this TODO in the builder:
Johnni Winther 2013/08/27 08:45:44 Done.
197 interceptedClasses.addAll(backend.interceptedClasses);
198 break;
199 }
194 if (user is! HInvoke) continue; 200 if (user is! HInvoke) continue;
195 // We don't handle escaping interceptors yet. 201 // We don't handle escaping interceptors yet.
196 interceptedClasses.addAll( 202 interceptedClasses.addAll(
197 backend.getInterceptedClassesOn(user.selector.name)); 203 backend.getInterceptedClassesOn(user.selector.name));
198 } 204 }
199 } 205 }
200 206
201 HInstruction receiver = node.receiver; 207 HInstruction receiver = node.receiver;
202 HType instructionType = receiver.instructionType; 208 HType instructionType = receiver.instructionType;
203 if (canUseSelfForInterceptor(instructionType, interceptedClasses)) { 209 if (canUseSelfForInterceptor(instructionType, interceptedClasses)) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 interceptor.sourceElement = user.sourceElement; 247 interceptor.sourceElement = user.sourceElement;
242 interceptor.instructionType = user.instructionType; 248 interceptor.instructionType = user.instructionType;
243 249
244 HBasicBlock block = user.block; 250 HBasicBlock block = user.block;
245 block.addAfter(user, interceptor); 251 block.addAfter(user, interceptor);
246 block.rewrite(user, interceptor); 252 block.rewrite(user, interceptor);
247 block.remove(user); 253 block.remove(user);
248 return true; 254 return true;
249 } 255 }
250 256
251 257
ngeoffray 2013/08/26 09:10:23 Get rid of extra line.
Johnni Winther 2013/08/27 08:45:44 Done.
252 bool visitOneShotInterceptor(HOneShotInterceptor node) { 258 bool visitOneShotInterceptor(HOneShotInterceptor node) {
253 HInstruction constant = tryComputeConstantInterceptor( 259 HInstruction constant = tryComputeConstantInterceptor(
254 node.inputs[1], node.interceptedClasses); 260 node.inputs[1], node.interceptedClasses);
255 261
256 if (constant == null) return false; 262 if (constant == null) return false;
257 263
258 Selector selector = node.selector; 264 Selector selector = node.selector;
259 // TODO(ngeoffray): make one shot interceptors know whether 265 // TODO(ngeoffray): make one shot interceptors know whether
260 // they have side effects. 266 // they have side effects.
261 HInstruction instruction; 267 HInstruction instruction;
(...skipping 14 matching lines...) Expand all
276 inputs[0] = constant; 282 inputs[0] = constant;
277 instruction = new HInvokeDynamicMethod(selector, inputs, true); 283 instruction = new HInvokeDynamicMethod(selector, inputs, true);
278 } 284 }
279 285
280 HBasicBlock block = node.block; 286 HBasicBlock block = node.block;
281 block.addAfter(node, instruction); 287 block.addAfter(node, instruction);
282 block.rewrite(node, instruction); 288 block.rewrite(node, instruction);
283 return true; 289 return true;
284 } 290 }
285 } 291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698