| OLD | NEW |
| 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 Loading... |
| 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 } | |
| 999 } | 995 } |
| 1000 | 996 |
| 1001 class HTypeGuard extends HCheck { | 997 class HTypeGuard extends HCheck { |
| 1002 final int state; | 998 final int state; |
| 1003 final HType guardedType; | 999 final HType guardedType; |
| 1004 bool isOn = false; | 1000 bool isOn = false; |
| 1005 int checkedInputIndex = 0; | 1001 int checkedInputIndex = 0; |
| 1006 | 1002 |
| 1007 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); | 1003 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); |
| 1008 | 1004 |
| 1005 void prepareGvn() { |
| 1006 assert(!hasSideEffects()); |
| 1007 setUseGvn(); |
| 1008 } |
| 1009 |
| 1009 HInstruction get guarded() => inputs[checkedInputIndex]; | 1010 HInstruction get guarded() => inputs[checkedInputIndex]; |
| 1010 HInstruction get checkedInput() => guarded; | 1011 HInstruction get checkedInput() => guarded; |
| 1011 | 1012 |
| 1012 HType computeTypeFromInputTypes() { | 1013 HType computeTypeFromInputTypes() { |
| 1013 return isOn ? guardedType : guarded.propagatedType; | 1014 return isOn ? guardedType : guarded.propagatedType; |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; | 1017 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; |
| 1017 | 1018 |
| 1018 bool isControlFlow() => true; | 1019 bool isControlFlow() => true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1035 * Default is that all checks must be performed dynamically. | 1036 * Default is that all checks must be performed dynamically. |
| 1036 */ | 1037 */ |
| 1037 int staticChecks = FULL_CHECK; | 1038 int staticChecks = FULL_CHECK; |
| 1038 | 1039 |
| 1039 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); | 1040 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); |
| 1040 | 1041 |
| 1041 HInstruction get length() => inputs[1]; | 1042 HInstruction get length() => inputs[1]; |
| 1042 HInstruction get index() => inputs[0]; | 1043 HInstruction get index() => inputs[0]; |
| 1043 bool isControlFlow() => true; | 1044 bool isControlFlow() => true; |
| 1044 | 1045 |
| 1046 void prepareGvn() { |
| 1047 assert(!hasSideEffects()); |
| 1048 setUseGvn(); |
| 1049 } |
| 1050 |
| 1045 HType get guaranteedType() => HType.INTEGER; | 1051 HType get guaranteedType() => HType.INTEGER; |
| 1046 | 1052 |
| 1047 accept(HVisitor visitor) => visitor.visitBoundsCheck(this); | 1053 accept(HVisitor visitor) => visitor.visitBoundsCheck(this); |
| 1048 int typeCode() => 2; | 1054 int typeCode() => 2; |
| 1049 bool typeEquals(other) => other is HBoundsCheck; | 1055 bool typeEquals(other) => other is HBoundsCheck; |
| 1050 bool dataEquals(HInstruction other) => true; | 1056 bool dataEquals(HInstruction other) => true; |
| 1051 } | 1057 } |
| 1052 | 1058 |
| 1053 class HIntegerCheck extends HCheck { | 1059 class HIntegerCheck extends HCheck { |
| 1054 bool alwaysFalse = false; | 1060 bool alwaysFalse = false; |
| 1055 | 1061 |
| 1056 HIntegerCheck(value) : super(<HInstruction>[value]); | 1062 HIntegerCheck(value) : super(<HInstruction>[value]); |
| 1057 | 1063 |
| 1058 HInstruction get value() => inputs[0]; | 1064 HInstruction get value() => inputs[0]; |
| 1059 bool isControlFlow() => true; | 1065 bool isControlFlow() => true; |
| 1060 | 1066 |
| 1067 void prepareGvn() { |
| 1068 assert(!hasSideEffects()); |
| 1069 setUseGvn(); |
| 1070 } |
| 1071 |
| 1061 HType get guaranteedType() => HType.INTEGER; | 1072 HType get guaranteedType() => HType.INTEGER; |
| 1062 | 1073 |
| 1063 accept(HVisitor visitor) => visitor.visitIntegerCheck(this); | 1074 accept(HVisitor visitor) => visitor.visitIntegerCheck(this); |
| 1064 int typeCode() => 3; | 1075 int typeCode() => 3; |
| 1065 bool typeEquals(other) => other is HIntegerCheck; | 1076 bool typeEquals(other) => other is HIntegerCheck; |
| 1066 bool dataEquals(HInstruction other) => true; | 1077 bool dataEquals(HInstruction other) => true; |
| 1067 } | 1078 } |
| 1068 | 1079 |
| 1069 class HConditionalBranch extends HControlFlow { | 1080 class HConditionalBranch extends HControlFlow { |
| 1070 HConditionalBranch(inputs) : super(inputs); | 1081 HConditionalBranch(inputs) : super(inputs); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 if (name == const SourceString('add') | 1235 if (name == const SourceString('add') |
| 1225 || name == const SourceString('removeLast')) { | 1236 || name == const SourceString('removeLast')) { |
| 1226 return HType.MUTABLE_ARRAY; | 1237 return HType.MUTABLE_ARRAY; |
| 1227 } | 1238 } |
| 1228 } | 1239 } |
| 1229 return HType.UNKNOWN; | 1240 return HType.UNKNOWN; |
| 1230 } | 1241 } |
| 1231 | 1242 |
| 1232 void prepareGvn() { | 1243 void prepareGvn() { |
| 1233 if (isLengthGetterOnStringOrArray()) { | 1244 if (isLengthGetterOnStringOrArray()) { |
| 1234 setUseGvn(); | 1245 clearAllSideEffects(); |
| 1235 setDependsOnSomething(); | |
| 1236 } else { | 1246 } else { |
| 1237 setAllSideEffects(); | 1247 setAllSideEffects(); |
| 1238 } | 1248 } |
| 1239 } | 1249 } |
| 1240 | 1250 |
| 1241 int typeCode() => 4; | 1251 int typeCode() => 4; |
| 1242 bool typeEquals(other) => other is HInvokeInterceptor; | 1252 bool typeEquals(other) => other is HInvokeInterceptor; |
| 1243 bool dataEquals(HInvokeInterceptor other) { | 1253 bool dataEquals(HInvokeInterceptor other) { |
| 1244 return getter == other.getter && name == other.name; | 1254 return getter == other.getter && name == other.name; |
| 1245 } | 1255 } |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2274 } | 2284 } |
| 2275 | 2285 |
| 2276 bool isChecked() => kind != NO_CHECK; | 2286 bool isChecked() => kind != NO_CHECK; |
| 2277 bool isCheckedModeCheck() => kind == CHECKED_MODE_CHECK; | 2287 bool isCheckedModeCheck() => kind == CHECKED_MODE_CHECK; |
| 2278 bool isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK; | 2288 bool isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK; |
| 2279 | 2289 |
| 2280 HType get guaranteedType() => type; | 2290 HType get guaranteedType() => type; |
| 2281 | 2291 |
| 2282 accept(HVisitor visitor) => visitor.visitTypeConversion(this); | 2292 accept(HVisitor visitor) => visitor.visitTypeConversion(this); |
| 2283 | 2293 |
| 2294 bool hasSideEffects() => kind != NO_CHECK; |
| 2284 bool isStatement() => kind == ARGUMENT_TYPE_CHECK; | 2295 bool isStatement() => kind == ARGUMENT_TYPE_CHECK; |
| 2285 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; | 2296 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; |
| 2286 } | 2297 } |
| 2287 | 2298 |
| 2288 class HStringConcat extends HInstruction { | 2299 class HStringConcat extends HInstruction { |
| 2289 final Node node; | 2300 final Node node; |
| 2290 HStringConcat(HInstruction left, HInstruction right, this.node) | 2301 HStringConcat(HInstruction left, HInstruction right, this.node) |
| 2291 : super(<HInstruction>[left, right]); | 2302 : super(<HInstruction>[left, right]); |
| 2292 HType get guaranteedType() => HType.STRING; | 2303 HType get guaranteedType() => HType.STRING; |
| 2293 | 2304 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2619 HBasicBlock get start() => expression.start; | 2630 HBasicBlock get start() => expression.start; |
| 2620 HBasicBlock get end() { | 2631 HBasicBlock get end() { |
| 2621 // We don't create a switch block if there are no cases. | 2632 // We don't create a switch block if there are no cases. |
| 2622 assert(!statements.isEmpty()); | 2633 assert(!statements.isEmpty()); |
| 2623 return statements.last().end; | 2634 return statements.last().end; |
| 2624 } | 2635 } |
| 2625 | 2636 |
| 2626 bool accept(HStatementInformationVisitor visitor) => | 2637 bool accept(HStatementInformationVisitor visitor) => |
| 2627 visitor.visitSwitchInfo(this); | 2638 visitor.visitSwitchInfo(this); |
| 2628 } | 2639 } |
| OLD | NEW |