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

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

Issue 9965047: Make constant lists immutable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index 8784c2b9ffda835e34308f2dc83adf128a451fe9..b71c0cced783bcd4be268484cce8999409fa933a 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -1386,6 +1386,14 @@ class SsaCodeGenerator implements HVisitor {
endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
}
+ void checkImmutableArray(HInstruction input) {
+ beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
+ buffer.add('!!');
+ use(input, JSPrecedence.MEMBER_PRECEDENCE);
+ buffer.add('.immutable\$list');
+ endExpression(JSPrecedence.PREFIX_PRECEDENCE);
+ }
+
void checkNull(HInstruction input) {
beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
use(input, JSPrecedence.EQUALITY_PRECEDENCE);
@@ -1571,6 +1579,15 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
checkString(input, '!==');
buffer.add(') ');
bailout(node, 'Not a string');
+ } else if (node.isMutableArray()) {
+ buffer.add('if (');
+ checkObject(input, '!==');
+ buffer.add('||');
+ checkArray(input, '!==');
+ buffer.add('||');
+ checkImmutableArray(input);
+ buffer.add(') ');
+ bailout(node, 'Not a mutable array');
} else if (node.isArray()) {
buffer.add('if (');
checkObject(input, '!==');
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/nodes.dart » ('j') | lib/compiler/implementation/ssa/nodes.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698