| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| (...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 } else if (target == backend.jsArrayRemoveLast) { | 1521 } else if (target == backend.jsArrayRemoveLast) { |
| 1522 methodName = 'pop'; | 1522 methodName = 'pop'; |
| 1523 } else if (target == backend.jsStringSplit) { | 1523 } else if (target == backend.jsStringSplit) { |
| 1524 methodName = 'split'; | 1524 methodName = 'split'; |
| 1525 // Split returns a List, so we make sure the backend knows the | 1525 // Split returns a List, so we make sure the backend knows the |
| 1526 // list class is instantiated. | 1526 // list class is instantiated. |
| 1527 world.registerInstantiatedClass(compiler.listClass); | 1527 world.registerInstantiatedClass(compiler.listClass); |
| 1528 } else if (target == backend.jsStringConcat) { | 1528 } else if (target == backend.jsStringConcat) { |
| 1529 push(new js.Binary('+', object, arguments[0]), node); | 1529 push(new js.Binary('+', object, arguments[0]), node); |
| 1530 return; | 1530 return; |
| 1531 } else if (target.isNative() && !compiler.enableTypeAssertions) { | 1531 } else if (target.isNative() |
| 1532 && !compiler.enableTypeAssertions |
| 1533 && target.isFunction()) { |
| 1532 // Enable direct calls to a native method only if we don't | 1534 // Enable direct calls to a native method only if we don't |
| 1533 // run in checked mode, where the Dart version may have | 1535 // run in checked mode, where the Dart version may have |
| 1534 // type annotations on parameters and return type that it | 1536 // type annotations on parameters and return type that it |
| 1535 // should check. | 1537 // should check. |
| 1536 // Also check that the parameters are not functions: it's | 1538 // Also check that the parameters are not functions: it's |
| 1537 // the callee that will translate them to JS functions. | 1539 // the callee that will translate them to JS functions. |
| 1538 // TODO(ngeoffray): There are some cases where we could | 1540 // TODO(ngeoffray): There are some cases where we could |
| 1539 // still inline in checked mode if we know the arguments | 1541 // still inline in checked mode if we know the arguments |
| 1540 // have the right type. And we could do the closure | 1542 // have the right type. And we could do the closure |
| 1541 // conversion as well as the return type annotation check. | 1543 // conversion as well as the return type annotation check. |
| 1542 bool canInlineNativeCall = true; | 1544 bool canInlineNativeCall = true; |
| 1543 target.computeSignature(compiler).forEachParameter((Element element) { | 1545 FunctionElement function = target; |
| 1546 function.computeSignature(compiler).forEachParameter((Element element)
{ |
| 1544 DartType type = element.computeType(compiler).unalias(compiler); | 1547 DartType type = element.computeType(compiler).unalias(compiler); |
| 1545 if (type is FunctionType) { | 1548 if (type is FunctionType) { |
| 1546 canInlineNativeCall = false; | 1549 canInlineNativeCall = false; |
| 1547 } | 1550 } |
| 1548 }); | 1551 }); |
| 1549 if (canInlineNativeCall) { | 1552 if (canInlineNativeCall) { |
| 1550 methodName = target.fixedBackendName(); | 1553 methodName = target.fixedBackendName(); |
| 1551 } | 1554 } |
| 1552 } | 1555 } |
| 1553 } | 1556 } |
| (...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3010 if (leftType.canBeNull() && rightType.canBeNull()) { | 3013 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 3011 if (left.isConstantNull() || right.isConstantNull() || | 3014 if (left.isConstantNull() || right.isConstantNull() || |
| 3012 (leftType.isPrimitive() && leftType == rightType)) { | 3015 (leftType.isPrimitive() && leftType == rightType)) { |
| 3013 return '=='; | 3016 return '=='; |
| 3014 } | 3017 } |
| 3015 return null; | 3018 return null; |
| 3016 } else { | 3019 } else { |
| 3017 return '==='; | 3020 return '==='; |
| 3018 } | 3021 } |
| 3019 } | 3022 } |
| OLD | NEW |