Chromium Code Reviews| 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 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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 HInstruction get right() => inputs[2]; | 1346 HInstruction get right() => inputs[2]; |
| 1347 | 1347 |
| 1348 HType computeInputsType() { | 1348 HType computeInputsType() { |
| 1349 HType leftType = left.type; | 1349 HType leftType = left.type; |
| 1350 HType rightType = right.type; | 1350 HType rightType = right.type; |
| 1351 if (leftType.isUnknown() || rightType.isUnknown()) { | 1351 if (leftType.isUnknown() || rightType.isUnknown()) { |
| 1352 return HType.UNKNOWN; | 1352 return HType.UNKNOWN; |
| 1353 } | 1353 } |
| 1354 return leftType.combine(rightType); | 1354 return leftType.combine(rightType); |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 abstract HInstruction fold(HGraph graph); | 1357 abstract HInstruction fold(HGraph graph); |
| 1358 abstract evaluate(num a, num b); | 1358 abstract evaluate(num a, num b); |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 class HBinaryArithmetic extends HInvokeBinary { | 1361 class HBinaryArithmetic extends HInvokeBinary { |
| 1362 HBinaryArithmetic(HStatic target, HInstruction left, HInstruction right) | 1362 HBinaryArithmetic(HStatic target, HInstruction left, HInstruction right) |
| 1363 : super(target, left, right); | 1363 : super(target, left, right); |
| 1364 | 1364 |
| 1365 void prepareGvn() { | 1365 void prepareGvn() { |
| 1366 // An arithmetic expression can take part in global value | 1366 // An arithmetic expression can take part in global value |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1783 if (hasElse) { | 1783 if (hasElse) { |
| 1784 if (dominated.length > 2) return dominated[2]; | 1784 if (dominated.length > 2) return dominated[2]; |
| 1785 } else { | 1785 } else { |
| 1786 if (dominated.length > 1) return dominated[1]; | 1786 if (dominated.length > 1) return dominated[1]; |
| 1787 } | 1787 } |
| 1788 return null; | 1788 return null; |
| 1789 } | 1789 } |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 class HLoopBranch extends HConditionalBranch { | 1792 class HLoopBranch extends HConditionalBranch { |
| 1793 HLoopBranch(HInstruction condition) : super(<HInstruction>[condition]); | 1793 static final int CONDITION_FIRST_LOOP = 0; |
| 1794 static final int DO_WHILE_LOOP = 1; | |
| 1795 | |
| 1796 final int kind; | |
| 1797 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) | |
| 1798 : super(<HInstruction>[condition]); | |
| 1794 toString() => 'loop-branch'; | 1799 toString() => 'loop-branch'; |
| 1795 accept(HVisitor visitor) => visitor.visitLoopBranch(this); | 1800 accept(HVisitor visitor) => visitor.visitLoopBranch(this); |
| 1796 | 1801 |
| 1797 bool isDoWhile() { | 1802 bool isDoWhile() { |
| 1798 bool result = block.dominatedBlocks.length == 1; | 1803 return kind === DO_WHILE_LOOP; |
| 1799 if (result) { | |
| 1800 // The first successor is the loop-body and thus a back-edge. | |
| 1801 assert(block.successors[0].id < block.id); | |
| 1802 assert(block.dominatedBlocks[0] === block.successors[1]); | |
| 1803 } else { | |
| 1804 assert(block.dominatedBlocks[0] === block.successors[0]); | |
| 1805 assert(block.dominatedBlocks[1] === block.successors[1]);; | |
| 1806 } | |
| 1807 return result; | |
| 1808 } | 1804 } |
| 1809 } | 1805 } |
| 1810 | 1806 |
| 1811 class HLiteral extends HInstruction { | 1807 class HLiteral extends HInstruction { |
| 1812 final value; | 1808 final value; |
| 1813 HLiteral.internal(this.value, HType type) : super(<HInstruction>[]) { | 1809 HLiteral.internal(this.value, HType type) : super(<HInstruction>[]) { |
| 1814 this.type = type; | 1810 this.type = type; |
| 1815 tryGenerateAtUseSite(); // Maybe avoid this if the literal is big? | 1811 tryGenerateAtUseSite(); // Maybe avoid this if the literal is big? |
| 1816 } | 1812 } |
| 1817 | 1813 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1878 | 1874 |
| 1879 static final IS_NOT_LOGICAL_OPERATOR = 0; | 1875 static final IS_NOT_LOGICAL_OPERATOR = 0; |
| 1880 static final IS_AND = 1; | 1876 static final IS_AND = 1; |
| 1881 static final IS_OR = 2; | 1877 static final IS_OR = 2; |
| 1882 | 1878 |
| 1883 int logicalOperatorType = IS_NOT_LOGICAL_OPERATOR; | 1879 int logicalOperatorType = IS_NOT_LOGICAL_OPERATOR; |
| 1884 | 1880 |
| 1885 // The order of the [inputs] must correspond to the order of the | 1881 // The order of the [inputs] must correspond to the order of the |
| 1886 // predecessor-edges. That is if an input comes from the first predecessor | 1882 // predecessor-edges. That is if an input comes from the first predecessor |
| 1887 // of the surrounding block, then the input must be the first in the [HPhi]. | 1883 // of the surrounding block, then the input must be the first in the [HPhi]. |
| 1884 HPhi(this.element) : super(<HInstruction>[]); | |
|
karlklose
2012/02/29 10:17:38
I would prefer to have a constructor HPhi(element,
Lasse Reichstein Nielsen
2012/02/29 10:42:02
Done. The HPhi is now equivalent to HPhi.multipleI
| |
| 1888 HPhi.singleInput(this.element, HInstruction input) | 1885 HPhi.singleInput(this.element, HInstruction input) |
| 1889 : super(<HInstruction>[input]); | 1886 : super(<HInstruction>[input]); |
| 1890 HPhi.manyInputs(this.element, List<HInstruction> inputs) | 1887 HPhi.manyInputs(this.element, List<HInstruction> inputs) |
| 1891 : super(inputs); | 1888 : super(inputs); |
| 1892 | 1889 |
| 1893 void addInput(HInstruction input) { | 1890 void addInput(HInstruction input) { |
| 1894 assert(isInBasicBlock()); | 1891 assert(isInBasicBlock()); |
| 1895 inputs.add(input); | 1892 inputs.add(input); |
| 1896 input.usedBy.add(this); | 1893 input.usedBy.add(this); |
| 1897 } | 1894 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 | 2252 |
| 2256 HInstruction get expression() => inputs[0]; | 2253 HInstruction get expression() => inputs[0]; |
| 2257 | 2254 |
| 2258 HType computeType() => HType.BOOLEAN; | 2255 HType computeType() => HType.BOOLEAN; |
| 2259 bool hasExpectedType() => true; | 2256 bool hasExpectedType() => true; |
| 2260 | 2257 |
| 2261 accept(HVisitor visitor) => visitor.visitIs(this); | 2258 accept(HVisitor visitor) => visitor.visitIs(this); |
| 2262 | 2259 |
| 2263 toString() => "$expression is $typeExpression"; | 2260 toString() => "$expression is $typeExpression"; |
| 2264 } | 2261 } |
| OLD | NEW |