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

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

Issue 14698026: Revert "Enable full type-checks in checked mode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1079
1080 HInstruction convertType(Compiler compiler, DartType type, int kind) { 1080 HInstruction convertType(Compiler compiler, DartType type, int kind) {
1081 if (type == null) return this; 1081 if (type == null) return this;
1082 if (identical(type.element, compiler.dynamicClass)) return this; 1082 if (identical(type.element, compiler.dynamicClass)) return this;
1083 if (identical(type.element, compiler.objectClass)) return this; 1083 if (identical(type.element, compiler.objectClass)) return this;
1084 if (type.isMalformed || type.kind != TypeKind.INTERFACE) { 1084 if (type.isMalformed || type.kind != TypeKind.INTERFACE) {
1085 return new HTypeConversion(type, kind, HType.UNKNOWN, this); 1085 return new HTypeConversion(type, kind, HType.UNKNOWN, this);
1086 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { 1086 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) {
1087 // Boolean conversion checks work on non-nullable booleans. 1087 // Boolean conversion checks work on non-nullable booleans.
1088 return new HTypeConversion(type, kind, HType.BOOLEAN, this); 1088 return new HTypeConversion(type, kind, HType.BOOLEAN, this);
1089 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) {
1090 throw 'creating compound check to $type (this = ${this})';
1091 } else { 1089 } else {
1092 HType subtype = new HType.subtype(type, compiler); 1090 HType subtype = new HType.subtype(type, compiler);
1093 return new HTypeConversion(type, kind, subtype, this); 1091 return new HTypeConversion(type, kind, subtype, this);
1094 } 1092 }
1095 } 1093 }
1096 1094
1097 /** 1095 /**
1098 * Return whether the instructions do not belong to a loop or 1096 * Return whether the instructions do not belong to a loop or
1099 * belong to the same loop. 1097 * belong to the same loop.
1100 */ 1098 */
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 sideEffects.setChangesIndex(); 2131 sideEffects.setChangesIndex();
2134 } 2132 }
2135 String toString() => 'index assign operator'; 2133 String toString() => 'index assign operator';
2136 accept(HVisitor visitor) => visitor.visitIndexAssign(this); 2134 accept(HVisitor visitor) => visitor.visitIndexAssign(this);
2137 2135
2138 HInstruction get receiver => inputs[0]; 2136 HInstruction get receiver => inputs[0];
2139 HInstruction get index => inputs[1]; 2137 HInstruction get index => inputs[1];
2140 HInstruction get value => inputs[2]; 2138 HInstruction get value => inputs[2];
2141 } 2139 }
2142 2140
2141 // TODO(karlklose): use this class to represent type conversions as well.
2143 class HIs extends HInstruction { 2142 class HIs extends HInstruction {
2144 /// A check against a raw type: 'o is int', 'o is A'. 2143 /// A check against a raw type: 'o is int', 'o is A'.
2145 static const int RAW_CHECK = 0; 2144 static const int RAW_CHECK = 0;
2146 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. 2145 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'.
2147 static const int COMPOUND_CHECK = 1; 2146 static const int COMPOUND_CHECK = 1;
2148 /// A check against a single type variable: 'o is T'. 2147 /// A check against a single type variable: 'o is T'.
2149 static const int VARIABLE_CHECK = 2; 2148 static const int VARIABLE_CHECK = 2;
2150 2149
2151 final DartType typeExpression; 2150 final DartType typeExpression;
2152 final bool nullOk; 2151 final bool nullOk;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 2198
2200 HTypeConversion(this.typeExpression, this.kind, 2199 HTypeConversion(this.typeExpression, this.kind,
2201 HType type, HInstruction input, 2200 HType type, HInstruction input,
2202 [this.receiverTypeCheckSelector]) 2201 [this.receiverTypeCheckSelector])
2203 : super(<HInstruction>[input]) { 2202 : super(<HInstruction>[input]) {
2204 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); 2203 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null);
2205 sourceElement = input.sourceElement; 2204 sourceElement = input.sourceElement;
2206 instructionType = type; 2205 instructionType = type;
2207 } 2206 }
2208 2207
2209 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind,
2210 HType type, HInstruction input,
2211 HInstruction typeRepresentation)
2212 : super(<HInstruction>[input, typeRepresentation]),
2213 receiverTypeCheckSelector = null {
2214 sourceElement = input.sourceElement;
2215 instructionType = type;
2216 }
2217
2218 bool get hasTypeRepresentation => inputs.length > 1;
2219 HInstruction get typeRepresentation => inputs[1];
2220
2221 HInstruction convertType(Compiler compiler, DartType type, int kind) {
2222 if (typeExpression == type) return this;
2223 return super.convertType(compiler, type, kind);
2224 }
2225
2226 bool get isChecked => kind != NO_CHECK; 2208 bool get isChecked => kind != NO_CHECK;
2227 bool get isCheckedModeCheck { 2209 bool get isCheckedModeCheck {
2228 return kind == CHECKED_MODE_CHECK 2210 return kind == CHECKED_MODE_CHECK
2229 || kind == BOOLEAN_CONVERSION_CHECK; 2211 || kind == BOOLEAN_CONVERSION_CHECK;
2230 } 2212 }
2231 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; 2213 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK;
2232 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; 2214 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK;
2233 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; 2215 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK;
2234 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; 2216 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK;
2235 2217
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 HBasicBlock get start => expression.start; 2604 HBasicBlock get start => expression.start;
2623 HBasicBlock get end { 2605 HBasicBlock get end {
2624 // We don't create a switch block if there are no cases. 2606 // We don't create a switch block if there are no cases.
2625 assert(!statements.isEmpty); 2607 assert(!statements.isEmpty);
2626 return statements.last.end; 2608 return statements.last.end;
2627 } 2609 }
2628 2610
2629 bool accept(HStatementInformationVisitor visitor) => 2611 bool accept(HStatementInformationVisitor visitor) =>
2630 visitor.visitSwitchInfo(this); 2612 visitor.visitSwitchInfo(this);
2631 } 2613 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698