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

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

Issue 10383065: Start creating a MemberSet abstraction, and use it to fold getters/setters into field accesses. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return node; 546 return node;
547 } 547 }
548 548
549 HInstruction visitTypeConversion(HTypeConversion node) { 549 HInstruction visitTypeConversion(HTypeConversion node) {
550 HInstruction value = node.inputs[0]; 550 HInstruction value = node.inputs[0];
551 // If the union of the types is still the input type then 551 // If the union of the types is still the input type then
552 // no conversion is required. 552 // no conversion is required.
553 HType combinedType = value.propagatedType.union(node.propagatedType); 553 HType combinedType = value.propagatedType.union(node.propagatedType);
554 return (combinedType == value.propagatedType) ? value : node; 554 return (combinedType == value.propagatedType) ? value : node;
555 } 555 }
556
557 HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
558 HInstruction receiver = node.inputs[0];
559 if (!receiver.propagatedType.isUseful()) return node;
560 Type type = receiver.propagatedType.computeType(compiler);
561 if (type === null) return node;
562 MemberSet memberSet = compiler.universe.memberSetFor(type, node.name);
563 if (memberSet.isEmpty() || !memberSet.hasJustFields()) return node;
564 return new HFieldGet(node.name, node.inputs[0]);
565 }
566
567 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) {
568 HInstruction receiver = node.inputs[0];
569 if (!receiver.propagatedType.isUseful()) return node;
570 Type type = receiver.propagatedType.computeType(compiler);
571 if (type === null) return node;
572 MemberSet memberSet = compiler.universe.memberSetFor(type, node.name);
573 if (memberSet.isEmpty() || !memberSet.hasJustFields()) return node;
574 return new HFieldSet(node.name, node.inputs[0], node.inputs[1]);
575 }
556 } 576 }
557 577
558 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { 578 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
559 final String name = "SsaCheckInserter"; 579 final String name = "SsaCheckInserter";
560 Element lengthInterceptor; 580 Element lengthInterceptor;
561 581
562 SsaCheckInserter(Compiler compiler) { 582 SsaCheckInserter(Compiler compiler) {
563 SourceString lengthString = const SourceString('length'); 583 SourceString lengthString = const SourceString('length');
564 lengthInterceptor = 584 lengthInterceptor =
565 compiler.builder.interceptors.getStaticGetInterceptor(lengthString); 585 compiler.builder.interceptors.getStaticGetInterceptor(lengthString);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 // the if block terminates. So any use of the instruction 1108 // the if block terminates. So any use of the instruction
1089 // after the join block should be changed to the new 1109 // after the join block should be changed to the new
1090 // instruction. 1110 // instruction.
1091 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); 1111 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType);
1092 } 1112 }
1093 // TODO(ngeoffray): Also change uses for the then block on a HType 1113 // TODO(ngeoffray): Also change uses for the then block on a HType
1094 // that knows it is not of a specific Type. 1114 // that knows it is not of a specific Type.
1095 } 1115 }
1096 } 1116 }
1097 } 1117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698