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

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

Issue 12509005: Add intersection of disjoint masks to the TypeMask implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Allow base == null. Ugh. Created 7 years, 9 months 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/optimize.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 visitBailoutTarget(HBailoutTarget node); 9 R visitBailoutTarget(HBailoutTarget node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 while (current != null) { 1107 while (current != null) {
1108 if (current == other) return true; 1108 if (current == other) return true;
1109 current = current.next; 1109 current = current.next;
1110 } 1110 }
1111 return false; 1111 return false;
1112 } 1112 }
1113 1113
1114 1114
1115 HInstruction convertType(Compiler compiler, DartType type, int kind) { 1115 HInstruction convertType(Compiler compiler, DartType type, int kind) {
1116 if (type == null) return this; 1116 if (type == null) return this;
1117
1118 // TODO(kasperl): This needs cleaning up. We shouldn't be creating
1119 // HType objects for malformed types.
1120 if (kind == HTypeConversion.CHECKED_MODE_CHECK && type.isMalformed) {
1121 kind = HTypeConversion.MALFORMED_CHECKED_MODE_CHECK;
1122 return new HTypeConversion(new HType.subtype(type, compiler), this, kind);
1123 }
1124
1117 if (identical(type.element, compiler.dynamicClass)) return this; 1125 if (identical(type.element, compiler.dynamicClass)) return this;
1118 if (identical(type.element, compiler.objectClass)) return this; 1126 if (identical(type.element, compiler.objectClass)) return this;
1119 1127
1120 // If the original can't be null, type conversion also can't produce null. 1128 // If the original can't be null, type conversion also can't produce null.
1121 bool canBeNull = instructionType.canBeNull(); 1129 bool canBeNull = instructionType.canBeNull();
1122 HType convertedType = new HType.subtype(type, compiler); 1130 HType convertedType = new HType.subtype(type, compiler);
1123 1131
1124 // No need to convert if we know the instruction has 1132 // No need to convert if we know the instruction has
1125 // [convertedType] as a bound. 1133 // [convertedType] as a bound.
1126 if (instructionType == convertedType) { 1134 if (instructionType == convertedType) {
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 } 2190 }
2183 2191
2184 class HTypeConversion extends HCheck { 2192 class HTypeConversion extends HCheck {
2185 final int kind; 2193 final int kind;
2186 2194
2187 static const int NO_CHECK = 0; 2195 static const int NO_CHECK = 0;
2188 static const int CHECKED_MODE_CHECK = 1; 2196 static const int CHECKED_MODE_CHECK = 1;
2189 static const int ARGUMENT_TYPE_CHECK = 2; 2197 static const int ARGUMENT_TYPE_CHECK = 2;
2190 static const int CAST_TYPE_CHECK = 3; 2198 static const int CAST_TYPE_CHECK = 3;
2191 static const int BOOLEAN_CONVERSION_CHECK = 4; 2199 static const int BOOLEAN_CONVERSION_CHECK = 4;
2200 static const int MALFORMED_CHECKED_MODE_CHECK = 5;
2192 2201
2193 HTypeConversion(HType type, HInstruction input, [this.kind = NO_CHECK]) 2202 HTypeConversion(HType type, HInstruction input, [this.kind = NO_CHECK])
2194 : super(<HInstruction>[input]) { 2203 : super(<HInstruction>[input]) {
2195 assert(type != null); 2204 assert(type != null);
2196 sourceElement = input.sourceElement; 2205 sourceElement = input.sourceElement;
2197 instructionType = type; 2206 instructionType = type;
2198 } 2207 }
2199 HTypeConversion.checkedModeCheck(HType type, HInstruction input) 2208 HTypeConversion.checkedModeCheck(HType type, HInstruction input)
2200 : this(type, input, CHECKED_MODE_CHECK); 2209 : this(type, input, CHECKED_MODE_CHECK);
2201 HTypeConversion.argumentTypeCheck(HType type, HInstruction input) 2210 HTypeConversion.argumentTypeCheck(HType type, HInstruction input)
2202 : this(type, input, ARGUMENT_TYPE_CHECK); 2211 : this(type, input, ARGUMENT_TYPE_CHECK);
2203 HTypeConversion.castCheck(HType type, HInstruction input) 2212 HTypeConversion.castCheck(HType type, HInstruction input)
2204 : this(type, input, CAST_TYPE_CHECK); 2213 : this(type, input, CAST_TYPE_CHECK);
2205 2214
2206
2207 bool get isChecked => kind != NO_CHECK; 2215 bool get isChecked => kind != NO_CHECK;
2208 bool get isCheckedModeCheck { 2216 bool get isCheckedModeCheck {
2209 return kind == CHECKED_MODE_CHECK || kind == BOOLEAN_CONVERSION_CHECK; 2217 return kind == CHECKED_MODE_CHECK
2218 || kind == BOOLEAN_CONVERSION_CHECK
2219 || kind == MALFORMED_CHECKED_MODE_CHECK;
2210 } 2220 }
2211 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; 2221 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK;
2212 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; 2222 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK;
2213 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; 2223 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK;
2224 bool get isMalformedCheckedModeCheck => kind == MALFORMED_CHECKED_MODE_CHECK;
2214 2225
2215 accept(HVisitor visitor) => visitor.visitTypeConversion(this); 2226 accept(HVisitor visitor) => visitor.visitTypeConversion(this);
2216 2227
2217 bool isJsStatement() => kind == ARGUMENT_TYPE_CHECK; 2228 bool isJsStatement() => kind == ARGUMENT_TYPE_CHECK;
2218 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; 2229 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK;
2219 bool canThrow() => isChecked; 2230 bool canThrow() => isChecked;
2220 2231
2221 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; 2232 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE;
2222 bool typeEquals(HInstruction other) => other is HTypeConversion; 2233 bool typeEquals(HInstruction other) => other is HTypeConversion;
2223 bool dataEquals(HTypeConversion other) { 2234 bool dataEquals(HTypeConversion other) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 HBasicBlock get start => expression.start; 2591 HBasicBlock get start => expression.start;
2581 HBasicBlock get end { 2592 HBasicBlock get end {
2582 // We don't create a switch block if there are no cases. 2593 // We don't create a switch block if there are no cases.
2583 assert(!statements.isEmpty); 2594 assert(!statements.isEmpty);
2584 return statements.last.end; 2595 return statements.last.end;
2585 } 2596 }
2586 2597
2587 bool accept(HStatementInformationVisitor visitor) => 2598 bool accept(HStatementInformationVisitor visitor) =>
2588 visitor.visitSwitchInfo(this); 2599 visitor.visitSwitchInfo(this);
2589 } 2600 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698