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 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 | 1373 |
1374 // Generate calls to the constructor bodies. | 1374 // Generate calls to the constructor bodies. |
1375 for (int index = constructors.length - 1; index >= 0; index--) { | 1375 for (int index = constructors.length - 1; index >= 0; index--) { |
1376 FunctionElement constructor = constructors[index]; | 1376 FunctionElement constructor = constructors[index]; |
1377 assert(invariant(functionElement, constructor.isImplementation)); | 1377 assert(invariant(functionElement, constructor.isImplementation)); |
1378 ConstructorBodyElement body = getConstructorBody(constructor); | 1378 ConstructorBodyElement body = getConstructorBody(constructor); |
1379 if (body == null) continue; | 1379 if (body == null) continue; |
1380 List bodyCallInputs = <HInstruction>[]; | 1380 List bodyCallInputs = <HInstruction>[]; |
1381 bodyCallInputs.add(newObject); | 1381 bodyCallInputs.add(newObject); |
1382 FunctionSignature functionSignature = body.computeSignature(compiler); | 1382 FunctionSignature functionSignature = body.computeSignature(compiler); |
1383 int arity = functionSignature.parameterCount; | |
1384 functionSignature.orderedForEachParameter((parameter) { | 1383 functionSignature.orderedForEachParameter((parameter) { |
1385 if (!localsHandler.isBoxed(parameter)) { | 1384 if (!localsHandler.isBoxed(parameter)) { |
1386 // The parameter will be a field in the box passed as the | 1385 // The parameter will be a field in the box passed as the |
1387 // last parameter. So no need to pass it. | 1386 // last parameter. So no need to pass it. |
1388 bodyCallInputs.add(localsHandler.readLocal(parameter)); | 1387 bodyCallInputs.add(localsHandler.readLocal(parameter)); |
1389 } | 1388 } |
1390 }); | 1389 }); |
1391 | 1390 |
1392 // If parameters are checked, we pass the already computed | 1391 // If parameters are checked, we pass the already computed |
1393 // boolean to the constructor body. | 1392 // boolean to the constructor body. |
(...skipping 19 matching lines...) Expand all Loading... |
1413 | 1412 |
1414 // TODO(ahe): The constructor name is statically resolved. See | 1413 // TODO(ahe): The constructor name is statically resolved. See |
1415 // SsaCodeGenerator.visitInvokeDynamicMethod. Is there a cleaner | 1414 // SsaCodeGenerator.visitInvokeDynamicMethod. Is there a cleaner |
1416 // way to do this? | 1415 // way to do this? |
1417 SourceString name = | 1416 SourceString name = |
1418 new SourceString(backend.namer.getName(body.declaration)); | 1417 new SourceString(backend.namer.getName(body.declaration)); |
1419 // TODO(kasperl): This seems fishy. We shouldn't be inventing all | 1418 // TODO(kasperl): This seems fishy. We shouldn't be inventing all |
1420 // these selectors. Maybe the resolver can do more of the work | 1419 // these selectors. Maybe the resolver can do more of the work |
1421 // for us here? | 1420 // for us here? |
1422 LibraryElement library = body.getLibrary(); | 1421 LibraryElement library = body.getLibrary(); |
1423 Selector selector = new Selector.call(name, library, arity); | 1422 Selector selector = new Selector.call( |
| 1423 name, library, bodyCallInputs.length - 1); |
1424 HInvokeDynamic invoke = | 1424 HInvokeDynamic invoke = |
1425 new HInvokeDynamicMethod(selector, bodyCallInputs); | 1425 new HInvokeDynamicMethod(selector, bodyCallInputs); |
1426 invoke.element = body; | 1426 invoke.element = body; |
1427 add(invoke); | 1427 add(invoke); |
1428 } | 1428 } |
1429 close(new HReturn(newObject)).addSuccessor(graph.exit); | 1429 close(new HReturn(newObject)).addSuccessor(graph.exit); |
1430 return closeFunction(); | 1430 return closeFunction(); |
1431 } | 1431 } |
1432 | 1432 |
1433 void addParameterCheckInstruction(Element element) { | 1433 void addParameterCheckInstruction(Element element) { |
(...skipping 3567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5001 new HSubGraphBlockInformation(elseBranch.graph)); | 5001 new HSubGraphBlockInformation(elseBranch.graph)); |
5002 | 5002 |
5003 HBasicBlock conditionStartBlock = conditionBranch.block; | 5003 HBasicBlock conditionStartBlock = conditionBranch.block; |
5004 conditionStartBlock.setBlockFlow(info, joinBlock); | 5004 conditionStartBlock.setBlockFlow(info, joinBlock); |
5005 SubGraph conditionGraph = conditionBranch.graph; | 5005 SubGraph conditionGraph = conditionBranch.graph; |
5006 HIf branch = conditionGraph.end.last; | 5006 HIf branch = conditionGraph.end.last; |
5007 assert(branch is HIf); | 5007 assert(branch is HIf); |
5008 branch.blockInformation = conditionStartBlock.blockFlow; | 5008 branch.blockInformation = conditionStartBlock.blockFlow; |
5009 } | 5009 } |
5010 } | 5010 } |
OLD | NEW |