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

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

Issue 10573027: Use GVN for length loads from arrays and strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 6 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
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/variable_allocator.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBitAnd(HBitAnd node); 7 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 8 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 9 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 10 R visitBitXor(HBitXor node);
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 * A [HCheck] instruction is an instruction that might do a dynamic 985 * A [HCheck] instruction is an instruction that might do a dynamic
986 * check at runtime on another instruction. To have proper instruction 986 * check at runtime on another instruction. To have proper instruction
987 * dependencies in the graph, instructions that depend on the check 987 * dependencies in the graph, instructions that depend on the check
988 * being done reference the [HCheck] instruction instead of the 988 * being done reference the [HCheck] instruction instead of the
989 * instruction itself. 989 * instruction itself.
990 */ 990 */
991 abstract class HCheck extends HInstruction { 991 abstract class HCheck extends HInstruction {
992 HCheck(inputs) : super(inputs); 992 HCheck(inputs) : super(inputs);
993 HInstruction get checkedInput() => inputs[0]; 993 HInstruction get checkedInput() => inputs[0];
994 bool isStatement() => true; 994 bool isStatement() => true;
995 void prepareGvn() {
996 assert(!hasSideEffects());
997 setUseGvn();
998 }
995 } 999 }
996 1000
997 class HTypeGuard extends HCheck { 1001 class HTypeGuard extends HCheck {
998 final int state; 1002 final int state;
999 final HType guardedType; 1003 final HType guardedType;
1000 bool isOn = false; 1004 bool isOn = false;
1001 int checkedInputIndex = 0; 1005 int checkedInputIndex = 0;
1002 1006
1003 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); 1007 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env);
1004 1008
1005 void prepareGvn() {
1006 assert(!hasSideEffects());
1007 setUseGvn();
1008 }
1009
1010 HInstruction get guarded() => inputs[checkedInputIndex]; 1009 HInstruction get guarded() => inputs[checkedInputIndex];
1011 HInstruction get checkedInput() => guarded; 1010 HInstruction get checkedInput() => guarded;
1012 1011
1013 HType computeTypeFromInputTypes() { 1012 HType computeTypeFromInputTypes() {
1014 return isOn ? guardedType : guarded.propagatedType; 1013 return isOn ? guardedType : guarded.propagatedType;
1015 } 1014 }
1016 1015
1017 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; 1016 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN;
1018 1017
1019 bool isControlFlow() => true; 1018 bool isControlFlow() => true;
(...skipping 16 matching lines...) Expand all
1036 * Default is that all checks must be performed dynamically. 1035 * Default is that all checks must be performed dynamically.
1037 */ 1036 */
1038 int staticChecks = FULL_CHECK; 1037 int staticChecks = FULL_CHECK;
1039 1038
1040 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); 1039 HBoundsCheck(length, index) : super(<HInstruction>[length, index]);
1041 1040
1042 HInstruction get length() => inputs[1]; 1041 HInstruction get length() => inputs[1];
1043 HInstruction get index() => inputs[0]; 1042 HInstruction get index() => inputs[0];
1044 bool isControlFlow() => true; 1043 bool isControlFlow() => true;
1045 1044
1046 void prepareGvn() {
1047 assert(!hasSideEffects());
1048 setUseGvn();
1049 }
1050
1051 HType get guaranteedType() => HType.INTEGER; 1045 HType get guaranteedType() => HType.INTEGER;
1052 1046
1053 accept(HVisitor visitor) => visitor.visitBoundsCheck(this); 1047 accept(HVisitor visitor) => visitor.visitBoundsCheck(this);
1054 int typeCode() => 2; 1048 int typeCode() => 2;
1055 bool typeEquals(other) => other is HBoundsCheck; 1049 bool typeEquals(other) => other is HBoundsCheck;
1056 bool dataEquals(HInstruction other) => true; 1050 bool dataEquals(HInstruction other) => true;
1057 } 1051 }
1058 1052
1059 class HIntegerCheck extends HCheck { 1053 class HIntegerCheck extends HCheck {
1060 bool alwaysFalse = false; 1054 bool alwaysFalse = false;
1061 1055
1062 HIntegerCheck(value) : super(<HInstruction>[value]); 1056 HIntegerCheck(value) : super(<HInstruction>[value]);
1063 1057
1064 HInstruction get value() => inputs[0]; 1058 HInstruction get value() => inputs[0];
1065 bool isControlFlow() => true; 1059 bool isControlFlow() => true;
1066 1060
1067 void prepareGvn() {
1068 assert(!hasSideEffects());
1069 setUseGvn();
1070 }
1071
1072 HType get guaranteedType() => HType.INTEGER; 1061 HType get guaranteedType() => HType.INTEGER;
1073 1062
1074 accept(HVisitor visitor) => visitor.visitIntegerCheck(this); 1063 accept(HVisitor visitor) => visitor.visitIntegerCheck(this);
1075 int typeCode() => 3; 1064 int typeCode() => 3;
1076 bool typeEquals(other) => other is HIntegerCheck; 1065 bool typeEquals(other) => other is HIntegerCheck;
1077 bool dataEquals(HInstruction other) => true; 1066 bool dataEquals(HInstruction other) => true;
1078 } 1067 }
1079 1068
1080 class HConditionalBranch extends HControlFlow { 1069 class HConditionalBranch extends HControlFlow {
1081 HConditionalBranch(inputs) : super(inputs); 1070 HConditionalBranch(inputs) : super(inputs);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 if (name == const SourceString('add') 1224 if (name == const SourceString('add')
1236 || name == const SourceString('removeLast')) { 1225 || name == const SourceString('removeLast')) {
1237 return HType.MUTABLE_ARRAY; 1226 return HType.MUTABLE_ARRAY;
1238 } 1227 }
1239 } 1228 }
1240 return HType.UNKNOWN; 1229 return HType.UNKNOWN;
1241 } 1230 }
1242 1231
1243 void prepareGvn() { 1232 void prepareGvn() {
1244 if (isLengthGetterOnStringOrArray()) { 1233 if (isLengthGetterOnStringOrArray()) {
1245 clearAllSideEffects(); 1234 setUseGvn();
1235 setDependsOnSomething();
1246 } else { 1236 } else {
1247 setAllSideEffects(); 1237 setAllSideEffects();
1248 } 1238 }
1249 } 1239 }
1250 1240
1251 int typeCode() => 4; 1241 int typeCode() => 4;
1252 bool typeEquals(other) => other is HInvokeInterceptor; 1242 bool typeEquals(other) => other is HInvokeInterceptor;
1253 bool dataEquals(HInvokeInterceptor other) { 1243 bool dataEquals(HInvokeInterceptor other) {
1254 return getter == other.getter && name == other.name; 1244 return getter == other.getter && name == other.name;
1255 } 1245 }
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 } 2274 }
2285 2275
2286 bool isChecked() => kind != NO_CHECK; 2276 bool isChecked() => kind != NO_CHECK;
2287 bool isCheckedModeCheck() => kind == CHECKED_MODE_CHECK; 2277 bool isCheckedModeCheck() => kind == CHECKED_MODE_CHECK;
2288 bool isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK; 2278 bool isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK;
2289 2279
2290 HType get guaranteedType() => type; 2280 HType get guaranteedType() => type;
2291 2281
2292 accept(HVisitor visitor) => visitor.visitTypeConversion(this); 2282 accept(HVisitor visitor) => visitor.visitTypeConversion(this);
2293 2283
2294 bool hasSideEffects() => kind != NO_CHECK;
2295 bool isStatement() => kind == ARGUMENT_TYPE_CHECK; 2284 bool isStatement() => kind == ARGUMENT_TYPE_CHECK;
2296 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; 2285 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK;
2297 } 2286 }
2298 2287
2299 class HStringConcat extends HInstruction { 2288 class HStringConcat extends HInstruction {
2300 final Node node; 2289 final Node node;
2301 HStringConcat(HInstruction left, HInstruction right, this.node) 2290 HStringConcat(HInstruction left, HInstruction right, this.node)
2302 : super(<HInstruction>[left, right]); 2291 : super(<HInstruction>[left, right]);
2303 HType get guaranteedType() => HType.STRING; 2292 HType get guaranteedType() => HType.STRING;
2304 2293
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 HBasicBlock get start() => expression.start; 2619 HBasicBlock get start() => expression.start;
2631 HBasicBlock get end() { 2620 HBasicBlock get end() {
2632 // We don't create a switch block if there are no cases. 2621 // We don't create a switch block if there are no cases.
2633 assert(!statements.isEmpty()); 2622 assert(!statements.isEmpty());
2634 return statements.last().end; 2623 return statements.last().end;
2635 } 2624 }
2636 2625
2637 bool accept(HStatementInformationVisitor visitor) => 2626 bool accept(HStatementInformationVisitor visitor) =>
2638 visitor.visitSwitchInfo(this); 2627 visitor.visitSwitchInfo(this);
2639 } 2628 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/variable_allocator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698