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

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

Issue 16737003: Break a cycle in the speculative type propagator by checking if a desired type goes to unknown. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « no previous file | tests/language/type_propagation2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart (revision 23800)
+++ sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart (working copy)
@@ -327,6 +327,10 @@
}
return desiredType;
}
+
+ bool hasBeenSpeculativelyOptimized(HInstruction instruction) {
+ return savedTypes.containsKey(instruction);
+ }
HType computeType(HInstruction instruction) {
// Once we are in a conflicting state don't update the type anymore.
@@ -334,7 +338,7 @@
if (oldType.isConflicting()) return oldType;
HType newType = super.computeType(instruction);
- if (oldType != newType && !savedTypes.containsKey(instruction)) {
+ if (oldType != newType && !hasBeenSpeculativelyOptimized(instruction)) {
savedTypes[instruction] = oldType;
}
// [computeDesiredType] goes to all usedBys and lets them compute their
@@ -344,11 +348,16 @@
HType desiredType = computeDesiredType(instruction);
// If the desired type is conflicting just return the computed type.
if (desiredType.isConflicting()) return newType;
+ if (desiredType.isUnknown() && hasBeenSpeculativelyOptimized(instruction)) {
+ // If we ever change our decision for a desired type to unknown,
+ // we stop the computation on this instruction.
+ return HType.CONFLICTING;
+ }
// TODO(ngeoffray): Allow speculative optimizations on
// non-primitive types?
if (!desiredType.isPrimitive()) return newType;
desiredType = newType.intersection(desiredType, compiler);
- if (desiredType != newType && !savedTypes.containsKey(instruction)) {
+ if (desiredType != newType && !hasBeenSpeculativelyOptimized(instruction)) {
savedTypes[instruction] = oldType;
}
return desiredType;
« no previous file with comments | « no previous file | tests/language/type_propagation2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698