Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: frog/leg/ssa/nodes.dart

Issue 9500010: Fix break implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/optimize.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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].
1888 HPhi.singleInput(this.element, HInstruction input) 1884 HPhi(this.element, List<HInstruction> inputs) : super(inputs);
1889 : super(<HInstruction>[input]); 1885 HPhi.noInputs(Element element) : this(element, <HInstruction>[]);
1890 HPhi.manyInputs(this.element, List<HInstruction> inputs) 1886 HPhi.singleInput(Element element, HInstruction input)
1891 : super(inputs); 1887 : this(element, <HInstruction>[input]);
1888 HPhi.manyInputs(Element element, List<HInstruction> inputs)
1889 : this(element, inputs);
1892 1890
1893 void addInput(HInstruction input) { 1891 void addInput(HInstruction input) {
1894 assert(isInBasicBlock()); 1892 assert(isInBasicBlock());
1895 inputs.add(input); 1893 inputs.add(input);
1896 input.usedBy.add(this); 1894 input.usedBy.add(this);
1897 } 1895 }
1898 1896
1899 // Compute the (shared) type of the inputs if any. If all inputs 1897 // Compute the (shared) type of the inputs if any. If all inputs
1900 // have the same known type return it. If any two inputs have 1898 // have the same known type return it. If any two inputs have
1901 // different known types, we'll return a conflict -- otherwise we'll 1899 // different known types, we'll return a conflict -- otherwise we'll
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 2253
2256 HInstruction get expression() => inputs[0]; 2254 HInstruction get expression() => inputs[0];
2257 2255
2258 HType computeType() => HType.BOOLEAN; 2256 HType computeType() => HType.BOOLEAN;
2259 bool hasExpectedType() => true; 2257 bool hasExpectedType() => true;
2260 2258
2261 accept(HVisitor visitor) => visitor.visitIs(this); 2259 accept(HVisitor visitor) => visitor.visitIs(this);
2262 2260
2263 toString() => "$expression is $typeExpression"; 2261 toString() => "$expression is $typeExpression";
2264 } 2262 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698