| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // Run the simplifier to remove unneeded type checks inserted by | 92 // Run the simplifier to remove unneeded type checks inserted by |
| 93 // type propagation. | 93 // type propagation. |
| 94 new SsaInstructionSimplifier(constantSystem, backend, this, work), | 94 new SsaInstructionSimplifier(constantSystem, backend, this, work), |
| 95 ]; | 95 ]; |
| 96 } | 96 } |
| 97 phases.forEach(runPhase); | 97 phases.forEach(runPhase); |
| 98 }); | 98 }); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 /// Returns `true` if [mask] represents only types that have a length that |
| 103 /// cannot change. The current implementation is conservative for the purpose |
| 104 /// of identifying gvn-able lengths and mis-identifies some unions of fixed |
| 105 /// length indexables (see TODO) as not fixed length. |
| 102 bool isFixedLength(mask, Compiler compiler) { | 106 bool isFixedLength(mask, Compiler compiler) { |
| 103 ClassWorld classWorld = compiler.world; | 107 ClassWorld classWorld = compiler.world; |
| 104 JavaScriptBackend backend = compiler.backend; | 108 JavaScriptBackend backend = compiler.backend; |
| 105 if (mask.isContainer && mask.length != null) { | 109 if (mask.isContainer && mask.length != null) { |
| 106 // A container on which we have inferred the length. | 110 // A container on which we have inferred the length. |
| 107 return true; | 111 return true; |
| 108 } else if (mask.containsOnly(backend.jsFixedArrayClass) | 112 } |
| 109 || mask.containsOnlyString(classWorld) | 113 // TODO(sra): Recognize any combination of fixed length indexables. |
| 110 || backend.isTypedArray(mask)) { | 114 if (mask.containsOnly(backend.jsFixedArrayClass) || |
| 115 mask.containsOnly(backend.jsUnmodifiableArrayClass) || |
| 116 mask.containsOnlyString(classWorld) || |
| 117 backend.isTypedArray(mask)) { |
| 111 return true; | 118 return true; |
| 112 } | 119 } |
| 113 return false; | 120 return false; |
| 114 } | 121 } |
| 115 | 122 |
| 116 /** | 123 /** |
| 117 * If both inputs to known operations are available execute the operation at | 124 * If both inputs to known operations are available execute the operation at |
| 118 * compile-time. | 125 * compile-time. |
| 119 */ | 126 */ |
| 120 class SsaInstructionSimplifier extends HBaseVisitor | 127 class SsaInstructionSimplifier extends HBaseVisitor |
| (...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 | 2286 |
| 2280 keyedValues.forEach((receiver, values) { | 2287 keyedValues.forEach((receiver, values) { |
| 2281 result.keyedValues[receiver] = | 2288 result.keyedValues[receiver] = |
| 2282 new Map<HInstruction, HInstruction>.from(values); | 2289 new Map<HInstruction, HInstruction>.from(values); |
| 2283 }); | 2290 }); |
| 2284 | 2291 |
| 2285 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2292 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 2286 return result; | 2293 return result; |
| 2287 } | 2294 } |
| 2288 } | 2295 } |
| OLD | NEW |