| 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 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 | 2695 |
| 2696 visitOperatorSend(node) { | 2696 visitOperatorSend(node) { |
| 2697 assert(node.selector is Operator); | 2697 assert(node.selector is Operator); |
| 2698 if (!methodInterceptionEnabled) { | 2698 if (!methodInterceptionEnabled) { |
| 2699 visitDynamicSend(node); | 2699 visitDynamicSend(node); |
| 2700 return; | 2700 return; |
| 2701 } | 2701 } |
| 2702 | 2702 |
| 2703 Operator op = node.selector; | 2703 Operator op = node.selector; |
| 2704 if (const SourceString("[]") == op.source) { | 2704 if (const SourceString("[]") == op.source) { |
| 2705 visitDynamicSend(node); | 2705 HStatic target = new HStatic(interceptors.getIndexInterceptor()); |
| 2706 add(target); |
| 2707 visit(node.receiver); |
| 2708 HInstruction receiver = pop(); |
| 2709 visit(node.argumentsNode); |
| 2710 HInstruction index = pop(); |
| 2711 push(new HIndex(target, receiver, index)); |
| 2706 } else if (const SourceString("&&") == op.source || | 2712 } else if (const SourceString("&&") == op.source || |
| 2707 const SourceString("||") == op.source) { | 2713 const SourceString("||") == op.source) { |
| 2708 visitLogicalAndOr(node, op); | 2714 visitLogicalAndOr(node, op); |
| 2709 } else if (const SourceString("!") == op.source) { | 2715 } else if (const SourceString("!") == op.source) { |
| 2710 visitLogicalNot(node); | 2716 visitLogicalNot(node); |
| 2711 } else if (node.argumentsNode is Prefix) { | 2717 } else if (node.argumentsNode is Prefix) { |
| 2712 visitUnary(node, op); | 2718 visitUnary(node, op); |
| 2713 } else if (const SourceString("is") == op.source) { | 2719 } else if (const SourceString("is") == op.source) { |
| 2714 visit(node.receiver); | 2720 visit(node.receiver); |
| 2715 HInstruction expression = pop(); | 2721 HInstruction expression = pop(); |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3579 String reasons = fetchReasonsFromMalformedType(type); | 3585 String reasons = fetchReasonsFromMalformedType(type); |
| 3580 // TODO(johnniwinther): Change to resemble type errors from bounds check | 3586 // TODO(johnniwinther): Change to resemble type errors from bounds check |
| 3581 // on type arguments. | 3587 // on type arguments. |
| 3582 generateRuntimeError(node, '$type is malformed: $reasons'); | 3588 generateRuntimeError(node, '$type is malformed: $reasons'); |
| 3583 } else { | 3589 } else { |
| 3584 visitNewSend(node.send, type); | 3590 visitNewSend(node.send, type); |
| 3585 } | 3591 } |
| 3586 } | 3592 } |
| 3587 } | 3593 } |
| 3588 | 3594 |
| 3589 HInvokeDynamicMethod buildInvokeDynamicWithOneArgument( | |
| 3590 Node node, Selector selector, HInstruction receiver, HInstruction arg0) { | |
| 3591 Set<ClassElement> interceptedClasses = | |
| 3592 getInterceptedClassesOn(node, selector); | |
| 3593 List<HInstruction> inputs = <HInstruction>[]; | |
| 3594 if (interceptedClasses != null) { | |
| 3595 inputs.add(invokeInterceptor(interceptedClasses, receiver, node)); | |
| 3596 } | |
| 3597 inputs.add(receiver); | |
| 3598 inputs.add(arg0); | |
| 3599 return new HInvokeDynamicMethod(selector, inputs); | |
| 3600 } | |
| 3601 | |
| 3602 visitSendSet(SendSet node) { | 3595 visitSendSet(SendSet node) { |
| 3603 Element element = elements[node]; | 3596 Element element = elements[node]; |
| 3604 if (!Elements.isUnresolved(element) && element.impliesType()) { | 3597 if (!Elements.isUnresolved(element) && element.impliesType()) { |
| 3605 Identifier selector = node.selector; | 3598 Identifier selector = node.selector; |
| 3606 generateThrowNoSuchMethod(node, selector.source.slowToString(), | 3599 generateThrowNoSuchMethod(node, selector.source.slowToString(), |
| 3607 argumentNodes: node.arguments); | 3600 argumentNodes: node.arguments); |
| 3608 return; | 3601 return; |
| 3609 } | 3602 } |
| 3610 Operator op = node.assignmentOperator; | 3603 Operator op = node.assignmentOperator; |
| 3611 if (node.isSuperCall) { | 3604 if (node.isSuperCall) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3643 // Compound assignments are considered as being prefix. | 3636 // Compound assignments are considered as being prefix. |
| 3644 bool isPrefix = !node.isPostfix; | 3637 bool isPrefix = !node.isPostfix; |
| 3645 Element getter = elements[node.selector]; | 3638 Element getter = elements[node.selector]; |
| 3646 if (isCompoundAssignment) { | 3639 if (isCompoundAssignment) { |
| 3647 value = pop(); | 3640 value = pop(); |
| 3648 index = pop(); | 3641 index = pop(); |
| 3649 } else { | 3642 } else { |
| 3650 index = pop(); | 3643 index = pop(); |
| 3651 value = graph.addConstantInt(1, constantSystem); | 3644 value = graph.addConstantInt(1, constantSystem); |
| 3652 } | 3645 } |
| 3653 | 3646 HStatic indexMethod = new HStatic(interceptors.getIndexInterceptor()); |
| 3654 HInvokeDynamicMethod left = buildInvokeDynamicWithOneArgument( | 3647 add(indexMethod); |
| 3655 node, new Selector.index(), receiver, index); | 3648 HInstruction left = new HIndex(indexMethod, receiver, index); |
| 3656 add(left); | 3649 add(left); |
| 3657 Element opElement = elements[op]; | 3650 Element opElement = elements[op]; |
| 3658 visitBinary(left, op, value); | 3651 visitBinary(left, op, value); |
| 3659 value = pop(); | 3652 value = pop(); |
| 3660 HInstruction assign = new HIndexAssign( | 3653 HInstruction assign = new HIndexAssign( |
| 3661 target, receiver, index, value); | 3654 target, receiver, index, value); |
| 3662 add(assign); | 3655 add(assign); |
| 3663 if (isPrefix) { | 3656 if (isPrefix) { |
| 3664 stack.add(value); | 3657 stack.add(value); |
| 3665 } else { | 3658 } else { |
| (...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5039 new HSubGraphBlockInformation(elseBranch.graph)); | 5032 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5040 | 5033 |
| 5041 HBasicBlock conditionStartBlock = conditionBranch.block; | 5034 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5042 conditionStartBlock.setBlockFlow(info, joinBlock); | 5035 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5043 SubGraph conditionGraph = conditionBranch.graph; | 5036 SubGraph conditionGraph = conditionBranch.graph; |
| 5044 HIf branch = conditionGraph.end.last; | 5037 HIf branch = conditionGraph.end.last; |
| 5045 assert(branch is HIf); | 5038 assert(branch is HIf); |
| 5046 branch.blockInformation = conditionStartBlock.blockFlow; | 5039 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5047 } | 5040 } |
| 5048 } | 5041 } |
| OLD | NEW |