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

Side by Side Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 10866021: Simplify HInvokeInterceptor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface OptimizationPhase { 5 interface OptimizationPhase {
6 String get name(); 6 String get name();
7 void visitGraph(HGraph graph); 7 void visitGraph(HGraph graph);
8 } 8 }
9 9
10 class SsaOptimizerTask extends CompilerTask { 10 class SsaOptimizerTask extends CompilerTask {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ListConstant constant = constantInput.constant; 199 ListConstant constant = constantInput.constant;
200 return graph.addConstantInt(constant.length); 200 return graph.addConstantInt(constant.length);
201 } else if (input.isConstantMap()) { 201 } else if (input.isConstantMap()) {
202 HConstant constantInput = input; 202 HConstant constantInput = input;
203 MapConstant constant = constantInput.constant; 203 MapConstant constant = constantInput.constant;
204 return graph.addConstantInt(constant.length); 204 return graph.addConstantInt(constant.length);
205 } 205 }
206 } 206 }
207 207
208 if (input.isString(types) 208 if (input.isString(types)
209 && node.name == const SourceString('toString')) { 209 && node.selector.name == const SourceString('toString')) {
210 return node.inputs[1]; 210 return node.inputs[1];
211 } 211 }
212 212
213 if (!input.canBePrimitive(types) && !node.getter && !node.setter) { 213 if (!input.canBePrimitive(types) && node.selector.isCall()) {
214 bool transformToDynamicInvocation = true; 214 bool transformToDynamicInvocation = true;
215 if (input.canBeNull(types)) { 215 if (input.canBeNull(types)) {
216 // Check if the method exists on Null. If yes we must not transform 216 // Check if the method exists on Null. If yes we must not transform
217 // the static interceptor call to a dynamic invocation. 217 // the static interceptor call to a dynamic invocation.
218 // TODO(floitsch): get a list of methods that exist on 'null' and only 218 // TODO(floitsch): get a list of methods that exist on 'null' and only
219 // bail out on them. 219 // bail out on them.
220 transformToDynamicInvocation = false; 220 transformToDynamicInvocation = false;
221 } 221 }
222 if (transformToDynamicInvocation) { 222 if (transformToDynamicInvocation) {
223 return fromInterceptorToDynamicInvocation(node, node.selector); 223 return fromInterceptorToDynamicInvocation(node, node.selector);
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 instruction = instruction.accept(this); 657 instruction = instruction.accept(this);
658 instruction = next; 658 instruction = next;
659 } 659 }
660 } 660 }
661 661
662 HBoundsCheck insertBoundsCheck(HInstruction node, 662 HBoundsCheck insertBoundsCheck(HInstruction node,
663 HInstruction receiver, 663 HInstruction receiver,
664 HInstruction index) { 664 HInstruction index) {
665 HStatic interceptor = new HStatic(lengthInterceptor); 665 HStatic interceptor = new HStatic(lengthInterceptor);
666 node.block.addBefore(node, interceptor); 666 node.block.addBefore(node, interceptor);
667 Selector selector = new Selector.call( 667 Selector selector = new Selector.getter(
668 lengthInterceptor.name, 668 const SourceString('length'),
669 lengthInterceptor.getLibrary(), // TODO(kasperl): Wrong. 669 lengthInterceptor.getLibrary()); // TODO(kasperl): Wrong.
ngeoffray 2012/08/22 13:58:54 Actually, I think the instruction to create should
670 0);
671 HInvokeInterceptor length = new HInvokeInterceptor( 670 HInvokeInterceptor length = new HInvokeInterceptor(
672 selector, 671 selector, <HInstruction>[interceptor, receiver]);
673 const SourceString("length"),
674 <HInstruction>[interceptor, receiver],
675 getter: true);
676 types[length] = HType.INTEGER; 672 types[length] = HType.INTEGER;
677 node.block.addBefore(node, length); 673 node.block.addBefore(node, length);
678 674
679 HBoundsCheck check = new HBoundsCheck(index, length); 675 HBoundsCheck check = new HBoundsCheck(index, length);
680 node.block.addBefore(node, check); 676 node.block.addBefore(node, check);
681 return check; 677 return check;
682 } 678 }
683 679
684 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { 680 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) {
685 HIntegerCheck check = new HIntegerCheck(value); 681 HIntegerCheck check = new HIntegerCheck(value);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 // this type for the field is still a strong signal 1327 // this type for the field is still a strong signal
1332 // indicating the expected type of the field. 1328 // indicating the expected type of the field.
1333 types[field] = type; 1329 types[field] = type;
1334 } else { 1330 } else {
1335 // If there are no invoked setters we know the type of 1331 // If there are no invoked setters we know the type of
1336 // this field for sure. 1332 // this field for sure.
1337 field.guaranteedType = type; 1333 field.guaranteedType = type;
1338 } 1334 }
1339 } 1335 }
1340 } 1336 }
OLDNEW
« lib/compiler/implementation/ssa/nodes.dart ('K') | « lib/compiler/implementation/ssa/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698