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

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: Address comments. 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) {
ngeoffray 2013/05/15 08:45:33 Use: } else if { throw... } else { ... } ins
karlklose 2013/05/15 12:59:16 Done.
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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 sideEffects.setChangesIndex(); 2129 sideEffects.setChangesIndex();
2127 } 2130 }
2128 String toString() => 'index assign operator'; 2131 String toString() => 'index assign operator';
2129 accept(HVisitor visitor) => visitor.visitIndexAssign(this); 2132 accept(HVisitor visitor) => visitor.visitIndexAssign(this);
2130 2133
2131 HInstruction get receiver => inputs[0]; 2134 HInstruction get receiver => inputs[0];
2132 HInstruction get index => inputs[1]; 2135 HInstruction get index => inputs[1];
2133 HInstruction get value => inputs[2]; 2136 HInstruction get value => inputs[2];
2134 } 2137 }
2135 2138
2136 // TODO(karlklose): use this class to represent type conversions as well.
2137 class HIs extends HInstruction { 2139 class HIs extends HInstruction {
2138 /// A check against a raw type: 'o is int', 'o is A'. 2140 /// A check against a raw type: 'o is int', 'o is A'.
2139 static const int RAW_CHECK = 0; 2141 static const int RAW_CHECK = 0;
2140 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. 2142 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'.
2141 static const int COMPOUND_CHECK = 1; 2143 static const int COMPOUND_CHECK = 1;
2142 /// A check against a single type variable: 'o is T'. 2144 /// A check against a single type variable: 'o is T'.
2143 static const int VARIABLE_CHECK = 2; 2145 static const int VARIABLE_CHECK = 2;
2144 2146
2145 final DartType typeExpression; 2147 final DartType typeExpression;
2146 final bool nullOk; 2148 final bool nullOk;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 2195
2194 HTypeConversion(this.typeExpression, this.kind, 2196 HTypeConversion(this.typeExpression, this.kind,
2195 HType type, HInstruction input, 2197 HType type, HInstruction input,
2196 [this.receiverTypeCheckSelector]) 2198 [this.receiverTypeCheckSelector])
2197 : super(<HInstruction>[input]) { 2199 : super(<HInstruction>[input]) {
2198 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); 2200 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null);
2199 sourceElement = input.sourceElement; 2201 sourceElement = input.sourceElement;
2200 instructionType = type; 2202 instructionType = type;
2201 } 2203 }
2202 2204
2205 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind,
2206 HType type, HInstruction input,
2207 HInstruction typeRepresentation)
2208 : super(<HInstruction>[input, typeRepresentation]),
2209 receiverTypeCheckSelector = null {
2210 sourceElement = input.sourceElement;
2211 instructionType = type;
2212 }
2213
2214 bool get hasTypeRepresentation => inputs.length > 1;
2215 HInstruction get typeRepresentation => inputs[1];
2216
2217 HInstruction convertType(Compiler compiler, DartType type, int kind) {
2218 if (typeExpression == type) return this;
2219 return super.convertType(compiler, type, kind);
2220 }
2221
2203 bool get isChecked => kind != NO_CHECK; 2222 bool get isChecked => kind != NO_CHECK;
2204 bool get isCheckedModeCheck { 2223 bool get isCheckedModeCheck {
2205 return kind == CHECKED_MODE_CHECK 2224 return kind == CHECKED_MODE_CHECK
2206 || kind == BOOLEAN_CONVERSION_CHECK; 2225 || kind == BOOLEAN_CONVERSION_CHECK;
2207 } 2226 }
2208 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; 2227 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK;
2209 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; 2228 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK;
2210 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; 2229 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK;
2211 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; 2230 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK;
2212 2231
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 HBasicBlock get start => expression.start; 2618 HBasicBlock get start => expression.start;
2600 HBasicBlock get end { 2619 HBasicBlock get end {
2601 // We don't create a switch block if there are no cases. 2620 // We don't create a switch block if there are no cases.
2602 assert(!statements.isEmpty); 2621 assert(!statements.isEmpty);
2603 return statements.last.end; 2622 return statements.last.end;
2604 } 2623 }
2605 2624
2606 bool accept(HStatementInformationVisitor visitor) => 2625 bool accept(HStatementInformationVisitor visitor) =>
2607 visitor.visitSwitchInfo(this); 2626 visitor.visitSwitchInfo(this);
2608 } 2627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698