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

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

Issue 10908068: Better tracking of provided types at call sites (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 assert(graph.isValid()); 171 assert(graph.isValid());
172 bool inLoop = functionsCalledInLoop.contains(element); 172 bool inLoop = functionsCalledInLoop.contains(element);
173 if (!inLoop) { 173 if (!inLoop) {
174 Selector selector = selectorsCalledInLoop[element.name]; 174 Selector selector = selectorsCalledInLoop[element.name];
175 inLoop = selector !== null && selector.applies(element, compiler); 175 inLoop = selector !== null && selector.applies(element, compiler);
176 } 176 }
177 graph.calledInLoop = inLoop; 177 graph.calledInLoop = inLoop;
178 178
179 // If there is an estimate of the parameter types assume these types when 179 // If there is an estimate of the parameter types assume these types when
180 // compiling. 180 // compiling.
181 OptionalParameterTypes defaultValueTypes = null;
182 FunctionSignature signature = element.computeSignature(compiler);
183 if (signature.optionalParameterCount > 0) {
184 defaultValueTypes =
185 new OptionalParameterTypes(signature.optionalParameterCount);
186 int index = 0;
187 signature.forEachOptionalParameter((Element parameter) {
188 Constant defaultValue = compiler.compileVariable(parameter);
189 HType type = HGraph.mapConstantTypeToSsaType(defaultValue);
190 defaultValueTypes.insert(index, parameter.name, type);
191 index++;
192 });
193 }
181 HTypeList parameterTypes = 194 HTypeList parameterTypes =
182 backend.optimisticParameterTypes( 195 backend.optimisticParameterTypes(element, defaultValueTypes);
183 element);
184 if (!parameterTypes.allUnknown) { 196 if (!parameterTypes.allUnknown) {
185 FunctionSignature signature = element.computeSignature(compiler);
186 int i = 0; 197 int i = 0;
187 signature.forEachParameter((Element param) { 198 signature.forEachParameter((Element param) {
188 builder.parameters[param].guaranteedType = parameterTypes[i++]; 199 builder.parameters[param].guaranteedType = parameterTypes[i++];
189 }); 200 });
190 } 201 }
191 backend.registerParameterTypesOptimization(element, parameterTypes); 202 backend.registerParameterTypesOptimization(
203 element, parameterTypes, defaultValueTypes);
192 204
193 if (compiler.tracer.enabled) { 205 if (compiler.tracer.enabled) {
194 String name; 206 String name;
195 if (element.isMember()) { 207 if (element.isMember()) {
196 String className = element.getEnclosingClass().name.slowToString(); 208 String className = element.getEnclosingClass().name.slowToString();
197 String memberName = element.name.slowToString(); 209 String memberName = element.name.slowToString();
198 name = "$className.$memberName"; 210 name = "$className.$memberName";
199 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { 211 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) {
200 name = "$name (body)"; 212 name = "$name (body)";
201 } 213 }
(...skipping 3731 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 new HSubGraphBlockInformation(elseBranch.graph)); 3945 new HSubGraphBlockInformation(elseBranch.graph));
3934 3946
3935 HBasicBlock conditionStartBlock = conditionBranch.block; 3947 HBasicBlock conditionStartBlock = conditionBranch.block;
3936 conditionStartBlock.setBlockFlow(info, joinBlock); 3948 conditionStartBlock.setBlockFlow(info, joinBlock);
3937 SubGraph conditionGraph = conditionBranch.graph; 3949 SubGraph conditionGraph = conditionBranch.graph;
3938 HIf branch = conditionGraph.end.last; 3950 HIf branch = conditionGraph.end.last;
3939 assert(branch is HIf); 3951 assert(branch is HIf);
3940 branch.blockInformation = conditionStartBlock.blockFlow; 3952 branch.blockInformation = conditionStartBlock.blockFlow;
3941 } 3953 }
3942 } 3954 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698