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

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

Issue 10544026: Simplify generated code for string interpolation by delaying the constant folding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. Created 8 years, 6 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/optimize.dart
diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
index d29e599fd5bb3738e8498a0bd61ffd9c05405196..877fc2994ad9675b8feffa7855eaba87e52bbb26 100644
--- a/lib/compiler/implementation/ssa/optimize.dart
+++ b/lib/compiler/implementation/ssa/optimize.dart
@@ -590,6 +590,19 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
if (field === null) return node;
return new HFieldSet(field, node.inputs[0], node.inputs[1]);
}
+
+ HInstruction visitStringConcat(HStringConcat node) {
+ DartString folded = const LiteralDartString("");
+ for (int i = 0; i < node.inputs.length; i++) {
+ HInstruction part = node.inputs[i];
+ if (!part.isConstant()) return node;
+ HConstant constant = part;
+ if (!constant.constant.isPrimitive()) return node;
+ PrimitiveConstant primitive = constant.constant;
+ folded = new DartString.concat(folded, primitive.toDartString());
+ }
+ return graph.addConstantString(folded, node);
+ }
}
class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {

Powered by Google App Engine
This is Rietveld 408576698