| 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 final SourceInformationFactory sourceInformationFactory; | 10 final SourceInformationFactory sourceInformationFactory; |
| (...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 use(node.receiver); | 1500 use(node.receiver); |
| 1501 List<js.Expression> arguments = <js.Expression>[pop()]; | 1501 List<js.Expression> arguments = <js.Expression>[pop()]; |
| 1502 push(js.propertyCall(isolate, name, arguments), node); | 1502 push(js.propertyCall(isolate, name, arguments), node); |
| 1503 registry.registerUseInterceptor(); | 1503 registry.registerUseInterceptor(); |
| 1504 } | 1504 } |
| 1505 } | 1505 } |
| 1506 | 1506 |
| 1507 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { | 1507 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { |
| 1508 use(node.receiver); | 1508 use(node.receiver); |
| 1509 js.Expression object = pop(); | 1509 js.Expression object = pop(); |
| 1510 String name = node.selector.name; | |
| 1511 String methodName; | 1510 String methodName; |
| 1512 List<js.Expression> arguments = visitArguments(node.inputs); | 1511 List<js.Expression> arguments = visitArguments(node.inputs); |
| 1513 Element target = node.element; | 1512 Element target = node.element; |
| 1514 | 1513 |
| 1515 if (target != null && !node.isInterceptedCall) { | 1514 if (target != null && !node.isInterceptedCall) { |
| 1516 if (target == backend.jsArrayAdd) { | 1515 if (target == backend.jsArrayAdd) { |
| 1517 methodName = 'push'; | 1516 methodName = 'push'; |
| 1518 } else if (target == backend.jsArrayRemoveLast) { | 1517 } else if (target == backend.jsArrayRemoveLast) { |
| 1519 methodName = 'pop'; | 1518 methodName = 'pop'; |
| 1520 } else if (target == backend.jsStringSplit) { | 1519 } else if (target == backend.jsStringSplit) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 ">=" : "<" | 1884 ">=" : "<" |
| 1886 }; | 1885 }; |
| 1887 return inverse ? inverseOperator[op] : op; | 1886 return inverse ? inverseOperator[op] : op; |
| 1888 } | 1887 } |
| 1889 | 1888 |
| 1890 void generateNot(HInstruction input) { | 1889 void generateNot(HInstruction input) { |
| 1891 bool canGenerateOptimizedComparison(HInstruction instruction) { | 1890 bool canGenerateOptimizedComparison(HInstruction instruction) { |
| 1892 if (instruction is !HRelational) return false; | 1891 if (instruction is !HRelational) return false; |
| 1893 | 1892 |
| 1894 HRelational relational = instruction; | 1893 HRelational relational = instruction; |
| 1895 BinaryOperation operation = relational.operation(backend.constantSystem); | |
| 1896 | 1894 |
| 1897 HInstruction left = relational.left; | 1895 HInstruction left = relational.left; |
| 1898 HInstruction right = relational.right; | 1896 HInstruction right = relational.right; |
| 1899 if (left.isStringOrNull(compiler) && right.isStringOrNull(compiler)) { | 1897 if (left.isStringOrNull(compiler) && right.isStringOrNull(compiler)) { |
| 1900 return true; | 1898 return true; |
| 1901 } | 1899 } |
| 1902 | 1900 |
| 1903 // This optimization doesn't work for NaN, so we only do it if the | 1901 // This optimization doesn't work for NaN, so we only do it if the |
| 1904 // type is known to be an integer. | 1902 // type is known to be an integer. |
| 1905 return left.isInteger(compiler) && right.isInteger(compiler); | 1903 return left.isInteger(compiler) && right.isInteger(compiler); |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 // be changed to match. | 2451 // be changed to match. |
| 2454 assert(relation == '===' || relation == '!=='); | 2452 assert(relation == '===' || relation == '!=='); |
| 2455 bool negative = relation == '!=='; | 2453 bool negative = relation == '!=='; |
| 2456 | 2454 |
| 2457 if (node.isVariableCheck || node.isCompoundCheck) { | 2455 if (node.isVariableCheck || node.isCompoundCheck) { |
| 2458 use(node.checkCall); | 2456 use(node.checkCall); |
| 2459 if (negative) push(new js.Prefix('!', pop())); | 2457 if (negative) push(new js.Prefix('!', pop())); |
| 2460 } else { | 2458 } else { |
| 2461 assert(node.isRawCheck); | 2459 assert(node.isRawCheck); |
| 2462 HInstruction interceptor = node.interceptor; | 2460 HInstruction interceptor = node.interceptor; |
| 2463 LibraryElement coreLibrary = compiler.coreLibrary; | |
| 2464 ClassElement objectClass = compiler.objectClass; | 2461 ClassElement objectClass = compiler.objectClass; |
| 2465 Element element = type.element; | 2462 Element element = type.element; |
| 2466 if (element == compiler.nullClass) { | 2463 if (element == compiler.nullClass) { |
| 2467 if (negative) { | 2464 if (negative) { |
| 2468 checkNonNull(input); | 2465 checkNonNull(input); |
| 2469 } else { | 2466 } else { |
| 2470 checkNull(input); | 2467 checkNull(input); |
| 2471 } | 2468 } |
| 2472 } else if (identical(element, objectClass) || type.treatAsDynamic) { | 2469 } else if (identical(element, objectClass) || type.treatAsDynamic) { |
| 2473 // The constant folder also does this optimization, but we make | 2470 // The constant folder also does this optimization, but we make |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 js.PropertyAccess accessHelper(String name) { | 2725 js.PropertyAccess accessHelper(String name) { |
| 2729 Element helper = backend.findHelper(name); | 2726 Element helper = backend.findHelper(name); |
| 2730 if (helper == null) { | 2727 if (helper == null) { |
| 2731 // For mocked-up tests. | 2728 // For mocked-up tests. |
| 2732 return js.js('(void 0).$name'); | 2729 return js.js('(void 0).$name'); |
| 2733 } | 2730 } |
| 2734 registry.registerStaticUse(helper); | 2731 registry.registerStaticUse(helper); |
| 2735 return backend.emitter.staticFunctionAccess(helper); | 2732 return backend.emitter.staticFunctionAccess(helper); |
| 2736 } | 2733 } |
| 2737 } | 2734 } |
| OLD | NEW |