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

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

Issue 10855170: Track types for arguments passed to calls to static functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 Selector call = new Selector.call( 1464 Selector call = new Selector.call(
1465 compiler.namer.CLOSURE_INVOCATION_NAME, 1465 compiler.namer.CLOSURE_INVOCATION_NAME,
1466 node.selector.library, 1466 node.selector.library,
1467 node.selector.argumentCount, 1467 node.selector.argumentCount,
1468 node.selector.namedArguments); 1468 node.selector.namedArguments);
1469 world.registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME, 1469 world.registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME,
1470 call); 1470 call);
1471 } 1471 }
1472 1472
1473 visitInvokeStatic(HInvokeStatic node) { 1473 visitInvokeStatic(HInvokeStatic node) {
1474 if (Elements.isStaticOrTopLevelFunction(node.element) &&
1475 node is !HInvokeSuper &&
1476 node is !HInvokeInterceptor &&
1477 node is !HInvokeBinary &&
1478 node is !HInvokeUnary &&
1479 node is !HIndex &&
1480 node is !HIndexAssign) {
1481 // Register this invocation to collect the types used at all call sites.
floitsch 2012/08/15 09:11:59 assert that the typeCode is the one you expect it
Søren Gjesse 2012/08/15 12:17:10 Done. We should look into giving named constants
1482 if (Elements.isStaticOrTopLevelFunction(node.element)) {
floitsch 2012/08/15 09:11:59 redundant if.
Søren Gjesse 2012/08/15 12:17:10 Removed.
1483 backend.registerStaticInvocation(node);
1484 }
1485 }
1474 use(node.target); 1486 use(node.target);
1475 push(new js.Call(pop(), visitArguments(node.inputs)), node); 1487 push(new js.Call(pop(), visitArguments(node.inputs)), node);
1476 } 1488 }
1477 1489
1478 visitInvokeSuper(HInvokeSuper node) { 1490 visitInvokeSuper(HInvokeSuper node) {
1479 Element superMethod = node.element; 1491 Element superMethod = node.element;
1480 Element superClass = superMethod.getEnclosingClass(); 1492 Element superClass = superMethod.getEnclosingClass();
1481 // Remove the element and 'this'. 1493 // Remove the element and 'this'.
1482 int argumentCount = node.inputs.length - 2; 1494 int argumentCount = node.inputs.length - 2;
1483 String className = compiler.namer.isolateAccess(superClass); 1495 String className = compiler.namer.isolateAccess(superClass);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 js.Call value = new js.Call(jsHelper, visitArguments([null, argument])); 1895 js.Call value = new js.Call(jsHelper, visitArguments([null, argument]));
1884 attachLocation(value, argument); 1896 attachLocation(value, argument);
1885 pushStatement(new js.Throw(value)); 1897 pushStatement(new js.Throw(value));
1886 } 1898 }
1887 1899
1888 void visitSwitch(HSwitch node) { 1900 void visitSwitch(HSwitch node) {
1889 // Switches are handled using [visitSwitchInfo]. 1901 // Switches are handled using [visitSwitchInfo].
1890 } 1902 }
1891 1903
1892 void visitStatic(HStatic node) { 1904 void visitStatic(HStatic node) {
1905 node.usedBy.forEach((HInstruction instr) {
1906 if (instr is !HInvokeStatic || instr.target !== node) {
floitsch 2012/08/15 09:11:59 not enough: foo(foo);
Søren Gjesse 2012/08/15 12:17:10 Good catch! Added check that the HStatic is also
1907 backend.registerNonCallStaticUse(node);
1908 }
1909 });
1893 world.registerStaticUse(node.element); 1910 world.registerStaticUse(node.element);
1894 push(new js.VariableUse(compiler.namer.isolateAccess(node.element))); 1911 push(new js.VariableUse(compiler.namer.isolateAccess(node.element)));
1895 } 1912 }
1896 1913
1897 void visitStaticStore(HStaticStore node) { 1914 void visitStaticStore(HStaticStore node) {
1898 world.registerStaticUse(node.element); 1915 world.registerStaticUse(node.element);
1899 js.VariableUse variableUse = 1916 js.VariableUse variableUse =
1900 new js.VariableUse(compiler.namer.isolateAccess(node.element)); 1917 new js.VariableUse(compiler.namer.isolateAccess(node.element));
1901 use(node.inputs[0]); 1918 use(node.inputs[0]);
1902 push(new js.Assignment(variableUse, pop()), node); 1919 push(new js.Assignment(variableUse, pop()), node);
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 if (leftType.canBeNull() && rightType.canBeNull()) { 2874 if (leftType.canBeNull() && rightType.canBeNull()) {
2858 if (left.isConstantNull() || right.isConstantNull() || 2875 if (left.isConstantNull() || right.isConstantNull() ||
2859 (leftType.isPrimitive() && leftType == rightType)) { 2876 (leftType.isPrimitive() && leftType == rightType)) {
2860 return '=='; 2877 return '==';
2861 } 2878 }
2862 return null; 2879 return null;
2863 } else { 2880 } else {
2864 return '==='; 2881 return '===';
2865 } 2882 }
2866 } 2883 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698