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

Unified Diff: frog/leg/ssa/types.dart

Issue 9784002: Support non-speculative type propagation. (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
« no previous file with comments | « frog/leg/ssa/optimize.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/ssa/types.dart
===================================================================
--- frog/leg/ssa/types.dart (revision 5905)
+++ frog/leg/ssa/types.dart (working copy)
@@ -7,12 +7,36 @@
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)
floitsch 2012/03/27 22:38:33 I prefer not to type 'this.X' parameters, but your
ngeoffray 2012/03/28 07:23:22 I will keep it with the types since that's what wa
: 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;
+ HType newType = instruction.computeType();
+
+ if (speculative) {
+ HType desiredType = instruction.computeDesiredType();
+ HType combined = newType.combine(desiredType);
+ if (combined.isKnown()) newType = combined;
+ }
+
+ bool changed = (instruction.type != newType);
+ if (instruction.type.isUnknown()) {
+ instruction.type = newType;
+ return changed;
+ } else if (changed) {
+ instruction.type = instruction.type.combine(newType);
+ return changed;
+ }
+ return false;
+ }
+
void visitGraph(HGraph graph) {
visitDominatorTree(graph);
processWorklist();
@@ -21,18 +45,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 +68,7 @@
HInstruction instruction = workmap[id];
assert(instruction !== null);
workmap.remove(id);
- if (instruction.updateType()) addUsersAndInputsToWorklist(instruction);
+ if (updateType(instruction)) addUsersAndInputsToWorklist(instruction);
}
}
« no previous file with comments | « frog/leg/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698