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

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

Issue 13019003: Enable full type-checks in checked mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use HTypeConversion instead of HIs. 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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 1089 } else {
1090 if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) {
1091 throw 'creating compound check to $type (this = ${this})';
1092 }
1090 HType subtype = new HType.subtype(type, compiler); 1093 HType subtype = new HType.subtype(type, compiler);
1091 return new HTypeConversion(type, kind, subtype, this); 1094 return new HTypeConversion(type, kind, subtype, this);
1092 } 1095 }
1093 } 1096 }
1094 1097
1095 /** 1098 /**
1096 * Return whether the instructions do not belong to a loop or 1099 * Return whether the instructions do not belong to a loop or
1097 * belong to the same loop. 1100 * belong to the same loop.
1098 */ 1101 */
1099 bool hasSameLoopHeaderAs(HInstruction other) { 1102 bool hasSameLoopHeaderAs(HInstruction other) {
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 sideEffects.setChangesIndex(); 2130 sideEffects.setChangesIndex();
2128 } 2131 }
2129 String toString() => 'index assign operator'; 2132 String toString() => 'index assign operator';
2130 accept(HVisitor visitor) => visitor.visitIndexAssign(this); 2133 accept(HVisitor visitor) => visitor.visitIndexAssign(this);
2131 2134
2132 HInstruction get receiver => inputs[0]; 2135 HInstruction get receiver => inputs[0];
2133 HInstruction get index => inputs[1]; 2136 HInstruction get index => inputs[1];
2134 HInstruction get value => inputs[2]; 2137 HInstruction get value => inputs[2];
2135 } 2138 }
2136 2139
2137 // TODO(karlklose): use this class to represent type conversions as well.
2138 class HIs extends HInstruction { 2140 class HIs extends HInstruction {
2139 /// A check against a raw type: 'o is int', 'o is A'. 2141 /// A check against a raw type: 'o is int', 'o is A'.
2140 static const int RAW_CHECK = 0; 2142 static const int RAW_CHECK = 0;
2141 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. 2143 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'.
2142 static const int COMPOUND_CHECK = 1; 2144 static const int COMPOUND_CHECK = 1;
2143 /// A check against a single type variable: 'o is T'. 2145 /// A check against a single type variable: 'o is T'.
2144 static const int VARIABLE_CHECK = 2; 2146 static const int VARIABLE_CHECK = 2;
2145 2147
2146 final DartType typeExpression; 2148 final DartType typeExpression;
2147 final bool nullOk; 2149 final bool nullOk;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 2196
2195 HTypeConversion(this.typeExpression, this.kind, 2197 HTypeConversion(this.typeExpression, this.kind,
2196 HType type, HInstruction input, 2198 HType type, HInstruction input,
2197 [this.receiverTypeCheckSelector]) 2199 [this.receiverTypeCheckSelector])
2198 : super(<HInstruction>[input]) { 2200 : super(<HInstruction>[input]) {
2199 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); 2201 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null);
2200 sourceElement = input.sourceElement; 2202 sourceElement = input.sourceElement;
2201 instructionType = type; 2203 instructionType = type;
2202 } 2204 }
2203 2205
2206 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind,
2207 HType type, HInstruction input,
2208 HInstruction typeRepresentation)
2209 : super(<HInstruction>[input, typeRepresentation]),
2210 receiverTypeCheckSelector = null {
2211 sourceElement = input.sourceElement;
2212 instructionType = type;
2213 }
2214
2215 bool get hasTypeRepresentation => inputs.length > 1;
2216 HInstruction get typeRepresentation => inputs[1];
2217
2218 HInstruction convertType(Compiler compiler, DartType type, int kind) {
2219 if (typeExpression == type) return this;
2220 return super.convertType(compiler, type, kind);
2221 }
2222
2204 bool get isChecked => kind != NO_CHECK; 2223 bool get isChecked => kind != NO_CHECK;
2205 bool get isCheckedModeCheck { 2224 bool get isCheckedModeCheck {
2206 return kind == CHECKED_MODE_CHECK 2225 return kind == CHECKED_MODE_CHECK
2207 || kind == BOOLEAN_CONVERSION_CHECK; 2226 || kind == BOOLEAN_CONVERSION_CHECK;
2208 } 2227 }
2209 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; 2228 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK;
2210 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; 2229 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK;
2211 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; 2230 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK;
2212 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; 2231 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK;
2213 2232
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 HBasicBlock get start => expression.start; 2619 HBasicBlock get start => expression.start;
2601 HBasicBlock get end { 2620 HBasicBlock get end {
2602 // We don't create a switch block if there are no cases. 2621 // We don't create a switch block if there are no cases.
2603 assert(!statements.isEmpty); 2622 assert(!statements.isEmpty);
2604 return statements.last.end; 2623 return statements.last.end;
2605 } 2624 }
2606 2625
2607 bool accept(HStatementInformationVisitor visitor) => 2626 bool accept(HStatementInformationVisitor visitor) =>
2608 visitor.visitSwitchInfo(this); 2627 visitor.visitSwitchInfo(this);
2609 } 2628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698