Chromium Code Reviews| 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 abstract class HVisitor<R> { | 5 abstract class HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBailoutTarget(HBailoutTarget node); | 7 R visitBailoutTarget(HBailoutTarget node); |
| 8 R visitBitAnd(HBitAnd node); | 8 R visitBitAnd(HBitAnd node); |
| 9 R visitBitNot(HBitNot node); | 9 R visitBitNot(HBitNot node); |
| 10 R visitBitOr(HBitOr node); | 10 R visitBitOr(HBitOr node); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 R visitLocalGet(HLocalGet node); | 44 R visitLocalGet(HLocalGet node); |
| 45 R visitLocalSet(HLocalSet node); | 45 R visitLocalSet(HLocalSet node); |
| 46 R visitLocalValue(HLocalValue node); | 46 R visitLocalValue(HLocalValue node); |
| 47 R visitLoopBranch(HLoopBranch node); | 47 R visitLoopBranch(HLoopBranch node); |
| 48 R visitModulo(HModulo node); | 48 R visitModulo(HModulo node); |
| 49 R visitMultiply(HMultiply node); | 49 R visitMultiply(HMultiply node); |
| 50 R visitNegate(HNegate node); | 50 R visitNegate(HNegate node); |
| 51 R visitNot(HNot node); | 51 R visitNot(HNot node); |
| 52 R visitParameterValue(HParameterValue node); | 52 R visitParameterValue(HParameterValue node); |
| 53 R visitPhi(HPhi node); | 53 R visitPhi(HPhi node); |
| 54 R visitRangeConversion(HRangeConversion node); | |
| 54 R visitReturn(HReturn node); | 55 R visitReturn(HReturn node); |
| 55 R visitShiftLeft(HShiftLeft node); | 56 R visitShiftLeft(HShiftLeft node); |
| 56 R visitShiftRight(HShiftRight node); | 57 R visitShiftRight(HShiftRight node); |
| 57 R visitStatic(HStatic node); | 58 R visitStatic(HStatic node); |
| 58 R visitStaticStore(HStaticStore node); | 59 R visitStaticStore(HStaticStore node); |
| 59 R visitStringConcat(HStringConcat node); | 60 R visitStringConcat(HStringConcat node); |
| 60 R visitSubtract(HSubtract node); | 61 R visitSubtract(HSubtract node); |
| 61 R visitSwitch(HSwitch node); | 62 R visitSwitch(HSwitch node); |
| 62 R visitThis(HThis node); | 63 R visitThis(HThis node); |
| 63 R visitThrow(HThrow node); | 64 R visitThrow(HThrow node); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 visitLocalGet(HLocalGet node) => visitFieldGet(node); | 309 visitLocalGet(HLocalGet node) => visitFieldGet(node); |
| 309 visitLocalSet(HLocalSet node) => visitFieldSet(node); | 310 visitLocalSet(HLocalSet node) => visitFieldSet(node); |
| 310 visitLocalValue(HLocalValue node) => visitInstruction(node); | 311 visitLocalValue(HLocalValue node) => visitInstruction(node); |
| 311 visitLoopBranch(HLoopBranch node) => visitConditionalBranch(node); | 312 visitLoopBranch(HLoopBranch node) => visitConditionalBranch(node); |
| 312 visitModulo(HModulo node) => visitBinaryArithmetic(node); | 313 visitModulo(HModulo node) => visitBinaryArithmetic(node); |
| 313 visitNegate(HNegate node) => visitInvokeUnary(node); | 314 visitNegate(HNegate node) => visitInvokeUnary(node); |
| 314 visitNot(HNot node) => visitInstruction(node); | 315 visitNot(HNot node) => visitInstruction(node); |
| 315 visitPhi(HPhi node) => visitInstruction(node); | 316 visitPhi(HPhi node) => visitInstruction(node); |
| 316 visitMultiply(HMultiply node) => visitBinaryArithmetic(node); | 317 visitMultiply(HMultiply node) => visitBinaryArithmetic(node); |
| 317 visitParameterValue(HParameterValue node) => visitLocalValue(node); | 318 visitParameterValue(HParameterValue node) => visitLocalValue(node); |
| 319 visitRangeConversion(HRangeConversion node) => visitCheck(node); | |
| 318 visitReturn(HReturn node) => visitControlFlow(node); | 320 visitReturn(HReturn node) => visitControlFlow(node); |
| 319 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node); | 321 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node); |
| 320 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node); | 322 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node); |
| 321 visitSubtract(HSubtract node) => visitBinaryArithmetic(node); | 323 visitSubtract(HSubtract node) => visitBinaryArithmetic(node); |
| 322 visitSwitch(HSwitch node) => visitControlFlow(node); | 324 visitSwitch(HSwitch node) => visitControlFlow(node); |
| 323 visitStatic(HStatic node) => visitInstruction(node); | 325 visitStatic(HStatic node) => visitInstruction(node); |
| 324 visitStaticStore(HStaticStore node) => visitInstruction(node); | 326 visitStaticStore(HStaticStore node) => visitInstruction(node); |
| 325 visitStringConcat(HStringConcat node) => visitInstruction(node); | 327 visitStringConcat(HStringConcat node) => visitInstruction(node); |
| 326 visitThis(HThis node) => visitParameterValue(node); | 328 visitThis(HThis node) => visitParameterValue(node); |
| 327 visitThrow(HThrow node) => visitControlFlow(node); | 329 visitThrow(HThrow node) => visitControlFlow(node); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 if (dominator !== block0) { | 702 if (dominator !== block0) { |
| 701 dominator.removeDominatedBlock(this); | 703 dominator.removeDominatedBlock(this); |
| 702 block0.addDominatedBlock(this); | 704 block0.addDominatedBlock(this); |
| 703 } | 705 } |
| 704 } | 706 } |
| 705 } | 707 } |
| 706 | 708 |
| 707 void forEachPhi(void f(HPhi phi)) { | 709 void forEachPhi(void f(HPhi phi)) { |
| 708 HPhi current = phis.first; | 710 HPhi current = phis.first; |
| 709 while (current !== null) { | 711 while (current !== null) { |
| 712 HInstruction saved = current.next; | |
| 710 f(current); | 713 f(current); |
| 711 current = current.next; | 714 current = saved; |
| 712 } | 715 } |
| 713 } | 716 } |
| 714 | 717 |
| 715 void forEachInstruction(void f(HInstruction instruction)) { | 718 void forEachInstruction(void f(HInstruction instruction)) { |
| 716 HInstruction current = first; | 719 HInstruction current = first; |
| 717 while (current !== null) { | 720 while (current !== null) { |
| 721 HInstruction saved = current.next; | |
| 718 f(current); | 722 f(current); |
| 719 current = current.next; | 723 current = saved; |
| 720 } | 724 } |
| 721 } | 725 } |
| 722 | 726 |
| 723 bool isValid() { | 727 bool isValid() { |
| 724 assert(isClosed()); | 728 assert(isClosed()); |
| 725 HValidator validator = new HValidator(); | 729 HValidator validator = new HValidator(); |
| 726 validator.visitBasicBlock(this); | 730 validator.visitBasicBlock(this); |
| 727 return validator.isValid; | 731 return validator.isValid; |
| 728 } | 732 } |
| 729 | 733 |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 accept(HVisitor visitor) => visitor.visitTypeGuard(this); | 1189 accept(HVisitor visitor) => visitor.visitTypeGuard(this); |
| 1186 int typeCode() => HInstruction.TYPE_GUARD_TYPECODE; | 1190 int typeCode() => HInstruction.TYPE_GUARD_TYPECODE; |
| 1187 bool typeEquals(other) => other is HTypeGuard; | 1191 bool typeEquals(other) => other is HTypeGuard; |
| 1188 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; | 1192 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; |
| 1189 } | 1193 } |
| 1190 | 1194 |
| 1191 class HBoundsCheck extends HCheck { | 1195 class HBoundsCheck extends HCheck { |
| 1192 static const int ALWAYS_FALSE = 0; | 1196 static const int ALWAYS_FALSE = 0; |
| 1193 static const int FULL_CHECK = 1; | 1197 static const int FULL_CHECK = 1; |
| 1194 static const int ALWAYS_ABOVE_ZERO = 2; | 1198 static const int ALWAYS_ABOVE_ZERO = 2; |
| 1195 static const int ALWAYS_TRUE = 3; | 1199 static const int ALWAYS_BELOW_LENGTH = 3; |
| 1200 static const int ALWAYS_TRUE = 4; | |
| 1196 /** | 1201 /** |
| 1197 * Details which tests have been done statically during compilation. | 1202 * Details which tests have been done statically during compilation. |
| 1198 * Default is that all checks must be performed dynamically. | 1203 * Default is that all checks must be performed dynamically. |
| 1199 */ | 1204 */ |
| 1200 int staticChecks = FULL_CHECK; | 1205 int staticChecks = FULL_CHECK; |
| 1201 | 1206 |
| 1202 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); | 1207 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); |
| 1203 | 1208 |
| 1204 HInstruction get length => inputs[1]; | 1209 HInstruction get length => inputs[1]; |
| 1205 HInstruction get index => inputs[0]; | 1210 HInstruction get index => inputs[0]; |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2559 bool isJsStatement(HTypeMap types) => kind == ARGUMENT_TYPE_CHECK; | 2564 bool isJsStatement(HTypeMap types) => kind == ARGUMENT_TYPE_CHECK; |
| 2560 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; | 2565 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; |
| 2561 | 2566 |
| 2562 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; | 2567 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; |
| 2563 bool typeEquals(HInstruction other) => other is HTypeConversion; | 2568 bool typeEquals(HInstruction other) => other is HTypeConversion; |
| 2564 bool dataEquals(HTypeConversion other) { | 2569 bool dataEquals(HTypeConversion other) { |
| 2565 return type == other.type && kind == other.kind; | 2570 return type == other.type && kind == other.kind; |
| 2566 } | 2571 } |
| 2567 } | 2572 } |
| 2568 | 2573 |
| 2574 class HRangeConversion extends HCheck { | |
| 2575 HRangeConversion(HInstruction input) : super(<HInstruction>[input]) { | |
| 2576 sourceElement = input.sourceElement; | |
| 2577 } | |
| 2578 accept(HVisitor visitor) => visitor.visitRangeConversion(this); | |
|
Søren Gjesse
2012/09/26 14:00:15
Maybe add a comment that we only do range analysis
ngeoffray
2012/09/27 13:22:02
Done.
| |
| 2579 HType get guaranteedType => HType.INTEGER; | |
| 2580 } | |
| 2581 | |
| 2569 class HStringConcat extends HInstruction { | 2582 class HStringConcat extends HInstruction { |
| 2570 final Node node; | 2583 final Node node; |
| 2571 HStringConcat(HInstruction left, HInstruction right, this.node) | 2584 HStringConcat(HInstruction left, HInstruction right, this.node) |
| 2572 : super(<HInstruction>[left, right]); | 2585 : super(<HInstruction>[left, right]); |
| 2573 HType get guaranteedType => HType.STRING; | 2586 HType get guaranteedType => HType.STRING; |
| 2574 | 2587 |
| 2575 HInstruction get left => inputs[0]; | 2588 HInstruction get left => inputs[0]; |
| 2576 HInstruction get right => inputs[1]; | 2589 HInstruction get right => inputs[1]; |
| 2577 | 2590 |
| 2578 accept(HVisitor visitor) => visitor.visitStringConcat(this); | 2591 accept(HVisitor visitor) => visitor.visitStringConcat(this); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2904 HBasicBlock get start => expression.start; | 2917 HBasicBlock get start => expression.start; |
| 2905 HBasicBlock get end { | 2918 HBasicBlock get end { |
| 2906 // We don't create a switch block if there are no cases. | 2919 // We don't create a switch block if there are no cases. |
| 2907 assert(!statements.isEmpty()); | 2920 assert(!statements.isEmpty()); |
| 2908 return statements.last().end; | 2921 return statements.last().end; |
| 2909 } | 2922 } |
| 2910 | 2923 |
| 2911 bool accept(HStatementInformationVisitor visitor) => | 2924 bool accept(HStatementInformationVisitor visitor) => |
| 2912 visitor.visitSwitchInfo(this); | 2925 visitor.visitSwitchInfo(this); |
| 2913 } | 2926 } |
| OLD | NEW |