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

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

Issue 23003031: Extract interceptor calls from raw is-checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Populate interceptedClasses dynamically Created 7 years, 3 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 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 2202
2203 class HIs extends HInstruction { 2203 class HIs extends HInstruction {
2204 /// A check against a raw type: 'o is int', 'o is A'. 2204 /// A check against a raw type: 'o is int', 'o is A'.
2205 static const int RAW_CHECK = 0; 2205 static const int RAW_CHECK = 0;
2206 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. 2206 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'.
2207 static const int COMPOUND_CHECK = 1; 2207 static const int COMPOUND_CHECK = 1;
2208 /// A check against a single type variable: 'o is T'. 2208 /// A check against a single type variable: 'o is T'.
2209 static const int VARIABLE_CHECK = 2; 2209 static const int VARIABLE_CHECK = 2;
2210 2210
2211 final DartType typeExpression; 2211 final DartType typeExpression;
2212 final bool nullOk;
2213 final int kind; 2212 final int kind;
2214 2213
2215 HIs(this.typeExpression, List<HInstruction> inputs, this.kind, 2214 HIs.direct(DartType typeExpression,
2216 {this.nullOk: false}) : super(inputs) { 2215 HInstruction expression)
2216 : this.internal(typeExpression, [expression], RAW_CHECK);
2217
2218 HIs.raw(DartType typeExpression,
2219 HInstruction expression,
2220 HInterceptor interceptor)
2221 : this.internal(typeExpression, [expression, interceptor], RAW_CHECK);
2222
2223 HIs.compound(DartType typeExpression,
2224 HInstruction expression,
2225 HInstruction call)
2226 : this.internal(typeExpression, [expression, call], COMPOUND_CHECK);
2227
2228 HIs.variable(DartType typeExpression,
2229 HInstruction expression,
2230 HInstruction call)
2231 : this.internal(typeExpression, [expression, call], VARIABLE_CHECK);
2232
2233 HIs.internal(this.typeExpression, List<HInstruction> inputs, this.kind)
2234 : super(inputs) {
2217 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK); 2235 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK);
2218 setUseGvn(); 2236 setUseGvn();
2219 instructionType = HType.BOOLEAN; 2237 instructionType = HType.BOOLEAN;
2220 } 2238 }
2221 2239
2222 HInstruction get expression => inputs[0]; 2240 HInstruction get expression => inputs[0];
2223 2241
2242 HInstruction get interceptor {
2243 assert(kind == RAW_CHECK);
2244 return inputs.length > 1 ? inputs[1] : null;
2245 }
2246
2224 HInstruction get checkCall { 2247 HInstruction get checkCall {
2225 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK); 2248 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK);
2226 return inputs[1]; 2249 return inputs[1];
2227 } 2250 }
2228 2251
2229 bool get isRawCheck => kind == RAW_CHECK; 2252 bool get isRawCheck => kind == RAW_CHECK;
2230 bool get isVariableCheck => kind == VARIABLE_CHECK; 2253 bool get isVariableCheck => kind == VARIABLE_CHECK;
2231 bool get isCompoundCheck => kind == COMPOUND_CHECK; 2254 bool get isCompoundCheck => kind == COMPOUND_CHECK;
2232 2255
2233 accept(HVisitor visitor) => visitor.visitIs(this); 2256 accept(HVisitor visitor) => visitor.visitIs(this);
2234 2257
2235 toString() => "$expression is $typeExpression"; 2258 toString() => "$expression is $typeExpression";
2236 2259
2237 int typeCode() => HInstruction.IS_TYPECODE; 2260 int typeCode() => HInstruction.IS_TYPECODE;
2238 2261
2239 bool typeEquals(HInstruction other) => other is HIs; 2262 bool typeEquals(HInstruction other) => other is HIs;
2240 2263
2241 bool dataEquals(HIs other) { 2264 bool dataEquals(HIs other) {
2242 return typeExpression == other.typeExpression 2265 return typeExpression == other.typeExpression
2243 && nullOk == other.nullOk
2244 && kind == other.kind; 2266 && kind == other.kind;
2245 } 2267 }
2246 } 2268 }
2247 2269
2248 class HTypeConversion extends HCheck { 2270 class HTypeConversion extends HCheck {
2249 final DartType typeExpression; 2271 final DartType typeExpression;
2250 final int kind; 2272 final int kind;
2251 final Selector receiverTypeCheckSelector; 2273 final Selector receiverTypeCheckSelector;
2252 final bool contextIsTypeArguments; 2274 final bool contextIsTypeArguments;
2253 2275
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 HBasicBlock get start => expression.start; 2729 HBasicBlock get start => expression.start;
2708 HBasicBlock get end { 2730 HBasicBlock get end {
2709 // We don't create a switch block if there are no cases. 2731 // We don't create a switch block if there are no cases.
2710 assert(!statements.isEmpty); 2732 assert(!statements.isEmpty);
2711 return statements.last.end; 2733 return statements.last.end;
2712 } 2734 }
2713 2735
2714 bool accept(HStatementInformationVisitor visitor) => 2736 bool accept(HStatementInformationVisitor visitor) =>
2715 visitor.visitSwitchInfo(this); 2737 visitor.visitSwitchInfo(this);
2716 } 2738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698