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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 9
10 String generateMethod(WorkItem work, HGraph graph) { 10 String generateMethod(WorkItem work, HGraph graph) {
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1366 endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
1367 } 1367 }
1368 1368
1369 void checkArray(HInstruction input, String cmp) { 1369 void checkArray(HInstruction input, String cmp) {
1370 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1370 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
1371 use(input, JSPrecedence.MEMBER_PRECEDENCE); 1371 use(input, JSPrecedence.MEMBER_PRECEDENCE);
1372 buffer.add('.constructor $cmp Array'); 1372 buffer.add('.constructor $cmp Array');
1373 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1373 endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
1374 } 1374 }
1375 1375
1376 void checkImmutableArray(HInstruction input) {
1377 beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
1378 buffer.add('!!');
1379 use(input, JSPrecedence.MEMBER_PRECEDENCE);
1380 buffer.add('.immutable\$list');
1381 endExpression(JSPrecedence.PREFIX_PRECEDENCE);
1382 }
1383
1376 void checkNull(HInstruction input) { 1384 void checkNull(HInstruction input) {
1377 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1385 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
1378 use(input, JSPrecedence.EQUALITY_PRECEDENCE); 1386 use(input, JSPrecedence.EQUALITY_PRECEDENCE);
1379 buffer.add(" === (void 0)"); 1387 buffer.add(" === (void 0)");
1380 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1388 endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
1381 } 1389 }
1382 1390
1383 void checkFunction(HInstruction input, Element element) { 1391 void checkFunction(HInstruction input, Element element) {
1384 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); 1392 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE);
1385 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1393 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 } else if (node.isBoolean()) { 1559 } else if (node.isBoolean()) {
1552 buffer.add('if ('); 1560 buffer.add('if (');
1553 checkBool(input, '!=='); 1561 checkBool(input, '!==');
1554 buffer.add(') '); 1562 buffer.add(') ');
1555 bailout(node, 'Not a boolean'); 1563 bailout(node, 'Not a boolean');
1556 } else if (node.isString()) { 1564 } else if (node.isString()) {
1557 buffer.add('if ('); 1565 buffer.add('if (');
1558 checkString(input, '!=='); 1566 checkString(input, '!==');
1559 buffer.add(') '); 1567 buffer.add(') ');
1560 bailout(node, 'Not a string'); 1568 bailout(node, 'Not a string');
1569 } else if (node.isMutableArray()) {
1570 buffer.add('if (');
1571 checkObject(input, '!==');
1572 buffer.add('||');
1573 checkArray(input, '!==');
1574 buffer.add('||');
1575 checkImmutableArray(input);
1576 buffer.add(') ');
1577 bailout(node, 'Not a mutable array');
1561 } else if (node.isArray()) { 1578 } else if (node.isArray()) {
1562 buffer.add('if ('); 1579 buffer.add('if (');
1563 checkObject(input, '!=='); 1580 checkObject(input, '!==');
1564 buffer.add('||'); 1581 buffer.add('||');
1565 checkArray(input, '!=='); 1582 checkArray(input, '!==');
1566 buffer.add(') '); 1583 buffer.add(') ');
1567 bailout(node, 'Not an array'); 1584 bailout(node, 'Not an array');
1568 } else if (node.isStringOrArray()) { 1585 } else if (node.isStringOrArray()) {
1569 buffer.add('if ('); 1586 buffer.add('if (');
1570 checkString(input, '!=='); 1587 checkString(input, '!==');
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 startBailoutSwitch(); 1865 startBailoutSwitch();
1849 } 1866 }
1850 } 1867 }
1851 1868
1852 void endElse(HIf node) { 1869 void endElse(HIf node) {
1853 if (node.elseBlock.hasGuards()) { 1870 if (node.elseBlock.hasGuards()) {
1854 endBailoutSwitch(); 1871 endBailoutSwitch();
1855 } 1872 }
1856 } 1873 }
1857 } 1874 }
OLDNEW
« 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