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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10854158: Make selector registration in the resolver and code generator more explicit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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
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 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
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
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 Selector call = new Selector.callClosureFrom(node.selector);
1467 Selector call = new Selector.call( 1479 world.registerDynamicInvocation(call.name, call);
1468 compiler.namer.CLOSURE_INVOCATION_NAME,
1469 node.selector.library,
1470 node.selector.argumentCount,
1471 node.selector.namedArguments);
1472 world.registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME,
1473 call);
1474 } 1480 }
1475 1481
1476 visitInvokeStatic(HInvokeStatic node) { 1482 visitInvokeStatic(HInvokeStatic node) {
1477 if (Elements.isStaticOrTopLevelFunction(node.element) && 1483 if (Elements.isStaticOrTopLevelFunction(node.element) &&
1478 node.typeCode() == HInvokeStatic.INVOKE_STATIC_TYPECODE) { 1484 node.typeCode() == HInvokeStatic.INVOKE_STATIC_TYPECODE) {
1479 // Register this invocation to collect the types used at all call sites. 1485 // Register this invocation to collect the types used at all call sites.
1480 backend.registerStaticInvocation(node); 1486 backend.registerStaticInvocation(node);
1481 } 1487 }
1482 use(node.target); 1488 use(node.target);
1483 push(new js.Call(pop(), visitArguments(node.inputs)), node); 1489 push(new js.Call(pop(), visitArguments(node.inputs)), node);
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 if (leftType.canBeNull() && rightType.canBeNull()) { 2896 if (leftType.canBeNull() && rightType.canBeNull()) {
2891 if (left.isConstantNull() || right.isConstantNull() || 2897 if (left.isConstantNull() || right.isConstantNull() ||
2892 (leftType.isPrimitive() && leftType == rightType)) { 2898 (leftType.isPrimitive() && leftType == rightType)) {
2893 return '=='; 2899 return '==';
2894 } 2900 }
2895 return null; 2901 return null;
2896 } else { 2902 } else {
2897 return '==='; 2903 return '===';
2898 } 2904 }
2899 } 2905 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698