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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 87783003: Add UInt32 and UInt31 types to better infer bit operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ClassElement jsBoolClass; 187 ClassElement jsBoolClass;
188 ClassElement jsPlainJavaScriptObjectClass; 188 ClassElement jsPlainJavaScriptObjectClass;
189 ClassElement jsUnknownJavaScriptObjectClass; 189 ClassElement jsUnknownJavaScriptObjectClass;
190 190
191 ClassElement jsIndexableClass; 191 ClassElement jsIndexableClass;
192 ClassElement jsMutableIndexableClass; 192 ClassElement jsMutableIndexableClass;
193 193
194 ClassElement jsMutableArrayClass; 194 ClassElement jsMutableArrayClass;
195 ClassElement jsFixedArrayClass; 195 ClassElement jsFixedArrayClass;
196 ClassElement jsExtendableArrayClass; 196 ClassElement jsExtendableArrayClass;
197 ClassElement jsUInt32Class;
198 ClassElement jsUInt31Class;
197 199
198 Element jsIndexableLength; 200 Element jsIndexableLength;
199 Element jsArrayTypedConstructor; 201 Element jsArrayTypedConstructor;
200 Element jsArrayRemoveLast; 202 Element jsArrayRemoveLast;
201 Element jsArrayAdd; 203 Element jsArrayAdd;
202 Element jsStringSplit; 204 Element jsStringSplit;
203 Element jsStringToString; 205 Element jsStringToString;
204 Element jsStringOperatorAdd; 206 Element jsStringOperatorAdd;
205 Element objectEquals; 207 Element objectEquals;
206 208
(...skipping 13 matching lines...) Expand all
220 * This element is a top-level variable (in generated output) that the 222 * This element is a top-level variable (in generated output) that the
221 * compiler initializes to a datastructure used to map from a Type to the 223 * compiler initializes to a datastructure used to map from a Type to the
222 * interceptor. See declaration of `mapTypeToInterceptor` in 224 * interceptor. See declaration of `mapTypeToInterceptor` in
223 * `interceptors.dart`. 225 * `interceptors.dart`.
224 */ 226 */
225 Element mapTypeToInterceptor; 227 Element mapTypeToInterceptor;
226 228
227 TypeMask get stringType => compiler.typesTask.stringType; 229 TypeMask get stringType => compiler.typesTask.stringType;
228 TypeMask get doubleType => compiler.typesTask.doubleType; 230 TypeMask get doubleType => compiler.typesTask.doubleType;
229 TypeMask get intType => compiler.typesTask.intType; 231 TypeMask get intType => compiler.typesTask.intType;
232 TypeMask get uint32Type => compiler.typesTask.uint32Type;
233 TypeMask get uint31Type => compiler.typesTask.uint31Type;
230 TypeMask get numType => compiler.typesTask.numType; 234 TypeMask get numType => compiler.typesTask.numType;
231 TypeMask get boolType => compiler.typesTask.boolType; 235 TypeMask get boolType => compiler.typesTask.boolType;
232 TypeMask get dynamicType => compiler.typesTask.dynamicType; 236 TypeMask get dynamicType => compiler.typesTask.dynamicType;
233 TypeMask get nullType => compiler.typesTask.nullType; 237 TypeMask get nullType => compiler.typesTask.nullType;
234 TypeMask get emptyType => const TypeMask.nonNullEmpty(); 238 TypeMask get emptyType => const TypeMask.nonNullEmpty();
235 TypeMask indexablePrimitiveType; 239 TypeMask indexablePrimitiveType;
236 TypeMask readableArrayType; 240 TypeMask readableArrayType;
237 TypeMask mutableArrayType; 241 TypeMask mutableArrayType;
238 TypeMask fixedArrayType; 242 TypeMask fixedArrayType;
239 TypeMask extendableArrayType; 243 TypeMask extendableArrayType;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 inlineCache.markAsNonInlinable(getInterceptorMethod, insideLoop: true); 573 inlineCache.markAsNonInlinable(getInterceptorMethod, insideLoop: true);
570 574
571 List<ClassElement> classes = [ 575 List<ClassElement> classes = [
572 jsInterceptorClass = 576 jsInterceptorClass =
573 compiler.findInterceptor('Interceptor'), 577 compiler.findInterceptor('Interceptor'),
574 jsStringClass = compiler.findInterceptor('JSString'), 578 jsStringClass = compiler.findInterceptor('JSString'),
575 jsArrayClass = compiler.findInterceptor('JSArray'), 579 jsArrayClass = compiler.findInterceptor('JSArray'),
576 // The int class must be before the double class, because the 580 // The int class must be before the double class, because the
577 // emitter relies on this list for the order of type checks. 581 // emitter relies on this list for the order of type checks.
578 jsIntClass = compiler.findInterceptor('JSInt'), 582 jsIntClass = compiler.findInterceptor('JSInt'),
583 jsUInt32Class = compiler.findInterceptor('JSUInt32'),
584 jsUInt31Class = compiler.findInterceptor('JSUInt31'),
579 jsDoubleClass = compiler.findInterceptor('JSDouble'), 585 jsDoubleClass = compiler.findInterceptor('JSDouble'),
580 jsNumberClass = compiler.findInterceptor('JSNumber'), 586 jsNumberClass = compiler.findInterceptor('JSNumber'),
581 jsNullClass = compiler.findInterceptor('JSNull'), 587 jsNullClass = compiler.findInterceptor('JSNull'),
582 jsBoolClass = compiler.findInterceptor('JSBool'), 588 jsBoolClass = compiler.findInterceptor('JSBool'),
583 jsMutableArrayClass = compiler.findInterceptor('JSMutableArray'), 589 jsMutableArrayClass = compiler.findInterceptor('JSMutableArray'),
584 jsFixedArrayClass = compiler.findInterceptor('JSFixedArray'), 590 jsFixedArrayClass = compiler.findInterceptor('JSFixedArray'),
585 jsExtendableArrayClass = compiler.findInterceptor('JSExtendableArray'), 591 jsExtendableArrayClass = compiler.findInterceptor('JSExtendableArray'),
586 jsPlainJavaScriptObjectClass = 592 jsPlainJavaScriptObjectClass =
587 compiler.findInterceptor('PlainJavaScriptObject'), 593 compiler.findInterceptor('PlainJavaScriptObject'),
588 jsUnknownJavaScriptObjectClass = 594 jsUnknownJavaScriptObjectClass =
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 } else if (cls == compiler.listClass 846 } else if (cls == compiler.listClass
841 || cls == jsArrayClass 847 || cls == jsArrayClass
842 || cls == jsFixedArrayClass 848 || cls == jsFixedArrayClass
843 || cls == jsExtendableArrayClass) { 849 || cls == jsExtendableArrayClass) {
844 addInterceptors(jsArrayClass, enqueuer, elements); 850 addInterceptors(jsArrayClass, enqueuer, elements);
845 addInterceptors(jsMutableArrayClass, enqueuer, elements); 851 addInterceptors(jsMutableArrayClass, enqueuer, elements);
846 addInterceptors(jsFixedArrayClass, enqueuer, elements); 852 addInterceptors(jsFixedArrayClass, enqueuer, elements);
847 addInterceptors(jsExtendableArrayClass, enqueuer, elements); 853 addInterceptors(jsExtendableArrayClass, enqueuer, elements);
848 } else if (cls == compiler.intClass || cls == jsIntClass) { 854 } else if (cls == compiler.intClass || cls == jsIntClass) {
849 addInterceptors(jsIntClass, enqueuer, elements); 855 addInterceptors(jsIntClass, enqueuer, elements);
856 addInterceptors(jsUInt32Class, enqueuer, elements);
857 addInterceptors(jsUInt31Class, enqueuer, elements);
850 addInterceptors(jsNumberClass, enqueuer, elements); 858 addInterceptors(jsNumberClass, enqueuer, elements);
851 } else if (cls == compiler.doubleClass || cls == jsDoubleClass) { 859 } else if (cls == compiler.doubleClass || cls == jsDoubleClass) {
852 addInterceptors(jsDoubleClass, enqueuer, elements); 860 addInterceptors(jsDoubleClass, enqueuer, elements);
853 addInterceptors(jsNumberClass, enqueuer, elements); 861 addInterceptors(jsNumberClass, enqueuer, elements);
854 } else if (cls == compiler.boolClass || cls == jsBoolClass) { 862 } else if (cls == compiler.boolClass || cls == jsBoolClass) {
855 addInterceptors(jsBoolClass, enqueuer, elements); 863 addInterceptors(jsBoolClass, enqueuer, elements);
856 } else if (cls == compiler.nullClass || cls == jsNullClass) { 864 } else if (cls == compiler.nullClass || cls == jsNullClass) {
857 addInterceptors(jsNullClass, enqueuer, elements); 865 addInterceptors(jsNullClass, enqueuer, elements);
858 } else if (cls == compiler.numClass || cls == jsNumberClass) { 866 } else if (cls == compiler.numClass || cls == jsNumberClass) {
859 addInterceptors(jsIntClass, enqueuer, elements); 867 addInterceptors(jsIntClass, enqueuer, elements);
868 addInterceptors(jsUInt32Class, enqueuer, elements);
869 addInterceptors(jsUInt31Class, enqueuer, elements);
860 addInterceptors(jsDoubleClass, enqueuer, elements); 870 addInterceptors(jsDoubleClass, enqueuer, elements);
861 addInterceptors(jsNumberClass, enqueuer, elements); 871 addInterceptors(jsNumberClass, enqueuer, elements);
862 } else if (cls == jsPlainJavaScriptObjectClass) { 872 } else if (cls == jsPlainJavaScriptObjectClass) {
863 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, elements); 873 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, elements);
864 } else if (cls == jsUnknownJavaScriptObjectClass) { 874 } else if (cls == jsUnknownJavaScriptObjectClass) {
865 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, elements); 875 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, elements);
866 } else if (Elements.isNativeOrExtendsNative(cls)) { 876 } else if (Elements.isNativeOrExtendsNative(cls)) {
867 addInterceptorsForNativeClassMembers(cls, enqueuer); 877 addInterceptorsForNativeClassMembers(cls, enqueuer);
868 } else if (cls == jsIndexingBehaviorInterface) { 878 } else if (cls == jsIndexingBehaviorInterface) {
869 // These two helpers are used by the emitter and the codegen. 879 // These two helpers are used by the emitter and the codegen.
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 } else if (element == jsNumberClass || element == compiler.numClass) { 1418 } else if (element == jsNumberClass || element == compiler.numClass) {
1409 if (nativeCheckOnly) return null; 1419 if (nativeCheckOnly) return null;
1410 return typeCast 1420 return typeCast
1411 ? 'numTypeCast' 1421 ? 'numTypeCast'
1412 : 'numTypeCheck'; 1422 : 'numTypeCheck';
1413 } else if (element == jsBoolClass || element == compiler.boolClass) { 1423 } else if (element == jsBoolClass || element == compiler.boolClass) {
1414 if (nativeCheckOnly) return null; 1424 if (nativeCheckOnly) return null;
1415 return typeCast 1425 return typeCast
1416 ? 'boolTypeCast' 1426 ? 'boolTypeCast'
1417 : 'boolTypeCheck'; 1427 : 'boolTypeCheck';
1418 } else if (element == jsIntClass || element == compiler.intClass) { 1428 } else if (element == jsIntClass || element == compiler.intClass
1429 || element == jsUInt32Class || element == jsUInt31Class) {
1419 if (nativeCheckOnly) return null; 1430 if (nativeCheckOnly) return null;
1420 return typeCast 1431 return typeCast
1421 ? 'intTypeCast' 1432 ? 'intTypeCast'
1422 : 'intTypeCheck'; 1433 : 'intTypeCheck';
1423 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { 1434 } else if (Elements.isNumberOrStringSupertype(element, compiler)) {
1424 if (nativeCheck) { 1435 if (nativeCheck) {
1425 return typeCast 1436 return typeCast
1426 ? 'numberOrStringSuperNativeTypeCast' 1437 ? 'numberOrStringSuperNativeTypeCast'
1427 : 'numberOrStringSuperNativeTypeCheck'; 1438 : 'numberOrStringSuperNativeTypeCheck';
1428 } else { 1439 } else {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1637
1627 Element getCyclicThrowHelper() { 1638 Element getCyclicThrowHelper() {
1628 return compiler.findHelper("throwCyclicInit"); 1639 return compiler.findHelper("throwCyclicInit");
1629 } 1640 }
1630 1641
1631 bool isNullImplementation(ClassElement cls) { 1642 bool isNullImplementation(ClassElement cls) {
1632 return cls == jsNullClass; 1643 return cls == jsNullClass;
1633 } 1644 }
1634 1645
1635 ClassElement get intImplementation => jsIntClass; 1646 ClassElement get intImplementation => jsIntClass;
1647 ClassElement get uint32Implementation => jsUInt32Class;
1648 ClassElement get uint31Implementation => jsUInt31Class;
1636 ClassElement get doubleImplementation => jsDoubleClass; 1649 ClassElement get doubleImplementation => jsDoubleClass;
1637 ClassElement get numImplementation => jsNumberClass; 1650 ClassElement get numImplementation => jsNumberClass;
1638 ClassElement get stringImplementation => jsStringClass; 1651 ClassElement get stringImplementation => jsStringClass;
1639 ClassElement get listImplementation => jsArrayClass; 1652 ClassElement get listImplementation => jsArrayClass;
1640 ClassElement get constListImplementation => jsArrayClass; 1653 ClassElement get constListImplementation => jsArrayClass;
1641 ClassElement get fixedListImplementation => jsFixedArrayClass; 1654 ClassElement get fixedListImplementation => jsFixedArrayClass;
1642 ClassElement get growableListImplementation => jsExtendableArrayClass; 1655 ClassElement get growableListImplementation => jsExtendableArrayClass;
1643 ClassElement get mapImplementation => mapLiteralClass; 1656 ClassElement get mapImplementation => mapLiteralClass;
1644 ClassElement get constMapImplementation => constMapLiteralClass; 1657 ClassElement get constMapImplementation => constMapLiteralClass;
1645 ClassElement get typeImplementation => typeLiteralClass; 1658 ClassElement get typeImplementation => typeLiteralClass;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 copy(constant.values); 1995 copy(constant.values);
1983 copy(constant.protoValue); 1996 copy(constant.protoValue);
1984 copy(constant); 1997 copy(constant);
1985 } 1998 }
1986 1999
1987 void visitConstructed(ConstructedConstant constant) { 2000 void visitConstructed(ConstructedConstant constant) {
1988 copy(constant.fields); 2001 copy(constant.fields);
1989 copy(constant); 2002 copy(constant);
1990 } 2003 }
1991 } 2004 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698