| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
| 9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 InliningState state = enterInlinedMethod( | 1117 InliningState state = enterInlinedMethod( |
| 1118 function, selector, arguments, currentNode); | 1118 function, selector, arguments, currentNode); |
| 1119 inlinedFrom(element, () { | 1119 inlinedFrom(element, () { |
| 1120 functionExpression.body.accept(this); | 1120 functionExpression.body.accept(this); |
| 1121 }); | 1121 }); |
| 1122 leaveInlinedMethod(state); | 1122 leaveInlinedMethod(state); |
| 1123 return true; | 1123 return true; |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 inlinedFrom(Element element, f()) { | 1126 inlinedFrom(Element element, f()) { |
| 1127 assert(element is FunctionElement || element is VariableElement); |
| 1127 return compiler.withCurrentElement(element, () { | 1128 return compiler.withCurrentElement(element, () { |
| 1128 sourceElementStack.add(element); | 1129 sourceElementStack.add(element); |
| 1129 var result = f(); | 1130 var result = f(); |
| 1130 sourceElementStack.removeLast(); | 1131 sourceElementStack.removeLast(); |
| 1131 return result; | 1132 return result; |
| 1132 }); | 1133 }); |
| 1133 } | 1134 } |
| 1134 | 1135 |
| 1135 /** | 1136 /** |
| 1136 * Documentation wanted -- johnniwinther | 1137 * Documentation wanted -- johnniwinther |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1156 constructor, | 1157 constructor, |
| 1157 compiledArguments)); | 1158 compiledArguments)); |
| 1158 if (!succeeded) { | 1159 if (!succeeded) { |
| 1159 // Non-matching super and redirects are compile-time errors and thus | 1160 // Non-matching super and redirects are compile-time errors and thus |
| 1160 // checked by the resolver. | 1161 // checked by the resolver. |
| 1161 compiler.internalError( | 1162 compiler.internalError( |
| 1162 "Parameters and arguments didn't match for super/redirect call", | 1163 "Parameters and arguments didn't match for super/redirect call", |
| 1163 element: constructor); | 1164 element: constructor); |
| 1164 } | 1165 } |
| 1165 | 1166 |
| 1166 sourceElementStack.add(constructor.enclosingElement); | 1167 inlinedFrom(constructor, () { |
| 1167 buildFieldInitializers(constructor.enclosingElement.implementation, | 1168 buildFieldInitializers(constructor.enclosingElement.implementation, |
| 1168 fieldValues); | 1169 fieldValues); |
| 1169 sourceElementStack.removeLast(); | 1170 }); |
| 1170 | 1171 |
| 1171 int index = 0; | 1172 int index = 0; |
| 1172 FunctionSignature params = constructor.computeSignature(compiler); | 1173 FunctionSignature params = constructor.computeSignature(compiler); |
| 1173 params.orderedForEachParameter((Element parameter) { | 1174 params.orderedForEachParameter((Element parameter) { |
| 1174 HInstruction argument = compiledArguments[index++]; | 1175 HInstruction argument = compiledArguments[index++]; |
| 1175 // Because we are inlining the initializer, we must update | 1176 // Because we are inlining the initializer, we must update |
| 1176 // what was given as parameter. This will be used in case | 1177 // what was given as parameter. This will be used in case |
| 1177 // there is a parameter check expression in the initializer. | 1178 // there is a parameter check expression in the initializer. |
| 1178 parameters[parameter] = argument; | 1179 parameters[parameter] = argument; |
| 1179 localsHandler.updateLocal(parameter, argument); | 1180 localsHandler.updateLocal(parameter, argument); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 Selector selector = elements.getSelector(call); | 1246 Selector selector = elements.getSelector(call); |
| 1246 Link<Node> arguments = call.arguments; | 1247 Link<Node> arguments = call.arguments; |
| 1247 inlineSuperOrRedirect(target, selector, arguments, constructors, | 1248 inlineSuperOrRedirect(target, selector, arguments, constructors, |
| 1248 fieldValues, constructor); | 1249 fieldValues, constructor); |
| 1249 foundSuperOrRedirect = true; | 1250 foundSuperOrRedirect = true; |
| 1250 } else { | 1251 } else { |
| 1251 // A field initializer. | 1252 // A field initializer. |
| 1252 SendSet init = link.head; | 1253 SendSet init = link.head; |
| 1253 Link<Node> arguments = init.arguments; | 1254 Link<Node> arguments = init.arguments; |
| 1254 assert(!arguments.isEmpty && arguments.tail.isEmpty); | 1255 assert(!arguments.isEmpty && arguments.tail.isEmpty); |
| 1255 sourceElementStack.add(constructor); | 1256 inlinedFrom(constructor, () { |
| 1256 visit(arguments.head); | 1257 visit(arguments.head); |
| 1257 sourceElementStack.removeLast(); | 1258 }); |
| 1258 fieldValues[elements[init]] = pop(); | 1259 fieldValues[elements[init]] = pop(); |
| 1259 } | 1260 } |
| 1260 } | 1261 } |
| 1261 } | 1262 } |
| 1262 | 1263 |
| 1263 if (!foundSuperOrRedirect) { | 1264 if (!foundSuperOrRedirect) { |
| 1264 // No super initializer found. Try to find the default constructor if | 1265 // No super initializer found. Try to find the default constructor if |
| 1265 // the class is not Object. | 1266 // the class is not Object. |
| 1266 ClassElement enclosingClass = constructor.getEnclosingClass(); | 1267 ClassElement enclosingClass = constructor.getEnclosingClass(); |
| 1267 ClassElement superClass = enclosingClass.superclass; | 1268 ClassElement superClass = enclosingClass.superclass; |
| (...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4971 new HSubGraphBlockInformation(elseBranch.graph)); | 4972 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4972 | 4973 |
| 4973 HBasicBlock conditionStartBlock = conditionBranch.block; | 4974 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4974 conditionStartBlock.setBlockFlow(info, joinBlock); | 4975 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4975 SubGraph conditionGraph = conditionBranch.graph; | 4976 SubGraph conditionGraph = conditionBranch.graph; |
| 4976 HIf branch = conditionGraph.end.last; | 4977 HIf branch = conditionGraph.end.last; |
| 4977 assert(branch is HIf); | 4978 assert(branch is HIf); |
| 4978 branch.blockInformation = conditionStartBlock.blockFlow; | 4979 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4979 } | 4980 } |
| 4980 } | 4981 } |
| OLD | NEW |