| 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 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 | 2017 |
| 2018 void push(HInstruction instruction) { | 2018 void push(HInstruction instruction) { |
| 2019 add(instruction); | 2019 add(instruction); |
| 2020 stack.add(instruction); | 2020 stack.add(instruction); |
| 2021 } | 2021 } |
| 2022 | 2022 |
| 2023 void pushWithPosition(HInstruction instruction, Node node) { | 2023 void pushWithPosition(HInstruction instruction, Node node) { |
| 2024 push(attachPosition(instruction, node)); | 2024 push(attachPosition(instruction, node)); |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 HInstruction peek() => stack.last; |
| 2028 |
| 2027 HInstruction pop() { | 2029 HInstruction pop() { |
| 2028 return stack.removeLast(); | 2030 return stack.removeLast(); |
| 2029 } | 2031 } |
| 2030 | 2032 |
| 2031 void dup() { | 2033 void dup() { |
| 2032 stack.add(stack.last); | 2034 stack.add(stack.last); |
| 2033 } | 2035 } |
| 2034 | 2036 |
| 2035 HInstruction popBoolified() { | 2037 HInstruction popBoolified() { |
| 2036 HInstruction value = pop(); | 2038 HInstruction value = pop(); |
| (...skipping 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4494 HInstruction initialValue = graph.addConstantNull(compiler); | 4496 HInstruction initialValue = graph.addConstantNull(compiler); |
| 4495 localsHandler.updateLocal(elements[definition], initialValue); | 4497 localsHandler.updateLocal(elements[definition], initialValue); |
| 4496 } else { | 4498 } else { |
| 4497 assert(definition is SendSet); | 4499 assert(definition is SendSet); |
| 4498 visitSendSet(definition); | 4500 visitSendSet(definition); |
| 4499 pop(); // Discard value. | 4501 pop(); // Discard value. |
| 4500 } | 4502 } |
| 4501 } | 4503 } |
| 4502 } | 4504 } |
| 4503 | 4505 |
| 4506 void setRtiIfNeeded(HInstruction object, Node node) { |
| 4507 InterfaceType type = elements.getType(node); |
| 4508 if (!backend.classNeedsRti(type.element)) return; |
| 4509 List<HInstruction> arguments = <HInstruction>[]; |
| 4510 for (DartType argument in type.typeArguments) { |
| 4511 arguments.add(analyzeTypeArgument(argument)); |
| 4512 } |
| 4513 callSetRuntimeTypeInfo(type.element, arguments, object); |
| 4514 } |
| 4515 |
| 4504 visitLiteralList(LiteralList node) { | 4516 visitLiteralList(LiteralList node) { |
| 4505 HInstruction instruction; | 4517 HInstruction instruction; |
| 4506 | 4518 |
| 4507 if (node.isConst()) { | 4519 if (node.isConst()) { |
| 4508 instruction = addConstant(node); | 4520 instruction = addConstant(node); |
| 4509 } else { | 4521 } else { |
| 4510 List<HInstruction> inputs = <HInstruction>[]; | 4522 List<HInstruction> inputs = <HInstruction>[]; |
| 4511 for (Link<Node> link = node.elements.nodes; | 4523 for (Link<Node> link = node.elements.nodes; |
| 4512 !link.isEmpty; | 4524 !link.isEmpty; |
| 4513 link = link.tail) { | 4525 link = link.tail) { |
| 4514 visit(link.head); | 4526 visit(link.head); |
| 4515 inputs.add(pop()); | 4527 inputs.add(pop()); |
| 4516 } | 4528 } |
| 4517 instruction = buildLiteralList(inputs); | 4529 instruction = buildLiteralList(inputs); |
| 4518 add(instruction); | 4530 add(instruction); |
| 4531 setRtiIfNeeded(instruction, node); |
| 4519 } | 4532 } |
| 4520 | 4533 |
| 4521 HType type = new HType.inferredForNode(currentElement, node, compiler); | 4534 HType type = new HType.inferredForNode(currentElement, node, compiler); |
| 4522 if (!type.containsAll(compiler)) instruction.instructionType = type; | 4535 if (!type.containsAll(compiler)) instruction.instructionType = type; |
| 4523 stack.add(instruction); | 4536 stack.add(instruction); |
| 4524 } | 4537 } |
| 4525 | 4538 |
| 4526 visitConditional(Conditional node) { | 4539 visitConditional(Conditional node) { |
| 4527 SsaBranchBuilder brancher = new SsaBranchBuilder(this, node); | 4540 SsaBranchBuilder brancher = new SsaBranchBuilder(this, node); |
| 4528 brancher.handleConditional(() => visit(node.condition), | 4541 brancher.handleConditional(() => visit(node.condition), |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4710 !link.isEmpty; | 4723 !link.isEmpty; |
| 4711 link = link.tail) { | 4724 link = link.tail) { |
| 4712 visit(link.head); | 4725 visit(link.head); |
| 4713 inputs.add(pop()); | 4726 inputs.add(pop()); |
| 4714 inputs.add(pop()); | 4727 inputs.add(pop()); |
| 4715 } | 4728 } |
| 4716 HLiteralList keyValuePairs = buildLiteralList(inputs); | 4729 HLiteralList keyValuePairs = buildLiteralList(inputs); |
| 4717 add(keyValuePairs); | 4730 add(keyValuePairs); |
| 4718 HType mapType = new HType.nonNullSubtype(backend.mapLiteralClass, compiler); | 4731 HType mapType = new HType.nonNullSubtype(backend.mapLiteralClass, compiler); |
| 4719 pushInvokeStatic(node, backend.getMapMaker(), [keyValuePairs], mapType); | 4732 pushInvokeStatic(node, backend.getMapMaker(), [keyValuePairs], mapType); |
| 4733 setRtiIfNeeded(peek(), node); |
| 4720 } | 4734 } |
| 4721 | 4735 |
| 4722 visitLiteralMapEntry(LiteralMapEntry node) { | 4736 visitLiteralMapEntry(LiteralMapEntry node) { |
| 4723 visit(node.value); | 4737 visit(node.value); |
| 4724 visit(node.key); | 4738 visit(node.key); |
| 4725 } | 4739 } |
| 4726 | 4740 |
| 4727 visitNamedArgument(NamedArgument node) { | 4741 visitNamedArgument(NamedArgument node) { |
| 4728 visit(node.expression); | 4742 visit(node.expression); |
| 4729 } | 4743 } |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5726 new HSubGraphBlockInformation(elseBranch.graph)); | 5740 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5727 | 5741 |
| 5728 HBasicBlock conditionStartBlock = conditionBranch.block; | 5742 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5729 conditionStartBlock.setBlockFlow(info, joinBlock); | 5743 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5730 SubGraph conditionGraph = conditionBranch.graph; | 5744 SubGraph conditionGraph = conditionBranch.graph; |
| 5731 HIf branch = conditionGraph.end.last; | 5745 HIf branch = conditionGraph.end.last; |
| 5732 assert(branch is HIf); | 5746 assert(branch is HIf); |
| 5733 branch.blockInformation = conditionStartBlock.blockFlow; | 5747 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5734 } | 5748 } |
| 5735 } | 5749 } |
| OLD | NEW |