| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 HBasicBlock entry; | 115 HBasicBlock entry; |
| 116 HBasicBlock exit; | 116 HBasicBlock exit; |
| 117 final List<HBasicBlock> blocks; | 117 final List<HBasicBlock> blocks; |
| 118 | 118 |
| 119 // We canonicalize all literals used within a graph so we do not | 119 // We canonicalize all literals used within a graph so we do not |
| 120 // have to worry about them for global value numbering. | 120 // have to worry about them for global value numbering. |
| 121 HLiteral nullLiteral; | 121 HLiteral nullLiteral; |
| 122 HLiteral trueLiteral; | 122 HLiteral trueLiteral; |
| 123 HLiteral falseLiteral; | 123 HLiteral falseLiteral; |
| 124 HLiteral nanLiteral; | 124 HLiteral nanLiteral; |
| 125 HLiteral negativeZeroLiteral; |
| 125 Map<int, HLiteral> intLiterals; | 126 Map<int, HLiteral> intLiterals; |
| 126 Map<double, HLiteral> doubleLiterals; | 127 Map<double, HLiteral> doubleLiterals; |
| 127 Map<num, HLiteral> numLiterals; | 128 Map<num, HLiteral> numLiterals; |
| 128 Map<String, HLiteral> stringLiterals; | 129 Map<String, HLiteral> stringLiterals; |
| 129 | 130 |
| 130 HGraph() : blocks = new List<HBasicBlock>() { | 131 HGraph() : blocks = new List<HBasicBlock>() { |
| 131 entry = addNewBlock(); | 132 entry = addNewBlock(); |
| 132 // The exit block will be added later, so it has an id that is | 133 // The exit block will be added later, so it has an id that is |
| 133 // after all others in the system. | 134 // after all others in the system. |
| 134 exit = new HBasicBlock(); | 135 exit = new HBasicBlock(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 165 } | 166 } |
| 166 | 167 |
| 167 HLiteral addNewLiteralNaN() { | 168 HLiteral addNewLiteralNaN() { |
| 168 if (nanLiteral === null) { | 169 if (nanLiteral === null) { |
| 169 nanLiteral = new HLiteral.internal(double.NAN, HType.DOUBLE); | 170 nanLiteral = new HLiteral.internal(double.NAN, HType.DOUBLE); |
| 170 entry.addAtExit(nanLiteral); | 171 entry.addAtExit(nanLiteral); |
| 171 } | 172 } |
| 172 return nanLiteral; | 173 return nanLiteral; |
| 173 } | 174 } |
| 174 | 175 |
| 176 HLiteral addNewNegativeZeroLiteral() { |
| 177 if (negativeZeroLiteral === null) { |
| 178 negativeZeroLiteral = new HLiteral.internal(-0.0, HType.DOUBLE); |
| 179 entry.addAtExit(negativeZeroLiteral); |
| 180 } |
| 181 return negativeZeroLiteral; |
| 182 } |
| 183 |
| 175 HLiteral addNewLiteralDouble(double value) { | 184 HLiteral addNewLiteralDouble(double value) { |
| 176 if (value.isNaN()) return addNewLiteralNaN(); // Avoid hashing NaN. | 185 if (value.isNaN()) return addNewLiteralNaN(); // Avoid hashing NaN. |
| 186 if (value == 0 && value.isNegative()) { |
| 187 // Avoid hashing -0.0 as it compares equal to 0.0. |
| 188 return addNewNegativeZeroLiteral(); |
| 189 } |
| 177 if (doubleLiterals === null) doubleLiterals = new Map<double, HLiteral>(); | 190 if (doubleLiterals === null) doubleLiterals = new Map<double, HLiteral>(); |
| 178 HLiteral result = doubleLiterals[value]; | 191 HLiteral result = doubleLiterals[value]; |
| 179 if (result === null) { | 192 if (result === null) { |
| 180 result = new HLiteral.internal(value, HType.DOUBLE); | 193 result = new HLiteral.internal(value, HType.DOUBLE); |
| 181 entry.addAtExit(result); | 194 entry.addAtExit(result); |
| 182 doubleLiterals[value] = result; | 195 doubleLiterals[value] = result; |
| 183 } | 196 } |
| 184 return result; | 197 return result; |
| 185 } | 198 } |
| 186 | 199 |
| (...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 | 2266 |
| 2254 HInstruction get expression() => inputs[0]; | 2267 HInstruction get expression() => inputs[0]; |
| 2255 | 2268 |
| 2256 HType computeType() => HType.BOOLEAN; | 2269 HType computeType() => HType.BOOLEAN; |
| 2257 bool hasExpectedType() => true; | 2270 bool hasExpectedType() => true; |
| 2258 | 2271 |
| 2259 accept(HVisitor visitor) => visitor.visitIs(this); | 2272 accept(HVisitor visitor) => visitor.visitIs(this); |
| 2260 | 2273 |
| 2261 toString() => "$expression is $typeExpression"; | 2274 toString() => "$expression is $typeExpression"; |
| 2262 } | 2275 } |
| OLD | NEW |