Chromium Code Reviews| Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart |
| diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart |
| index f716f05e023f7479bd72b9f731accc4b9f2a9dcb..c787e92b3bcad362977fb54143181adbd06cbc49 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart |
| @@ -2541,7 +2541,20 @@ class TypePropagationVisitor implements Visitor { |
| {bool canReplace: false}) { |
| // TODO(asgerf): Separate constant folding from side effect analysis. |
| setValue(prim, updateValue); |
| - prim.isSafeForElimination = canReplace && updateValue.isConstant; |
| + prim.isSafeForElimination = canReplace && |
| + updateValue.isConstant && |
| + constantIsSafeToCopy(updateValue.constant); |
| + } |
| + |
| + bool constantIsSafeToCopy(ConstantValue constant) { |
| + // TODO(25230, 25231): Refer to large shared strings by name. |
| + // This number is chosen to prevent huge strings being copied. Don't make |
| + // this too small, otherwise it will suppress otherwise harmless constant |
| + // folding. |
| + const int MAXIMUM_LENGTH_OF_DUPLICATED_STRING = 500; |
|
asgerf
2015/12/11 12:27:12
I think the better place to do this is in visitLet
sra1
2015/12/11 19:13:26
Done.
|
| + return constant is StringConstantValue |
| + ? constant.length < MAXIMUM_LENGTH_OF_DUPLICATED_STRING |
| + : true; |
| } |
| bool isInterceptedSelector(Selector selector) { |