| Index: lib/compiler/implementation/ssa/types_propagation.dart
|
| diff --git a/lib/compiler/implementation/ssa/types.dart b/lib/compiler/implementation/ssa/types_propagation.dart
|
| similarity index 84%
|
| copy from lib/compiler/implementation/ssa/types.dart
|
| copy to lib/compiler/implementation/ssa/types_propagation.dart
|
| index 0f12bb9e8e1b3d6998147afeddea202411b5822c..a147f5e8e3ef26344bbd5fdb1a0e930e9a5c1ac5 100644
|
| --- a/lib/compiler/implementation/ssa/types.dart
|
| +++ b/lib/compiler/implementation/ssa/types_propagation.dart
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| @@ -39,11 +39,16 @@ class SsaTypePropagator extends HGraphVisitor implements OptimizationPhase {
|
| visitBasicBlock(HBasicBlock block) {
|
| if (block.isLoopHeader()) {
|
| block.forEachPhi((HPhi phi) {
|
| - // Set the initial type for the phi. In theory we would need to mark the
|
| - // type of all other incoming edges as "unitialized" and take this into
|
| - // account when doing the propagation inside the phis. Just setting
|
| - // the [propagatedType] is however easier.
|
| - phi.propagatedType = phi.inputs[0].propagatedType;
|
| + // Once the propagation has run once the propagated type can already
|
| + // be set. In this case we use that one for the first iteration of the
|
| + // loop.
|
| + if (phi.propagatedType.isUnknown()) {
|
| + // Set the initial type for the phi. In theory we would need to mark
|
| + // the type of all other incoming edges as "unitialized" and take this
|
| + // into account when doing the propagation inside the phis. Just
|
| + // setting the [propagatedType] is however easier.
|
| + phi.propagatedType = phi.inputs[0].propagatedType;
|
| + }
|
| addToWorkList(phi);
|
| });
|
| } else {
|
| @@ -110,8 +115,8 @@ class SsaSpeculativeTypePropagator extends SsaTypePropagator {
|
| HType computeDesiredType(HInstruction instruction) {
|
| HType desiredType = HType.UNKNOWN;
|
| for (final user in instruction.usedBy) {
|
| - desiredType =
|
| - desiredType.combine(user.computeDesiredTypeForInput(instruction));
|
| + HType userType = user.computeDesiredTypeForInput(instruction);
|
| + desiredType = desiredType.intersection(userType);
|
| // No need to continue if two users disagree on the type.
|
| if (desiredType.isConflicting()) break;
|
| }
|
| @@ -134,6 +139,6 @@ class SsaSpeculativeTypePropagator extends SsaTypePropagator {
|
| // TODO(ngeoffray): Allow speculative optimizations on
|
| // non-primitive types?
|
| if (desiredType.isNonPrimitive()) return newType;
|
| - return newType.combine(desiredType);
|
| + return newType.intersection(desiredType);
|
| }
|
| }
|
|
|