| 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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 abstract class HCheck extends HInstruction { | 977 abstract class HCheck extends HInstruction { |
| 978 HCheck(inputs) : super(inputs); | 978 HCheck(inputs) : super(inputs); |
| 979 HInstruction get checkedInput() => inputs[0]; | 979 HInstruction get checkedInput() => inputs[0]; |
| 980 bool isStatement() => true; | 980 bool isStatement() => true; |
| 981 } | 981 } |
| 982 | 982 |
| 983 class HTypeGuard extends HCheck { | 983 class HTypeGuard extends HCheck { |
| 984 final int state; | 984 final int state; |
| 985 final HType guardedType; | 985 final HType guardedType; |
| 986 bool isOn = false; | 986 bool isOn = false; |
| 987 // A list of sorted variable names to be able to share a common |
| 988 // environment between type guards with the same [state]. |
| 989 List<String> sortedVariableNames; |
| 990 |
| 987 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); | 991 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); |
| 988 | 992 |
| 989 void prepareGvn() { | 993 void prepareGvn() { |
| 990 assert(!hasSideEffects()); | 994 assert(!hasSideEffects()); |
| 991 setUseGvn(); | 995 setUseGvn(); |
| 992 } | 996 } |
| 993 | 997 |
| 994 HInstruction get guarded() => inputs.last(); | 998 HInstruction get guarded() => inputs.last(); |
| 995 HInstruction get checkedInput() => guarded; | 999 HInstruction get checkedInput() => guarded; |
| 996 | 1000 |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 this.labels); | 2487 this.labels); |
| 2484 | 2488 |
| 2485 HBasicBlock get start() { | 2489 HBasicBlock get start() { |
| 2486 if (initializer !== null) return initializer.start; | 2490 if (initializer !== null) return initializer.start; |
| 2487 if (kind == DO_WHILE_LOOP) { | 2491 if (kind == DO_WHILE_LOOP) { |
| 2488 return body.start; | 2492 return body.start; |
| 2489 } | 2493 } |
| 2490 return condition.start; | 2494 return condition.start; |
| 2491 } | 2495 } |
| 2492 | 2496 |
| 2497 HBasicBlock get loopHeader() { |
| 2498 return kind == DO_WHILE_LOOP ? body.start : condition.start; |
| 2499 } |
| 2500 |
| 2493 HBasicBlock get end() { | 2501 HBasicBlock get end() { |
| 2494 if (updates !== null) return updates.end; | 2502 if (updates !== null) return updates.end; |
| 2495 if (kind == DO_WHILE_LOOP) { | 2503 if (kind == DO_WHILE_LOOP) { |
| 2496 return condition.end; | 2504 return condition.end; |
| 2497 } | 2505 } |
| 2498 return body.end; | 2506 return body.end; |
| 2499 } | 2507 } |
| 2500 | 2508 |
| 2501 static int loopType(Node node) { | 2509 static int loopType(Node node) { |
| 2502 return node.accept(const LoopTypeVisitor()); | 2510 return node.accept(const LoopTypeVisitor()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2580 HBasicBlock get start() => expression.start; | 2588 HBasicBlock get start() => expression.start; |
| 2581 HBasicBlock get end() { | 2589 HBasicBlock get end() { |
| 2582 // We don't create a switch block if there are no cases. | 2590 // We don't create a switch block if there are no cases. |
| 2583 assert(!statements.isEmpty()); | 2591 assert(!statements.isEmpty()); |
| 2584 return statements.last().end; | 2592 return statements.last().end; |
| 2585 } | 2593 } |
| 2586 | 2594 |
| 2587 bool accept(HStatementInformationVisitor visitor) => | 2595 bool accept(HStatementInformationVisitor visitor) => |
| 2588 visitor.visitSwitchInfo(this); | 2596 visitor.visitSwitchInfo(this); |
| 2589 } | 2597 } |
| OLD | NEW |