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

Unified Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 1376603003: dart2js: improve ssa utilization of bool value types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 07611f654a3292066d02ec241076f47e28dc7c3b..d4a55a4ee065f519ffdaa03c296d2ef8f77c112f 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -200,6 +200,24 @@ class SsaInstructionSimplifier extends HBaseVisitor
return node;
}
+ void replaceUsesWithConstant(HInstruction known) {
+ if (known.isValue() && !known.canBeNull()) {
+ ValueTypeMask valueMask = known.instructionType;
+ if (valueMask.value.isBool) {
+ bool knownValue = valueMask.value.isTrue;
+ var users = new List.from(known.usedBy);
+ users.forEach((HInstruction user) {
sra1 2015/09/30 16:49:39 maybe just write: for (HInstruction user in known
Harry Terkelsen 2015/09/30 18:39:26 Done.
+ user.changeUse(known, graph.addConstantBool(knownValue, compiler));
sra1 2015/09/30 16:49:39 Factor this into (1) finding the HConstant (if any
Harry Terkelsen 2015/09/30 18:39:26 Done.
+ });
+ }
+ }
+ }
+
+ HInstruction visitParameterValue(HParameterValue node) {
+ replaceUsesWithConstant(node);
sra1 2015/09/30 16:49:40 Reading this I ask 'why'? Maybe call it propagateC
Harry Terkelsen 2015/09/30 18:39:26 Done.
+ return node;
+ }
+
HInstruction visitBoolify(HBoolify node) {
List<HInstruction> inputs = node.inputs;
assert(inputs.length == 1);
@@ -402,6 +420,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
}
}
+ replaceUsesWithConstant(node);
sra1 2015/09/30 16:49:40 Any reason not to do this first? It might require
Harry Terkelsen 2015/09/30 18:39:26 Done.
return node;
}
@@ -811,6 +830,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
if (folded != node) return folded;
}
HInstruction receiver = node.getDartReceiver(compiler);
+ replaceUsesWithConstant(node);
sra1 2015/09/30 16:49:39 Any reason not to do this first? We might know we
Harry Terkelsen 2015/09/30 18:39:26 Done.
Element field = findConcreteFieldForDynamicAccess(
receiver, node.selector);
if (field == null) return node;
@@ -867,6 +887,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
HInstruction visitInvokeStatic(HInvokeStatic node) {
+ replaceUsesWithConstant(node);
if (node.element == backend.getCheckConcurrentModificationError()) {
if (node.inputs.length == 2) {
HInstruction firstArgument = node.inputs[0];
@@ -1306,13 +1327,6 @@ class SsaLiveBlockAnalyzer extends HBaseVisitor {
} else {
markBlockLive(instruction.elseBlock);
}
- } else if (condition.isValue()) {
- ValueTypeMask valueType = condition.instructionType;
- if (valueType.value == true) {
- markBlockLive(instruction.thenBlock);
- } else {
- markBlockLive(instruction.elseBlock);
- }
} else {
visitControlFlow(instruction);
}

Powered by Google App Engine
This is Rietveld 408576698