| 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. |
| 11 */ | 11 */ |
| 12 class InterceptedElement extends ElementX { | 12 class InterceptedElement extends ElementX { |
| 13 final DartType type; | 13 final DartType type; |
| 14 InterceptedElement(this.type, String name, Element enclosing) | 14 InterceptedElement(this.type, String name, Element enclosing) |
| 15 : super(name, ElementKind.PARAMETER, enclosing); | 15 : super(name, ElementKind.PARAMETER, enclosing); |
| 16 | 16 |
| 17 DartType computeType(Compiler compiler) => type; | 17 DartType computeType(Compiler compiler) => type; |
| 18 |
| 19 accept(ElementVisitor visitor) => visitor.visitInterceptedElement(this); |
| 18 } | 20 } |
| 19 | 21 |
| 20 class SsaBuilderTask extends CompilerTask { | 22 class SsaBuilderTask extends CompilerTask { |
| 21 final CodeEmitterTask emitter; | 23 final CodeEmitterTask emitter; |
| 22 final JavaScriptBackend backend; | 24 final JavaScriptBackend backend; |
| 23 | 25 |
| 24 String get name => 'SSA builder'; | 26 String get name => 'SSA builder'; |
| 25 | 27 |
| 26 SsaBuilderTask(JavaScriptBackend backend) | 28 SsaBuilderTask(JavaScriptBackend backend) |
| 27 : emitter = backend.emitter, | 29 : emitter = backend.emitter, |
| (...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 if ((function.isConstructor() || function.isGenerativeConstructorBody()) | 1310 if ((function.isConstructor() || function.isGenerativeConstructorBody()) |
| 1309 && backend.classNeedsRti(enclosing)) { | 1311 && backend.classNeedsRti(enclosing)) { |
| 1310 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | 1312 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { |
| 1311 HInstruction argument = compiledArguments[argumentIndex++]; | 1313 HInstruction argument = compiledArguments[argumentIndex++]; |
| 1312 newLocalsHandler.updateLocal(typeVariable.element, argument); | 1314 newLocalsHandler.updateLocal(typeVariable.element, argument); |
| 1313 }); | 1315 }); |
| 1314 } | 1316 } |
| 1315 assert(argumentIndex == compiledArguments.length); | 1317 assert(argumentIndex == compiledArguments.length); |
| 1316 | 1318 |
| 1317 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. | 1319 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. |
| 1318 returnElement = new ElementX("result", | 1320 returnElement = new VariableElementX.synthetic("result", |
| 1319 ElementKind.VARIABLE, | 1321 ElementKind.VARIABLE, function); |
| 1320 function); | |
| 1321 newLocalsHandler.updateLocal(returnElement, | 1322 newLocalsHandler.updateLocal(returnElement, |
| 1322 graph.addConstantNull(compiler)); | 1323 graph.addConstantNull(compiler)); |
| 1323 elements = compiler.enqueuer.resolution.getCachedElements(function); | 1324 elements = compiler.enqueuer.resolution.getCachedElements(function); |
| 1324 assert(elements != null); | 1325 assert(elements != null); |
| 1325 returnType = signature.returnType; | 1326 returnType = signature.returnType; |
| 1326 stack = <HInstruction>[]; | 1327 stack = <HInstruction>[]; |
| 1327 inliningStack.add(state); | 1328 inliningStack.add(state); |
| 1328 localsHandler = newLocalsHandler; | 1329 localsHandler = newLocalsHandler; |
| 1329 return state; | 1330 return state; |
| 1330 } | 1331 } |
| (...skipping 4027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5358 SubGraph bodyGraph = new SubGraph(startTryBlock, lastOpenedBlock); | 5359 SubGraph bodyGraph = new SubGraph(startTryBlock, lastOpenedBlock); |
| 5359 SubGraph catchGraph = null; | 5360 SubGraph catchGraph = null; |
| 5360 HLocalValue exception = null; | 5361 HLocalValue exception = null; |
| 5361 | 5362 |
| 5362 if (!node.catchBlocks.isEmpty) { | 5363 if (!node.catchBlocks.isEmpty) { |
| 5363 localsHandler = new LocalsHandler.from(savedLocals); | 5364 localsHandler = new LocalsHandler.from(savedLocals); |
| 5364 startCatchBlock = graph.addNewBlock(); | 5365 startCatchBlock = graph.addNewBlock(); |
| 5365 open(startCatchBlock); | 5366 open(startCatchBlock); |
| 5366 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. | 5367 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. |
| 5367 // Note that the name of this element is irrelevant. | 5368 // Note that the name of this element is irrelevant. |
| 5368 Element element = new ElementX('exception', | 5369 Element element = new VariableElementX.synthetic('exception', |
| 5369 ElementKind.PARAMETER, | 5370 ElementKind.PARAMETER, currentElement); |
| 5370 currentElement); | |
| 5371 exception = new HLocalValue(element, backend.nonNullType); | 5371 exception = new HLocalValue(element, backend.nonNullType); |
| 5372 add(exception); | 5372 add(exception); |
| 5373 HInstruction oldRethrowableException = rethrowableException; | 5373 HInstruction oldRethrowableException = rethrowableException; |
| 5374 rethrowableException = exception; | 5374 rethrowableException = exception; |
| 5375 | 5375 |
| 5376 pushInvokeStatic(node, backend.getExceptionUnwrapper(), [exception]); | 5376 pushInvokeStatic(node, backend.getExceptionUnwrapper(), [exception]); |
| 5377 HInvokeStatic unwrappedException = pop(); | 5377 HInvokeStatic unwrappedException = pop(); |
| 5378 tryInstruction.exception = exception; | 5378 tryInstruction.exception = exception; |
| 5379 Link<Node> link = node.catchBlocks.nodes; | 5379 Link<Node> link = node.catchBlocks.nodes; |
| 5380 | 5380 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5954 new HSubGraphBlockInformation(elseBranch.graph)); | 5954 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5955 | 5955 |
| 5956 HBasicBlock conditionStartBlock = conditionBranch.block; | 5956 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5957 conditionStartBlock.setBlockFlow(info, joinBlock); | 5957 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5958 SubGraph conditionGraph = conditionBranch.graph; | 5958 SubGraph conditionGraph = conditionBranch.graph; |
| 5959 HIf branch = conditionGraph.end.last; | 5959 HIf branch = conditionGraph.end.last; |
| 5960 assert(branch is HIf); | 5960 assert(branch is HIf); |
| 5961 branch.blockInformation = conditionStartBlock.blockFlow; | 5961 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5962 } | 5962 } |
| 5963 } | 5963 } |
| OLD | NEW |