| 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 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 graph = compileConstructor(builder, work); | 164 graph = compileConstructor(builder, work); |
| 165 } else if (kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY || | 165 } else if (kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY || |
| 166 kind === ElementKind.FUNCTION || | 166 kind === ElementKind.FUNCTION || |
| 167 kind === ElementKind.GETTER || | 167 kind === ElementKind.GETTER || |
| 168 kind === ElementKind.SETTER) { | 168 kind === ElementKind.SETTER) { |
| 169 graph = builder.buildMethod(work.element); | 169 graph = builder.buildMethod(work.element); |
| 170 } else if (kind === ElementKind.FIELD) { | 170 } else if (kind === ElementKind.FIELD) { |
| 171 graph = builder.buildLazyInitializer(work.element); | 171 graph = builder.buildLazyInitializer(work.element); |
| 172 } | 172 } |
| 173 assert(graph.isValid()); | 173 assert(graph.isValid()); |
| 174 <<<<<<< HEAD |
| 174 if (kind !== ElementKind.FIELD) { | 175 if (kind !== ElementKind.FIELD) { |
| 175 bool inLoop = functionsCalledInLoop.contains(element); | 176 bool inLoop = functionsCalledInLoop.contains(element); |
| 176 if (!inLoop) { | 177 if (!inLoop) { |
| 177 Selector selector = selectorsCalledInLoop[element.name]; | 178 Selector selector = selectorsCalledInLoop[element.name]; |
| 178 inLoop = selector !== null && selector.applies(element, compiler); | 179 inLoop = selector !== null && selector.applies(element, compiler); |
| 179 } | 180 } |
| 180 graph.calledInLoop = inLoop; | 181 graph.calledInLoop = inLoop; |
| 181 | 182 |
| 182 // If there is an estimate of the parameter types assume these types | 183 // If there is an estimate of the parameter types assume these types |
| 183 // when compiling. | 184 // when compiling. |
| 184 HTypeList parameterTypes = | 185 HTypeList parameterTypes = |
| 185 backend.optimisticParameterTypes( | 186 backend.optimisticParameterTypes( |
| 186 element); | 187 element); |
| 187 if (!parameterTypes.allUnknown) { | 188 if (!parameterTypes.allUnknown) { |
| 188 FunctionElement functionElement = element; | 189 FunctionElement functionElement = element; |
| 189 FunctionSignature signature = | 190 FunctionSignature signature = |
| 190 functionElement.computeSignature(compiler); | 191 functionElement.computeSignature(compiler); |
| 191 int i = 0; | 192 int i = 0; |
| 192 signature.forEachParameter((Element param) { | 193 signature.forEachParameter((Element param) { |
| 193 builder.parameters[param].guaranteedType = parameterTypes[i++]; | 194 builder.parameters[param].guaranteedType = parameterTypes[i++]; |
| 194 }); | 195 }); |
| 195 } | 196 } |
| 196 backend.registerParameterTypesOptimization(element, parameterTypes); | 197 backend.registerParameterTypesOptimization(element, parameterTypes); |
| 197 } | 198 } |
| 199 ======= |
| 200 bool inLoop = functionsCalledInLoop.contains(element); |
| 201 if (!inLoop) { |
| 202 Selector selector = selectorsCalledInLoop[element.name]; |
| 203 inLoop = selector !== null && selector.applies(element, compiler); |
| 204 } |
| 205 graph.calledInLoop = inLoop; |
| 206 |
| 207 // If there is an estimate of the parameter types assume these types when |
| 208 // compiling. |
| 209 OptionalParameterTypes defaultValueTypes = null; |
| 210 FunctionSignature signature = element.computeSignature(compiler); |
| 211 if (signature.optionalParameterCount > 0) { |
| 212 defaultValueTypes = |
| 213 new OptionalParameterTypes(signature.optionalParameterCount); |
| 214 int index = 0; |
| 215 signature.forEachOptionalParameter((Element parameter) { |
| 216 Constant defaultValue = compiler.compileVariable(parameter); |
| 217 HType type = HGraph.mapConstantTypeToSsaType(defaultValue); |
| 218 defaultValueTypes.update(index, parameter.name, type); |
| 219 index++; |
| 220 }); |
| 221 } |
| 222 HTypeList parameterTypes = |
| 223 backend.optimisticParameterTypes(element, defaultValueTypes); |
| 224 if (!parameterTypes.allUnknown) { |
| 225 int i = 0; |
| 226 signature.forEachParameter((Element param) { |
| 227 builder.parameters[param].guaranteedType = parameterTypes[i++]; |
| 228 }); |
| 229 } |
| 230 backend.registerParameterTypesOptimization( |
| 231 element, parameterTypes, defaultValueTypes); |
| 232 >>>>>>> Better tracking of provided types at call sites |
| 198 | 233 |
| 199 if (compiler.tracer.enabled) { | 234 if (compiler.tracer.enabled) { |
| 200 String name; | 235 String name; |
| 201 if (element.isMember()) { | 236 if (element.isMember()) { |
| 202 String className = element.getEnclosingClass().name.slowToString(); | 237 String className = element.getEnclosingClass().name.slowToString(); |
| 203 String memberName = element.name.slowToString(); | 238 String memberName = element.name.slowToString(); |
| 204 name = "$className.$memberName"; | 239 name = "$className.$memberName"; |
| 205 if (element.isGenerativeConstructorBody()) { | 240 if (element.isGenerativeConstructorBody()) { |
| 206 name = "$name (body)"; | 241 name = "$name (body)"; |
| 207 } | 242 } |
| (...skipping 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4026 new HSubGraphBlockInformation(elseBranch.graph)); | 4061 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4027 | 4062 |
| 4028 HBasicBlock conditionStartBlock = conditionBranch.block; | 4063 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4029 conditionStartBlock.setBlockFlow(info, joinBlock); | 4064 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4030 SubGraph conditionGraph = conditionBranch.graph; | 4065 SubGraph conditionGraph = conditionBranch.graph; |
| 4031 HIf branch = conditionGraph.end.last; | 4066 HIf branch = conditionGraph.end.last; |
| 4032 assert(branch is HIf); | 4067 assert(branch is HIf); |
| 4033 branch.blockInformation = conditionStartBlock.blockFlow; | 4068 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4034 } | 4069 } |
| 4035 } | 4070 } |
| OLD | NEW |