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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart

Issue 701793002: Fix a bug in the handling of Phi nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comments Created 6 years, 1 month 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
Index: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart b/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart
index 53107a11ecf2d690a512a5f6cafdef6e14861e7d..ae3427a55e791a355daa0ad0478488cb874ccdeb 100644
--- a/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart
@@ -26,7 +26,8 @@ import '../elements/elements.dart';
import '../native/native.dart' as native;
import '../tree/tree.dart' as ast
show DartString,
- Node;
+ Node,
+ TryStatement;
import '../types/types.dart'
show ContainerTypeMask,
DictionaryTypeMask,
@@ -439,6 +440,17 @@ class TypeInformationSystem extends TypeSystem<TypeInformation> {
return result;
}
+ PhiElementTypeInformation _addPhi(ast.Node node,
+ Local variable,
+ inputType,
+ bool isLoop) {
+ PhiElementTypeInformation result =
+ new PhiElementTypeInformation(currentMember, node, isLoop, variable);
+ allocatedTypes.add(result);
+ result.addAssignment(inputType);
+ return result;
+ }
+
PhiElementTypeInformation allocatePhi(ast.Node node,
Local variable,
inputType) {
@@ -446,19 +458,23 @@ class TypeInformationSystem extends TypeSystem<TypeInformation> {
// the try/catch block [node]. If it is, no need to allocate a new
// phi.
if (inputType is PhiElementTypeInformation &&
- inputType.branchNode == node) {
+ inputType.branchNode == node &&
+ inputType.branchNode is ast.TryStatement) {
return inputType;
}
- PhiElementTypeInformation result =
- new PhiElementTypeInformation(currentMember, node, true, variable);
- allocatedTypes.add(result);
- result.addAssignment(inputType);
- return result;
+ return _addPhi(node, variable, inputType, false);
+ }
+
+ PhiElementTypeInformation allocateLoopPhi(ast.Node node,
+ Local variable,
+ inputType) {
+ return _addPhi(node, variable, inputType, true);
}
TypeInformation simplifyPhi(ast.Node node,
Local variable,
PhiElementTypeInformation phiType) {
+ assert(phiType.branchNode == node);
if (phiType.assignments.length == 1) return phiType.assignments.first;
return phiType;
}

Powered by Google App Engine
This is Rietveld 408576698