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

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

Issue 11052011: Fix some warnings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 2 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 6
7 final JavaScriptBackend backend; 7 final JavaScriptBackend backend;
8 8
9 SsaCodeGeneratorTask(JavaScriptBackend backend) 9 SsaCodeGeneratorTask(JavaScriptBackend backend)
10 : this.backend = backend, 10 : this.backend = backend,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (block.last is HReturn) { 69 if (block.last is HReturn) {
70 backend.registerReturnType(work.element, types[block.last.inputs[0]]); 70 backend.registerReturnType(work.element, types[block.last.inputs[0]]);
71 } else { 71 } else {
72 backend.registerReturnType(work.element, HType.NULL); 72 backend.registerReturnType(work.element, HType.NULL);
73 } 73 }
74 }); 74 });
75 compiler.tracer.traceGraph("codegen", graph); 75 compiler.tracer.traceGraph("codegen", graph);
76 Map<Element, String> parameterNames = getParameterNames(work); 76 Map<Element, String> parameterNames = getParameterNames(work);
77 // Use [work.element] to ensure that the parameter element come from 77 // Use [work.element] to ensure that the parameter element come from
78 // the declaration. 78 // the declaration.
79 work.element.computeSignature(compiler).forEachParameter((element) { 79 FunctionElement function = work.element;
80 function.computeSignature(compiler).forEachParameter((element) {
80 compiler.enqueuer.codegen.addToWorkList(element); 81 compiler.enqueuer.codegen.addToWorkList(element);
81 }); 82 });
82 List<js.Parameter> parameters = <js.Parameter>[]; 83 List<js.Parameter> parameters = <js.Parameter>[];
83 parameterNames.forEach((element, name) { 84 parameterNames.forEach((element, name) {
84 parameters.add(new js.Parameter(name)); 85 parameters.add(new js.Parameter(name));
85 }); 86 });
86 addTypeParameters(work.element, parameters, parameterNames); 87 addTypeParameters(work.element, parameters, parameterNames);
87 String parametersString = Strings.join(parameterNames.getValues(), ", "); 88 String parametersString = Strings.join(parameterNames.getValues(), ", ");
88 SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator( 89 SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator(
89 backend, work, parameters, parameterNames); 90 backend, work, parameters, parameterNames);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 parameterNames[element] = function.isNative() 172 parameterNames[element] = function.isNative()
172 ? element.name.slowToString() 173 ? element.name.slowToString()
173 : JsNames.getValid('${element.name.slowToString()}'); 174 : JsNames.getValid('${element.name.slowToString()}');
174 }); 175 });
175 return parameterNames; 176 return parameterNames;
176 } 177 }
177 } 178 }
178 179
179 typedef void ElementAction(Element element); 180 typedef void ElementAction(Element element);
180 181
181 class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { 182 abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
182 /** 183 /**
183 * Returned by [expressionType] to tell how code can be generated for 184 * Returned by [expressionType] to tell how code can be generated for
184 * a subgraph. 185 * a subgraph.
185 * - [TYPE_STATEMENT] means that the graph must be generated as a statement, 186 * - [TYPE_STATEMENT] means that the graph must be generated as a statement,
186 * which is always possible. 187 * which is always possible.
187 * - [TYPE_EXPRESSION] means that the graph can be generated as an expression, 188 * - [TYPE_EXPRESSION] means that the graph can be generated as an expression,
188 * or possibly several comma-separated expressions. 189 * or possibly several comma-separated expressions.
189 * - [TYPE_DECLARATION] means that the graph can be generated as an 190 * - [TYPE_DECLARATION] means that the graph can be generated as an
190 * expression, and that it only generates expressions of the form 191 * expression, and that it only generates expressions of the form
191 * variable = expression 192 * variable = expression
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 "==" : "!=", 1810 "==" : "!=",
1810 "!=" : "==", 1811 "!=" : "==",
1811 "===": "!==", 1812 "===": "!==",
1812 "!==": "===", 1813 "!==": "===",
1813 "<" : ">=", 1814 "<" : ">=",
1814 "<=" : ">", 1815 "<=" : ">",
1815 ">" : "<=", 1816 ">" : "<=",
1816 ">=" : "<" 1817 ">=" : "<"
1817 }; 1818 };
1818 HRelational relational = input; 1819 HRelational relational = input;
1820
1819 visitInvokeBinary(input, 1821 visitInvokeBinary(input,
1820 inverseOperator[relational.operation.name.stringValue]); 1822 inverseOperator[relational.operation.name.stringValue]);
1821 } else { 1823 } else {
1822 use(input); 1824 use(input);
1823 push(new js.Prefix("!", pop())); 1825 push(new js.Prefix("!", pop()));
1824 } 1826 }
1825 } 1827 }
1826 1828
1827 visitParameterValue(HParameterValue node) => visitLocalValue(node); 1829 visitParameterValue(HParameterValue node) => visitLocalValue(node);
1828 1830
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 2443
2442 SourceString helper; 2444 SourceString helper;
2443 if (node.isBooleanConversionCheck) { 2445 if (node.isBooleanConversionCheck) {
2444 helper = const SourceString('boolConversionCheck'); 2446 helper = const SourceString('boolConversionCheck');
2445 } else { 2447 } else {
2446 helper = backend.getCheckedModeHelper(type); 2448 helper = backend.getCheckedModeHelper(type);
2447 if (node.isCastTypeCheck) { 2449 if (node.isCastTypeCheck) {
2448 helper = castNames[helper.stringValue]; 2450 helper = castNames[helper.stringValue];
2449 } 2451 }
2450 } 2452 }
2451 Element helperElement = compiler.findHelper(helper); 2453 FunctionElement helperElement = compiler.findHelper(helper);
2452 world.registerStaticUse(helperElement); 2454 world.registerStaticUse(helperElement);
2453 List<js.Expression> arguments = <js.Expression>[]; 2455 List<js.Expression> arguments = <js.Expression>[];
2454 use(node.checkedInput); 2456 use(node.checkedInput);
2455 arguments.add(pop()); 2457 arguments.add(pop());
2456 if (helperElement.computeSignature(compiler).parameterCount != 1) { 2458 if (helperElement.computeSignature(compiler).parameterCount != 1) {
2457 String additionalArgument = backend.namer.operatorIs(element); 2459 String additionalArgument = backend.namer.operatorIs(element);
2458 arguments.add(new js.LiteralString("'$additionalArgument'")); 2460 arguments.add(new js.LiteralString("'$additionalArgument'"));
2459 } 2461 }
2460 String helperName = backend.namer.isolateAccess(helperElement); 2462 String helperName = backend.namer.isolateAccess(helperElement);
2461 push(new js.Call(new js.VariableUse(helperName), arguments)); 2463 push(new js.Call(new js.VariableUse(helperName), arguments));
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 if (leftType.canBeNull() && rightType.canBeNull()) { 2984 if (leftType.canBeNull() && rightType.canBeNull()) {
2983 if (left.isConstantNull() || right.isConstantNull() || 2985 if (left.isConstantNull() || right.isConstantNull() ||
2984 (leftType.isPrimitive() && leftType == rightType)) { 2986 (leftType.isPrimitive() && leftType == rightType)) {
2985 return '=='; 2987 return '==';
2986 } 2988 }
2987 return null; 2989 return null;
2988 } else { 2990 } else {
2989 return '==='; 2991 return '===';
2990 } 2992 }
2991 } 2993 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698