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

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

Issue 9956152: Reapply "Refactor type propagation." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Apply fix. 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/nodes.dart ('k') | lib/compiler/implementation/ssa/tracer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/optimize.dart
diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
index 544f529b302ec5b4850773d661f236a2b6acfa4e..0b58830472c3856281ab91e0b21685c7f553b0fe 100644
--- a/lib/compiler/implementation/ssa/optimize.dart
+++ b/lib/compiler/implementation/ssa/optimize.dart
@@ -54,8 +54,8 @@ class SsaOptimizerTask extends CompilerTask {
// propagate types from the instruction to the type guard. We do it
// now to be able to optimize further.
work.guards.forEach((HTypeGuard guard) {
- guard.type = guard.guarded.type;
- guard.guarded.type = HType.UNKNOWN;
+ guard.propagatedType = guard.guarded.propagatedType;
+ guard.guarded.propagatedType = HType.UNKNOWN;
});
// We also need to insert range and integer checks for the type guards,
// now that they know their type. We did not need to do that
@@ -99,8 +99,8 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
block.remove(instruction);
// If the replacement instruction does not know its type yet,
// use the type of the instruction.
- if (!replacement.type.isKnown()) {
- replacement.type = instruction.type;
+ if (!replacement.propagatedType.isUseful()) {
+ replacement.propagatedType = instruction.propagatedType;
}
}
instruction = next;
@@ -117,7 +117,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
HInstruction input = inputs[0];
if (input.isBoolean()) return input;
// All values !== true are boolified to false.
- if (input.type.isKnown()) {
+ if (input.propagatedType.isUseful()) {
return graph.addConstantBool(false);
}
return node;
@@ -186,7 +186,8 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
HInstruction visitTypeGuard(HTypeGuard node) {
HInstruction value = node.guarded;
- return (value.type.combine(node.type) == value.type) ? value : node;
+ HType combinedType = value.propagatedType.combine(node.propagatedType);
+ return (combinedType == value.propagatedType) ? value : node;
}
HInstruction visitIntegerCheck(HIntegerCheck node) {
@@ -201,7 +202,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
compiler.unimplemented("visitIs for type variables");
}
- HType expressionType = node.expression.type;
+ HType expressionType = node.expression.propagatedType;
if (element === compiler.objectClass
|| element === compiler.dynamicClass) {
return graph.addConstantBool(true);
@@ -284,7 +285,7 @@ class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
const SourceString("length"),
true,
<HInstruction>[interceptor, receiver]);
- length.type = HType.NUMBER;
+ length.propagatedType = HType.INTEGER;
node.block.addBefore(node, length);
HBoundsCheck check = new HBoundsCheck(length, index);
@@ -299,9 +300,12 @@ class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
}
void visitIndex(HIndex node) {
- if (!node.builtin) return;
- if (node.index is HBoundsCheck) return;
- HInstruction index = insertIntegerCheck(node, node.index);
+ if (!node.receiver.isStringOrArray()) return;
+ HInstruction index = node.index;
+ if (index is HBoundsCheck) return;
+ if (!node.index.isInteger()) {
+ index = insertIntegerCheck(node, index);
+ }
index = insertBoundsCheck(node, node.receiver, index);
HIndex newInstruction = new HIndex(node.target, node.receiver, index);
node.block.addBefore(node, newInstruction);
@@ -310,9 +314,12 @@ class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
}
void visitIndexAssign(HIndexAssign node) {
- if (!node.builtin) return;
- if (node.index is HBoundsCheck) return;
- HInstruction index = insertIntegerCheck(node, node.index);
+ if (!node.receiver.isMutableArray()) return;
+ HInstruction index = node.index;
+ if (index is HBoundsCheck) return;
+ if (!node.index.isInteger()) {
+ index = insertIntegerCheck(node, index);
+ }
index = insertBoundsCheck(node, node.receiver, index);
HIndexAssign newInstruction =
new HIndexAssign(node.target, node.receiver, index, node.value);
« no previous file with comments | « lib/compiler/implementation/ssa/nodes.dart ('k') | lib/compiler/implementation/ssa/tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698