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

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

Issue 9874014: New CL for https://chromiumcodereview.appspot.com/9784002/: Support non-speculative type propagatio… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
Index: lib/compiler/implementation/ssa/types.dart
===================================================================
--- lib/compiler/implementation/ssa/types.dart (revision 5967)
+++ lib/compiler/implementation/ssa/types.dart (working copy)
@@ -7,12 +7,35 @@
final Map<int, HInstruction> workmap;
final List<int> worklist;
final Compiler compiler;
+ final bool speculative;
final String name = 'type propagator';
- SsaTypePropagator(Compiler this.compiler)
+ SsaTypePropagator(Compiler this.compiler, bool this.speculative)
Lasse Reichstein Nielsen 2012/03/29 11:46:55 As mentioned: make this argument optional so you c
: workmap = new Map<int, HInstruction>(),
worklist = new List<int>();
+ // Re-compute and update the type of the instruction. Returns
+ // whether or not the type was changed.
+ bool updateType(HInstruction instruction) {
+ if (instruction.type.isConflicting()) return false;
+
+ // Constants have the type they have. It can't be changed.
+ if (instruction.isConstant()) return false;
+ HType oldType = instruction.type;
+ HType newType = instruction.computeType();
+
+ if (speculative) {
Lasse Reichstein Nielsen 2012/03/29 11:46:55 Is this the only place speculative is used? If so
ngeoffray 2012/03/29 12:51:02 Done.
+ HType desiredType = instruction.computeDesiredType();
+ HType combined = newType.combine(desiredType);
+ // If the propagated type [newType] does not conflict with the
+ // speculated type [desiredType], use it.
+ if (combined.isKnown()) newType = combined;
+ }
+
+ instruction.type = oldType.combine(newType);
+ return oldType !== instruction.type;
+ }
+
void visitGraph(HGraph graph) {
visitDominatorTree(graph);
processWorklist();
@@ -21,18 +44,19 @@
visitBasicBlock(HBasicBlock block) {
if (block.isLoopHeader()) {
block.forEachPhi((HPhi phi) {
- phi.setInitialTypeForLoopPhi();
+ // Set the initial type for the phi.
+ phi.type = phi.inputs[0].type;
addToWorkList(phi);
});
} else {
block.forEachPhi((HPhi phi) {
- if (phi.updateType()) addUsersAndInputsToWorklist(phi);
+ if (updateType(phi)) addUsersAndInputsToWorklist(phi);
});
}
HInstruction instruction = block.first;
while (instruction !== null) {
- if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
+ if (updateType(instruction)) addUsersAndInputsToWorklist(instruction);
instruction = instruction.next;
}
}
@@ -43,7 +67,7 @@
HInstruction instruction = workmap[id];
assert(instruction !== null);
workmap.remove(id);
- if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
+ if (updateType(instruction)) addUsersAndInputsToWorklist(instruction);
}
}

Powered by Google App Engine
This is Rietveld 408576698