Chromium Code Reviews| 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 3881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3892 } | 3892 } |
| 3893 | 3893 |
| 3894 visitThrow(Throw node) { | 3894 visitThrow(Throw node) { |
| 3895 if (node.expression == null) { | 3895 if (node.expression == null) { |
| 3896 HInstruction exception = rethrowableException; | 3896 HInstruction exception = rethrowableException; |
| 3897 if (exception == null) { | 3897 if (exception == null) { |
| 3898 exception = graph.addConstantNull(constantSystem); | 3898 exception = graph.addConstantNull(constantSystem); |
| 3899 compiler.internalError( | 3899 compiler.internalError( |
| 3900 'rethrowableException should not be null', node: node); | 3900 'rethrowableException should not be null', node: node); |
| 3901 } | 3901 } |
| 3902 close(new HThrow(exception, isRethrow: true)); | 3902 handleInTryStatement(); |
| 3903 close(new HThrow(exception, isRethrow: true)).addSuccessor(graph.exit); | |
|
kasperl
2013/04/11 12:28:53
I'd prefer a new version of close that adds the ex
ngeoffray
2013/04/11 12:52:28
Done.
| |
| 3903 } else { | 3904 } else { |
| 3904 visit(node.expression); | 3905 visit(node.expression); |
| 3905 close(new HThrow(pop())); | 3906 handleInTryStatement(); |
| 3907 close(new HThrow(pop())).addSuccessor(graph.exit); | |
| 3906 } | 3908 } |
| 3907 } | 3909 } |
| 3908 | 3910 |
| 3909 visitTypeAnnotation(TypeAnnotation node) { | 3911 visitTypeAnnotation(TypeAnnotation node) { |
| 3910 compiler.internalError('visiting type annotation in SSA builder', | 3912 compiler.internalError('visiting type annotation in SSA builder', |
| 3911 node: node); | 3913 node: node); |
| 3912 } | 3914 } |
| 3913 | 3915 |
| 3914 visitVariableDefinitions(VariableDefinitions node) { | 3916 visitVariableDefinitions(VariableDefinitions node) { |
| 3915 for (Link<Node> link = node.definitions.nodes; | 3917 for (Link<Node> link = node.definitions.nodes; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4307 // default case. | 4309 // default case. |
| 4308 expressionBlock.addSuccessor(block); | 4310 expressionBlock.addSuccessor(block); |
| 4309 hasDefault = true; | 4311 hasDefault = true; |
| 4310 } | 4312 } |
| 4311 open(block); | 4313 open(block); |
| 4312 localsHandler = new LocalsHandler.from(savedLocals); | 4314 localsHandler = new LocalsHandler.from(savedLocals); |
| 4313 visit(switchCase.statements); | 4315 visit(switchCase.statements); |
| 4314 if (!isAborted() && caseIterator.hasNext) { | 4316 if (!isAborted() && caseIterator.hasNext) { |
| 4315 pushInvokeHelper0(getFallThroughErrorElement, HType.UNKNOWN); | 4317 pushInvokeHelper0(getFallThroughErrorElement, HType.UNKNOWN); |
| 4316 HInstruction error = pop(); | 4318 HInstruction error = pop(); |
| 4317 close(new HThrow(error)); | 4319 close(new HThrow(error)).addSuccessor(graph.exit); |
| 4318 } | 4320 } |
| 4319 statements.add( | 4321 statements.add( |
| 4320 new HSubGraphBlockInformation(new SubGraph(block, lastOpenedBlock))); | 4322 new HSubGraphBlockInformation(new SubGraph(block, lastOpenedBlock))); |
| 4321 } | 4323 } |
| 4322 | 4324 |
| 4323 // Add a join-block if necessary. | 4325 // Add a join-block if necessary. |
| 4324 // We create [joinBlock] early, and then go through the cases that might | 4326 // We create [joinBlock] early, and then go through the cases that might |
| 4325 // want to jump to it. In each case, if we add [joinBlock] as a successor | 4327 // want to jump to it. In each case, if we add [joinBlock] as a successor |
| 4326 // of another block, we also add an element to [caseHandlers] that is used | 4328 // of another block, we also add an element to [caseHandlers] that is used |
| 4327 // to create the phis in [joinBlock]. | 4329 // to create the phis in [joinBlock]. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4424 // Called for the statements on all but the last case block. | 4426 // Called for the statements on all but the last case block. |
| 4425 // Ensures that a user expecting a fallthrough gets an error. | 4427 // Ensures that a user expecting a fallthrough gets an error. |
| 4426 void visitStatementsAndAbort() { | 4428 void visitStatementsAndAbort() { |
| 4427 visit(node.statements); | 4429 visit(node.statements); |
| 4428 if (!isAborted()) { | 4430 if (!isAborted()) { |
| 4429 compiler.reportWarning(node, 'Missing break at end of switch case'); | 4431 compiler.reportWarning(node, 'Missing break at end of switch case'); |
| 4430 Element element = | 4432 Element element = |
| 4431 compiler.findHelper(const SourceString("getFallThroughError")); | 4433 compiler.findHelper(const SourceString("getFallThroughError")); |
| 4432 pushInvokeHelper0(element, HType.UNKNOWN); | 4434 pushInvokeHelper0(element, HType.UNKNOWN); |
| 4433 HInstruction error = pop(); | 4435 HInstruction error = pop(); |
| 4434 close(new HThrow(error)); | 4436 close(new HThrow(error)).addSuccessor(graph.exit); |
| 4435 } | 4437 } |
| 4436 } | 4438 } |
| 4437 | 4439 |
| 4438 Link<Node> skipLabels(Link<Node> labelsAndCases) { | 4440 Link<Node> skipLabels(Link<Node> labelsAndCases) { |
| 4439 while (!labelsAndCases.isEmpty && labelsAndCases.head is Label) { | 4441 while (!labelsAndCases.isEmpty && labelsAndCases.head is Label) { |
| 4440 labelsAndCases = labelsAndCases.tail; | 4442 labelsAndCases = labelsAndCases.tail; |
| 4441 } | 4443 } |
| 4442 return labelsAndCases; | 4444 return labelsAndCases; |
| 4443 } | 4445 } |
| 4444 | 4446 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4640 pushInvokeHelper1( | 4642 pushInvokeHelper1( |
| 4641 backend.getTraceFromException(), exception, HType.UNKNOWN); | 4643 backend.getTraceFromException(), exception, HType.UNKNOWN); |
| 4642 HInstruction traceInstruction = pop(); | 4644 HInstruction traceInstruction = pop(); |
| 4643 localsHandler.updateLocal(elements[trace], traceInstruction); | 4645 localsHandler.updateLocal(elements[trace], traceInstruction); |
| 4644 } | 4646 } |
| 4645 visit(catchBlock); | 4647 visit(catchBlock); |
| 4646 } | 4648 } |
| 4647 | 4649 |
| 4648 void visitElse() { | 4650 void visitElse() { |
| 4649 if (link.isEmpty) { | 4651 if (link.isEmpty) { |
| 4650 close(new HThrow(exception, isRethrow: true)); | 4652 HBasicBlock block = close(new HThrow(exception, isRethrow: true)); |
| 4653 block.addSuccessor(graph.exit); | |
| 4651 } else { | 4654 } else { |
| 4652 CatchBlock newBlock = link.head; | 4655 CatchBlock newBlock = link.head; |
| 4653 handleIf(node, | 4656 handleIf(node, |
| 4654 () { pushCondition(newBlock); }, | 4657 () { pushCondition(newBlock); }, |
| 4655 visitThen, visitElse); | 4658 visitThen, visitElse); |
| 4656 } | 4659 } |
| 4657 } | 4660 } |
| 4658 | 4661 |
| 4659 CatchBlock firstBlock = link.head; | 4662 CatchBlock firstBlock = link.head; |
| 4660 handleIf(node, () { pushCondition(firstBlock); }, visitThen, visitElse); | 4663 handleIf(node, () { pushCondition(firstBlock); }, visitThen, visitElse); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 4682 addExitTrySuccessor(successor) { | 4685 addExitTrySuccessor(successor) { |
| 4683 if (successor == null) return; | 4686 if (successor == null) return; |
| 4684 // Iterate over all blocks created inside this try/catch, and | 4687 // Iterate over all blocks created inside this try/catch, and |
| 4685 // attach successor information to blocks that end with | 4688 // attach successor information to blocks that end with |
| 4686 // [HExitTry]. | 4689 // [HExitTry]. |
| 4687 for (int i = startTryBlock.id; i < successor.id; i++) { | 4690 for (int i = startTryBlock.id; i < successor.id; i++) { |
| 4688 HBasicBlock block = graph.blocks[i]; | 4691 HBasicBlock block = graph.blocks[i]; |
| 4689 var last = block.last; | 4692 var last = block.last; |
| 4690 if (last is HExitTry) { | 4693 if (last is HExitTry) { |
| 4691 block.addSuccessor(successor); | 4694 block.addSuccessor(successor); |
| 4692 } else if (last is HTry) { | |
| 4693 // Skip all blocks inside this nested try/catch. | |
| 4694 i = last.joinBlock.id; | |
| 4695 } | 4695 } |
| 4696 } | 4696 } |
| 4697 } | 4697 } |
| 4698 | 4698 |
| 4699 // Setup all successors. The entry block that contains the [HTry] | 4699 // Setup all successors. The entry block that contains the [HTry] |
| 4700 // has 1) the body, 2) the catch, 3) the finally, and 4) the exit | 4700 // has 1) the body, 2) the catch, 3) the finally, and 4) the exit |
| 4701 // blocks as successors. | 4701 // blocks as successors. |
| 4702 enterBlock.addSuccessor(startTryBlock); | 4702 enterBlock.addSuccessor(startTryBlock); |
| 4703 addOptionalSuccessor(enterBlock, startCatchBlock); | 4703 addOptionalSuccessor(enterBlock, startCatchBlock); |
| 4704 addOptionalSuccessor(enterBlock, startFinallyBlock); | 4704 addOptionalSuccessor(enterBlock, startFinallyBlock); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5162 new HSubGraphBlockInformation(elseBranch.graph)); | 5162 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5163 | 5163 |
| 5164 HBasicBlock conditionStartBlock = conditionBranch.block; | 5164 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5165 conditionStartBlock.setBlockFlow(info, joinBlock); | 5165 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5166 SubGraph conditionGraph = conditionBranch.graph; | 5166 SubGraph conditionGraph = conditionBranch.graph; |
| 5167 HIf branch = conditionGraph.end.last; | 5167 HIf branch = conditionGraph.end.last; |
| 5168 assert(branch is HIf); | 5168 assert(branch is HIf); |
| 5169 branch.blockInformation = conditionStartBlock.blockFlow; | 5169 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5170 } | 5170 } |
| 5171 } | 5171 } |
| OLD | NEW |