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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/nodes.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 ssa; 5 part of ssa;
6 6
7 abstract class HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBitAnd(HBitAnd node); 9 R visitBitAnd(HBitAnd node);
10 R visitBitNot(HBitNot node); 10 R visitBitNot(HBitNot node);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 HBasicBlock addNewLoopHeaderBlock(TargetElement target, 157 HBasicBlock addNewLoopHeaderBlock(TargetElement target,
158 List<LabelElement> labels) { 158 List<LabelElement> labels) {
159 HBasicBlock result = addNewBlock(); 159 HBasicBlock result = addNewBlock();
160 result.loopInformation = 160 result.loopInformation =
161 new HLoopInformation(result, target, labels); 161 new HLoopInformation(result, target, labels);
162 return result; 162 return result;
163 } 163 }
164 164
165 static TypeMask mapConstantTypeToSsaType(Constant constant,
166 Compiler compiler) {
167 JavaScriptBackend backend = compiler.backend;
168 if (constant.isNull()) return backend.nullType;
169 if (constant.isBool()) return backend.boolType;
170 if (constant.isInt()) return backend.intType;
171 if (constant.isDouble()) return backend.doubleType;
172 if (constant.isString()) return backend.stringType;
173 if (constant.isList()) return backend.readableArrayType;
174 if (constant.isFunction()) return backend.nonNullType;
175 if (constant.isSentinel()) return backend.nonNullType;
176 // TODO(sra): What is the type of the prototype of an interceptor?
177 if (constant.isInterceptor()) return backend.nonNullType;
178 ObjectConstant objectConstant = constant;
179 if (backend.isInterceptorClass(objectConstant.type.element)) {
180 return backend.nonNullType;
181 }
182 return new TypeMask.nonNullExact(objectConstant.type.element);
183 }
184
185 HConstant addConstant(Constant constant, Compiler compiler) { 165 HConstant addConstant(Constant constant, Compiler compiler) {
186 HConstant result = constants[constant]; 166 HConstant result = constants[constant];
187 if (result == null) { 167 if (result == null) {
188 TypeMask type = mapConstantTypeToSsaType(constant, compiler); 168 TypeMask type = constant.computeMask(compiler);
189 result = new HConstant.internal(constant, type); 169 result = new HConstant.internal(constant, type);
190 entry.addAtExit(result); 170 entry.addAtExit(result);
191 constants[constant] = result; 171 constants[constant] = result;
192 } else if (result.block == null) { 172 } else if (result.block == null) {
193 // The constant was not used anymore. 173 // The constant was not used anymore.
194 entry.addAtExit(result); 174 entry.addAtExit(result);
195 } 175 }
196 return result; 176 return result;
197 } 177 }
198 178
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 bool canBePrimitiveString(Compiler compiler) { 894 bool canBePrimitiveString(Compiler compiler) {
915 JavaScriptBackend backend = compiler.backend; 895 JavaScriptBackend backend = compiler.backend;
916 return instructionType.contains(backend.jsStringClass, compiler); 896 return instructionType.contains(backend.jsStringClass, compiler);
917 } 897 }
918 898
919 bool isInteger(Compiler compiler) { 899 bool isInteger(Compiler compiler) {
920 return instructionType.containsOnlyInt(compiler) 900 return instructionType.containsOnlyInt(compiler)
921 && !instructionType.isNullable; 901 && !instructionType.isNullable;
922 } 902 }
923 903
904 bool isUInt32(Compiler compiler) {
905 JavaScriptBackend backend = compiler.backend;
906 return !instructionType.isNullable
907 && instructionType.satisfies(backend.jsUInt32Class, compiler);
908 }
909
910 bool isUInt31(Compiler compiler) {
911 JavaScriptBackend backend = compiler.backend;
912 return !instructionType.isNullable
913 && instructionType.satisfies(backend.jsUInt31Class, compiler);
914 }
915
924 bool isIntegerOrNull(Compiler compiler) { 916 bool isIntegerOrNull(Compiler compiler) {
925 return instructionType.containsOnlyInt(compiler); 917 return instructionType.containsOnlyInt(compiler);
926 } 918 }
927 919
928 bool isNumber(Compiler compiler) { 920 bool isNumber(Compiler compiler) {
929 return instructionType.containsOnlyNum(compiler) 921 return instructionType.containsOnlyNum(compiler)
930 && !instructionType.isNullable; 922 && !instructionType.isNullable;
931 } 923 }
932 924
933 bool isNumberOrNull(Compiler compiler) { 925 bool isNumberOrNull(Compiler compiler) {
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 HBasicBlock get start => expression.start; 2830 HBasicBlock get start => expression.start;
2839 HBasicBlock get end { 2831 HBasicBlock get end {
2840 // We don't create a switch block if there are no cases. 2832 // We don't create a switch block if there are no cases.
2841 assert(!statements.isEmpty); 2833 assert(!statements.isEmpty);
2842 return statements.last.end; 2834 return statements.last.end;
2843 } 2835 }
2844 2836
2845 bool accept(HStatementInformationVisitor visitor) => 2837 bool accept(HStatementInformationVisitor visitor) =>
2846 visitor.visitSwitchInfo(this); 2838 visitor.visitSwitchInfo(this);
2847 } 2839 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698