Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 70703002: Add constructors for JSArray (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
3792 bool isFixedList = false; 3791 bool isFixedList = false;
3793 3792
3794 TypeMask computeType(element) { 3793 TypeMask computeType(element) {
3795 Element originalElement = elements[send]; 3794 Element originalElement = elements[send];
3796 if (Elements.isFixedListConstructorCall(originalElement, send, compiler) 3795 if (Elements.isFixedListConstructorCall(originalElement, send, compiler)
3797 || Elements.isFilledListConstructorCall( 3796 || Elements.isFilledListConstructorCall(
3798 originalElement, send, compiler)) { 3797 originalElement, send, compiler)) {
3799 isListConstructor = true;
3800 isFixedList = true; 3798 isFixedList = true;
3801 TypeMask inferred = 3799 TypeMask inferred =
3802 TypeMaskFactory.inferredForNode(currentElement, send, compiler); 3800 TypeMaskFactory.inferredForNode(currentElement, send, compiler);
3803 return inferred.containsAll(compiler) 3801 return inferred.containsAll(compiler)
3804 ? backend.fixedArrayType 3802 ? backend.fixedArrayType
3805 : inferred; 3803 : inferred;
3806 } else if (Elements.isGrowableListConstructorCall( 3804 } else if (Elements.isGrowableListConstructorCall(
3807 originalElement, send, compiler)) { 3805 originalElement, send, compiler)) {
3808 isListConstructor = true;
3809 TypeMask inferred = 3806 TypeMask inferred =
3810 TypeMaskFactory.inferredForNode(currentElement, send, compiler); 3807 TypeMaskFactory.inferredForNode(currentElement, send, compiler);
3811 return inferred.containsAll(compiler) 3808 return inferred.containsAll(compiler)
3812 ? backend.extendableArrayType 3809 ? backend.extendableArrayType
3813 : inferred; 3810 : inferred;
3814 } else if (Elements.isConstructorOfTypedArraySubclass( 3811 } else if (Elements.isConstructorOfTypedArraySubclass(
3815 originalElement, compiler)) { 3812 originalElement, compiler)) {
3816 isFixedList = true; 3813 isFixedList = true;
3817 TypeMask inferred = 3814 TypeMask inferred =
3818 TypeMaskFactory.inferredForNode(currentElement, send, compiler); 3815 TypeMaskFactory.inferredForNode(currentElement, send, compiler);
(...skipping 10 matching lines...) Expand all
3829 } 3826 }
3830 } 3827 }
3831 3828
3832 Element constructor = elements[send]; 3829 Element constructor = elements[send];
3833 Selector selector = elements.getSelector(send); 3830 Selector selector = elements.getSelector(send);
3834 FunctionElement functionElement = constructor; 3831 FunctionElement functionElement = constructor;
3835 constructor = functionElement.redirectionTarget; 3832 constructor = functionElement.redirectionTarget;
3836 3833
3837 final bool isSymbolConstructor = 3834 final bool isSymbolConstructor =
3838 functionElement == compiler.symbolConstructor; 3835 functionElement == compiler.symbolConstructor;
3836 final bool isJSArrayTypedConstructor =
3837 functionElement == backend.jsArrayTypedConstructor;
3839 3838
3840 if (isSymbolConstructor) { 3839 if (isSymbolConstructor) {
3841 constructor = compiler.symbolValidatedConstructor; 3840 constructor = compiler.symbolValidatedConstructor;
3842 assert(invariant(send, constructor != null, 3841 assert(invariant(send, constructor != null,
3843 message: 'Constructor Symbol.validated is missing')); 3842 message: 'Constructor Symbol.validated is missing'));
3844 selector = compiler.symbolValidatedConstructorSelector; 3843 selector = compiler.symbolValidatedConstructorSelector;
3845 assert(invariant(send, selector != null, 3844 assert(invariant(send, selector != null,
3846 message: 'Constructor Symbol.validated is missing')); 3845 message: 'Constructor Symbol.validated is missing'));
3847 } 3846 }
3848 3847
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3894 3893
3895 if (isFixedList) { 3894 if (isFixedList) {
3896 JavaScriptItemCompilationContext context = work.compilationContext; 3895 JavaScriptItemCompilationContext context = work.compilationContext;
3897 context.allocatedFixedLists.add(newInstance); 3896 context.allocatedFixedLists.add(newInstance);
3898 } 3897 }
3899 3898
3900 // The List constructor forwards to a Dart static method that does 3899 // The List constructor forwards to a Dart static method that does
3901 // not know about the type argument. Therefore we special case 3900 // not know about the type argument. Therefore we special case
3902 // this constructor to have the setRuntimeTypeInfo called where 3901 // this constructor to have the setRuntimeTypeInfo called where
3903 // the 'new' is done. 3902 // the 'new' is done.
3904 if (isListConstructor && backend.classNeedsRti(compiler.listClass)) { 3903 if (isJSArrayTypedConstructor &&
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/backend.dart ('k') | sdk/lib/_internal/lib/core_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698