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

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: Addressed comment. Created 8 years, 8 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 | « no previous file | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index ca7c21e368a18446428099cee77066d16fd7f76d..0b25012c91302fb190fee28216abd5c9598ac05c 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -1373,6 +1373,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);
@@ -1558,6 +1566,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698