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

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

Issue 15299002: Reapply "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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1083
1084 HInstruction convertType(Compiler compiler, DartType type, int kind) { 1084 HInstruction convertType(Compiler compiler, DartType type, int kind) {
1085 if (type == null) return this; 1085 if (type == null) return this;
1086 if (identical(type.element, compiler.dynamicClass)) return this; 1086 if (identical(type.element, compiler.dynamicClass)) return this;
1087 if (identical(type.element, compiler.objectClass)) return this; 1087 if (identical(type.element, compiler.objectClass)) return this;
1088 if (type.isMalformed || type.kind != TypeKind.INTERFACE) { 1088 if (type.isMalformed || type.kind != TypeKind.INTERFACE) {
1089 return new HTypeConversion(type, kind, HType.UNKNOWN, this); 1089 return new HTypeConversion(type, kind, HType.UNKNOWN, this);
1090 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { 1090 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) {
1091 // Boolean conversion checks work on non-nullable booleans. 1091 // Boolean conversion checks work on non-nullable booleans.
1092 return new HTypeConversion(type, kind, HType.BOOLEAN, this); 1092 return new HTypeConversion(type, kind, HType.BOOLEAN, this);
1093 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) {
1094 throw 'creating compound check to $type (this = ${this})';
1093 } else { 1095 } else {
1094 HType subtype = new HType.subtype(type, compiler); 1096 HType subtype = new HType.subtype(type, compiler);
1095 return new HTypeConversion(type, kind, subtype, this); 1097 return new HTypeConversion(type, kind, subtype, this);
1096 } 1098 }
1097 } 1099 }
1098 1100
1099 /** 1101 /**
1100 * Return whether the instructions do not belong to a loop or 1102 * Return whether the instructions do not belong to a loop or
1101 * belong to the same loop. 1103 * belong to the same loop.
1102 */ 1104 */
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 sideEffects.setChangesIndex(); 2150 sideEffects.setChangesIndex();
2149 } 2151 }
2150 String toString() => 'index assign operator'; 2152 String toString() => 'index assign operator';
2151 accept(HVisitor visitor) => visitor.visitIndexAssign(this); 2153 accept(HVisitor visitor) => visitor.visitIndexAssign(this);
2152 2154
2153 HInstruction get receiver => inputs[0]; 2155 HInstruction get receiver => inputs[0];
2154 HInstruction get index => inputs[1]; 2156 HInstruction get index => inputs[1];
2155 HInstruction get value => inputs[2]; 2157 HInstruction get value => inputs[2];
2156 } 2158 }
2157 2159
2158 // TODO(karlklose): use this class to represent type conversions as well.
2159 class HIs extends HInstruction { 2160 class HIs extends HInstruction {
2160 /// A check against a raw type: 'o is int', 'o is A'. 2161 /// A check against a raw type: 'o is int', 'o is A'.
2161 static const int RAW_CHECK = 0; 2162 static const int RAW_CHECK = 0;
2162 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. 2163 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'.
2163 static const int COMPOUND_CHECK = 1; 2164 static const int COMPOUND_CHECK = 1;
2164 /// A check against a single type variable: 'o is T'. 2165 /// A check against a single type variable: 'o is T'.
2165 static const int VARIABLE_CHECK = 2; 2166 static const int VARIABLE_CHECK = 2;
2166 2167
2167 final DartType typeExpression; 2168 final DartType typeExpression;
2168 final bool nullOk; 2169 final bool nullOk;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 2216
2216 HTypeConversion(this.typeExpression, this.kind, 2217 HTypeConversion(this.typeExpression, this.kind,
2217 HType type, HInstruction input, 2218 HType type, HInstruction input,
2218 [this.receiverTypeCheckSelector]) 2219 [this.receiverTypeCheckSelector])
2219 : super(<HInstruction>[input]) { 2220 : super(<HInstruction>[input]) {
2220 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); 2221 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null);
2221 sourceElement = input.sourceElement; 2222 sourceElement = input.sourceElement;
2222 instructionType = type; 2223 instructionType = type;
2223 } 2224 }
2224 2225
2226 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind,
2227 HType type, HInstruction input,
2228 HInstruction typeRepresentation)
2229 : super(<HInstruction>[input, typeRepresentation]),
2230 receiverTypeCheckSelector = null {
2231 sourceElement = input.sourceElement;
2232 instructionType = type;
2233 }
2234
2235 bool get hasTypeRepresentation => inputs.length > 1;
2236 HInstruction get typeRepresentation => inputs[1];
2237
2238 HInstruction convertType(Compiler compiler, DartType type, int kind) {
2239 if (typeExpression == type) return this;
2240 return super.convertType(compiler, type, kind);
2241 }
2242
2225 bool get isChecked => kind != NO_CHECK; 2243 bool get isChecked => kind != NO_CHECK;
2226 bool get isCheckedModeCheck { 2244 bool get isCheckedModeCheck {
2227 return kind == CHECKED_MODE_CHECK 2245 return kind == CHECKED_MODE_CHECK
2228 || kind == BOOLEAN_CONVERSION_CHECK; 2246 || kind == BOOLEAN_CONVERSION_CHECK;
2229 } 2247 }
2230 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; 2248 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK;
2231 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; 2249 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK;
2232 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; 2250 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK;
2233 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; 2251 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK;
2234 2252
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 HBasicBlock get start => expression.start; 2642 HBasicBlock get start => expression.start;
2625 HBasicBlock get end { 2643 HBasicBlock get end {
2626 // We don't create a switch block if there are no cases. 2644 // We don't create a switch block if there are no cases.
2627 assert(!statements.isEmpty); 2645 assert(!statements.isEmpty);
2628 return statements.last.end; 2646 return statements.last.end;
2629 } 2647 }
2630 2648
2631 bool accept(HStatementInformationVisitor visitor) => 2649 bool accept(HStatementInformationVisitor visitor) =>
2632 visitor.visitSwitchInfo(this); 2650 visitor.visitSwitchInfo(this);
2633 } 2651 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698