Chromium Code Reviews| 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 final JavaScriptBackend backend; | 6 final JavaScriptBackend backend; |
| 7 SsaCodeGeneratorTask(JavaScriptBackend backend) | 7 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 8 : this.backend = backend, | 8 : this.backend = backend, |
| 9 super(backend.compiler); | 9 super(backend.compiler); |
| 10 String get name() => 'SSA code generator'; | 10 String get name() => 'SSA code generator'; |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1403 } else { | 1403 } else { |
| 1404 methodName = compiler.namer.instanceMethodInvocationName( | 1404 methodName = compiler.namer.instanceMethodInvocationName( |
| 1405 currentLibrary, node.name, node.selector); | 1405 currentLibrary, node.name, node.selector); |
| 1406 arguments = visitArguments(node.inputs); | 1406 arguments = visitArguments(node.inputs); |
| 1407 bool inLoop = node.block.enclosingLoopHeader !== null; | 1407 bool inLoop = node.block.enclosingLoopHeader !== null; |
| 1408 | 1408 |
| 1409 // Register this invocation to collect the types used at all call sites. | 1409 // Register this invocation to collect the types used at all call sites. |
| 1410 Selector selector = getOptimizedSelectorFor(node, node.selector); | 1410 Selector selector = getOptimizedSelectorFor(node, node.selector); |
| 1411 backend.registerDynamicInvocation(node, selector); | 1411 backend.registerDynamicInvocation(node, selector); |
| 1412 | 1412 |
| 1413 if (node.element !== null) { | 1413 // If we don't know what we're calling or if we are calling a getter, |
| 1414 // we need to register that fact that we may be calling a closure | |
| 1415 // with the same arguments. | |
| 1416 Element target = node.element; | |
| 1417 if (target === null || target.isGetter()) { | |
| 1418 // TODO(kasperl): If we have a typed selector for the call, we | |
| 1419 // may know something about the types of closures that need | |
| 1420 // the specific closure call method. | |
| 1421 Selector call = new Selector.callClosureFrom(selector); | |
| 1422 world.registerDynamicInvocation(call.name, call); | |
| 1423 } | |
| 1424 | |
| 1425 if (target !== null) { | |
| 1414 // If we know we're calling a specific method, register that | 1426 // If we know we're calling a specific method, register that |
| 1415 // method only. | 1427 // method only. |
| 1416 if (inLoop) backend.builder.functionsCalledInLoop.add(node.element); | 1428 if (inLoop) backend.builder.functionsCalledInLoop.add(target); |
| 1417 world.registerDynamicInvocationOf(node.element); | 1429 world.registerDynamicInvocationOf(target); |
| 1418 } else { | 1430 } else { |
| 1419 if (inLoop) backend.builder.selectorsCalledInLoop[node.name] = selector; | 1431 if (inLoop) backend.builder.selectorsCalledInLoop[node.name] = selector; |
| 1420 world.registerDynamicInvocation(node.name, selector); | 1432 world.registerDynamicInvocation(node.name, selector); |
| 1421 } | 1433 } |
| 1422 } | 1434 } |
| 1423 push(jsPropertyCall(object, methodName, arguments), node); | 1435 push(jsPropertyCall(object, methodName, arguments), node); |
| 1424 } | 1436 } |
| 1425 | 1437 |
| 1426 Selector getOptimizedSelectorFor(HInvokeDynamic node, | 1438 Selector getOptimizedSelectorFor(HInvokeDynamic node, |
| 1427 Selector defaultSelector) { | 1439 Selector defaultSelector) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1456 world.registerDynamicGetter( | 1468 world.registerDynamicGetter( |
| 1457 node.name, getOptimizedSelectorFor(node, getter)); | 1469 node.name, getOptimizedSelectorFor(node, getter)); |
| 1458 } | 1470 } |
| 1459 | 1471 |
| 1460 visitInvokeClosure(HInvokeClosure node) { | 1472 visitInvokeClosure(HInvokeClosure node) { |
| 1461 use(node.receiver); | 1473 use(node.receiver); |
| 1462 push(jsPropertyCall(pop(), | 1474 push(jsPropertyCall(pop(), |
| 1463 compiler.namer.closureInvocationName(node.selector), | 1475 compiler.namer.closureInvocationName(node.selector), |
| 1464 visitArguments(node.inputs)), | 1476 visitArguments(node.inputs)), |
| 1465 node); | 1477 node); |
| 1466 // TODO(floitsch): we should have a separate list for closure invocations. | 1478 // TODO(floitsch): we should have a separate list for closure invocations. |
|
floitsch
2012/08/15 14:14:04
remove comment.
kasperl
2012/08/16 10:35:47
Done.
| |
| 1467 Selector call = new Selector.call( | 1479 Selector call = new Selector.callClosureFrom(node.selector); |
| 1468 compiler.namer.CLOSURE_INVOCATION_NAME, | 1480 world.registerDynamicInvocation(call.name, call); |
| 1469 node.selector.library, | |
| 1470 node.selector.argumentCount, | |
| 1471 node.selector.namedArguments); | |
| 1472 world.registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME, | |
| 1473 call); | |
| 1474 } | 1481 } |
| 1475 | 1482 |
| 1476 visitInvokeStatic(HInvokeStatic node) { | 1483 visitInvokeStatic(HInvokeStatic node) { |
| 1477 use(node.target); | 1484 use(node.target); |
| 1478 push(new js.Call(pop(), visitArguments(node.inputs)), node); | 1485 push(new js.Call(pop(), visitArguments(node.inputs)), node); |
| 1479 } | 1486 } |
| 1480 | 1487 |
| 1481 visitInvokeSuper(HInvokeSuper node) { | 1488 visitInvokeSuper(HInvokeSuper node) { |
| 1482 Element superMethod = node.element; | 1489 Element superMethod = node.element; |
| 1483 Element superClass = superMethod.getEnclosingClass(); | 1490 Element superClass = superMethod.getEnclosingClass(); |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2860 if (leftType.canBeNull() && rightType.canBeNull()) { | 2867 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2861 if (left.isConstantNull() || right.isConstantNull() || | 2868 if (left.isConstantNull() || right.isConstantNull() || |
| 2862 (leftType.isPrimitive() && leftType == rightType)) { | 2869 (leftType.isPrimitive() && leftType == rightType)) { |
| 2863 return '=='; | 2870 return '=='; |
| 2864 } | 2871 } |
| 2865 return null; | 2872 return null; |
| 2866 } else { | 2873 } else { |
| 2867 return '==='; | 2874 return '==='; |
| 2868 } | 2875 } |
| 2869 } | 2876 } |
| OLD | NEW |