| OLD | NEW |
| 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 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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 abstract class HCheck extends HInstruction { | 978 abstract class HCheck extends HInstruction { |
| 979 HCheck(inputs) : super(inputs); | 979 HCheck(inputs) : super(inputs); |
| 980 HInstruction get checkedInput() => inputs[0]; | 980 HInstruction get checkedInput() => inputs[0]; |
| 981 bool isStatement() => true; | 981 bool isStatement() => true; |
| 982 } | 982 } |
| 983 | 983 |
| 984 class HTypeGuard extends HCheck { | 984 class HTypeGuard extends HCheck { |
| 985 final int state; | 985 final int state; |
| 986 final HType guardedType; | 986 final HType guardedType; |
| 987 bool isOn = false; | 987 bool isOn = false; |
| 988 int checkedInputIndex = 0; | |
| 989 | |
| 990 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); | 988 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); |
| 991 | 989 |
| 992 void prepareGvn() { | 990 void prepareGvn() { |
| 993 assert(!hasSideEffects()); | 991 assert(!hasSideEffects()); |
| 994 setUseGvn(); | 992 setUseGvn(); |
| 995 } | 993 } |
| 996 | 994 |
| 997 HInstruction get guarded() => inputs[checkedInputIndex]; | 995 HInstruction get guarded() => inputs.last(); |
| 998 HInstruction get checkedInput() => guarded; | 996 HInstruction get checkedInput() => guarded; |
| 999 | 997 |
| 1000 HType computeTypeFromInputTypes() { | 998 HType computeTypeFromInputTypes() { |
| 1001 return isOn ? guardedType : guarded.propagatedType; | 999 return isOn ? guardedType : guarded.propagatedType; |
| 1002 } | 1000 } |
| 1003 | 1001 |
| 1004 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; | 1002 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; |
| 1005 | 1003 |
| 1006 bool isControlFlow() => true; | 1004 bool isControlFlow() => true; |
| 1007 | 1005 |
| 1008 accept(HVisitor visitor) => visitor.visitTypeGuard(this); | 1006 accept(HVisitor visitor) => visitor.visitTypeGuard(this); |
| 1009 int typeCode() => 1; | 1007 int typeCode() => 1; |
| 1010 bool typeEquals(other) => other is HTypeGuard; | 1008 bool typeEquals(other) => other is HTypeGuard; |
| 1011 bool dataEquals(HTypeGuard other) { | 1009 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; |
| 1012 return guarded == other.guarded && guardedType == other.guardedType; | |
| 1013 } | |
| 1014 } | 1010 } |
| 1015 | 1011 |
| 1016 class HBoundsCheck extends HCheck { | 1012 class HBoundsCheck extends HCheck { |
| 1017 static final int ALWAYS_FALSE = 0; | 1013 static final int ALWAYS_FALSE = 0; |
| 1018 static final int FULL_CHECK = 1; | 1014 static final int FULL_CHECK = 1; |
| 1019 static final int ALWAYS_ABOVE_ZERO = 2; | 1015 static final int ALWAYS_ABOVE_ZERO = 2; |
| 1020 static final int ALWAYS_TRUE = 3; | 1016 static final int ALWAYS_TRUE = 3; |
| 1021 /** | 1017 /** |
| 1022 * Details which tests have been done statically during compilation. | 1018 * Details which tests have been done statically during compilation. |
| 1023 * Default is that all checks must be performed dynamically. | 1019 * Default is that all checks must be performed dynamically. |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2488 this.labels); | 2484 this.labels); |
| 2489 | 2485 |
| 2490 HBasicBlock get start() { | 2486 HBasicBlock get start() { |
| 2491 if (initializer !== null) return initializer.start; | 2487 if (initializer !== null) return initializer.start; |
| 2492 if (kind == DO_WHILE_LOOP) { | 2488 if (kind == DO_WHILE_LOOP) { |
| 2493 return body.start; | 2489 return body.start; |
| 2494 } | 2490 } |
| 2495 return condition.start; | 2491 return condition.start; |
| 2496 } | 2492 } |
| 2497 | 2493 |
| 2498 HBasicBlock get loopHeader() { | |
| 2499 return kind == DO_WHILE_LOOP ? body.start : condition.start; | |
| 2500 } | |
| 2501 | |
| 2502 HBasicBlock get end() { | 2494 HBasicBlock get end() { |
| 2503 if (updates !== null) return updates.end; | 2495 if (updates !== null) return updates.end; |
| 2504 if (kind == DO_WHILE_LOOP) { | 2496 if (kind == DO_WHILE_LOOP) { |
| 2505 return condition.end; | 2497 return condition.end; |
| 2506 } | 2498 } |
| 2507 return body.end; | 2499 return body.end; |
| 2508 } | 2500 } |
| 2509 | 2501 |
| 2510 static int loopType(Node node) { | 2502 static int loopType(Node node) { |
| 2511 return node.accept(const LoopTypeVisitor()); | 2503 return node.accept(const LoopTypeVisitor()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2589 HBasicBlock get start() => expression.start; | 2581 HBasicBlock get start() => expression.start; |
| 2590 HBasicBlock get end() { | 2582 HBasicBlock get end() { |
| 2591 // We don't create a switch block if there are no cases. | 2583 // We don't create a switch block if there are no cases. |
| 2592 assert(!statements.isEmpty()); | 2584 assert(!statements.isEmpty()); |
| 2593 return statements.last().end; | 2585 return statements.last().end; |
| 2594 } | 2586 } |
| 2595 | 2587 |
| 2596 bool accept(HStatementInformationVisitor visitor) => | 2588 bool accept(HStatementInformationVisitor visitor) => |
| 2597 visitor.visitSwitchInfo(this); | 2589 visitor.visitSwitchInfo(this); |
| 2598 } | 2590 } |
| OLD | NEW |