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

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
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/types/types.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..066594997e940c8a878cc735b731e46b779647d5 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -200,6 +200,41 @@ class SsaInstructionSimplifier extends HBaseVisitor
return node;
}
+ ConstantValue getConstantFromType(HInstruction node) {
+ if (node.isValue() && !node.canBeNull()) {
+ ValueTypeMask valueMask = node.instructionType;
+ if (valueMask.value.isBool) {
+ return valueMask.value;
+ }
+ // TODO(het): consider supporting other values (short strings?)
+ }
+ return null;
+ }
+
+ void propagateConstantValueToUses(HInstruction node) {
+ if (node.usedBy.isEmpty) return;
+ ConstantValue value = getConstantFromType(node);
+ if (value != null) {
+ HConstant constant = graph.addConstant(value, compiler);
+ for (HInstruction user in node.usedBy.toList()) {
+ user.changeUse(node, constant);
+ }
+ }
+ }
+
+ HInstruction visitParameterValue(HParameterValue node) {
+ // It is possible for the parameter value to be assigned to in the function
+ // body. If that happens then we should not forward the constant value to
+ // its uses since since the uses reachable from the assignment may have
+ // values in addition to the constant passed to the function.
+ if (node.usedBy.any((user) =>
+ user is HLocalSet && identical(user.local, node))) {
+ return node;
+ }
+ propagateConstantValueToUses(node);
+ return node;
+ }
+
HInstruction visitBoolify(HBoolify node) {
List<HInstruction> inputs = node.inputs;
assert(inputs.length == 1);
@@ -372,6 +407,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
HInstruction visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
+ propagateConstantValueToUses(node);
if (node.isInterceptedCall) {
HInstruction folded = handleInterceptedCall(node);
if (folded != node) return folded;
@@ -806,6 +842,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
+ propagateConstantValueToUses(node);
if (node.isInterceptedCall) {
HInstruction folded = handleInterceptedCall(node);
if (folded != node) return folded;
@@ -867,6 +904,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
HInstruction visitInvokeStatic(HInvokeStatic node) {
+ propagateConstantValueToUses(node);
if (node.element == backend.getCheckConcurrentModificationError()) {
if (node.inputs.length == 2) {
HInstruction firstArgument = node.inputs[0];
@@ -1306,13 +1344,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);
}
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/types/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698