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 3770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3781 pushInvokeStatic( | 3781 pushInvokeStatic( |
3782 null, | 3782 null, |
3783 typeInfoSetterElement, | 3783 typeInfoSetterElement, |
3784 <HInstruction>[newObject, typeInfo], | 3784 <HInstruction>[newObject, typeInfo], |
3785 backend.dynamicType); | 3785 backend.dynamicType); |
3786 pop(); | 3786 pop(); |
3787 } | 3787 } |
3788 | 3788 |
3789 handleNewSend(NewExpression node) { | 3789 handleNewSend(NewExpression node) { |
3790 Send send = node.send; | 3790 Send send = node.send; |
| 3791 bool isListConstructor = false; |
3791 bool isFixedList = false; | 3792 bool isFixedList = false; |
3792 | 3793 |
3793 TypeMask computeType(element) { | 3794 TypeMask computeType(element) { |
3794 Element originalElement = elements[send]; | 3795 Element originalElement = elements[send]; |
3795 if (Elements.isFixedListConstructorCall(originalElement, send, compiler) | 3796 if (Elements.isFixedListConstructorCall(originalElement, send, compiler) |
3796 || Elements.isFilledListConstructorCall( | 3797 || Elements.isFilledListConstructorCall( |
3797 originalElement, send, compiler)) { | 3798 originalElement, send, compiler)) { |
| 3799 isListConstructor = true; |
3798 isFixedList = true; | 3800 isFixedList = true; |
3799 TypeMask inferred = | 3801 TypeMask inferred = |
3800 TypeMaskFactory.inferredForNode(currentElement, send, compiler); | 3802 TypeMaskFactory.inferredForNode(currentElement, send, compiler); |
3801 return inferred.containsAll(compiler) | 3803 return inferred.containsAll(compiler) |
3802 ? backend.fixedArrayType | 3804 ? backend.fixedArrayType |
3803 : inferred; | 3805 : inferred; |
3804 } else if (Elements.isGrowableListConstructorCall( | 3806 } else if (Elements.isGrowableListConstructorCall( |
3805 originalElement, send, compiler)) { | 3807 originalElement, send, compiler)) { |
| 3808 isListConstructor = true; |
3806 TypeMask inferred = | 3809 TypeMask inferred = |
3807 TypeMaskFactory.inferredForNode(currentElement, send, compiler); | 3810 TypeMaskFactory.inferredForNode(currentElement, send, compiler); |
3808 return inferred.containsAll(compiler) | 3811 return inferred.containsAll(compiler) |
3809 ? backend.extendableArrayType | 3812 ? backend.extendableArrayType |
3810 : inferred; | 3813 : inferred; |
3811 } else if (Elements.isConstructorOfTypedArraySubclass( | 3814 } else if (Elements.isConstructorOfTypedArraySubclass( |
3812 originalElement, compiler)) { | 3815 originalElement, compiler)) { |
3813 isFixedList = true; | 3816 isFixedList = true; |
3814 TypeMask inferred = | 3817 TypeMask inferred = |
3815 TypeMaskFactory.inferredForNode(currentElement, send, compiler); | 3818 TypeMaskFactory.inferredForNode(currentElement, send, compiler); |
(...skipping 10 matching lines...) Expand all Loading... |
3826 } | 3829 } |
3827 } | 3830 } |
3828 | 3831 |
3829 Element constructor = elements[send]; | 3832 Element constructor = elements[send]; |
3830 Selector selector = elements.getSelector(send); | 3833 Selector selector = elements.getSelector(send); |
3831 FunctionElement functionElement = constructor; | 3834 FunctionElement functionElement = constructor; |
3832 constructor = functionElement.redirectionTarget; | 3835 constructor = functionElement.redirectionTarget; |
3833 | 3836 |
3834 final bool isSymbolConstructor = | 3837 final bool isSymbolConstructor = |
3835 functionElement == compiler.symbolConstructor; | 3838 functionElement == compiler.symbolConstructor; |
3836 final bool isJSArrayTypedConstructor = | |
3837 functionElement == backend.jsArrayTypedConstructor; | |
3838 | 3839 |
3839 if (isSymbolConstructor) { | 3840 if (isSymbolConstructor) { |
3840 constructor = compiler.symbolValidatedConstructor; | 3841 constructor = compiler.symbolValidatedConstructor; |
3841 assert(invariant(send, constructor != null, | 3842 assert(invariant(send, constructor != null, |
3842 message: 'Constructor Symbol.validated is missing')); | 3843 message: 'Constructor Symbol.validated is missing')); |
3843 selector = compiler.symbolValidatedConstructorSelector; | 3844 selector = compiler.symbolValidatedConstructorSelector; |
3844 assert(invariant(send, selector != null, | 3845 assert(invariant(send, selector != null, |
3845 message: 'Constructor Symbol.validated is missing')); | 3846 message: 'Constructor Symbol.validated is missing')); |
3846 } | 3847 } |
3847 | 3848 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3893 | 3894 |
3894 if (isFixedList) { | 3895 if (isFixedList) { |
3895 JavaScriptItemCompilationContext context = work.compilationContext; | 3896 JavaScriptItemCompilationContext context = work.compilationContext; |
3896 context.allocatedFixedLists.add(newInstance); | 3897 context.allocatedFixedLists.add(newInstance); |
3897 } | 3898 } |
3898 | 3899 |
3899 // The List constructor forwards to a Dart static method that does | 3900 // The List constructor forwards to a Dart static method that does |
3900 // not know about the type argument. Therefore we special case | 3901 // not know about the type argument. Therefore we special case |
3901 // this constructor to have the setRuntimeTypeInfo called where | 3902 // this constructor to have the setRuntimeTypeInfo called where |
3902 // the 'new' is done. | 3903 // the 'new' is done. |
3903 if (isJSArrayTypedConstructor && | 3904 if (isListConstructor && backend.classNeedsRti(compiler.listClass)) { |
3904 backend.classNeedsRti(compiler.listClass)) { | |
3905 handleListConstructor(type, send, newInstance); | 3905 handleListConstructor(type, send, newInstance); |
3906 } | 3906 } |
3907 | 3907 |
3908 // Finally, if we called a redirecting factory constructor, check the type. | 3908 // Finally, if we called a redirecting factory constructor, check the type. |
3909 if (isRedirected) { | 3909 if (isRedirected) { |
3910 HInstruction checked = potentiallyCheckType(newInstance, type); | 3910 HInstruction checked = potentiallyCheckType(newInstance, type); |
3911 if (checked != newInstance) { | 3911 if (checked != newInstance) { |
3912 pop(); | 3912 pop(); |
3913 stack.add(checked); | 3913 stack.add(checked); |
3914 } | 3914 } |
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5889 new HSubGraphBlockInformation(elseBranch.graph)); | 5889 new HSubGraphBlockInformation(elseBranch.graph)); |
5890 | 5890 |
5891 HBasicBlock conditionStartBlock = conditionBranch.block; | 5891 HBasicBlock conditionStartBlock = conditionBranch.block; |
5892 conditionStartBlock.setBlockFlow(info, joinBlock); | 5892 conditionStartBlock.setBlockFlow(info, joinBlock); |
5893 SubGraph conditionGraph = conditionBranch.graph; | 5893 SubGraph conditionGraph = conditionBranch.graph; |
5894 HIf branch = conditionGraph.end.last; | 5894 HIf branch = conditionGraph.end.last; |
5895 assert(branch is HIf); | 5895 assert(branch is HIf); |
5896 branch.blockInformation = conditionStartBlock.blockFlow; | 5896 branch.blockInformation = conditionStartBlock.blockFlow; |
5897 } | 5897 } |
5898 } | 5898 } |
OLD | NEW |