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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_propagation.dart

Issue 1519773002: Don't constant fold large strings. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698