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

Unified Diff: lib/compiler/implementation/ssa/types_propagation.dart

Issue 10139012: Refactor types in ssa nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/ssa/types.dart ('k') | tests/language/language-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « lib/compiler/implementation/ssa/types.dart ('k') | tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698