| OLD | NEW |
| 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 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1379 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 void checkArray(HInstruction input, String cmp) { | 1382 void checkArray(HInstruction input, String cmp) { |
| 1383 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1383 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1384 use(input, JSPrecedence.MEMBER_PRECEDENCE); | 1384 use(input, JSPrecedence.MEMBER_PRECEDENCE); |
| 1385 buffer.add('.constructor $cmp Array'); | 1385 buffer.add('.constructor $cmp Array'); |
| 1386 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1386 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 void checkImmutableArray(HInstruction input) { |
| 1390 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1391 buffer.add('!!'); |
| 1392 use(input, JSPrecedence.MEMBER_PRECEDENCE); |
| 1393 buffer.add('.immutable\$list'); |
| 1394 endExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1395 } |
| 1396 |
| 1389 void checkNull(HInstruction input) { | 1397 void checkNull(HInstruction input) { |
| 1390 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1398 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1391 use(input, JSPrecedence.EQUALITY_PRECEDENCE); | 1399 use(input, JSPrecedence.EQUALITY_PRECEDENCE); |
| 1392 buffer.add(" === (void 0)"); | 1400 buffer.add(" === (void 0)"); |
| 1393 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1401 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1394 } | 1402 } |
| 1395 | 1403 |
| 1396 void checkFunction(HInstruction input, Element element) { | 1404 void checkFunction(HInstruction input, Element element) { |
| 1397 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); | 1405 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); |
| 1398 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1406 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 } else if (node.isBoolean()) { | 1572 } else if (node.isBoolean()) { |
| 1565 buffer.add('if ('); | 1573 buffer.add('if ('); |
| 1566 checkBool(input, '!=='); | 1574 checkBool(input, '!=='); |
| 1567 buffer.add(') '); | 1575 buffer.add(') '); |
| 1568 bailout(node, 'Not a boolean'); | 1576 bailout(node, 'Not a boolean'); |
| 1569 } else if (node.isString()) { | 1577 } else if (node.isString()) { |
| 1570 buffer.add('if ('); | 1578 buffer.add('if ('); |
| 1571 checkString(input, '!=='); | 1579 checkString(input, '!=='); |
| 1572 buffer.add(') '); | 1580 buffer.add(') '); |
| 1573 bailout(node, 'Not a string'); | 1581 bailout(node, 'Not a string'); |
| 1582 } else if (node.isMutableArray()) { |
| 1583 buffer.add('if ('); |
| 1584 checkObject(input, '!=='); |
| 1585 buffer.add('||'); |
| 1586 checkArray(input, '!=='); |
| 1587 buffer.add('||'); |
| 1588 checkImmutableArray(input); |
| 1589 buffer.add(') '); |
| 1590 bailout(node, 'Not a mutable array'); |
| 1574 } else if (node.isArray()) { | 1591 } else if (node.isArray()) { |
| 1575 buffer.add('if ('); | 1592 buffer.add('if ('); |
| 1576 checkObject(input, '!=='); | 1593 checkObject(input, '!=='); |
| 1577 buffer.add('||'); | 1594 buffer.add('||'); |
| 1578 checkArray(input, '!=='); | 1595 checkArray(input, '!=='); |
| 1579 buffer.add(') '); | 1596 buffer.add(') '); |
| 1580 bailout(node, 'Not an array'); | 1597 bailout(node, 'Not an array'); |
| 1581 } else if (node.isStringOrArray()) { | 1598 } else if (node.isStringOrArray()) { |
| 1582 buffer.add('if ('); | 1599 buffer.add('if ('); |
| 1583 checkString(input, '!=='); | 1600 checkString(input, '!=='); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 startBailoutSwitch(); | 1878 startBailoutSwitch(); |
| 1862 } | 1879 } |
| 1863 } | 1880 } |
| 1864 | 1881 |
| 1865 void endElse(HIf node) { | 1882 void endElse(HIf node) { |
| 1866 if (node.elseBlock.hasGuards()) { | 1883 if (node.elseBlock.hasGuards()) { |
| 1867 endBailoutSwitch(); | 1884 endBailoutSwitch(); |
| 1868 } | 1885 } |
| 1869 } | 1886 } |
| 1870 } | 1887 } |
| OLD | NEW |