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 23003031: Extract interceptor calls from raw is-checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Avoid generating an interceptor when unused. Created 7 years, 4 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 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after
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; 2212 final bool nullOk;
2213 final int kind; 2213 final int kind;
2214 2214
2215 HIs(this.typeExpression, List<HInstruction> inputs, this.kind, 2215 HIs.direct(DartType typeExpression,
2216 {this.nullOk: false}) : super(inputs) { 2216 HInstruction expression)
2217 : this.internal(typeExpression, [expression], RAW_CHECK);
2218
2219 HIs.raw(DartType typeExpression,
2220 HInstruction expression,
2221 HInterceptor interceptor)
2222 : this.internal(typeExpression, [expression, interceptor], RAW_CHECK);
2223
2224 HIs.compound(DartType typeExpression,
2225 HInstruction expression,
2226 HInstruction call)
2227 : this.internal(typeExpression, [expression, call], COMPOUND_CHECK);
2228
2229 HIs.variable(DartType typeExpression,
2230 HInstruction expression,
2231 HInstruction call)
2232 : this.internal(typeExpression, [expression, call], VARIABLE_CHECK);
2233
2234 HIs.internal(this.typeExpression, List<HInstruction> inputs, this.kind,
2235 {this.nullOk: false}) : super(inputs) {
ngeoffray 2013/08/24 11:16:26 I think we can remove 'nullOK' now, it does not lo
Johnni Winther 2013/08/26 07:34:00 Done.
2217 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK); 2236 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK);
2218 setUseGvn(); 2237 setUseGvn();
2219 instructionType = HType.BOOLEAN; 2238 instructionType = HType.BOOLEAN;
2220 } 2239 }
2221 2240
2222 HInstruction get expression => inputs[0]; 2241 HInstruction get expression => inputs[0];
2223 2242
2243 HInstruction get interceptor {
2244 assert(kind == RAW_CHECK);
2245 return inputs.length > 1 ? inputs[1] : null;
2246 }
2247
2224 HInstruction get checkCall { 2248 HInstruction get checkCall {
2225 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK); 2249 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK);
2226 return inputs[1]; 2250 return inputs[1];
2227 } 2251 }
2228 2252
2229 bool get isRawCheck => kind == RAW_CHECK; 2253 bool get isRawCheck => kind == RAW_CHECK;
2230 bool get isVariableCheck => kind == VARIABLE_CHECK; 2254 bool get isVariableCheck => kind == VARIABLE_CHECK;
2231 bool get isCompoundCheck => kind == COMPOUND_CHECK; 2255 bool get isCompoundCheck => kind == COMPOUND_CHECK;
2232 2256
2233 accept(HVisitor visitor) => visitor.visitIs(this); 2257 accept(HVisitor visitor) => visitor.visitIs(this);
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 HBasicBlock get start => expression.start; 2731 HBasicBlock get start => expression.start;
2708 HBasicBlock get end { 2732 HBasicBlock get end {
2709 // We don't create a switch block if there are no cases. 2733 // We don't create a switch block if there are no cases.
2710 assert(!statements.isEmpty); 2734 assert(!statements.isEmpty);
2711 return statements.last.end; 2735 return statements.last.end;
2712 } 2736 }
2713 2737
2714 bool accept(HStatementInformationVisitor visitor) => 2738 bool accept(HStatementInformationVisitor visitor) =>
2715 visitor.visitSwitchInfo(this); 2739 visitor.visitSwitchInfo(this);
2716 } 2740 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698